19#include <QButtonGroup>
21#include <klocalizedstring.h>
33 , currentActionState(currentZoomState)
46 : KSelectAction(text, parent)
49 setIcon(
koIcon(
"zoom-original"));
51 setMaxComboViewCount( 15 );
64 d->currentZoomState = zoomState;
65 d->currentActionState.setZoomState(zoomState);
67 d->guiUpdateCompressor.start();
78 qreal zoom = QLocale().toDouble(
value, &isValid);
84 QString trimmedValue =
value.trimmed();
85 if (trimmedValue.endsWith(
'%')) {
86 stringRemoveLast(trimmedValue);
87 }
else if (trimmedValue.startsWith(
'%')) {
92 stringRemoveFirst(trimmedValue);
94 zoom = QLocale().toDouble(trimmedValue, &isValid);
103 const KoZoomState &zoomState =
d->currentActionState.zoomState;
105 qRound(zoomState.
zoom * 1000.0) != qRound(zoom * 10.0)) {
115 if (index < 0 || index >=
d->currentActionState.realGuiLevels.size())
return;
116 if (index ==
d->currentActionState.currentRealLevelIndex)
return;
118 KoZoomMode::Mode mode = std::get<KoZoomMode::Mode>(
d->currentActionState.realGuiLevels[index]);
119 qreal zoom = std::get<qreal>(
d->currentActionState.realGuiLevels[index]);
128 std::transform(
d->currentActionState.realGuiLevels.begin(),
129 d->currentActionState.realGuiLevels.end(),
130 std::back_inserter(values),
131 [](
const auto &item) {
132 return std::get<QString>(item);
136 QSignalBlocker b(
this);
138 setCurrentItem(
d->currentActionState.currentRealLevelIndex);
143 d->currentActionState.currentRealLevelIndex,
144 d->currentActionState.currentRealLevelText);
149 if (value < 0 || value >=
d->currentActionState.standardLevels.size())
return;
152 qreal zoom =
d->currentActionState.standardLevels[
value];
189 const int index =
d->currentActionState.calcNearestStandardLevel();
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
void syncSliderWithZoom()
void slotZoomLevelChangedIndex(int index)
QWidget * createWidget(QWidget *parent) override
KoZoomAction(const QString &text, QObject *parent)
KisSignalCompressor guiUpdateCompressor
void zoomChanged(KoZoomMode::Mode mode, qreal zoom)
void sigInternalUpdateUsePrintResolutionMode(bool value)
Private(KoZoomAction *_parent)
KoZoomActionState currentActionState
void sliderValueChanged(int value)
void sigUsePrintResolutionModeChanged(bool value)
void setUsePrintResolutionMode(bool value)
void slotTextZoomChanged(const QString &value)
void sigInternalUpdateZoomLevelsSliderState(int size, int index)
void sigInternalUpdateZoomLevelsComboState(const QStringList &values, int index, const QString &activeText)
void slotUpdateGuiAfterZoom()
void slotZoomStateChanged(const KoZoomState &zoomState)
KoZoomState currentZoomState
#define koIcon(name)
Use these macros for icons without any issues.
void stringRemoveFirst(QString &str)
void stringRemoveLast(QString &str)