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 <QFormLayout> | 32 | #include <QFormLayout> | ||
32 | #include <QGridLayout> | 33 | #include <QGridLayout> | ||
33 | #include <QLabel> | 34 | #include <QLabel> | ||
▲ Show 20 Lines • Show All 95 Lines • ▼ Show 20 Line(s) | 42 | { | |||
129 | mCancelAction = new QAction(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18n("Cancel"), this); | 130 | mCancelAction = new QAction(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18n("Cancel"), this); | ||
130 | mCancelAction->setShortcut(QKeySequence::Cancel); | 131 | mCancelAction->setShortcut(QKeySequence::Cancel); | ||
131 | connect(mCancelAction, &QAction::triggered, this, [this] { | 132 | connect(mCancelAction, &QAction::triggered, this, [this] { | ||
132 | emit screenshotCanceled(); | 133 | emit screenshotCanceled(); | ||
133 | setButtonState(State::TakeNewScreenshot); | 134 | setButtonState(State::TakeNewScreenshot); | ||
134 | }); | 135 | }); | ||
135 | 136 | | |||
136 | // the take a new screenshot button | 137 | // the take a new screenshot button | ||
137 | mTakeScreenshotButton = new QToolButton(this); | 138 | mTakeScreenshotButton = new ProgressButton(this); | ||
138 | mTakeScreenshotButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | 139 | mTakeScreenshotButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | ||
139 | mTakeScreenshotButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | 140 | mTakeScreenshotButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); | ||
140 | setButtonState(State::TakeNewScreenshot); | 141 | setButtonState(State::TakeNewScreenshot); | ||
141 | mTakeScreenshotButton->setFocus(); | 142 | mTakeScreenshotButton->setFocus(); | ||
142 | 143 | | |||
143 | // finally, finish up the layouts | 144 | // finally, finish up the layouts | ||
144 | mRightLayout = new QVBoxLayout; | 145 | mRightLayout = new QVBoxLayout; | ||
145 | mRightLayout->addStretch(1); | 146 | mRightLayout->addStretch(1); | ||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | |||||
265 | } | 266 | } | ||
266 | 267 | | |||
267 | void KSWidget::setButtonState(State state) | 268 | void KSWidget::setButtonState(State state) | ||
268 | { | 269 | { | ||
269 | switch (state) { | 270 | switch (state) { | ||
270 | case State::TakeNewScreenshot: | 271 | case State::TakeNewScreenshot: | ||
271 | mTakeScreenshotButton->removeAction(mCancelAction); | 272 | mTakeScreenshotButton->removeAction(mCancelAction); | ||
272 | mTakeScreenshotButton->setDefaultAction(mTakeNewScreenshotAction); | 273 | mTakeScreenshotButton->setDefaultAction(mTakeNewScreenshotAction); | ||
274 | mTakeScreenshotButton->setProgress(0); | ||||
273 | break; | 275 | break; | ||
274 | case State::Cancel: | 276 | case State::Cancel: | ||
275 | mTakeScreenshotButton->removeAction(mTakeNewScreenshotAction); | 277 | mTakeScreenshotButton->removeAction(mTakeNewScreenshotAction); | ||
276 | mTakeScreenshotButton->setDefaultAction(mCancelAction); | 278 | mTakeScreenshotButton->setDefaultAction(mCancelAction); | ||
277 | break; | 279 | break; | ||
278 | } | 280 | } | ||
279 | } | 281 | } | ||
282 | | ||||
283 | void KSWidget::setProgress(double progress) | ||||
284 | { | ||||
285 | mTakeScreenshotButton->setProgress(progress); | ||||
286 | } | ||||
287 | |