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
|
@ -53,7 +53,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
|
|
||||||
navBack = navToolbar->addAction( QIcon( ":/icons/previous.png" ), tr( "Back" ) );
|
navBack = navToolbar->addAction( QIcon( ":/icons/previous.png" ), tr( "Back" ) );
|
||||||
navForward = navToolbar->addAction( QIcon( ":/icons/next.png" ), tr( "Forward" ) );
|
navForward = navToolbar->addAction( QIcon( ":/icons/next.png" ), tr( "Forward" ) );
|
||||||
|
|
||||||
enableScanPopup = navToolbar->addAction( QIcon( ":/icons/wizard.png" ), tr( "Scan Popup" ) );
|
enableScanPopup = navToolbar->addAction( QIcon( ":/icons/wizard.png" ), tr( "Scan Popup" ) );
|
||||||
enableScanPopup->setCheckable( true );
|
enableScanPopup->setCheckable( true );
|
||||||
enableScanPopup->setVisible( cfg.preferences.enableScanPopup );
|
enableScanPopup->setVisible( cfg.preferences.enableScanPopup );
|
||||||
|
@ -122,7 +122,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
|
|
||||||
if ( trayIcon )
|
if ( trayIcon )
|
||||||
trayIcon->setToolTip( tr( "Loading..." ) );
|
trayIcon->setToolTip( tr( "Loading..." ) );
|
||||||
|
|
||||||
connect( navBack, SIGNAL( activated() ),
|
connect( navBack, SIGNAL( activated() ),
|
||||||
this, SLOT( backClicked() ) );
|
this, SLOT( backClicked() ) );
|
||||||
connect( navForward, SIGNAL( activated() ),
|
connect( navForward, SIGNAL( activated() ),
|
||||||
|
@ -163,7 +163,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
|
|
||||||
connect( ui.preferences, SIGNAL( activated() ),
|
connect( ui.preferences, SIGNAL( activated() ),
|
||||||
this, SLOT( editPreferences() ) );
|
this, SLOT( editPreferences() ) );
|
||||||
|
|
||||||
connect( ui.visitHomepage, SIGNAL( activated() ),
|
connect( ui.visitHomepage, SIGNAL( activated() ),
|
||||||
this, SLOT( visitHomepage() ) );
|
this, SLOT( visitHomepage() ) );
|
||||||
connect( ui.visitForum, SIGNAL( activated() ),
|
connect( ui.visitForum, SIGNAL( activated() ),
|
||||||
|
@ -176,13 +176,13 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
|
|
||||||
connect( ui.translateLine, SIGNAL( textChanged( QString const & ) ),
|
connect( ui.translateLine, SIGNAL( textChanged( QString const & ) ),
|
||||||
this, SLOT( translateInputChanged( QString const & ) ) );
|
this, SLOT( translateInputChanged( QString const & ) ) );
|
||||||
|
|
||||||
connect( ui.translateLine, SIGNAL( returnPressed() ),
|
connect( ui.translateLine, SIGNAL( returnPressed() ),
|
||||||
this, SLOT( translateInputFinished() ) );
|
this, SLOT( translateInputFinished() ) );
|
||||||
|
|
||||||
connect( ui.wordList, SIGNAL( itemSelectionChanged() ),
|
connect( ui.wordList, SIGNAL( itemSelectionChanged() ),
|
||||||
this, SLOT( wordListSelectionChanged() ) );
|
this, SLOT( wordListSelectionChanged() ) );
|
||||||
|
|
||||||
connect( &wordFinder, SIGNAL( updated() ),
|
connect( &wordFinder, SIGNAL( updated() ),
|
||||||
this, SLOT( prefixMatchUpdated() ) );
|
this, SLOT( prefixMatchUpdated() ) );
|
||||||
connect( &wordFinder, SIGNAL( finished() ),
|
connect( &wordFinder, SIGNAL( finished() ),
|
||||||
|
@ -211,11 +211,14 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
|
|
||||||
view.showDefinition( tr( "Welcome!" ), UINT_MAX );
|
view.showDefinition( tr( "Welcome!" ), UINT_MAX );
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.translateLine->setFocus();
|
ui.translateLine->setFocus();
|
||||||
|
|
||||||
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();
|
||||||
|
@ -298,7 +301,7 @@ void LoadDictionaries::handlePath( Config::Path const & path )
|
||||||
{
|
{
|
||||||
vector< sptr< Dictionary::Class > > stardictDictionaries =
|
vector< sptr< Dictionary::Class > > stardictDictionaries =
|
||||||
Stardict::makeDictionaries( allFiles, Config::getIndexDir().toLocal8Bit().data(), *this );
|
Stardict::makeDictionaries( allFiles, Config::getIndexDir().toLocal8Bit().data(), *this );
|
||||||
|
|
||||||
dictionaries.insert( dictionaries.end(), stardictDictionaries.begin(),
|
dictionaries.insert( dictionaries.end(), stardictDictionaries.begin(),
|
||||||
stardictDictionaries.end() );
|
stardictDictionaries.end() );
|
||||||
}
|
}
|
||||||
|
@ -360,7 +363,7 @@ void MainWindow::updateTrayIcon()
|
||||||
enableScanPopup->isChecked() ?
|
enableScanPopup->isChecked() ?
|
||||||
":/icons/programicon_scan.png" :
|
":/icons/programicon_scan.png" :
|
||||||
":/icons/programicon.png" ) );
|
":/icons/programicon.png" ) );
|
||||||
|
|
||||||
trayIcon->setToolTip( "GoldenDict" );
|
trayIcon->setToolTip( "GoldenDict" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -405,14 +408,14 @@ void MainWindow::applyProxySettings()
|
||||||
{
|
{
|
||||||
proxy.setHostName( cfg.preferences.proxyServer.host );
|
proxy.setHostName( cfg.preferences.proxyServer.host );
|
||||||
proxy.setPort( cfg.preferences.proxyServer.port );
|
proxy.setPort( cfg.preferences.proxyServer.port );
|
||||||
|
|
||||||
if ( cfg.preferences.proxyServer.user.size() )
|
if ( cfg.preferences.proxyServer.user.size() )
|
||||||
proxy.setUser( cfg.preferences.proxyServer.user );
|
proxy.setUser( cfg.preferences.proxyServer.user );
|
||||||
|
|
||||||
if ( cfg.preferences.proxyServer.password.size() )
|
if ( cfg.preferences.proxyServer.password.size() )
|
||||||
proxy.setPassword( cfg.preferences.proxyServer.password );
|
proxy.setPassword( cfg.preferences.proxyServer.password );
|
||||||
}
|
}
|
||||||
|
|
||||||
QNetworkProxy::setApplicationProxy( proxy );
|
QNetworkProxy::setApplicationProxy( proxy );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,9 +556,9 @@ void MainWindow::makeScanPopup()
|
||||||
|
|
||||||
if ( !cfg.preferences.enableScanPopup )
|
if ( !cfg.preferences.enableScanPopup )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
scanPopup = new ScanPopup( 0, cfg, articleNetMgr, dictionaries, groupInstances );
|
scanPopup = new ScanPopup( 0, cfg, articleNetMgr, dictionaries, groupInstances );
|
||||||
|
|
||||||
if ( enableScanPopup->isChecked() )
|
if ( enableScanPopup->isChecked() )
|
||||||
scanPopup->enableScanning();
|
scanPopup->enableScanning();
|
||||||
}
|
}
|
||||||
|
@ -711,7 +714,7 @@ void MainWindow::pronounce()
|
||||||
|
|
||||||
void MainWindow::updatePronounceAvailability()
|
void MainWindow::updatePronounceAvailability()
|
||||||
{
|
{
|
||||||
bool pronounceEnabled = ui.tabWidget->count() > 0 &&
|
bool pronounceEnabled = ui.tabWidget->count() > 0 &&
|
||||||
dynamic_cast< ArticleView & >( *( ui.tabWidget->currentWidget() ) ).hasSound();
|
dynamic_cast< ArticleView & >( *( ui.tabWidget->currentWidget() ) ).hasSound();
|
||||||
|
|
||||||
navPronounce->setEnabled( pronounceEnabled );
|
navPronounce->setEnabled( pronounceEnabled );
|
||||||
|
@ -765,15 +768,18 @@ void MainWindow::editPreferences()
|
||||||
if ( preferences.exec() == QDialog::Accepted )
|
if ( preferences.exec() == QDialog::Accepted )
|
||||||
{
|
{
|
||||||
cfg.preferences = preferences.getPreferences();
|
cfg.preferences = preferences.getPreferences();
|
||||||
|
|
||||||
enableScanPopup->setVisible( cfg.preferences.enableScanPopup );
|
enableScanPopup->setVisible( cfg.preferences.enableScanPopup );
|
||||||
|
|
||||||
if ( !cfg.preferences.enableScanPopup )
|
if ( !cfg.preferences.enableScanPopup )
|
||||||
enableScanPopup->setChecked( false );
|
enableScanPopup->setChecked( false );
|
||||||
|
|
||||||
updateTrayIcon();
|
updateTrayIcon();
|
||||||
applyProxySettings();
|
applyProxySettings();
|
||||||
makeScanPopup();
|
makeScanPopup();
|
||||||
|
|
||||||
|
setAutostart(cfg.preferences.autoStart);
|
||||||
|
|
||||||
Config::save( cfg );
|
Config::save( cfg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -846,7 +852,7 @@ void MainWindow::updateMatchResults( bool finished )
|
||||||
WordFinder::SearchResults const & results = wordFinder.getResults();
|
WordFinder::SearchResults const & results = wordFinder.getResults();
|
||||||
|
|
||||||
ui.wordList->setUpdatesEnabled( false );
|
ui.wordList->setUpdatesEnabled( false );
|
||||||
|
|
||||||
for( unsigned x = 0; x < results.size(); ++x )
|
for( unsigned x = 0; x < results.size(); ++x )
|
||||||
{
|
{
|
||||||
QListWidgetItem * i = ui.wordList->item( x );
|
QListWidgetItem * i = ui.wordList->item( x );
|
||||||
|
@ -922,7 +928,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
|
||||||
if ( ev->type() == QEvent::KeyPress )
|
if ( ev->type() == QEvent::KeyPress )
|
||||||
{
|
{
|
||||||
QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev );
|
QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev );
|
||||||
|
|
||||||
if ( keyEvent->matches( QKeySequence::MoveToNextLine ) && ui.wordList->count() )
|
if ( keyEvent->matches( QKeySequence::MoveToNextLine ) && ui.wordList->count() )
|
||||||
{
|
{
|
||||||
ui.wordList->setFocus( Qt::ShortcutFocusReason );
|
ui.wordList->setFocus( Qt::ShortcutFocusReason );
|
||||||
|
@ -1026,11 +1032,11 @@ void MainWindow::showTranslationFor( QString const & inWord )
|
||||||
|
|
||||||
{
|
{
|
||||||
set< wstring > altsSet;
|
set< wstring > altsSet;
|
||||||
|
|
||||||
for( unsigned x = 0; x < activeDicts.size(); ++x )
|
for( unsigned x = 0; x < activeDicts.size(); ++x )
|
||||||
{
|
{
|
||||||
vector< wstring > found = activeDicts[ x ]->findHeadwordsForSynonym( word );
|
vector< wstring > found = activeDicts[ x ]->findHeadwordsForSynonym( word );
|
||||||
|
|
||||||
altsSet.insert( found.begin(), found.end() );
|
altsSet.insert( found.begin(), found.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1114,7 +1120,7 @@ void MainWindow::scanEnableToggled( bool on )
|
||||||
else
|
else
|
||||||
scanPopup->disableScanning();
|
scanPopup->disableScanning();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTrayIcon();
|
updateTrayIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ private slots:
|
||||||
|
|
||||||
void prefixMatchUpdated();
|
void prefixMatchUpdated();
|
||||||
void prefixMatchFinished();
|
void prefixMatchFinished();
|
||||||
|
|
||||||
void wordListItemActivated( QListWidgetItem * );
|
void wordListItemActivated( QListWidgetItem * );
|
||||||
void wordListSelectionChanged();
|
void wordListSelectionChanged();
|
||||||
|
|
||||||
|
@ -170,18 +170,22 @@ private slots:
|
||||||
|
|
||||||
void openLinkInNewTab( QUrl const &, QUrl const & );
|
void openLinkInNewTab( QUrl const &, QUrl const & );
|
||||||
void showDefinitionInNewTab( QString const & word, unsigned group );
|
void showDefinitionInNewTab( QString const & word, unsigned group );
|
||||||
|
|
||||||
void showTranslationFor( QString const & );
|
void showTranslationFor( QString const & );
|
||||||
|
|
||||||
void trayIconActivated( QSystemTrayIcon::ActivationReason );
|
void trayIconActivated( QSystemTrayIcon::ActivationReason );
|
||||||
|
|
||||||
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