added zoom buttons

This commit is contained in:
ars_goldendict 2009-04-30 19:57:25 +00:00
parent e94ed0f25d
commit 3e2ae16e96
9 changed files with 89 additions and 9 deletions

View file

@ -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 );

View file

@ -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 );

View file

@ -155,6 +155,8 @@ struct Preferences
bool checkForNewReleases;
qreal zoomFactor;
Preferences();
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
src/icons/icon32_zoomin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -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;
}
@ -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 );
}
}

View file

@ -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();

View file

@ -21,5 +21,8 @@
<file>icons/icon32_dictd.png</file>
<file>icons/icon32_hunspell.png</file>
<file>icons/icon32_wiki.png</file>
<file>icons/icon32_zoombase.png</file>
<file>icons/icon32_zoomin.png</file>
<file>icons/icon32_zoomout.png</file>
</qresource>
</RCC>