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 "ExportManager.h" | ||||
27 | #include "Config.h" | ||||
26 | 28 | | |||
27 | #include <QApplication> | 29 | #include <QApplication> | ||
28 | #include <QCheckBox> | 30 | #include <QCheckBox> | ||
29 | #include <QComboBox> | 31 | #include <QComboBox> | ||
30 | #include <QDebug> | 32 | #include <QDebug> | ||
31 | #include <QFormLayout> | 33 | #include <QFormLayout> | ||
32 | #include <QGridLayout> | 34 | #include <QGridLayout> | ||
33 | #include <QLabel> | 35 | #include <QLabel> | ||
34 | #include <QPushButton> | 36 | #include <QPushButton> | ||
35 | #include <QShortcut> | 37 | #include <QShortcut> | ||
38 | #include <QStackedLayout> | ||||
39 | | ||||
40 | #ifdef KIMAGEANNOTATOR_FOUND | ||||
41 | #include <kImageAnnotator/KImageAnnotator.h> | ||||
42 | #endif | ||||
36 | 43 | | |||
37 | #include <KLocalizedString> | 44 | #include <KLocalizedString> | ||
38 | 45 | | |||
39 | KSWidget::KSWidget(const Platform::GrabModes &theGrabModes, QWidget *parent) : | 46 | KSWidget::KSWidget(const Platform::GrabModes &theGrabModes, QWidget *parent) : | ||
40 | QWidget(parent) | 47 | QWidget(parent) | ||
41 | { | 48 | { | ||
42 | // get a handle to the configuration manager | 49 | // get a handle to the configuration manager | ||
43 | SpectacleConfig *lConfigMgr = SpectacleConfig::instance(); | 50 | SpectacleConfig *lConfigMgr = SpectacleConfig::instance(); | ||
44 | 51 | | |||
52 | mStack = new QStackedLayout(this); | ||||
53 | | ||||
45 | // we'll init the widget that holds the image first | 54 | // we'll init the widget that holds the image first | ||
46 | mImageWidget = new KSImageWidget(this); | 55 | mImageWidget = new KSImageWidget(this); | ||
47 | mImageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | 56 | mImageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | ||
48 | connect(mImageWidget, &KSImageWidget::dragInitiated, this, &KSWidget::dragInitiated); | 57 | connect(mImageWidget, &KSImageWidget::dragInitiated, this, &KSWidget::dragInitiated); | ||
49 | 58 | | |||
59 | #ifdef KIMAGEANNOTATOR_FOUND | ||||
60 | mAnnotator = new kImageAnnotator::KImageAnnotator(); | ||||
61 | mAnnotator->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | ||||
62 | mStack->addWidget(mAnnotator); | ||||
63 | #endif | ||||
64 | | ||||
50 | // the capture mode options first | 65 | // the capture mode options first | ||
51 | mCaptureModeLabel = new QLabel(i18n("<b>Capture Mode</b>"), this); | 66 | mCaptureModeLabel = new QLabel(i18n("<b>Capture Mode</b>"), this); | ||
52 | mCaptureArea = new QComboBox(this); | 67 | mCaptureArea = new QComboBox(this); | ||
53 | QString lFullScreenLabel = QApplication::screens().count() == 1 | 68 | QString lFullScreenLabel = QApplication::screens().count() == 1 | ||
54 | ? i18n("Full Screen") | 69 | ? i18n("Full Screen") | ||
55 | : i18n("Full Screen (All Monitors)"); | 70 | : i18n("Full Screen (All Monitors)"); | ||
56 | 71 | | |||
57 | if (theGrabModes.testFlag(Platform::GrabMode::AllScreens)) | 72 | if (theGrabModes.testFlag(Platform::GrabMode::AllScreens)) | ||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Line(s) | |||||
141 | mRightLayout->addLayout(mCaptureModeForm); | 156 | mRightLayout->addLayout(mCaptureModeForm); | ||
142 | mRightLayout->addStretch(1); | 157 | mRightLayout->addStretch(1); | ||
143 | mRightLayout->addWidget(mContentOptionsLabel); | 158 | mRightLayout->addWidget(mContentOptionsLabel); | ||
144 | mRightLayout->addLayout(mContentOptionsForm); | 159 | mRightLayout->addLayout(mContentOptionsForm); | ||
145 | mRightLayout->addStretch(10); | 160 | mRightLayout->addStretch(10); | ||
146 | mRightLayout->addWidget(mTakeScreenshotButton, 1, Qt::AlignHCenter); | 161 | mRightLayout->addWidget(mTakeScreenshotButton, 1, Qt::AlignHCenter); | ||
147 | mRightLayout->setContentsMargins(10, 0, 0, 10); | 162 | mRightLayout->setContentsMargins(10, 0, 0, 10); | ||
148 | 163 | | |||
149 | mMainLayout = new QGridLayout(this); | 164 | mMainLayout = new QGridLayout(); | ||
165 | | ||||
150 | mMainLayout->addWidget(mImageWidget, 0, 0, 1, 1); | 166 | mMainLayout->addWidget(mImageWidget, 0, 0, 1, 1); | ||
151 | mMainLayout->addLayout(mRightLayout, 0, 1, 1, 1); | 167 | mMainLayout->addLayout(mRightLayout, 0, 1, 1, 1); | ||
152 | mMainLayout->setColumnMinimumWidth(0, 320); | 168 | mMainLayout->setColumnMinimumWidth(0, 320); | ||
153 | mMainLayout->setColumnMinimumWidth(1, 320); | 169 | mMainLayout->setColumnMinimumWidth(1, 320); | ||
154 | 170 | | |||
171 | placeHolder = new QWidget(); | ||||
172 | placeHolder->setLayout(mMainLayout); | ||||
173 | | ||||
174 | mStack->addWidget(placeHolder); | ||||
175 | | ||||
176 | #ifdef KIMAGEANNOTATOR_FOUND | ||||
177 | mStack->addWidget(mAnnotator); | ||||
178 | #endif | ||||
179 | | ||||
155 | // and read in the saved checkbox states and capture mode indices | 180 | // and read in the saved checkbox states and capture mode indices | ||
156 | mMousePointer->setChecked (lConfigMgr->includePointerChecked()); | 181 | mMousePointer->setChecked (lConfigMgr->includePointerChecked()); | ||
157 | mWindowDecorations->setChecked (lConfigMgr->includeDecorationsChecked()); | 182 | mWindowDecorations->setChecked (lConfigMgr->includeDecorationsChecked()); | ||
158 | mCaptureOnClick->setChecked (lConfigMgr->onClickChecked()); | 183 | mCaptureOnClick->setChecked (lConfigMgr->onClickChecked()); | ||
159 | mCaptureTransientOnly->setChecked (lConfigMgr->captureTransientWindowOnlyChecked()); | 184 | mCaptureTransientOnly->setChecked (lConfigMgr->captureTransientWindowOnlyChecked()); | ||
160 | mQuitAfterSaveOrCopy->setChecked (lConfigMgr->quitAfterSaveOrCopyChecked()); | 185 | mQuitAfterSaveOrCopy->setChecked (lConfigMgr->quitAfterSaveOrCopyChecked()); | ||
161 | if (lConfigMgr->captureMode() >= 0) { | 186 | if (lConfigMgr->captureMode() >= 0) { | ||
162 | mCaptureArea->setCurrentIndex (lConfigMgr->captureMode()); | 187 | mCaptureArea->setCurrentIndex (lConfigMgr->captureMode()); | ||
163 | } | 188 | } | ||
davidre: Duplicated in Line 62 | |||||
164 | mDelayMsec->setValue (lConfigMgr->captureDelay()); | 189 | mDelayMsec->setValue (lConfigMgr->captureDelay()); | ||
165 | } | 190 | } | ||
166 | 191 | | |||
167 | int KSWidget::imagePaddingWidth() const | 192 | int KSWidget::imagePaddingWidth() const | ||
168 | { | 193 | { | ||
169 | int lRightLayoutLeft = 0; | 194 | int lRightLayoutLeft = 0; | ||
170 | int lRightLayoutRight = 0; | 195 | int lRightLayoutRight = 0; | ||
171 | int lMainLayoutRight = 0; | 196 | int lMainLayoutRight = 0; | ||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 273 | case Spectacle::CaptureMode::RectangularRegion: | |||
251 | break; | 276 | break; | ||
252 | case Spectacle::CaptureMode::TransientWithParent: | 277 | case Spectacle::CaptureMode::TransientWithParent: | ||
253 | case Spectacle::CaptureMode::InvalidChoice: | 278 | case Spectacle::CaptureMode::InvalidChoice: | ||
254 | default: | 279 | default: | ||
255 | qCWarning(SPECTACLE_GUI_LOG) << "Skipping invalid or unreachable enum value"; | 280 | qCWarning(SPECTACLE_GUI_LOG) << "Skipping invalid or unreachable enum value"; | ||
256 | break; | 281 | break; | ||
257 | } | 282 | } | ||
258 | } | 283 | } | ||
284 | | ||||
285 | #ifdef KIMAGEANNOTATOR_FOUND | ||||
286 | void KSWidget::showAnnotator() | ||||
287 | { | ||||
288 | mStack->setCurrentIndex(1); | ||||
289 | mAnnotator->loadImage(ExportManager::instance()->pixmap()); | ||||
290 | } | ||||
291 | | ||||
292 | void KSWidget::hideAnnotator() | ||||
293 | { | ||||
294 | mStack->setCurrentIndex(0); | ||||
295 | QImage image = mAnnotator->image(); | ||||
296 | QPixmap px = QPixmap::fromImage(image); | ||||
297 | setScreenshotPixmap(px); | ||||
298 | ExportManager::instance()->setPixmap(px); | ||||
299 | } | ||||
300 | #endif |
Duplicated in Line 62