Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/KSWidget.cpp
Show All 17 Lines | |||||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "KSWidget.h" | 20 | #include "KSWidget.h" | ||
21 | #include "spectacle_gui_debug.h" | 21 | #include "spectacle_gui_debug.h" | ||
22 | 22 | | |||
23 | #include "KSImageWidget.h" | 23 | #include "KSImageWidget.h" | ||
24 | #include "SmartSpinBox.h" | 24 | #include "SmartSpinBox.h" | ||
25 | #include "SpectacleConfig.h" | 25 | #include "SpectacleConfig.h" | ||
26 | #include "ProgressButton.h" | ||||
26 | 27 | | |||
27 | #include <QAction> | 28 | #include <QAction> | ||
28 | #include <QApplication> | 29 | #include <QApplication> | ||
29 | #include <QCheckBox> | 30 | #include <QCheckBox> | ||
30 | #include <QComboBox> | 31 | #include <QComboBox> | ||
31 | #include <QDebug> | 32 | #include <QDebug> | ||
32 | #include <QFormLayout> | 33 | #include <QFormLayout> | ||
33 | #include <QGridLayout> | 34 | #include <QGridLayout> | ||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 43 | { | |||
130 | mCancelAction = new QAction(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18n("Cancel"), this); | 131 | mCancelAction = new QAction(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18n("Cancel"), this); | ||
131 | mCancelAction->setShortcut(QKeySequence::Cancel); | 132 | mCancelAction->setShortcut(QKeySequence::Cancel); | ||
132 | connect(mCancelAction, &QAction::triggered, this, [this] { | 133 | connect(mCancelAction, &QAction::triggered, this, [this] { | ||
133 | emit screenshotCanceled(); | 134 | emit screenshotCanceled(); | ||
134 | setButtonState(State::TakeNewScreenshot); | 135 | setButtonState(State::TakeNewScreenshot); | ||
135 | }); | 136 | }); | ||
136 | 137 | | |||
137 | // the take a new screenshot button | 138 | // the take a new screenshot button | ||
138 | mTakeScreenshotButton = new QToolButton(this); | 139 | mTakeScreenshotButton = new ProgressButton(this); | ||
139 | mTakeScreenshotButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | 140 | mTakeScreenshotButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | ||
140 | mTakeScreenshotButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | 141 | mTakeScreenshotButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||
141 | setButtonState(State::TakeNewScreenshot); | 142 | setButtonState(State::TakeNewScreenshot); | ||
142 | mTakeScreenshotButton->setFocus(); | 143 | mTakeScreenshotButton->setFocus(); | ||
143 | 144 | | |||
144 | // finally, finish up the layouts | 145 | // finally, finish up the layouts | ||
145 | mRightLayout = new QVBoxLayout; | 146 | mRightLayout = new QVBoxLayout; | ||
146 | mRightLayout->addStretch(1); | 147 | mRightLayout->addStretch(1); | ||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | |||||
266 | } | 267 | } | ||
267 | 268 | | |||
268 | void KSWidget::setButtonState(State state) | 269 | void KSWidget::setButtonState(State state) | ||
269 | { | 270 | { | ||
270 | switch (state) { | 271 | switch (state) { | ||
271 | case State::TakeNewScreenshot: | 272 | case State::TakeNewScreenshot: | ||
272 | mTakeScreenshotButton->removeAction(mCancelAction); | 273 | mTakeScreenshotButton->removeAction(mCancelAction); | ||
273 | mTakeScreenshotButton->setDefaultAction(mTakeNewScreenshotAction); | 274 | mTakeScreenshotButton->setDefaultAction(mTakeNewScreenshotAction); | ||
275 | mTakeScreenshotButton->setProgress(0); | ||||
274 | break; | 276 | break; | ||
275 | case State::Cancel: | 277 | case State::Cancel: | ||
276 | mTakeScreenshotButton->removeAction(mTakeNewScreenshotAction); | 278 | mTakeScreenshotButton->removeAction(mTakeNewScreenshotAction); | ||
277 | mTakeScreenshotButton->setDefaultAction(mCancelAction); | 279 | mTakeScreenshotButton->setDefaultAction(mCancelAction); | ||
278 | break; | 280 | break; | ||
279 | } | 281 | } | ||
280 | } | 282 | } | ||
283 | | ||||
284 | void KSWidget::setProgress(double progress) | ||||
285 | { | ||||
286 | mTakeScreenshotButton->setProgress(progress); | ||||
287 | } | ||||
288 | |