Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/KSWidget.cpp
Show All 30 Lines | |||||
31 | #include <QCheckBox> | 31 | #include <QCheckBox> | ||
32 | #include <QComboBox> | 32 | #include <QComboBox> | ||
33 | #include <QFormLayout> | 33 | #include <QFormLayout> | ||
34 | #include <QGridLayout> | 34 | #include <QGridLayout> | ||
35 | #include <QLabel> | 35 | #include <QLabel> | ||
36 | #include <QShortcut> | 36 | #include <QShortcut> | ||
37 | #include <QToolButton> | 37 | #include <QToolButton> | ||
38 | 38 | | |||
39 | #include <KConfigDialogManager> | ||||
39 | #include <KLocalizedString> | 40 | #include <KLocalizedString> | ||
40 | 41 | | |||
41 | KSWidget::KSWidget(const Platform::GrabModes &theGrabModes, QWidget *parent) : | 42 | KSWidget::KSWidget(const Platform::GrabModes &theGrabModes, QWidget *parent) | ||
42 | QWidget(parent) | 43 | : QWidget(parent) | ||
43 | { | 44 | { | ||
44 | // we'll init the widget that holds the image first | 45 | // we'll init the widget that holds the image first | ||
45 | mImageWidget = new KSImageWidget(this); | 46 | mImageWidget = new KSImageWidget(this); | ||
46 | mImageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | 47 | mImageWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | ||
47 | connect(mImageWidget, &KSImageWidget::dragInitiated, this, &KSWidget::dragInitiated); | 48 | connect(mImageWidget, &KSImageWidget::dragInitiated, this, &KSWidget::dragInitiated); | ||
48 | 49 | | |||
49 | // the capture mode options first | 50 | // the capture mode options first | ||
50 | mCaptureModeLabel = new QLabel(i18n("<b>Capture Mode</b>"), this); | 51 | mCaptureModeLabel = new QLabel(i18n("<b>Capture Mode</b>"), this); | ||
Show All 14 Lines | |||||
65 | } | 66 | } | ||
66 | if (theGrabModes.testFlag(Platform::GrabMode::WindowUnderCursor)) { | 67 | if (theGrabModes.testFlag(Platform::GrabMode::WindowUnderCursor)) { | ||
67 | mCaptureArea->insertItem(4, i18n("Window Under Cursor"), Spectacle::CaptureMode::WindowUnderCursor); | 68 | mCaptureArea->insertItem(4, i18n("Window Under Cursor"), Spectacle::CaptureMode::WindowUnderCursor); | ||
68 | } | 69 | } | ||
69 | if (theGrabModes.testFlag(Platform::GrabMode::TransientWithParent)) { | 70 | if (theGrabModes.testFlag(Platform::GrabMode::TransientWithParent)) { | ||
70 | mTransientWithParentAvailable = true; | 71 | mTransientWithParentAvailable = true; | ||
71 | } | 72 | } | ||
72 | mCaptureArea->setMinimumWidth(240); | 73 | mCaptureArea->setMinimumWidth(240); | ||
74 | mCaptureArea->setObjectName(QStringLiteral("kcfg_captureMode")); | ||||
75 | mCaptureArea->setProperty("kcfg_property", QByteArray("currentData")); | ||||
73 | #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) | 76 | #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) | ||
74 | connect(mCaptureArea, qOverload<int>(&QComboBox::currentIndexChanged), this, &KSWidget::captureModeChanged); | 77 | connect(mCaptureArea, qOverload<int>(&QComboBox::currentIndexChanged), this, &KSWidget::captureModeChanged); | ||
75 | #else | 78 | #else | ||
76 | connect(mCaptureArea, qOverload<int, const QString &>(&QComboBox::currentIndexChanged), this, &KSWidget::captureModeChanged); | 79 | connect(mCaptureArea, qOverload<int, const QString &>(&QComboBox::currentIndexChanged), this, &KSWidget::captureModeChanged); | ||
77 | #endif | 80 | #endif | ||
81 | | ||||
78 | mDelayMsec = new SmartSpinBox(this); | 82 | mDelayMsec = new SmartSpinBox(this); | ||
79 | mDelayMsec->setDecimals(1); | 83 | mDelayMsec->setDecimals(1); | ||
80 | mDelayMsec->setSingleStep(1.0); | 84 | mDelayMsec->setSingleStep(1.0); | ||
81 | mDelayMsec->setMinimum(0.0); | 85 | mDelayMsec->setMinimum(0.0); | ||
82 | mDelayMsec->setMaximum(999.9); | 86 | mDelayMsec->setMaximum(999.9); | ||
83 | mDelayMsec->setSpecialValueText(i18n("No Delay")); | 87 | mDelayMsec->setSpecialValueText(i18n("No Delay")); | ||
84 | mDelayMsec->setMinimumWidth(160); | 88 | mDelayMsec->setMinimumWidth(160); | ||
85 | connect(mDelayMsec, qOverload<qreal>(&SmartSpinBox::valueChanged), &Settings::setCaptureDelay); | 89 | mDelayMsec->setObjectName(QStringLiteral("kcfg_captureDelay")); | ||
86 | 90 | | |||
87 | mCaptureOnClick = new QCheckBox(i18n("On Click"), this); | 91 | mCaptureOnClick = new QCheckBox(i18n("On Click"), this); | ||
88 | mCaptureOnClick->setToolTip(i18n("Wait for a mouse click before capturing the screenshot image")); | 92 | mCaptureOnClick->setToolTip(i18n("Wait for a mouse click before capturing the screenshot image")); | ||
89 | connect(mCaptureOnClick, &QCheckBox::stateChanged, this, &KSWidget::onClickStateChanged); | 93 | connect(mCaptureOnClick, &QCheckBox::stateChanged, this, &KSWidget::onClickStateChanged); | ||
90 | connect(mCaptureOnClick, &QCheckBox::clicked, &Settings::setOnClickChecked); | 94 | mCaptureOnClick->setObjectName(QStringLiteral("kcfg_onClickChecked")); | ||
91 | 95 | | |||
92 | mDelayLayout = new QHBoxLayout; | 96 | mDelayLayout = new QHBoxLayout; | ||
93 | mDelayLayout->addWidget(mDelayMsec); | 97 | mDelayLayout->addWidget(mDelayMsec); | ||
94 | mDelayLayout->addWidget(mCaptureOnClick); | 98 | mDelayLayout->addWidget(mCaptureOnClick); | ||
95 | 99 | | |||
96 | mCaptureModeForm = new QFormLayout; | 100 | mCaptureModeForm = new QFormLayout; | ||
97 | mCaptureModeForm->addRow(i18n("Area:"), mCaptureArea); | 101 | mCaptureModeForm->addRow(i18n("Area:"), mCaptureArea); | ||
98 | mCaptureModeForm->addRow(i18n("Delay:"), mDelayLayout); | 102 | mCaptureModeForm->addRow(i18n("Delay:"), mDelayLayout); | ||
99 | mCaptureModeForm->setContentsMargins(24, 0, 0, 0); | 103 | mCaptureModeForm->setContentsMargins(24, 0, 0, 0); | ||
100 | 104 | | |||
101 | // options (mouse pointer, window decorations, quit after saving or copying) | 105 | // options (mouse pointer, window decorations, quit after saving or copying) | ||
102 | mContentOptionsLabel = new QLabel(this); | 106 | mContentOptionsLabel = new QLabel(this); | ||
103 | mContentOptionsLabel->setText(i18n("<b>Options</b>")); | 107 | mContentOptionsLabel->setText(i18n("<b>Options</b>")); | ||
104 | 108 | | |||
105 | mMousePointer = new QCheckBox(i18n("Include mouse pointer"), this); | 109 | mMousePointer = new QCheckBox(i18n("Include mouse pointer"), this); | ||
106 | mMousePointer->setToolTip(i18n("Show the mouse cursor in the screenshot image")); | 110 | mMousePointer->setToolTip(i18n("Show the mouse cursor in the screenshot image")); | ||
107 | connect(mMousePointer, &QCheckBox::clicked, &Settings::setIncludePointer); | 111 | mMousePointer->setObjectName(QStringLiteral("kcfg_includePointer")); | ||
108 | 112 | | |||
109 | mWindowDecorations = new QCheckBox(i18n("Include window titlebar and borders"), this); | 113 | mWindowDecorations = new QCheckBox(i18n("Include window titlebar and borders"), this); | ||
110 | mWindowDecorations->setToolTip(i18n("Show the window title bar, the minimize/maximize/close buttons, and the window border")); | 114 | mWindowDecorations->setToolTip(i18n("Show the window title bar, the minimize/maximize/close buttons, and the window border")); | ||
111 | mWindowDecorations->setEnabled(false); | 115 | mWindowDecorations->setEnabled(false); | ||
112 | connect(mWindowDecorations, &QCheckBox::clicked, &Settings::setIncludeDecorations); | 116 | mWindowDecorations->setObjectName(QStringLiteral("kcfg_includeDecorations")); | ||
113 | 117 | | |||
114 | mCaptureTransientOnly = new QCheckBox(i18n("Capture the current pop-up only"), this); | 118 | mCaptureTransientOnly = new QCheckBox(i18n("Capture the current pop-up only"), this); | ||
115 | mCaptureTransientOnly->setToolTip(i18n("Capture only the current pop-up window (like a menu, tooltip etc).\n" | 119 | mCaptureTransientOnly->setToolTip(i18n("Capture only the current pop-up window (like a menu, tooltip etc).\n" | ||
116 | "If disabled, the pop-up is captured along with the parent window")); | 120 | "If disabled, the pop-up is captured along with the parent window")); | ||
117 | mCaptureTransientOnly->setEnabled(false); | 121 | mCaptureTransientOnly->setEnabled(false); | ||
118 | connect(mCaptureTransientOnly, &QCheckBox::clicked, &Settings::setTransientOnly); | 122 | mCaptureTransientOnly->setObjectName(QStringLiteral("kcfg_transientOnly")); | ||
119 | 123 | | |||
120 | mQuitAfterSaveOrCopy = new QCheckBox(i18n("Quit after manual Save or Copy"), this); | 124 | mQuitAfterSaveOrCopy = new QCheckBox(i18n("Quit after manual Save or Copy"), this); | ||
121 | mQuitAfterSaveOrCopy->setToolTip(i18n("Quit Spectacle after manually saving or copying the image")); | 125 | mQuitAfterSaveOrCopy->setToolTip(i18n("Quit Spectacle after manually saving or copying the image")); | ||
122 | connect(mQuitAfterSaveOrCopy, &QCheckBox::clicked, &Settings::setQuitAfterSaveCopyExport); | 126 | mQuitAfterSaveOrCopy->setObjectName(QStringLiteral("kcfg_quitAfterSaveCopyExport")); | ||
123 | 127 | | |||
124 | mContentOptionsForm = new QVBoxLayout; | 128 | mContentOptionsForm = new QVBoxLayout; | ||
125 | mContentOptionsForm->addWidget(mMousePointer); | 129 | mContentOptionsForm->addWidget(mMousePointer); | ||
126 | mContentOptionsForm->addWidget(mWindowDecorations); | 130 | mContentOptionsForm->addWidget(mWindowDecorations); | ||
127 | mContentOptionsForm->addWidget(mCaptureTransientOnly); | 131 | mContentOptionsForm->addWidget(mCaptureTransientOnly); | ||
128 | mContentOptionsForm->addWidget(mQuitAfterSaveOrCopy); | 132 | mContentOptionsForm->addWidget(mQuitAfterSaveOrCopy); | ||
129 | mContentOptionsForm->setContentsMargins(24, 0, 0, 0); | 133 | mContentOptionsForm->setContentsMargins(24, 0, 0, 0); | ||
130 | 134 | | |||
Show All 28 Lines | |||||
159 | mRightLayout->setContentsMargins(10, 0, 0, 10); | 163 | mRightLayout->setContentsMargins(10, 0, 0, 10); | ||
160 | 164 | | |||
161 | mMainLayout = new QGridLayout(this); | 165 | mMainLayout = new QGridLayout(this); | ||
162 | mMainLayout->addWidget(mImageWidget, 0, 0, 1, 1); | 166 | mMainLayout->addWidget(mImageWidget, 0, 0, 1, 1); | ||
163 | mMainLayout->addLayout(mRightLayout, 0, 1, 1, 1); | 167 | mMainLayout->addLayout(mRightLayout, 0, 1, 1, 1); | ||
164 | mMainLayout->setColumnMinimumWidth(0, 320); | 168 | mMainLayout->setColumnMinimumWidth(0, 320); | ||
165 | mMainLayout->setColumnMinimumWidth(1, 320); | 169 | mMainLayout->setColumnMinimumWidth(1, 320); | ||
166 | 170 | | |||
167 | // and read in the saved checkbox states and capture mode indices | | |||
168 | mMousePointer->setChecked(Settings::includePointer()); | | |||
169 | mWindowDecorations->setChecked(Settings::includeDecorations()); | | |||
170 | mCaptureOnClick->setChecked(Settings::onClickChecked()); | | |||
171 | mCaptureTransientOnly->setChecked(Settings::transientOnly()); | | |||
172 | mQuitAfterSaveOrCopy->setChecked(Settings::quitAfterSaveCopyExport()); | | |||
173 | mDelayMsec->setValue(Settings::captureDelay()); | | |||
174 | int index = mCaptureArea->findData(Settings::captureMode()); | 171 | int index = mCaptureArea->findData(Settings::captureMode()); | ||
175 | mCaptureArea->setCurrentIndex(index >= 0 ? index : 0); | 172 | mCaptureArea->setCurrentIndex(index >= 0 ? index : 0); | ||
173 | auto mConfigManager = new KConfigDialogManager(this, Settings::self()); | ||||
174 | connect(mConfigManager, &KConfigDialogManager::widgetModified, mConfigManager, &KConfigDialogManager::updateSettings); | ||||
176 | } | 175 | } | ||
177 | 176 | | |||
178 | int KSWidget::imagePaddingWidth() const | 177 | int KSWidget::imagePaddingWidth() const | ||
179 | { | 178 | { | ||
180 | int lRightLayoutLeft = 0; | 179 | int lRightLayoutLeft = 0; | ||
181 | int lRightLayoutRight = 0; | 180 | int lRightLayoutRight = 0; | ||
182 | int lMainLayoutRight = 0; | 181 | int lMainLayoutRight = 0; | ||
183 | 182 | | |||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 230 | { | |||
234 | } else if (theState == Qt::Unchecked) { | 233 | } else if (theState == Qt::Unchecked) { | ||
235 | mDelayMsec->setEnabled(true); | 234 | mDelayMsec->setEnabled(true); | ||
236 | } | 235 | } | ||
237 | } | 236 | } | ||
238 | 237 | | |||
239 | void KSWidget::captureModeChanged(int theIndex) | 238 | void KSWidget::captureModeChanged(int theIndex) | ||
240 | { | 239 | { | ||
241 | Spectacle::CaptureMode captureMode = static_cast<Spectacle::CaptureMode>(mCaptureArea->itemData(theIndex).toInt()); | 240 | Spectacle::CaptureMode captureMode = static_cast<Spectacle::CaptureMode>(mCaptureArea->itemData(theIndex).toInt()); | ||
242 | Settings::setCaptureMode(captureMode); | | |||
243 | | ||||
244 | switch(captureMode) { | 241 | switch(captureMode) { | ||
245 | case Spectacle::CaptureMode::WindowUnderCursor: | 242 | case Spectacle::CaptureMode::WindowUnderCursor: | ||
246 | mWindowDecorations->setEnabled(true); | 243 | mWindowDecorations->setEnabled(true); | ||
247 | if (mTransientWithParentAvailable) { | 244 | if (mTransientWithParentAvailable) { | ||
248 | mCaptureTransientOnly->setEnabled(true); | 245 | mCaptureTransientOnly->setEnabled(true); | ||
249 | } else { | 246 | } else { | ||
250 | mCaptureTransientOnly->setEnabled(false); | 247 | mCaptureTransientOnly->setEnabled(false); | ||
251 | } | 248 | } | ||
Show All 39 Lines |