mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14: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();
|
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();
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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>&File</string>
|
<string>&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>&Preferences...</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="sources">
|
<action name="sources">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Sources...</string>
|
<string>&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>&Groups...</string>
|
<string>&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>&Preferences...</string>
|
<string>&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>&About</string>
|
<string>&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>&Quit</string>
|
<string>&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>&Forum</string>
|
<string>&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>
|
||||||
|
|
Loading…
Reference in a new issue