From 3e2ae16e9675329c426578de9575b8f87aeb81fb Mon Sep 17 00:00:00 2001 From: ars_goldendict Date: Thu, 30 Apr 2009 19:57:25 +0000 Subject: [PATCH] added zoom buttons --- src/articleview.hh | 11 ++++--- src/config.cc | 17 +++++++++- src/config.hh | 2 ++ src/icons/icon32_zoombase.png | Bin 0 -> 1738 bytes src/icons/icon32_zoomin.png | Bin 0 -> 1696 bytes src/icons/icon32_zoomout.png | Bin 0 -> 1662 bytes src/mainwindow.cc | 58 +++++++++++++++++++++++++++++++--- src/mainwindow.hh | 7 ++++ src/resources.qrc | 3 ++ 9 files changed, 89 insertions(+), 9 deletions(-) create mode 100644 src/icons/icon32_zoombase.png create mode 100644 src/icons/icon32_zoomin.png create mode 100644 src/icons/icon32_zoomout.png diff --git a/src/articleview.hh b/src/articleview.hh index 811d2094..aefd8899 100644 --- a/src/articleview.hh +++ b/src/articleview.hh @@ -59,12 +59,12 @@ public: /// Clears the view and sets the application-global waiting cursor, /// which will be restored when some article loads eventually. void showAnticipation(); - + /// Opens the given link. Supposed to be used in response to /// openLinkInNewTab() signal. The link scheme is therefore supposed to be /// one of the internal ones. void openLink( QUrl const & url, QUrl const & referrer ); - + /// Goes back in history void back() { ui.definition->back(); } @@ -83,6 +83,9 @@ public: /// Plays the first audio reference on the page, if any. void playSound(); + void setZoomFactor( qreal factor ) + { ui.definition->setZoomFactor( factor ); } + signals: void iconChanged( ArticleView *, QIcon const & icon ); @@ -92,7 +95,7 @@ signals: void pageLoaded(); /// Singals that the following link was requested to be opened in new tab - void openLinkInNewTab( QUrl const &, QUrl const & referrer ); + void openLinkInNewTab( QUrl const &, QUrl const & referrer ); /// Singals that the following definition was requested to be showed in new tab void showDefinitionInNewTab( QString const & word, unsigned group ); @@ -114,7 +117,7 @@ private: /// Attempts removing last temporary file created. void cleanupTemp(); - + protected: // We need this to hide the search bar when we're showed diff --git a/src/config.cc b/src/config.cc index 41f2126d..ac952f70 100644 --- a/src/config.cc +++ b/src/config.cc @@ -88,7 +88,9 @@ Preferences::Preferences(): scanPopupAltModeSecs( 3 ), pronounceOnLoadMain( false ), pronounceOnLoadPopup( false ), - checkForNewReleases( true ) + checkForNewReleases( true ), + + zoomFactor( 1 ) { } @@ -333,6 +335,15 @@ Class load() throw( exError ) c.preferences.closeToTray = ( preferences.namedItem( "closeToTray" ).toElement().text() == "1" ); c.preferences.autoStart = ( preferences.namedItem( "autoStart" ).toElement().text() == "1" ); + if ( !preferences.namedItem( "zoomFactor" ).isNull() ) + { + c.preferences.zoomFactor = preferences.namedItem( "zoomFactor" ).toElement().text().toDouble(); + if ( c.preferences.zoomFactor < 0.5 ) + c.preferences.zoomFactor = 0.5; + else if ( c.preferences.zoomFactor > 5 ) + c.preferences.zoomFactor = 5; + } + applyBoolOption( c.preferences.enableMainWindowHotkey, preferences.namedItem( "enableMainWindowHotkey" ) ); if ( !preferences.namedItem( "mainWindowHotkey" ).isNull() ) c.preferences.mainWindowHotkey = QKeySequence::fromString( preferences.namedItem( "mainWindowHotkey" ).toElement().text() ); @@ -582,6 +593,10 @@ void save( Class const & c ) throw( exError ) opt.appendChild( dd.createTextNode( c.preferences.autoStart ? "1":"0" ) ); preferences.appendChild( opt ); + opt = dd.createElement( "zoomFactor" ); + opt.appendChild( dd.createTextNode( QString::number( c.preferences.zoomFactor ) ) ); + preferences.appendChild( opt ); + opt = dd.createElement( "enableMainWindowHotkey" ); opt.appendChild( dd.createTextNode( c.preferences.enableMainWindowHotkey ? "1":"0" ) ); preferences.appendChild( opt ); diff --git a/src/config.hh b/src/config.hh index cde9da5f..7264d4c7 100644 --- a/src/config.hh +++ b/src/config.hh @@ -155,6 +155,8 @@ struct Preferences bool checkForNewReleases; + qreal zoomFactor; + Preferences(); }; diff --git a/src/icons/icon32_zoombase.png b/src/icons/icon32_zoombase.png new file mode 100644 index 0000000000000000000000000000000000000000..ed0c0c79820a0cdf940c8dc4cd603360091e8dd9 GIT binary patch literal 1738 zcmV;*1~vJKP)RCwCOmU~cCRUF69xpx=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wl0~EpX|!RaBpYvm7I(408>7w(8(z>yJ-^c-o7IxPuX_ z;SW-SJV1+tagv&kK=(icplcup4+ejp@-m&ah{4zi!q$la2nMr_dbYB>%lfkb!7l`0 z8>a&-wH{9)8`I{pd7tR>iEH`!k*x~vCaPO}{ZFXmND2`~~t zv@nK+g?PIK$ymf1SDe1Vi+%^(@B~6N3sH5T(|Qo*G@;oi+kyadEg})DAe{q4*+G%E z9w6QZOKfwRfxyTaKvWFoATX=J9TfruD+a)31)Do$Lhm3zQ0T8#v9*vOSDd&}O>c2# zW+9xI83_LHb+)>q(@NfrC&d8RPDeIX2x8{M#C!n6EkQwUIDV5i9q%ky0sugW-+SKj zZToGmP%Ho~Y)aBoB|z8!?A=d+IfkSUi@uU{Cfkr^nFER+{0n+a07*qoM6N<$f@Sm(pa1{> literal 0 HcmV?d00001 diff --git a/src/icons/icon32_zoomin.png b/src/icons/icon32_zoomin.png new file mode 100644 index 0000000000000000000000000000000000000000..d46f5aff0d9810d21bc98be02776e843b2db7ee9 GIT binary patch literal 1696 zcmV;R24DG!P)M)aAbHgK4feb(o@*sSNy95h=Ip27A;w_Brzc&;Vl2!TU%T2c64;8A)&(#KX`(# z_{RnCPm5vY;NTFPl$2E2($aE|LC23Dr{LgV3J3`3me65`A3X38hxivRKny;`&CM;g zxVX5jxw)BAQc~zWpH)|_<}WQ9<-9h3ko%6qkkDa=A3X38hxon}@u&5+v$G2+EG%qm zXlS4vA)%eq7q2;`?;Vw<=a(Ko?vwnlCT=ZCf`kq`{NRC)IK=m5U-T|OW_ZNL##S{o zHBn65zD}D}Tl1uqDKSGfo!mR~Ktue-l508PXF85TLWdoG@W4kL;*kgWG%i5Q-qh9A z^-xt+)%}u^5?US@_MP-W=3Z%2McAy2ThXbFcTc>#E{=S6WD_KG*x?5ce8eFhd5}+& zF7y~I{N&>T*)b)RLdGk zf6a9=2zYMK?oGy7> zAjy|Ws~PY20(98f4<7i4Lp<^zAM*C41M8!rqHban#pa&+cId9=2nXs!S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p?S#5flF!;LnVtauybS4xygX#m?B<1FEeH^Y#1{KV6E*aMRB;TQoqwlMcM^w%3={G zS7`M9w#qyqLTQKqBQg5nV$>F*Q(MMt#vFz-W3D(k{eZpEcC_N`HWsnVSw(x?)%4j? z4Hd4`=p9Ur@PZy^r~s8%|M85e;{ER^I>LWP^BL~qMD)X5Y`QQOQ5s>#B3x9omqo0% zS5;xJ$g}z%2*B~%%pyLIn5EROnre(!v#&ToL!R~$I18Z;jF1V#6@b5i;S(N1b74;uQ$1b?A0q}atp6DP2BW`gTyAkL3jhEB07*qo IM6N<$f`v>W)&Kwi literal 0 HcmV?d00001 diff --git a/src/mainwindow.cc b/src/mainwindow.cc index a9af2269..e6c6745e 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -77,6 +77,20 @@ MainWindow::MainWindow( Config::Class & cfg_ ): connect( navPronounce, SIGNAL( triggered() ), this, SLOT( pronounce() ) ); + // zooming + navToolbar->addSeparator(); + zoomIn = navToolbar->addAction( QIcon( ":/icons/icon32_zoomin.png" ), tr( "Increase zoom factor" ) ); + zoomOut = navToolbar->addAction( QIcon( ":/icons/icon32_zoomout.png" ), tr( "Decrease zoom factor" ) ); + zoomBase = navToolbar->addAction( QIcon( ":/icons/icon32_zoombase.png" ), tr( "Reset zoom factor to default" ) ); + + connect( zoomIn, SIGNAL( triggered() ), + this, SLOT( zoomin() ) ); + connect( zoomOut, SIGNAL( triggered() ), + this, SLOT( zoomout() ) ); + connect( zoomBase, SIGNAL( triggered() ), + this, SLOT( unzoom() ) ); + + // tray icon connect( trayIconMenu.addAction( tr( "Show &Main Window" ) ), SIGNAL( activated() ), this, SLOT( showMainWindow() ) ); trayIconMenu.addAction( enableScanPopup ); @@ -466,6 +480,8 @@ ArticleView * MainWindow::createNewTab( bool switchToIt, if ( switchToIt ) ui.tabWidget->setCurrentIndex( index ); + view->setZoomFactor( cfg.preferences.zoomFactor ); + return view; } @@ -569,18 +585,18 @@ void MainWindow::editDictionaries() { hotkeyWrapper.reset(); // No hotkeys while we're editing dictionaries scanPopup.reset(); // No scan popup either. No one should use dictionaries. - + EditDictionaries dicts( this, cfg, dictionaries, dictNetMgr ); dicts.exec(); - + if ( dicts.areDictionariesChanged() || dicts.areGroupsChanged() ) { updateGroupList(); - + Config::save( cfg ); } - + makeScanPopup(); installHotKeys(); } @@ -1198,3 +1214,37 @@ void MainWindow::on_actionCloseToTray_activated() { toggleMainWindow( !cfg.preferences.enableTrayIcon ); } + +void MainWindow::zoomin() +{ + if ( cfg.preferences.zoomFactor >= 5 ) + return; // 5x is maximum + + cfg.preferences.zoomFactor += 0.1; + applyZoomFactor(); +} + +void MainWindow::zoomout() +{ + if ( cfg.preferences.zoomFactor <= 0.5 ) + return; // 0.5x is minimum + + cfg.preferences.zoomFactor -= 0.1; + applyZoomFactor(); +} + +void MainWindow::unzoom() +{ + cfg.preferences.zoomFactor = 1; + applyZoomFactor(); +} + +void MainWindow::applyZoomFactor() +{ + for ( int i = 0; i < ui.tabWidget->count(); i++ ) + { + ArticleView & view = + dynamic_cast< ArticleView & >( *( ui.tabWidget->widget(i) ) ); + view.setZoomFactor( cfg.preferences.zoomFactor ); + } +} diff --git a/src/mainwindow.hh b/src/mainwindow.hh index d76b168d..32c9d453 100644 --- a/src/mainwindow.hh +++ b/src/mainwindow.hh @@ -50,6 +50,7 @@ private: switchToNextTabAction, switchToPrevTabAction; QToolBar * navToolbar; QAction * navBack, * navForward, * navPronounce, * enableScanPopup; + QAction * zoomIn, * zoomOut, * zoomBase; QMenu trayIconMenu; QToolButton addTab; Config::Class & cfg; @@ -100,6 +101,8 @@ private: /// Creates hotkeyWrapper and hooks the currently set keys for it void installHotKeys(); + void applyZoomFactor(); + private slots: void hotKeyActivated( int ); @@ -143,6 +146,10 @@ private slots: /// reference, if it has any. void pronounce(); + void zoomin(); + void zoomout(); + void unzoom(); + void editDictionaries(); void editPreferences(); diff --git a/src/resources.qrc b/src/resources.qrc index 972892be..3fd09209 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -21,5 +21,8 @@ icons/icon32_dictd.png icons/icon32_hunspell.png icons/icon32_wiki.png + icons/icon32_zoombase.png + icons/icon32_zoomin.png + icons/icon32_zoomout.png