Allow entering of "123" zoom instead of only "123%". Previously, if it couldn't find a % to chop, it would kill the last digit (the '3' in "123", giving an incorrect, 12%).

Add hack to get around "10&0%" action text which sometimes happens with kdelibs4.

okular developers: after updating kdelibs, zooming should work perfectly - please let me know if it doesn't.


svn path=/trunk/playground/graphics/okular/; revision=567575
remotes/origin/old/work/newpageview
Clarence Dang 20 years ago
parent d261d27274
commit 8ecc533c70
  1. 19
      ui/pageview.cpp

@ -1774,6 +1774,8 @@ void PageView::selectionClear()
void PageView::updateZoom( ZoomMode newZoomMode )
{
kDebug () << "PageView::updateZoom(newZoomMode=" << newZoomMode << ")" << endl;
if ( newZoomMode == ZoomFixed )
{
if ( d->aZoom->currentItem() == 0 )
@ -1788,7 +1790,12 @@ void PageView::updateZoom( ZoomMode newZoomMode )
{
case ZoomFixed:{ //ZoomFixed case
QString z = d->aZoom->currentText();
newFactor = KGlobal::locale()->readNumber( z.remove( z.indexOf( '%' ), 1 ) ) / 100.0;
kDebug () << "\tcurrentText=" << z << endl;
// kdelibs4 sometimes adds accelerators to actions' text directly :(
z.remove ('&');
z.remove ('%');
newFactor = KGlobal::locale()->readNumber( z ) / 100.0;
kDebug () << "\tnewFactor=" << newFactor << endl;
}break;
case ZoomIn:
newFactor += (newFactor > 0.99) ? ( newFactor > 1.99 ? 0.5 : 0.2 ) : 0.1;
@ -1819,6 +1826,7 @@ void PageView::updateZoom( ZoomMode newZoomMode )
if ( newZoomMode != d->zoomMode || (newZoomMode == ZoomFixed && newFactor != d->zoomFactor ) )
{
kDebug () << "\tcausing update=" << newFactor << endl;
// rebuild layout and update the whole viewport
d->zoomMode = newZoomMode;
d->zoomFactor = newFactor;
@ -1848,6 +1856,7 @@ void PageView::updateZoomText()
if ( d->zoomMode != ZoomFixed && d->items.count() > 0 )
d->zoomFactor = d->items[ qMax( 0, (int)d->document->currentPage() ) ]->zoomFactor();
float newFactor = d->zoomFactor;
kDebug () << "PageView::updateZoomText() newFactor=" << newFactor << endl;
d->aZoom->removeAllActions();
// add items that describe fit actions
@ -1860,11 +1869,17 @@ void PageView::updateZoomText()
int idx = 0,
selIdx = 2; // use 3 if "fit text" present
bool inserted = false; //use: "d->zoomMode != ZoomFixed" to hide Fit/* zoom ratio
kDebug () << "\tloop" << endl;
while ( idx < 10 || !inserted )
{
kDebug () << "\t\tidx=" << idx << " inserted=" << inserted << endl;
float value = idx < 10 ? zoomValue[ idx ] : newFactor;
kDebug () << "\t\t\tvalue=" << value << endl;
if ( !inserted && newFactor < (value - 0.0001) )
{
value = newFactor;
kDebug () << "\t\t\t\tnewFactor might come before us; value=newFactor=" << newFactor << endl;
}
else
idx ++;
if ( value > (newFactor - 0.0001) && value < (newFactor + 0.0001) )
@ -1873,8 +1888,10 @@ void PageView::updateZoomText()
selIdx++;
QString localValue( KGlobal::locale()->formatNumber( value * 100.0, 2 ) );
localValue.remove( KGlobal::locale()->decimalSymbol() + double_oh );
kDebug () << "\t\t\tadding '" << localValue << "'" << endl;
translated << QString( "%1%" ).arg( localValue );
}
kDebug () << "\tsetItems(" << translated << ")" << endl;
d->aZoom->setItems( translated );
// select current item in list

Loading…
Cancel
Save