Fixed #143: Make the new UI mode the default one.

This commit is contained in:
Tvangeste 2013-01-05 12:26:55 +01:00
parent 09bc4b46bd
commit 9ad4da4cb5
4 changed files with 28 additions and 21 deletions

View file

@ -95,6 +95,7 @@ Preferences::Preferences():
selectWordBySingleClick( false ), selectWordBySingleClick( false ),
escKeyHidesMainWindow( false ), escKeyHidesMainWindow( false ),
alwaysOnTop ( false ), alwaysOnTop ( false ),
searchInDock ( false ),
enableMainWindowHotkey( true ), enableMainWindowHotkey( true ),
mainWindowHotkey( QKeySequence( "Ctrl+F11,F11" ) ), mainWindowHotkey( QKeySequence( "Ctrl+F11,F11" ) ),
@ -615,6 +616,7 @@ Class load() throw( exError )
c.preferences.closeToTray = ( preferences.namedItem( "closeToTray" ).toElement().text() == "1" ); c.preferences.closeToTray = ( preferences.namedItem( "closeToTray" ).toElement().text() == "1" );
c.preferences.autoStart = ( preferences.namedItem( "autoStart" ).toElement().text() == "1" ); c.preferences.autoStart = ( preferences.namedItem( "autoStart" ).toElement().text() == "1" );
c.preferences.alwaysOnTop = ( preferences.namedItem( "alwaysOnTop" ).toElement().text() == "1" ); c.preferences.alwaysOnTop = ( preferences.namedItem( "alwaysOnTop" ).toElement().text() == "1" );
c.preferences.searchInDock = ( preferences.namedItem( "searchInDock" ).toElement().text() == "1" );
if ( !preferences.namedItem( "doubleClickTranslates" ).isNull() ) if ( !preferences.namedItem( "doubleClickTranslates" ).isNull() )
c.preferences.doubleClickTranslates = ( preferences.namedItem( "doubleClickTranslates" ).toElement().text() == "1" ); c.preferences.doubleClickTranslates = ( preferences.namedItem( "doubleClickTranslates" ).toElement().text() == "1" );
@ -1274,6 +1276,10 @@ void save( Class const & c ) throw( exError )
opt.appendChild( dd.createTextNode( c.preferences.alwaysOnTop ? "1" : "0" ) ); opt.appendChild( dd.createTextNode( c.preferences.alwaysOnTop ? "1" : "0" ) );
preferences.appendChild( opt ); preferences.appendChild( opt );
opt = dd.createElement( "searchInDock" );
opt.appendChild( dd.createTextNode( c.preferences.searchInDock ? "1" : "0" ) );
preferences.appendChild( opt );
{ {
QDomElement proxy = dd.createElement( "proxyserver" ); QDomElement proxy = dd.createElement( "proxyserver" );
preferences.appendChild( proxy ); preferences.appendChild( proxy );

View file

@ -160,6 +160,10 @@ struct Preferences
bool escKeyHidesMainWindow; bool escKeyHidesMainWindow;
bool alwaysOnTop; bool alwaysOnTop;
/// An old UI mode when tranlateLine and wordList
/// are in the dockable side panel, not on the toolbar.
bool searchInDock;
bool enableMainWindowHotkey; bool enableMainWindowHotkey;
HotKey mainWindowHotkey; HotKey mainWindowHotkey;
bool enableClipboardHotkey; bool enableClipboardHotkey;

View file

@ -73,7 +73,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
articleNetMgr( this, dictionaries, articleMaker, articleNetMgr( this, dictionaries, articleMaker,
cfg.preferences.disallowContentFromOtherSites ), cfg.preferences.disallowContentFromOtherSites ),
dictNetMgr( this ), dictNetMgr( this ),
searchInDock( false ),
wordFinder( this ), wordFinder( this ),
newReleaseCheckTimer( this ), newReleaseCheckTimer( this ),
wordListSelChanged( false ) wordListSelChanged( false )
@ -195,10 +194,10 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
searchPaneTitleBar.setLayout( &searchPaneTitleBarLayout ); searchPaneTitleBar.setLayout( &searchPaneTitleBarLayout );
ui.searchPane->setTitleBarWidget( &searchPaneTitleBar ); ui.searchPane->setTitleBarWidget( &searchPaneTitleBar );
connect( ui.searchPane, SIGNAL( visibilityChanged( bool ) ), connect( ui.searchPane->toggleViewAction(), SIGNAL( triggered( bool ) ),
this, SLOT( updateSearchPaneAndBar() ) ); this, SLOT( updateSearchPaneAndBar( bool ) ) );
if (searchInDock) if ( cfg.preferences.searchInDock )
{ {
groupList = groupListInDock; groupList = groupListInDock;
translateLine = ui.translateLine; translateLine = ui.translateLine;
@ -595,6 +594,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
if ( cfg.mainWindowState.size() ) if ( cfg.mainWindowState.size() )
restoreState( cfg.mainWindowState, 1 ); restoreState( cfg.mainWindowState, 1 );
updateSearchPaneAndBar( cfg.preferences.searchInDock );
ui.searchPane->setVisible( cfg.preferences.searchInDock );
applyProxySettings(); applyProxySettings();
applyWebSettings(); applyWebSettings();
@ -682,12 +684,11 @@ void MainWindow::ctrlTabPressed()
tabListButton->click(); tabListButton->click();
} }
void MainWindow::updateSearchPaneAndBar() void MainWindow::updateSearchPaneAndBar( bool searchInDock )
{ {
if ( searchInDock )
if ( ui.searchPane->isVisible() )
{ {
searchInDock = true; cfg.preferences.searchInDock = true;
groupList = groupListInDock; groupList = groupListInDock;
translateLine = ui.translateLine; translateLine = ui.translateLine;
@ -701,7 +702,7 @@ void MainWindow::updateSearchPaneAndBar()
} }
else else
{ {
searchInDock = false; cfg.preferences.searchInDock = false;
groupList = groupListInToolbar; groupList = groupListInToolbar;
translateLine = translateBox->translateLine(); translateLine = translateBox->translateLine();
@ -1774,7 +1775,7 @@ void MainWindow::translateInputFinished( bool checkModifiers )
showTranslationFor( word ); showTranslationFor( word );
if ( searchInDock ) if ( cfg.preferences.searchInDock )
{ {
if ( ui.searchPane->isFloating() ) if ( ui.searchPane->isFloating() )
activateWindow(); activateWindow();
@ -1818,7 +1819,7 @@ void MainWindow::handleShiftF3()
void MainWindow::focusTranslateLine() void MainWindow::focusTranslateLine()
{ {
if ( searchInDock ) if ( cfg.preferences.searchInDock )
{ {
if ( ui.searchPane->isFloating() ) if ( ui.searchPane->isFloating() )
ui.searchPane->activateWindow(); ui.searchPane->activateWindow();
@ -1952,7 +1953,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
// when the main window is moved or resized, hide the word list suggestions // when the main window is moved or resized, hide the word list suggestions
if ( obj == this && ( ev->type() == QEvent::Move || ev->type() == QEvent::Resize ) ) if ( obj == this && ( ev->type() == QEvent::Move || ev->type() == QEvent::Resize ) )
{ {
if ( !searchInDock ) if ( !cfg.preferences.searchInDock )
{ {
wordList->hide(); wordList->hide();
return false; return false;
@ -1990,7 +1991,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
{ {
QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev ); QKeyEvent * keyEvent = static_cast< QKeyEvent * >( ev );
if (searchInDock) if ( cfg.preferences.searchInDock )
{ {
if ( keyEvent->matches( QKeySequence::MoveToNextLine ) && wordList->count() ) if ( keyEvent->matches( QKeySequence::MoveToNextLine ) && wordList->count() )
{ {
@ -2035,7 +2036,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
if ( keyEvent->matches( QKeySequence::InsertParagraphSeparator ) && if ( keyEvent->matches( QKeySequence::InsertParagraphSeparator ) &&
wordList->selectedItems().size() ) wordList->selectedItems().size() )
{ {
if ( searchInDock ) if ( cfg.preferences.searchInDock )
{ {
if ( ui.searchPane->isFloating() ) if ( ui.searchPane->isFloating() )
activateWindow(); activateWindow();
@ -2043,7 +2044,7 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
getCurrentArticleView()->focus(); getCurrentArticleView()->focus();
return searchInDock; return cfg.preferences.searchInDock;
} }
if( showHistory && keyEvent->matches( QKeySequence::Delete ) && ui.wordList->count() ) if( showHistory && keyEvent->matches( QKeySequence::Delete ) && ui.wordList->count() )
@ -2208,7 +2209,7 @@ void MainWindow::typingEvent( QString const & t )
} }
else else
{ {
if ( ( searchInDock && ui.searchPane->isFloating() ) || ui.dictsPane->isFloating() ) if ( ( cfg.preferences.searchInDock && ui.searchPane->isFloating() ) || ui.dictsPane->isFloating() )
ui.searchPane->activateWindow(); ui.searchPane->activateWindow();
if( translateLine->isEnabled() ) if( translateLine->isEnabled() )

View file

@ -133,10 +133,6 @@ private:
// since their requests can be destroyed // since their requests can be destroyed
// in a separate thread // in a separate thread
/// An old UI mode when tranlateLine and wordList
/// are in the dockable side panel, not on the toolbar.
bool searchInDock;
QListWidget * wordList; QListWidget * wordList;
QLineEdit * translateLine; QLineEdit * translateLine;
@ -381,7 +377,7 @@ private slots:
void on_alwaysOnTop_triggered( bool checked ); void on_alwaysOnTop_triggered( bool checked );
void focusWordList(); void focusWordList();
void updateSearchPaneAndBar(); void updateSearchPaneAndBar( bool searchInDock );
/// Add word to history /// Add word to history
void addWordToHistory( const QString & word ); void addWordToHistory( const QString & word );