+ Apply autoStart property (patch by Ars)

+ Close to sysTray menu item (patch by Ars)
* Shortcuts and tooltols for menu items (patch by Ars)
This commit is contained in:
Konstantin Isakov 2009-04-18 18:47:01 +00:00
parent abc7d564b2
commit 5a886ade11
3 changed files with 96 additions and 33 deletions

View file

@ -216,6 +216,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
updateTrayIcon(); updateTrayIcon();
// Update autostart info
setAutostart(cfg.preferences.autoStart);
// Only show window initially if it wasn't configured differently // Only show window initially if it wasn't configured differently
if ( !cfg.preferences.enableTrayIcon || !cfg.preferences.startToTray ) if ( !cfg.preferences.enableTrayIcon || !cfg.preferences.startToTray )
show(); show();
@ -774,6 +777,9 @@ void MainWindow::editPreferences()
updateTrayIcon(); updateTrayIcon();
applyProxySettings(); applyProxySettings();
makeScanPopup(); makeScanPopup();
setAutostart(cfg.preferences.autoStart);
Config::save( cfg ); Config::save( cfg );
} }
} }
@ -1154,3 +1160,30 @@ void MainWindow::showAbout()
about.exec(); about.exec();
} }
void MainWindow::setAutostart(bool autostart)
{
#ifdef Q_OS_WIN32
QSettings reg("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Run",
QSettings::NativeFormat);
if (autostart)
reg.setValue(QCoreApplication::applicationName(), QCoreApplication::applicationFilePath());
else
reg.remove(QCoreApplication::applicationName());
reg.sync();
#else
// this is for KDE
QString app_fname = QFileInfo(QCoreApplication::applicationFilePath()).baseName();
QString lnk(QDir::homePath()+"/.kde/Autostart/"+app_fname);
if (autostart) {
QFile f(QCoreApplication::applicationFilePath());
f.link(lnk);
} else {
QFile::remove(lnk);
}
#endif
}
void MainWindow::on_actionCloseToTray_activated()
{
close();
}

View file

@ -177,11 +177,15 @@ private slots:
void scanEnableToggled( bool ); void scanEnableToggled( bool );
void setAutostart( bool );
void showMainWindow(); void showMainWindow();
void visitHomepage(); void visitHomepage();
void visitForum(); void visitForum();
void showAbout(); void showAbout();
void on_actionCloseToTray_activated();
}; };
#endif #endif

View file

@ -239,13 +239,14 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>653</width> <width>653</width>
<height>26</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuFile"> <widget class="QMenu" name="menuFile">
<property name="title"> <property name="title">
<string>&amp;File</string> <string>&amp;File</string>
</property> </property>
<addaction name="actionCloseToTray"/>
<addaction name="quit"/> <addaction name="quit"/>
</widget> </widget>
<widget class="QMenu" name="menu_Edit"> <widget class="QMenu" name="menu_Edit">
@ -270,25 +271,29 @@
<addaction name="menu_Help"/> <addaction name="menu_Help"/>
</widget> </widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<action name="action_Preferences">
<property name="text">
<string>&amp;Preferences...</string>
</property>
</action>
<action name="sources"> <action name="sources">
<property name="text"> <property name="text">
<string>&amp;Sources...</string> <string>&amp;Sources...</string>
</property> </property>
<property name="shortcut">
<string>F2</string>
</property>
</action> </action>
<action name="groups"> <action name="groups">
<property name="text"> <property name="text">
<string>&amp;Groups...</string> <string>&amp;Groups...</string>
</property> </property>
<property name="shortcut">
<string>F3</string>
</property>
</action> </action>
<action name="preferences"> <action name="preferences">
<property name="text"> <property name="text">
<string>&amp;Preferences...</string> <string>&amp;Preferences...</string>
</property> </property>
<property name="shortcut">
<string>F4</string>
</property>
</action> </action>
<action name="visitHomepage"> <action name="visitHomepage">
<property name="text"> <property name="text">
@ -299,17 +304,40 @@
<property name="text"> <property name="text">
<string>&amp;About</string> <string>&amp;About</string>
</property> </property>
<property name="toolTip">
<string>About GoldenDict</string>
</property>
<property name="shortcut">
<string>F1</string>
</property>
</action> </action>
<action name="quit"> <action name="quit">
<property name="text"> <property name="text">
<string>&amp;Quit</string> <string>&amp;Quit</string>
</property> </property>
<property name="toolTip">
<string>Quit from application</string>
</property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action> </action>
<action name="visitForum"> <action name="visitForum">
<property name="text"> <property name="text">
<string>&amp;Forum</string> <string>&amp;Forum</string>
</property> </property>
</action> </action>
<action name="actionCloseToTray">
<property name="text">
<string>Close</string>
</property>
<property name="toolTip">
<string>Close window (or go to tray if enabled)</string>
</property>
<property name="shortcut">
<string>Ctrl+F4</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
@ -322,8 +350,6 @@
<tabstop>translateLine</tabstop> <tabstop>translateLine</tabstop>
<tabstop>tabWidget</tabstop> <tabstop>tabWidget</tabstop>
</tabstops> </tabstops>
<resources> <resources/>
<include location="resources.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>