[Digikam-devel] [Bug 106508] Please change scaling behavior
Gilles Caulier
caulier.gilles at gmail.com
Mon Mar 19 22:52:14 GMT 2007
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=106508
caulier.gilles gmail com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution| |FIXED
------- Additional Comments From caulier.gilles gmail com 2007-03-19 23:52 -------
SVN commit 644437 by cgilles:
digiKam from trunk : add a combo box with a pre-zoom selection options like gimp prvovide. You can enter a customized zoom scale value if you want.
BUG: 106508
M +22 -26 canvas/canvas.cpp
M +1 -0 canvas/canvas.h
M +2 -1 editor/digikamimagewindowui.rc
M +56 -7 editor/editorwindow.cpp
M +3 -1 editor/editorwindow.h
M +8 -0 editor/editorwindowprivate.h
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/canvas.cpp #644436:644437
@ -1,6 +1,6 @
/* ============================================================
* Authors: Renchi Raju <renchi pooh tam uiuc edu>
- * Gilles Caulier <caulier dot gilles at gmail dot com>
+ * Gilles Caulier <caulier dot gilles at gmail dot com>
* Date : 2003-01-09
* Description : image editor canvas management class
*
@ -70,16 +70,15 @
public:
- CanvasPrivate() :
- tileSize(128), maxZoom(8.0)
+ CanvasPrivate() :
+ tileSize(128), minZoom(0.1), maxZoom(10.0), zoomStep(0.1)
{
- tileCache.setMaxCost((10*1024*1024)/(tileSize*tileSize*4));
- tileCache.setAutoDelete(true);
-
parent = 0;
im = 0;
rubber = 0;
paintTimer = 0;
+ tileCache.setMaxCost((10*1024*1024)/(tileSize*tileSize*4));
+ tileCache.setAutoDelete(true);
}
bool autoZoom;
@ -97,7 +96,9 @
int midButtonY;
double zoom;
+ const double minZoom;
const double maxZoom;
+ const double zoomStep;
QRect *rubber;
QRect pixmapRect;
@ -114,7 +115,6 @
QWidget *parent;
DImgInterface *im;
-
};
Canvas::Canvas(QWidget *parent)
@ -817,12 +817,12 @
bool Canvas::maxZoom()
{
- return ((d->zoom + 1.0/16.0) >= d->maxZoom);
+ return ((d->zoom + d->zoomStep) >= d->maxZoom);
}
bool Canvas::minZoom()
{
- return ((d->zoom - 1.0/16.0) <= 0.1);
+ return ((d->zoom - d->zoomStep) <= d->minZoom);
}
bool Canvas::exifRotated()
@ -832,33 +832,29 @
void Canvas::slotIncreaseZoom()
{
- if (d->autoZoom || maxZoom())
+ if (maxZoom())
return;
- float cpx = (contentsX() + visibleWidth() / 2.0) / d->zoom;
- float cpy = (contentsY() + visibleHeight() / 2.0) / d->zoom;
+ setZoomFactor(d->zoom + d->zoomStep);
+}
- d->zoom = d->zoom + 1.0/16.0;
- d->im->zoom(d->zoom);
- updateContentsSize();
+void Canvas::slotDecreaseZoom()
+{
+ if (minZoom())
+ return;
- viewport()->setUpdatesEnabled(false);
- center((int)(cpx * d->zoom), (int)(cpy * d->zoom));
- viewport()->setUpdatesEnabled(true);
- viewport()->update();
-
- emit signalZoomChanged(d->zoom);
+ setZoomFactor(d->zoom - d->zoomStep);
}
-void Canvas::slotDecreaseZoom()
+void Canvas::setZoomFactor(float zoom)
{
- if (d->autoZoom || minZoom())
+ if (d->autoZoom)
return;
float cpx = (contentsX() + visibleWidth() / 2.0) / d->zoom;
- float cpy = (contentsY() + visibleHeight() / 2.0) / d->zoom;
-
- d->zoom = d->zoom - 1.0/16.0;
+ float cpy = (contentsY() + visibleHeight() / 2.0) / d->zoom;
+
+ d->zoom = zoom;
d->im->zoom(d->zoom);
updateContentsSize();
--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/canvas.h #644436:644437
@ -75,6 +75,7 @
DImg currentImage();
QString currentImageFileFormat();
+ void setZoomFactor(float z);
bool maxZoom();
bool minZoom();
bool exifRotated();
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/digikamimagewindowui.rc #644436:644437
@ -1,5 +1,5 @
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<gui version="10" name="digikamimagewindow" >
+<gui version="11" name="digikamimagewindow" >
<MenuBar>
@ -87,6 +87,7 @
<Action name="editorwindow_revert" />
<Separator/>
<Action name="editorwindow_zoomplus" />
+ <Action name="editorwindow_zoomto" />
<Action name="editorwindow_zoomminus" />
<Action name="editorwindow_zoomfit" />
<Separator/>
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/editorwindow.cpp #644436:644437
@ -26,6 +26,10 @
#include <sys/stat.h>
}
+// C++ includes.
+
+#include <cmath>
+
// Qt includes.
#include <qlabel.h>
@ -70,6 +74,7 @
#include <kstatusbar.h>
#include <kprogress.h>
#include <kwin.h>
+#include <kcombobox.h>
// Local includes.
@ -311,12 +316,41 @
d->zoomPlusAction = KStdAction::zoomIn(m_canvas, SLOT(slotIncreaseZoom()),
actionCollection(), "editorwindow_zoomplus");
+
+
d->zoomMinusAction = KStdAction::zoomOut(m_canvas, SLOT(slotDecreaseZoom()),
actionCollection(), "editorwindow_zoomminus");
+
d->zoomFitAction = new KToggleAction(i18n("Zoom &AutoFit"), "viewmagfit",
CTRL+SHIFT+Key_A, this, SLOT(slotToggleAutoZoom()),
actionCollection(), "editorwindow_zoomfit");
+ d->zoomCombo = new KComboBox(true);
+ d->zoomCombo->setDuplicatesEnabled(false);
+ d->zoomCombo->setFocusPolicy(ClickFocus);
+ d->zoomCombo->setInsertionPolicy(QComboBox::NoInsertion);
+ d->zoomComboAction = new KWidgetAction(d->zoomCombo, i18n("Zoom"), 0, 0, 0,
+ actionCollection(), "editorwindow_zoomto");
+
+ d->zoomCombo->insertItem(QString("10%"));
+ d->zoomCombo->insertItem(QString("25%"));
+ d->zoomCombo->insertItem(QString("50%"));
+ d->zoomCombo->insertItem(QString("75%"));
+ d->zoomCombo->insertItem(QString("100%"));
+ d->zoomCombo->insertItem(QString("150%"));
+ d->zoomCombo->insertItem(QString("200%"));
+ d->zoomCombo->insertItem(QString("300%"));
+ d->zoomCombo->insertItem(QString("450%"));
+ d->zoomCombo->insertItem(QString("600%"));
+ d->zoomCombo->insertItem(QString("800%"));
+
+ connect(d->zoomCombo, SIGNAL(activated(int)),
+ this, SLOT(slotZoomSelected()) );
+
+ connect(d->zoomCombo, SIGNAL(returnPressed(const QString&)),
+ this, SLOT(slotZoomTextChanged(const QString &)) );
+
+
#if KDE_IS_VERSION(3,2,0)
m_fullScreenAction = KStdAction::fullScreen(this, SLOT(slotToggleFullScreen()),
actionCollection(), this, "editorwindow_fullscreen");
@ -618,21 +652,36 @
bool checked = d->zoomFitAction->isChecked();
d->zoomPlusAction->setEnabled(!checked);
+ d->zoomComboAction->setEnabled(!checked);
d->zoomMinusAction->setEnabled(!checked);
m_canvas->slotToggleAutoZoom();
}
+void EditorWindow::slotZoomTextChanged(const QString &txt)
+{
+ double zoom = KGlobal::locale()->readNumber(txt) / 100.0;
+ if (zoom > 0.0)
+ m_canvas->setZoomFactor(zoom);
+}
+
+void EditorWindow::slotZoomSelected()
+{
+ QString txt = d->zoomCombo->currentText();
+ txt = txt.left(txt.find('%'));
+ slotZoomTextChanged(txt);
+}
+
void EditorWindow::slotZoomChanged(float zoom)
{
- m_zoomLabel->setText(i18n("Zoom: ") +
- QString::number(zoom*100, 'f', 2) +
- QString("%"));
+ m_zoomLabel->setText(i18n("Zoom: %1%").arg(QString::number(lround(zoom*100.0))));
- d->zoomPlusAction->setEnabled(!m_canvas->maxZoom() &&
- !d->zoomFitAction->isChecked());
- d->zoomMinusAction->setEnabled(!m_canvas->minZoom() &&
- !d->zoomFitAction->isChecked());
+ d->zoomPlusAction->setEnabled(!m_canvas->maxZoom() && !d->zoomFitAction->isChecked());
+ d->zoomMinusAction->setEnabled(!m_canvas->minZoom() && !d->zoomFitAction->isChecked());
+
+ d->zoomCombo->blockSignals(true);
+ d->zoomCombo->setCurrentText(QString::number(lround(zoom*100.0)) + QString("%"));
+ d->zoomCombo->blockSignals(false);
}
void EditorWindow::slotEscapePressed()
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/editorwindow.h #644436:644437
@ -173,7 +173,6 @
void slotEscapePressed();
void slotToggleAutoZoom();
- void slotZoomChanged(float zoom);
void slotSelected(bool);
void slotLoadingProgress(const QString& filePath, float progress);
@ -206,6 +205,9 @
void slotSavingFinished(const QString &filename, bool success);
void slotDonateMoney();
void slotToggleSlideShow();
+ void slotZoomSelected();
+ void slotZoomTextChanged(const QString &);
+ void slotZoomChanged(float zoom);
private:
--- trunk/extragear/graphics/digikam/utilities/imageeditor/editor/editorwindowprivate.h #644436:644437
@ -24,8 +24,10 @
class QToolButton;
+class KComboBox;
class KAction;
class KToggleAction;
+class KWidgetAction;
class KSelectAction;
class KActionMenu;
class KAccel;
@ -72,6 +74,8 @
viewUnderExpoAction = 0;
viewOverExpoAction = 0;
slideShowAction = 0;
+ zoomCombo = 0;
+ zoomComboAction = 0;
}
~EditorWindowPriv()
@ -82,6 +86,8 @
bool fullScreenHideToolBar;
bool slideShowInFullScreen;
+ KComboBox *zoomCombo;
+
QToolButton *cmViewIndicator;
QToolButton *underExposureIndicator;
QToolButton *overExposureIndicator;
@ -108,6 +114,8 @
KToggleAction *viewUnderExpoAction;
KToggleAction *viewOverExpoAction;
+ KWidgetAction *zoomComboAction;
+
KAccel *accelerators;
ICCSettingsContainer *ICCSettings;
More information about the Digikam-devel
mailing list