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); | ||
45 | | ||||
davidre: Unrelated whitespace change | |||||
44 | QRadioButton* takeNew = new QRadioButton(i18n("Take a new screenshot"), this); | 46 | QRadioButton* takeNew = new QRadioButton(i18n("Take a new screenshot"), this); | ||
45 | QRadioButton* startNewInstance = new QRadioButton(i18n("Open a new Spectacle window"), this); | 47 | QRadioButton* startNewInstance = new QRadioButton(i18n("Open a new Spectacle window"), this); | ||
46 | mPrintKeyActionGroup = new QButtonGroup(this); | 48 | mPrintKeyActionGroup = new QButtonGroup(this); | ||
47 | mPrintKeyActionGroup->setExclusive(true); | 49 | mPrintKeyActionGroup->setExclusive(true); | ||
48 | mPrintKeyActionGroup->addButton(takeNew, SpectacleConfig::PrintKeyActionRunning::TakeNewScreenshot); | 50 | mPrintKeyActionGroup->addButton(takeNew, SpectacleConfig::PrintKeyActionRunning::TakeNewScreenshot); | ||
49 | mPrintKeyActionGroup->addButton(startNewInstance, SpectacleConfig::PrintKeyActionRunning::StartNewInstance); | 51 | mPrintKeyActionGroup->addButton(startNewInstance, SpectacleConfig::PrintKeyActionRunning::StartNewInstance); | ||
50 | connect( mPrintKeyActionGroup, qOverload<int, bool>(&QButtonGroup::buttonToggled), this, &GeneralOptionsPage::markDirty); | 52 | connect( mPrintKeyActionGroup, qOverload<int, bool>(&QButtonGroup::buttonToggled), this, &GeneralOptionsPage::markDirty); | ||
51 | mainLayout->addRow(i18n("Press screenshot key to:"), takeNew); | 53 | mainLayout->addRow(i18n("Press screenshot key to:"), takeNew); | ||
52 | mainLayout->addRow(QString(), startNewInstance); | 54 | mainLayout->addRow(QString(), startNewInstance); | ||
53 | //On Wayland we can't programmatically raise and focus the window so we have to hide the option | 55 | //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)) { | 56 | if (!(KWindowSystem::isPlatformWayland() || qstrcmp(qgetenv("XDG_SESSION_TYPE"), "wayland") == 0)) { | ||
55 | QRadioButton* focusWindow = new QRadioButton(i18n("Return focus to Spectacle"), this); | 57 | QRadioButton* focusWindow = new QRadioButton(i18n("Return focus to Spectacle"), this); | ||
56 | mPrintKeyActionGroup->addButton( focusWindow, SpectacleConfig::PrintKeyActionRunning::FocusWindow); | 58 | mPrintKeyActionGroup->addButton( focusWindow, SpectacleConfig::PrintKeyActionRunning::FocusWindow); | ||
57 | mainLayout->addRow(QString(), focusWindow); | 59 | mainLayout->addRow(QString(), focusWindow); | ||
58 | } | 60 | } | ||
59 | 61 | | |||
62 | mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||||
63 | | ||||
64 | // copy file or file location to clipboard after taking a screenshot | ||||
65 | QRadioButton *doNothing = new QRadioButton(i18n("Do nothing"), this); | ||||
66 | QRadioButton *copyImageToClipboard = new QRadioButton(i18n("Copy image to clipboard"), this); | ||||
67 | QRadioButton *autoSaveImage = new QRadioButton(i18n("Autosave the image to the default location"), this); | ||||
68 | mAfterTakingScreenshotGroup = new QButtonGroup(this); | ||||
69 | mAfterTakingScreenshotGroup->setExclusive(true); | ||||
70 | mAfterTakingScreenshotGroup->addButton(doNothing, SpectacleConfig::AfterTakingScreenshotAction::DoNothing); | ||||
71 | mAfterTakingScreenshotGroup->addButton(copyImageToClipboard, SpectacleConfig::AfterTakingScreenshotAction::CopyImageToClipboard); | ||||
72 | mAfterTakingScreenshotGroup->addButton(autoSaveImage, SpectacleConfig::AfterTakingScreenshotAction::AutoSaveImage); | ||||
73 | connect(mAfterTakingScreenshotGroup, qOverload<int, bool>(&QButtonGroup::buttonToggled), this, &GeneralOptionsPage::markDirty); | ||||
74 | mainLayout->addRow(i18n("After taking a screenshot:"), doNothing); | ||||
75 | mainLayout->addRow(QString(), copyImageToClipboard); | ||||
76 | mainLayout->addRow(QString(), autoSaveImage); | ||||
77 | | ||||
78 | mainLayout->addItem(new QSpacerItem(0, 18, QSizePolicy::Fixed, QSizePolicy::Fixed)); | ||||
79 | | ||||
60 | // Rectangular Region settings | 80 | // Rectangular Region settings | ||
davidre: Comment needs to be updated | |||||
61 | KTitleWidget *titleWidget = new KTitleWidget(this); | 81 | KTitleWidget *rectangularRegionWidget = new KTitleWidget(this); | ||
62 | titleWidget->setText(i18n("Rectangular Region")); | 82 | rectangularRegionWidget->setText(i18n("Rectangular Region")); | ||
63 | titleWidget->setLevel(2); | 83 | rectangularRegionWidget->setLevel(2); | ||
64 | mainLayout->addRow(titleWidget); | 84 | mainLayout->addRow(rectangularRegionWidget); | ||
davidre: Why change this variable name? Unrelated to this patch | |||||
65 | 85 | | |||
66 | // use light background | 86 | // use light background | ||
67 | mUseLightBackground = new QCheckBox(i18n("Use light background"), this); | 87 | mUseLightBackground = new QCheckBox(i18n("Use light background"), this); | ||
68 | connect(mUseLightBackground, &QCheckBox::toggled, this, &GeneralOptionsPage::markDirty); | 88 | connect(mUseLightBackground, &QCheckBox::toggled, this, &GeneralOptionsPage::markDirty); | ||
69 | mainLayout->addRow(i18n("General:"), mUseLightBackground); | 89 | mainLayout->addRow(i18n("General:"), mUseLightBackground); | ||
70 | 90 | | |||
71 | // show magnifier | 91 | // show magnifier | ||
72 | mShowMagnifier = new QCheckBox(i18n("Show magnifier"), this); | 92 | mShowMagnifier = new QCheckBox(i18n("Show magnifier"), this); | ||
Show All 36 Lines | 128 | { | |||
109 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | 129 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | ||
110 | 130 | | |||
111 | cfgManager->setUseLightRegionMaskColour(mUseLightBackground->checkState() == Qt::Checked); | 131 | cfgManager->setUseLightRegionMaskColour(mUseLightBackground->checkState() == Qt::Checked); | ||
112 | cfgManager->setRememberLastRectangularRegion(mRememberUntilClosed->isChecked() || mRememberAlways->isChecked()); | 132 | cfgManager->setRememberLastRectangularRegion(mRememberUntilClosed->isChecked() || mRememberAlways->isChecked()); | ||
113 | cfgManager->setAlwaysRememberRegion (mRememberAlways->isChecked()); | 133 | cfgManager->setAlwaysRememberRegion (mRememberAlways->isChecked()); | ||
114 | cfgManager->setShowMagnifierChecked(mShowMagnifier->checkState() == Qt::Checked); | 134 | cfgManager->setShowMagnifierChecked(mShowMagnifier->checkState() == Qt::Checked); | ||
115 | cfgManager->setUseReleaseToCaptureChecked(mReleaseToCapture->checkState() == Qt::Checked); | 135 | cfgManager->setUseReleaseToCaptureChecked(mReleaseToCapture->checkState() == Qt::Checked); | ||
116 | cfgManager->setPrintKeyActionRunning(static_cast<SpectacleConfig::PrintKeyActionRunning>(mPrintKeyActionGroup->checkedId())); | 136 | cfgManager->setPrintKeyActionRunning(static_cast<SpectacleConfig::PrintKeyActionRunning>(mPrintKeyActionGroup->checkedId())); | ||
137 | cfgManager->setAfterTakingScreenshotAction(static_cast<SpectacleConfig::AfterTakingScreenshotAction>(mAfterTakingScreenshotGroup->checkedId())); | ||||
117 | 138 | | |||
118 | mChangesMade = false; | 139 | mChangesMade = false; | ||
119 | } | 140 | } | ||
120 | 141 | | |||
121 | void GeneralOptionsPage::resetChanges() | 142 | void GeneralOptionsPage::resetChanges() | ||
122 | { | 143 | { | ||
123 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | 144 | SpectacleConfig *cfgManager = SpectacleConfig::instance(); | ||
124 | 145 | | |||
125 | mUseLightBackground->setChecked(cfgManager->useLightRegionMaskColour()); | 146 | mUseLightBackground->setChecked(cfgManager->useLightRegionMaskColour()); | ||
126 | mRememberUntilClosed->setChecked(cfgManager->rememberLastRectangularRegion()); | 147 | mRememberUntilClosed->setChecked(cfgManager->rememberLastRectangularRegion()); | ||
127 | mRememberAlways->setChecked(cfgManager->alwaysRememberRegion()); | 148 | mRememberAlways->setChecked(cfgManager->alwaysRememberRegion()); | ||
128 | mShowMagnifier->setChecked(cfgManager->showMagnifierChecked()); | 149 | mShowMagnifier->setChecked(cfgManager->showMagnifierChecked()); | ||
129 | mReleaseToCapture->setChecked(cfgManager->useReleaseToCapture()); | 150 | mReleaseToCapture->setChecked(cfgManager->useReleaseToCapture()); | ||
130 | mPrintKeyActionGroup->button(cfgManager->printKeyActionRunning())->setChecked(true); | 151 | mPrintKeyActionGroup->button(cfgManager->printKeyActionRunning())->setChecked(true); | ||
152 | mAfterTakingScreenshotGroup->button(cfgManager->afterTakingScreenshotAction())->setChecked(true); | ||||
131 | 153 | | |||
132 | mChangesMade = false; | 154 | mChangesMade = false; | ||
133 | } | 155 | } |
Unrelated whitespace change