Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/SettingsDialog/GeneralOptionsPage.cpp
Show All 31 Lines | |||||
32 | #include <QSpacerItem> | 32 | #include <QSpacerItem> | ||
33 | 33 | | |||
34 | GeneralOptionsPage::GeneralOptionsPage(QWidget *parent) : | 34 | GeneralOptionsPage::GeneralOptionsPage(QWidget *parent) : | ||
35 | SettingsPage(parent) | 35 | SettingsPage(parent) | ||
36 | { | 36 | { | ||
37 | QFormLayout *mainLayout = new QFormLayout(this); | 37 | QFormLayout *mainLayout = new QFormLayout(this); | ||
38 | setLayout(mainLayout); | 38 | setLayout(mainLayout); | ||
39 | 39 | | |||
40 | // When spectacle is running settings | ||||
40 | KTitleWidget* runningTitle = new KTitleWidget(this); | 41 | KTitleWidget* runningTitle = new KTitleWidget(this); | ||
41 | runningTitle->setText(i18n("When Spectacle is Running")); | 42 | runningTitle->setText(i18n("When Spectacle is Running")); | ||
42 | runningTitle->setLevel(2); | 43 | runningTitle->setLevel(2); | ||
43 | mainLayout->addRow(runningTitle); | 44 | mainLayout->addRow(runningTitle); | ||
44 | QRadioButton* takeNew = new QRadioButton(i18n("Take a new screenshot"), this); | 45 | QRadioButton* takeNew = new QRadioButton(i18n("Take a new screenshot"), this); | ||
davidre: Unrelated whitespace change | |||||
45 | QRadioButton* startNewInstance = new QRadioButton(i18n("Open a new Spectacle window"), this); | 46 | QRadioButton* startNewInstance = new QRadioButton(i18n("Open a new Spectacle window"), this); | ||
46 | mPrintKeyActionGroup = new QButtonGroup(this); | 47 | mPrintKeyActionGroup = new QButtonGroup(this); | ||
47 | mPrintKeyActionGroup->setExclusive(true); | 48 | mPrintKeyActionGroup->setExclusive(true); | ||
48 | mPrintKeyActionGroup->addButton(takeNew, SpectacleConfig::PrintKeyActionRunning::TakeNewScreenshot); | 49 | mPrintKeyActionGroup->addButton(takeNew, SpectacleConfig::PrintKeyActionRunning::TakeNewScreenshot); | ||
49 | mPrintKeyActionGroup->addButton(startNewInstance, SpectacleConfig::PrintKeyActionRunning::StartNewInstance); | 50 | mPrintKeyActionGroup->addButton(startNewInstance, SpectacleConfig::PrintKeyActionRunning::StartNewInstance); | ||
50 | connect( mPrintKeyActionGroup, qOverload<int, bool>(&QButtonGroup::buttonToggled), this, &GeneralOptionsPage::markDirty); | 51 | connect( mPrintKeyActionGroup, qOverload<int, bool>(&QButtonGroup::buttonToggled), this, &GeneralOptionsPage::markDirty); | ||
51 | mainLayout->addRow(i18n("Press screenshot key to:"), takeNew); | 52 | mainLayout->addRow(i18n("Press screenshot key to:"), takeNew); | ||
52 | mainLayout->addRow(QString(), startNewInstance); | 53 | mainLayout->addRow(QString(), startNewInstance); | ||
53 | //On Wayland we can't programmatically raise and focus the window so we have to hide the option | 54 | //On Wayland we can't programmatically raise and focus the window so we have to hide the option | ||
54 | if (!(KWindowSystem::isPlatformWayland() || qstrcmp(qgetenv("XDG_SESSION_TYPE"), "wayland") == 0)) { | 55 | if (!(KWindowSystem::isPlatformWayland() || qstrcmp(qgetenv("XDG_SESSION_TYPE"), "wayland") == 0)) { | ||
55 | QRadioButton* focusWindow = new QRadioButton(i18n("Return focus to Spectacle"), this); | 56 | QRadioButton* focusWindow = new QRadioButton(i18n("Return focus to Spectacle"), this); | ||
56 | mPrintKeyActionGroup->addButton( focusWindow, SpectacleConfig::PrintKeyActionRunning::FocusWindow); | 57 | mPrintKeyActionGroup->addButton( focusWindow, SpectacleConfig::PrintKeyActionRunning::FocusWindow); | ||
57 | mainLayout->addRow(QString(), focusWindow); | 58 | mainLayout->addRow(QString(), focusWindow); | ||
58 | } | 59 | } | ||
59 | 60 | | |||
60 | mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed)); | 61 | mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
61 | 62 | | |||
62 | // copy file or file location to clipboard after taking a screenshot | 63 | // actions to take after taking a screenshot | ||
davidre: Comment needs to be updated | |||||
63 | QRadioButton *doNothing = new QRadioButton(i18n("Do nothing"), this); | 64 | mCopyImageToClipboard = new QCheckBox(i18n("Copy image to clipboard"), this); | ||
64 | QRadioButton *copyImageToClipboard = new QRadioButton(i18n("Copy image to clipboard"), this); | 65 | connect(mCopyImageToClipboard, &QCheckBox::toggled, this, &GeneralOptionsPage::markDirty); | ||
65 | mAfterTakingScreenshotGroup = new QButtonGroup(this); | 66 | mainLayout->addRow(i18n("After taking a screenshot:"), mCopyImageToClipboard); | ||
66 | mAfterTakingScreenshotGroup->setExclusive(true); | 67 | | ||
67 | mAfterTakingScreenshotGroup->addButton(doNothing, SpectacleConfig::AfterTakingScreenshotAction::DoNothing); | 68 | mAutoSaveImage = new QCheckBox(i18n("Autosave the image to the default location"), this); | ||
68 | mAfterTakingScreenshotGroup->addButton(copyImageToClipboard, SpectacleConfig::AfterTakingScreenshotAction::CopyImageToClipboard); | 69 | connect(mAutoSaveImage, &QCheckBox::toggled, this, &GeneralOptionsPage::markDirty); | ||
69 | connect(mAfterTakingScreenshotGroup, qOverload<int, bool>(&QButtonGroup::buttonToggled), this, &GeneralOptionsPage::markDirty); | 70 | mainLayout->addRow(QString(), mAutoSaveImage); | ||
70 | mainLayout->addRow(i18n("After taking a screenshot:"), doNothing); | 71 | | ||
71 | mainLayout->addRow(QString(), copyImageToClipboard); | 72 | mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||
72 | 73 | | |||
73 | // Rectangular Region settings | 74 | // Rectangular Region settings | ||
74 | KTitleWidget *titleWidget = new KTitleWidget(this); | 75 | KTitleWidget *titleWidget = new KTitleWidget(this); | ||
75 | titleWidget->setText(i18n("Rectangular Region")); | 76 | titleWidget->setText(i18n("Rectangular Region")); | ||
76 | titleWidget->setLevel(2); | 77 | titleWidget->setLevel(2); | ||
77 | mainLayout->addRow(titleWidget); | 78 | mainLayout->addRow(titleWidget); | ||
davidre: Why change this variable name? Unrelated to this patch | |||||
78 | 79 | | |||
79 | // use light background | 80 | // use light background | ||
80 | mUseLightBackground = new QCheckBox(i18n("Use light background"), this); | 81 | mUseLightBackground = new QCheckBox(i18n("Use light background"), this); | ||
81 | connect(mUseLightBackground, &QCheckBox::toggled, this, &GeneralOptionsPage::markDirty); | 82 | connect(mUseLightBackground, &QCheckBox::toggled, this, &GeneralOptionsPage::markDirty); | ||
82 | mainLayout->addRow(i18n("General:"), mUseLightBackground); | 83 | mainLayout->addRow(i18n("General:"), mUseLightBackground); | ||
83 | 84 | | |||
84 | // show magnifier | 85 | // show magnifier | ||
85 | mShowMagnifier = new QCheckBox(i18n("Show magnifier"), this); | 86 | mShowMagnifier = new QCheckBox(i18n("Show magnifier"), this); | ||
Show All 36 Lines | 122 | { | |||
122 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | 123 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | ||
123 | 124 | | |||
124 | cfgManager->setUseLightRegionMaskColour(mUseLightBackground->checkState() == Qt::Checked); | 125 | cfgManager->setUseLightRegionMaskColour(mUseLightBackground->checkState() == Qt::Checked); | ||
125 | cfgManager->setRememberLastRectangularRegion(mRememberUntilClosed->isChecked() || mRememberAlways->isChecked()); | 126 | cfgManager->setRememberLastRectangularRegion(mRememberUntilClosed->isChecked() || mRememberAlways->isChecked()); | ||
126 | cfgManager->setAlwaysRememberRegion (mRememberAlways->isChecked()); | 127 | cfgManager->setAlwaysRememberRegion (mRememberAlways->isChecked()); | ||
127 | cfgManager->setShowMagnifierChecked(mShowMagnifier->checkState() == Qt::Checked); | 128 | cfgManager->setShowMagnifierChecked(mShowMagnifier->checkState() == Qt::Checked); | ||
128 | cfgManager->setUseReleaseToCaptureChecked(mReleaseToCapture->checkState() == Qt::Checked); | 129 | cfgManager->setUseReleaseToCaptureChecked(mReleaseToCapture->checkState() == Qt::Checked); | ||
129 | cfgManager->setPrintKeyActionRunning(static_cast<SpectacleConfig::PrintKeyActionRunning>(mPrintKeyActionGroup->checkedId())); | 130 | cfgManager->setPrintKeyActionRunning(static_cast<SpectacleConfig::PrintKeyActionRunning>(mPrintKeyActionGroup->checkedId())); | ||
130 | cfgManager->setAfterTakingScreenshotAction(static_cast<SpectacleConfig::AfterTakingScreenshotAction>(mAfterTakingScreenshotGroup->checkedId())); | 131 | cfgManager->setCopyImageToClipboard(mCopyImageToClipboard->checkState() == Qt::Checked); | ||
132 | cfgManager->setAutoSaveImage(mAutoSaveImage->checkState() == Qt::Checked); | ||||
131 | 133 | | |||
132 | mChangesMade = false; | 134 | mChangesMade = false; | ||
133 | } | 135 | } | ||
134 | 136 | | |||
135 | void GeneralOptionsPage::resetChanges() | 137 | void GeneralOptionsPage::resetChanges() | ||
136 | { | 138 | { | ||
137 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | 139 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | ||
138 | 140 | | |||
139 | mUseLightBackground->setChecked(cfgManager->useLightRegionMaskColour()); | 141 | mUseLightBackground->setChecked(cfgManager->useLightRegionMaskColour()); | ||
140 | mRememberUntilClosed->setChecked(cfgManager->rememberLastRectangularRegion()); | 142 | mRememberUntilClosed->setChecked(cfgManager->rememberLastRectangularRegion()); | ||
141 | mRememberAlways->setChecked(cfgManager->alwaysRememberRegion()); | 143 | mRememberAlways->setChecked(cfgManager->alwaysRememberRegion()); | ||
142 | mShowMagnifier->setChecked(cfgManager->showMagnifierChecked()); | 144 | mShowMagnifier->setChecked(cfgManager->showMagnifierChecked()); | ||
143 | mReleaseToCapture->setChecked(cfgManager->useReleaseToCapture()); | 145 | mReleaseToCapture->setChecked(cfgManager->useReleaseToCapture()); | ||
144 | mPrintKeyActionGroup->button(cfgManager->printKeyActionRunning())->setChecked(true); | 146 | mPrintKeyActionGroup->button(cfgManager->printKeyActionRunning())->setChecked(true); | ||
145 | mAfterTakingScreenshotGroup->button(cfgManager->afterTakingScreenshotAction())->setChecked(true); | 147 | mCopyImageToClipboard->setChecked(cfgManager->copyImageToClipboard()); | ||
148 | mAutoSaveImage->setChecked(cfgManager->autoSaveImage()); | ||||
146 | 149 | | |||
147 | mChangesMade = false; | 150 | mChangesMade = false; | ||
148 | } | 151 | } |
Unrelated whitespace change