[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdegraphics/kghostview
From: Waldo Bastian <bastian () kde ! org>
Date: 2004-06-12 15:39:15
Message-ID: 20040612153915.46EC998EA () office ! kde ! org
[Download RAW message or body]
CVS commit by waba:
Correctly show actual zoom percentage with fit top width / screen (BR83063)
CCMAIL: 83063-done@bugs.kde.org
M +31 -14 kgv_view.cpp 1.183
M +2 -0 kgv_view.h 1.81
--- kdegraphics/kghostview/kgv_view.cpp #1.182:1.183
@@ -17,7 +17,9 @@
*/
+#include <qcombobox.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qframe.h>
+#include <qlineedit.h>
#include <qtable.h>
#include <qlayout.h>
@@ -84,5 +86,6 @@ KGVPart::KGVPart( QWidget* parentWidget,
_isGuiInitialized( false ),
_isFileDirty( false ),
- _stickyOptions( false )
+ _stickyOptions( false ),
+ _customZoomIndex( -1 )
{
setInstance( KGVFactory::instance() );
@@ -255,5 +258,5 @@ KGVPart::KGVPart( QWidget* parentWidget,
first != last;
++first ) {
- translated << QString( i18n( "zoom-factor (percentage)", "%1%" ) ).arg( *first * 100.0 );
+ translated << i18n( "zoom-factor (percentage)", "%1%" ).arg( *first * 100.0 );
if ( *first == 1.0 ) idx = cur;
++cur;
@@ -550,5 +553,12 @@ void KGVPart::updateZoomActions()
_zoomTo->setEnabled( true );
QStringList items = _zoomTo->items();
- double zoom = miniWidget()->displayOptions().magnification();
+ bool updateItems = false;
+ if (_customZoomIndex != -1)
+ {
+ items.remove(items.at(_customZoomIndex));
+ _customZoomIndex = -1;
+ updateItems = true;
+ }
+ double zoom = floor(miniWidget()->displayOptions().magnification()*1000.0) / 10.0;
unsigned idx = 0;
for ( QStringList::iterator first = items.begin(), last = items.end();
@@ -560,18 +570,22 @@ void KGVPart::updateZoomActions()
bool ok = false;
double z = cur.toDouble(&ok);
- if ( ok && std::abs( z - zoom * 100.0 ) < 0.1 ) {
+ if ( ok ) {
+ if (std::abs( z - zoom ) < 0.1 ) {
+ if (updateItems)
+ _zoomTo->setItems( items );
_zoomTo->setCurrentItem( idx );
return;
}
+ if ( z > zoom )
+ break;
+ }
++idx;
}
- /* TODO:
- *
- * One should reorder the _zoomTo->items() list here.
- * This is because any values the user types in himself will get
- * put at the end of the list, which is not optimal.
- *
- * LPC 19 Jun 2003
- */
+
+ // Show percentage that isn't predefined
+ items.insert( items.at(idx), 1, i18n( "zoom-factor (percentage)", "%1%" ).arg( zoom ) );
+ _zoomTo->setItems( items );
+ _zoomTo->setCurrentItem( idx );
+ _customZoomIndex = idx;
}
@@ -879,4 +893,5 @@ void KGVPart::slotZoom( const QString& n
miniWidget()->redisplay();
_mainWidget->setFocus();
+ updateZoomActions();
}
@@ -887,4 +902,5 @@ void KGVPart::slotFitToPage()
miniWidget()->fitWidth( pageView()->viewport()->width() - 16 );
// We subtract 16 pixels because of the page decoration.
+ updateZoomActions();
}
@@ -905,4 +921,5 @@ void KGVPart::slotDoFitToScreen()
miniWidget()->fitWidthHeight( pageView()->viewport()->width() - 16,
pageView()->viewport()->height() - 16 );
+ updateZoomActions();
}
--- kdegraphics/kghostview/kgv_view.h #1.80:1.81
@@ -220,4 +220,6 @@ private:
bool _stickyOptions : 1;
+ int _customZoomIndex;
+
DisplayOptions _options;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic