mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-17 23:04:06 +00:00
+ 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:
parent
abc7d564b2
commit
5a886ade11
|
@ -216,6 +216,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
|
||||
updateTrayIcon();
|
||||
|
||||
// Update autostart info
|
||||
setAutostart(cfg.preferences.autoStart);
|
||||
|
||||
// Only show window initially if it wasn't configured differently
|
||||
if ( !cfg.preferences.enableTrayIcon || !cfg.preferences.startToTray )
|
||||
show();
|
||||
|
@ -774,6 +777,9 @@ void MainWindow::editPreferences()
|
|||
updateTrayIcon();
|
||||
applyProxySettings();
|
||||
makeScanPopup();
|
||||
|
||||
setAutostart(cfg.preferences.autoStart);
|
||||
|
||||
Config::save( cfg );
|
||||
}
|
||||
}
|
||||
|
@ -1154,3 +1160,30 @@ void MainWindow::showAbout()
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -177,11 +177,15 @@ private slots:
|
|||
|
||||
void scanEnableToggled( bool );
|
||||
|
||||
void setAutostart( bool );
|
||||
|
||||
void showMainWindow();
|
||||
|
||||
void visitHomepage();
|
||||
void visitForum();
|
||||
void showAbout();
|
||||
|
||||
void on_actionCloseToTray_activated();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -239,13 +239,14 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>653</width>
|
||||
<height>26</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>&File</string>
|
||||
</property>
|
||||
<addaction name="actionCloseToTray"/>
|
||||
<addaction name="quit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Edit">
|
||||
|
@ -270,25 +271,29 @@
|
|||
<addaction name="menu_Help"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="action_Preferences">
|
||||
<property name="text">
|
||||
<string>&Preferences...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="sources">
|
||||
<property name="text">
|
||||
<string>&Sources...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F2</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="groups">
|
||||
<property name="text">
|
||||
<string>&Groups...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F3</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="preferences">
|
||||
<property name="text">
|
||||
<string>&Preferences...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F4</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="visitHomepage">
|
||||
<property name="text">
|
||||
|
@ -299,17 +304,40 @@
|
|||
<property name="text">
|
||||
<string>&About</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>About GoldenDict</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F1</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="quit">
|
||||
<property name="text">
|
||||
<string>&Quit</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Quit from application</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="visitForum">
|
||||
<property name="text">
|
||||
<string>&Forum</string>
|
||||
</property>
|
||||
</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>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
@ -322,8 +350,6 @@
|
|||
<tabstop>translateLine</tabstop>
|
||||
<tabstop>tabWidget</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
</resources>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
Loading…
Reference in a new issue