diff --git a/src/Gui/KSWidget.h b/src/Gui/KSWidget.h --- a/src/Gui/KSWidget.h +++ b/src/Gui/KSWidget.h @@ -36,6 +36,8 @@ class QCheckBox; class QLabel; +class KConfigDialogManager; + class KSImageWidget; class ProgressButton; class SmartSpinBox; @@ -98,4 +100,5 @@ bool mTransientWithParentAvailable { false }; QAction *mTakeNewScreenshotAction; QAction *mCancelAction; + KConfigDialogManager *mConfigManager; }; diff --git a/src/Gui/KSWidget.cpp b/src/Gui/KSWidget.cpp --- a/src/Gui/KSWidget.cpp +++ b/src/Gui/KSWidget.cpp @@ -36,10 +36,11 @@ #include #include +#include #include -KSWidget::KSWidget(const Platform::GrabModes &theGrabModes, QWidget *parent) : - QWidget(parent) +KSWidget::KSWidget(const Platform::GrabModes &theGrabModes, QWidget *parent) + : QWidget(parent) { // we'll init the widget that holds the image first mImageWidget = new KSImageWidget(this); @@ -70,24 +71,27 @@ mTransientWithParentAvailable = true; } mCaptureArea->setMinimumWidth(240); + mCaptureArea->setObjectName(QStringLiteral("kcfg_captureMode")); + mCaptureArea->setProperty("kcfg_property", QByteArray("currentData")); #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) connect(mCaptureArea, qOverload(&QComboBox::currentIndexChanged), this, &KSWidget::captureModeChanged); #else connect(mCaptureArea, qOverload(&QComboBox::currentIndexChanged), this, &KSWidget::captureModeChanged); #endif + mDelayMsec = new SmartSpinBox(this); mDelayMsec->setDecimals(1); mDelayMsec->setSingleStep(1.0); mDelayMsec->setMinimum(0.0); mDelayMsec->setMaximum(999.9); mDelayMsec->setSpecialValueText(i18n("No Delay")); mDelayMsec->setMinimumWidth(160); - connect(mDelayMsec, qOverload(&SmartSpinBox::valueChanged), &Settings::setCaptureDelay); + mDelayMsec->setObjectName(QStringLiteral("kcfg_captureDelay")); mCaptureOnClick = new QCheckBox(i18n("On Click"), this); mCaptureOnClick->setToolTip(i18n("Wait for a mouse click before capturing the screenshot image")); connect(mCaptureOnClick, &QCheckBox::stateChanged, this, &KSWidget::onClickStateChanged); - connect(mCaptureOnClick, &QCheckBox::clicked, &Settings::setOnClickChecked); + mCaptureOnClick->setObjectName(QStringLiteral("kcfg_onClickChecked")); mDelayLayout = new QHBoxLayout; mDelayLayout->addWidget(mDelayMsec); @@ -104,22 +108,22 @@ mMousePointer = new QCheckBox(i18n("Include mouse pointer"), this); mMousePointer->setToolTip(i18n("Show the mouse cursor in the screenshot image")); - connect(mMousePointer, &QCheckBox::clicked, &Settings::setIncludePointer); + mMousePointer->setObjectName(QStringLiteral("kcfg_includePointer")); mWindowDecorations = new QCheckBox(i18n("Include window titlebar and borders"), this); mWindowDecorations->setToolTip(i18n("Show the window title bar, the minimize/maximize/close buttons, and the window border")); mWindowDecorations->setEnabled(false); - connect(mWindowDecorations, &QCheckBox::clicked, &Settings::setIncludeDecorations); + mWindowDecorations->setObjectName(QStringLiteral("kcfg_includeDecorations")); mCaptureTransientOnly = new QCheckBox(i18n("Capture the current pop-up only"), this); mCaptureTransientOnly->setToolTip(i18n("Capture only the current pop-up window (like a menu, tooltip etc).\n" "If disabled, the pop-up is captured along with the parent window")); mCaptureTransientOnly->setEnabled(false); - connect(mCaptureTransientOnly, &QCheckBox::clicked, &Settings::setTransientOnly); + mCaptureTransientOnly->setObjectName(QStringLiteral("kcfg_transientOnly")); mQuitAfterSaveOrCopy = new QCheckBox(i18n("Quit after manual Save or Copy"), this); mQuitAfterSaveOrCopy->setToolTip(i18n("Quit Spectacle after manually saving or copying the image")); - connect(mQuitAfterSaveOrCopy, &QCheckBox::clicked, &Settings::setQuitAfterSaveCopyExport); + mQuitAfterSaveOrCopy->setObjectName(QStringLiteral("kcfg_quitAfterSaveCopyExport")); mContentOptionsForm = new QVBoxLayout; mContentOptionsForm->addWidget(mMousePointer); @@ -164,15 +168,10 @@ mMainLayout->setColumnMinimumWidth(0, 320); mMainLayout->setColumnMinimumWidth(1, 320); - // and read in the saved checkbox states and capture mode indices - mMousePointer->setChecked(Settings::includePointer()); - mWindowDecorations->setChecked(Settings::includeDecorations()); - mCaptureOnClick->setChecked(Settings::onClickChecked()); - mCaptureTransientOnly->setChecked(Settings::transientOnly()); - mQuitAfterSaveOrCopy->setChecked(Settings::quitAfterSaveCopyExport()); - mDelayMsec->setValue(Settings::captureDelay()); int index = mCaptureArea->findData(Settings::captureMode()); mCaptureArea->setCurrentIndex(index >= 0 ? index : 0); + auto mConfigManager = new KConfigDialogManager(this, Settings::self()); + connect(mConfigManager, &KConfigDialogManager::widgetModified, mConfigManager, &KConfigDialogManager::updateSettings); } int KSWidget::imagePaddingWidth() const @@ -239,8 +238,6 @@ void KSWidget::captureModeChanged(int theIndex) { Spectacle::CaptureMode captureMode = static_cast(mCaptureArea->itemData(theIndex).toInt()); - Settings::setCaptureMode(captureMode); - switch(captureMode) { case Spectacle::CaptureMode::WindowUnderCursor: mWindowDecorations->setEnabled(true);