mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-04 07:54:06 +00:00
+ Options to open tabs in background and open tabs after the current one added.
This commit is contained in:
parent
92280c0534
commit
5e7f41a64e
|
@ -41,6 +41,8 @@ ProxyServer::ProxyServer(): enabled( false ), type( Socks5 ), port( 3128 )
|
||||||
}
|
}
|
||||||
|
|
||||||
Preferences::Preferences():
|
Preferences::Preferences():
|
||||||
|
newTabsOpenAfterCurrentOne( false ),
|
||||||
|
newTabsOpenInBackground( true ),
|
||||||
enableTrayIcon( true ),
|
enableTrayIcon( true ),
|
||||||
startToTray( false ),
|
startToTray( false ),
|
||||||
closeToTray( true ),
|
closeToTray( true ),
|
||||||
|
@ -243,6 +245,8 @@ Class load() throw( exError )
|
||||||
if ( !preferences.isNull() )
|
if ( !preferences.isNull() )
|
||||||
{
|
{
|
||||||
c.preferences.interfaceLanguage = preferences.namedItem( "interfaceLanguage" ).toElement().text();
|
c.preferences.interfaceLanguage = preferences.namedItem( "interfaceLanguage" ).toElement().text();
|
||||||
|
c.preferences.newTabsOpenAfterCurrentOne = ( preferences.namedItem( "newTabsOpenAfterCurrentOne" ).toElement().text() == "1" );
|
||||||
|
c.preferences.newTabsOpenInBackground = ( preferences.namedItem( "newTabsOpenInBackground" ).toElement().text() == "1" );
|
||||||
c.preferences.enableTrayIcon = ( preferences.namedItem( "enableTrayIcon" ).toElement().text() == "1" );
|
c.preferences.enableTrayIcon = ( preferences.namedItem( "enableTrayIcon" ).toElement().text() == "1" );
|
||||||
c.preferences.startToTray = ( preferences.namedItem( "startToTray" ).toElement().text() == "1" );
|
c.preferences.startToTray = ( preferences.namedItem( "startToTray" ).toElement().text() == "1" );
|
||||||
c.preferences.closeToTray = ( preferences.namedItem( "closeToTray" ).toElement().text() == "1" );
|
c.preferences.closeToTray = ( preferences.namedItem( "closeToTray" ).toElement().text() == "1" );
|
||||||
|
@ -455,6 +459,14 @@ void save( Class const & c ) throw( exError )
|
||||||
opt.appendChild( dd.createTextNode( c.preferences.interfaceLanguage ) );
|
opt.appendChild( dd.createTextNode( c.preferences.interfaceLanguage ) );
|
||||||
preferences.appendChild( opt );
|
preferences.appendChild( opt );
|
||||||
|
|
||||||
|
opt = dd.createElement( "newTabsOpenAfterCurrentOne" );
|
||||||
|
opt.appendChild( dd.createTextNode( c.preferences.newTabsOpenAfterCurrentOne ? "1":"0" ) );
|
||||||
|
preferences.appendChild( opt );
|
||||||
|
|
||||||
|
opt = dd.createElement( "newTabsOpenInBackground" );
|
||||||
|
opt.appendChild( dd.createTextNode( c.preferences.newTabsOpenInBackground ? "1":"0" ) );
|
||||||
|
preferences.appendChild( opt );
|
||||||
|
|
||||||
opt = dd.createElement( "enableTrayIcon" );
|
opt = dd.createElement( "enableTrayIcon" );
|
||||||
opt.appendChild( dd.createTextNode( c.preferences.enableTrayIcon ? "1":"0" ) );
|
opt.appendChild( dd.createTextNode( c.preferences.enableTrayIcon ? "1":"0" ) );
|
||||||
preferences.appendChild( opt );
|
preferences.appendChild( opt );
|
||||||
|
|
|
@ -99,6 +99,8 @@ struct ProxyServer
|
||||||
struct Preferences
|
struct Preferences
|
||||||
{
|
{
|
||||||
QString interfaceLanguage; // Empty value corresponds to system default
|
QString interfaceLanguage; // Empty value corresponds to system default
|
||||||
|
bool newTabsOpenAfterCurrentOne;
|
||||||
|
bool newTabsOpenInBackground;
|
||||||
bool enableTrayIcon;
|
bool enableTrayIcon;
|
||||||
bool startToTray;
|
bool startToTray;
|
||||||
bool closeToTray;
|
bool closeToTray;
|
||||||
|
|
|
@ -579,6 +579,12 @@ void MainWindow::indexingDictionary( QString dictionaryName )
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::addNewTab()
|
void MainWindow::addNewTab()
|
||||||
|
{
|
||||||
|
createNewTab( true, tr( "(untitled)" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
ArticleView * MainWindow::createNewTab( bool switchToIt,
|
||||||
|
QString const & name )
|
||||||
{
|
{
|
||||||
ArticleView * view = new ArticleView( this, articleNetMgr, dictionaries,
|
ArticleView * view = new ArticleView( this, articleNetMgr, dictionaries,
|
||||||
groupInstances, false, cfg );
|
groupInstances, false, cfg );
|
||||||
|
@ -593,15 +599,25 @@ void MainWindow::addNewTab()
|
||||||
|
|
||||||
connect( view, SIGNAL( openLinkInNewTab( QUrl const &, QUrl const & ) ),
|
connect( view, SIGNAL( openLinkInNewTab( QUrl const &, QUrl const & ) ),
|
||||||
this, SLOT( openLinkInNewTab( QUrl const &, QUrl const & ) ) );
|
this, SLOT( openLinkInNewTab( QUrl const &, QUrl const & ) ) );
|
||||||
|
|
||||||
connect( view, SIGNAL( showDefinitionInNewTab( QString const &, unsigned ) ),
|
connect( view, SIGNAL( showDefinitionInNewTab( QString const &, unsigned ) ),
|
||||||
this, SLOT( showDefinitionInNewTab( QString const &, unsigned ) ) );
|
this, SLOT( showDefinitionInNewTab( QString const &, unsigned ) ) );
|
||||||
|
|
||||||
ui.tabWidget->addTab( view, tr( "(untitled)" ) );
|
|
||||||
|
|
||||||
ui.tabWidget->setCurrentIndex( ui.tabWidget->count() - 1 );
|
int index = cfg.preferences.newTabsOpenAfterCurrentOne ?
|
||||||
|
ui.tabWidget->currentIndex() + 1 : ui.tabWidget->count();
|
||||||
|
|
||||||
|
QString escaped = name;
|
||||||
|
escaped.replace( "&", "&&" );
|
||||||
|
|
||||||
|
ui.tabWidget->insertTab( index, view, escaped );
|
||||||
|
|
||||||
|
if ( switchToIt )
|
||||||
|
ui.tabWidget->setCurrentIndex( index );
|
||||||
|
|
||||||
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::tabCloseRequested( int x )
|
void MainWindow::tabCloseRequested( int x )
|
||||||
{
|
{
|
||||||
if ( ui.tabWidget->count() < 2 )
|
if ( ui.tabWidget->count() < 2 )
|
||||||
|
@ -957,23 +973,13 @@ void MainWindow::wordListSelectionChanged()
|
||||||
void MainWindow::openLinkInNewTab( QUrl const & url,
|
void MainWindow::openLinkInNewTab( QUrl const & url,
|
||||||
QUrl const & referrer )
|
QUrl const & referrer )
|
||||||
{
|
{
|
||||||
addNewTab();
|
createNewTab( !cfg.preferences.newTabsOpenInBackground, "" )->openLink( url, referrer );
|
||||||
|
|
||||||
ArticleView & view =
|
|
||||||
dynamic_cast< ArticleView & >( *( ui.tabWidget->currentWidget() ) );
|
|
||||||
|
|
||||||
view.openLink( url, referrer );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showDefinitionInNewTab( QString const & word,
|
void MainWindow::showDefinitionInNewTab( QString const & word,
|
||||||
unsigned group )
|
unsigned group )
|
||||||
{
|
{
|
||||||
addNewTab();
|
createNewTab( !cfg.preferences.newTabsOpenInBackground, word )->showDefinition( word, group );
|
||||||
|
|
||||||
ArticleView & view =
|
|
||||||
dynamic_cast< ArticleView & >( *( ui.tabWidget->currentWidget() ) );
|
|
||||||
|
|
||||||
view.showDefinition( word, group );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showTranslationFor( QString const & inWord )
|
void MainWindow::showTranslationFor( QString const & inWord )
|
||||||
|
|
|
@ -164,6 +164,10 @@ private slots:
|
||||||
void wordListItemActivated( QListWidgetItem * );
|
void wordListItemActivated( QListWidgetItem * );
|
||||||
void wordListSelectionChanged();
|
void wordListSelectionChanged();
|
||||||
|
|
||||||
|
/// Creates a new tab, which is to be populated then with some content.
|
||||||
|
ArticleView * createNewTab( bool switchToIt,
|
||||||
|
QString const & name );
|
||||||
|
|
||||||
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 );
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@ Preferences::Preferences( QWidget * parent, Config::Preferences const & p ):
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.newTabsOpenAfterCurrentOne->setChecked( p.newTabsOpenAfterCurrentOne );
|
||||||
|
ui.newTabsOpenInBackground->setChecked( p.newTabsOpenInBackground );
|
||||||
ui.enableTrayIcon->setChecked( p.enableTrayIcon );
|
ui.enableTrayIcon->setChecked( p.enableTrayIcon );
|
||||||
ui.startToTray->setChecked( p.startToTray );
|
ui.startToTray->setChecked( p.startToTray );
|
||||||
ui.closeToTray->setChecked( p.closeToTray );
|
ui.closeToTray->setChecked( p.closeToTray );
|
||||||
|
@ -119,6 +121,8 @@ Config::Preferences Preferences::getPreferences()
|
||||||
ui.interfaceLanguage->itemData(
|
ui.interfaceLanguage->itemData(
|
||||||
ui.interfaceLanguage->currentIndex() ).toString();
|
ui.interfaceLanguage->currentIndex() ).toString();
|
||||||
|
|
||||||
|
p.newTabsOpenAfterCurrentOne = ui.newTabsOpenAfterCurrentOne->isChecked();
|
||||||
|
p.newTabsOpenInBackground = ui.newTabsOpenInBackground->isChecked();
|
||||||
p.enableTrayIcon = ui.enableTrayIcon->isChecked();
|
p.enableTrayIcon = ui.enableTrayIcon->isChecked();
|
||||||
p.startToTray = ui.startToTray->isChecked();
|
p.startToTray = ui.startToTray->isChecked();
|
||||||
p.closeToTray = ui.closeToTray->isChecked();
|
p.closeToTray = ui.closeToTray->isChecked();
|
||||||
|
|
|
@ -40,6 +40,39 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Tabbed browsing</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_11">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="newTabsOpenInBackground">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Normally, opening a new tab switches to it immediately.
|
||||||
|
With this on however, new tabs will be opened without
|
||||||
|
switching to them.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Open new tabs in background</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="newTabsOpenAfterCurrentOne">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>With this on, new tabs are opened just after the
|
||||||
|
current, active one. Otherwise they are added to
|
||||||
|
be the last ones.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Open new tabs after the current one</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="enableTrayIcon">
|
<widget class="QGroupBox" name="enableTrayIcon">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
|
Loading…
Reference in a new issue