Improve settings logic and layout

Rearrange setting so it's no more possible to have all three options activated at once: copy image to clipboard, save location to clipboard and autosave image.
Added check to avoid having all three settings at once. Updated layout with some spacers.

BUG: 420477
parent 1e7b22b8
......@@ -7,25 +7,69 @@
<x>0</x>
<y>0</y>
<width>463</width>
<height>446</height>
<height>558</height>
</rect>
</property>
<layout class="QFormLayout">
<item row="0" column="0" colspan="2">
<item row="0" column="0">
<widget class="QLabel" name="afterScreenshotLabel">
<property name="text">
<string>After taking a screenshot:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="kcfg_copyImageToClipboard">
<property name="text">
<string>Copy image to clipboard</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="kcfg_autoSaveImage">
<property name="text">
<string>Autosave the image to the default location</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="kcfg_copySaveLocation">
<property name="text">
<string>Copy file location to clipboard after saving</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="2">
<widget class="KTitleWidget" name="runningTitle">
<property name="text">
<string>When Spectacle is Running</string>
<string>While Spectacle is running</string>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="5" column="0">
<widget class="QLabel" name="printKeyActionLabel">
<property name="text">
<string>Press screenshot key to:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="5" column="1">
<widget class="QGroupBox" name="kcfg_printKeyActionRunning">
<property name="title">
<string/>
......@@ -34,6 +78,9 @@
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="newScreenshotButton">
<property name="text">
......@@ -61,44 +108,7 @@
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QLabel" name="afterScreenshotLabel">
<property name="text">
<string>After taking a screenshot:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="kcfg_copyImageToClipboard">
<property name="text">
<string>Copy image to clipboard</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="kcfg_autoSaveImage">
<property name="text">
<string>Autosave the image to the default location</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -114,49 +124,49 @@
</property>
</spacer>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="KTitleWidget" name="regionTitle">
<property name="text">
<string>Rectangular Region</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="generalLabel">
<property name="text">
<string>General:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QCheckBox" name="kcfg_useLightMaskColour">
<property name="text">
<string>Use light background</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QCheckBox" name="kcfg_showMagnifier">
<property name="text">
<string>Show magnifier</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QCheckBox" name="kcfg_useReleaseToCapture">
<property name="text">
<string>Accept on click-and-release</string>
</property>
</widget>
</item>
<item row="10" column="0">
<item row="12" column="0">
<widget class="QLabel" name="rememberLabel">
<property name="text">
<string>Remember selected area:</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="12" column="1">
<widget class="QRadioButton" name="neverRemeberButton">
<property name="text">
<string>Never</string>
......@@ -169,7 +179,7 @@
</attribute>
</widget>
</item>
<item row="11" column="1">
<item row="13" column="1">
<widget class="QRadioButton" name="kcfg_alwaysRememberRegion">
<property name="text">
<string>Always</string>
......@@ -179,7 +189,7 @@
</attribute>
</widget>
</item>
<item row="12" column="1">
<item row="14" column="1">
<widget class="QRadioButton" name="kcfg_rememberLastRectangularRegion">
<property name="text">
<string>Until Spectacle is closed</string>
......@@ -189,6 +199,22 @@
</attribute>
</widget>
</item>
<item row="11" column="1">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
......@@ -198,6 +224,20 @@
<header>ktitlewidget.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>kcfg_copyImageToClipboard</tabstop>
<tabstop>kcfg_autoSaveImage</tabstop>
<tabstop>kcfg_copySaveLocation</tabstop>
<tabstop>newScreenshotButton</tabstop>
<tabstop>newWindowButton</tabstop>
<tabstop>activateWindowButton</tabstop>
<tabstop>kcfg_useLightMaskColour</tabstop>
<tabstop>kcfg_showMagnifier</tabstop>
<tabstop>kcfg_useReleaseToCapture</tabstop>
<tabstop>neverRemeberButton</tabstop>
<tabstop>kcfg_alwaysRememberRegion</tabstop>
<tabstop>kcfg_rememberLastRectangularRegion</tabstop>
</tabstops>
<resources/>
<connections/>
<buttongroups>
......
......@@ -36,6 +36,9 @@ GeneralOptionsPage::GeneralOptionsPage(QWidget *parent)
m_ui->runningTitle->setLevel(2);
m_ui->regionTitle->setLevel(2);
connect(m_ui->kcfg_copyImageToClipboard, &QCheckBox::stateChanged, this, &GeneralOptionsPage::updateAutomaticActions);
connect(m_ui->kcfg_autoSaveImage, &QCheckBox::stateChanged, this, &GeneralOptionsPage::updateAutomaticActions);
//On Wayland we can't programmatically raise and focus the window so we have to hide the option
if (KWindowSystem::isPlatformWayland() || qstrcmp(qgetenv("XDG_SESSION_TYPE"), "wayland") == 0) {
delete m_ui->activateWindowButton;
......@@ -43,3 +46,14 @@ GeneralOptionsPage::GeneralOptionsPage(QWidget *parent)
}
GeneralOptionsPage::~GeneralOptionsPage() = default;
void GeneralOptionsPage::updateAutomaticActions() {
if (m_ui->kcfg_copyImageToClipboard->isChecked() && m_ui->kcfg_autoSaveImage->isChecked()) {
m_ui->kcfg_copySaveLocation->setCheckState(Qt::CheckState::Unchecked);
m_ui->kcfg_copySaveLocation->setCheckable(false);
m_ui->kcfg_copySaveLocation->setDisabled(true);
} else {
m_ui->kcfg_copySaveLocation->setCheckable(true);
m_ui->kcfg_copySaveLocation->setEnabled(true);
}
}
......@@ -36,6 +36,8 @@ class GeneralOptionsPage : public QWidget
private:
void updateAutomaticActions();
QScopedPointer<Ui_GeneralOptions> m_ui;
};
......
......@@ -28,14 +28,7 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="kcfg_copySaveLocation">
<property name="text">
<string>Copy file location to clipboard after saving</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="2" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -51,14 +44,7 @@
</property>
</spacer>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Choose the image quality when saving with lossy image formats like JPEG</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="3" column="0">
<widget class="QLabel" name="qualityLabel">
<property name="text">
<string>Compression Quality:</string>
......@@ -68,7 +54,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="3" column="1">
<layout class="QVBoxLayout" name="qualityVLayout">
<item>
<layout class="QHBoxLayout" name="qualityHLayout">
......@@ -121,8 +107,8 @@
</item>
</layout>
</item>
<item row="8" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<item row="7" column="0" colspan="2">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
......@@ -137,14 +123,14 @@
</property>
</spacer>
</item>
<item row="9" column="0">
<item row="8" column="0">
<widget class="QLabel" name="PreviewLabel">
<property name="text">
<string comment="Preview of the user configured filename">Preview:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="8" column="1">
<widget class="QLabel" name="preview">
<property name="text">
<string/>
......@@ -161,6 +147,29 @@
</property>
</widget>
</item>
<item row="5" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>Choose the image quality when saving with lossy image formats like JPEG</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......@@ -177,12 +186,32 @@
<signal>valueChanged(int)</signal>
<receiver>qualitySpinner</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>qualitySpinner</sender>
<signal>valueChanged(int)</signal>
<receiver>kcfg_compressionQuality</receiver>
<slot>setValue(int)</slot>
<hints>
<hint type="sourcelabel">
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel">
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -25,6 +25,10 @@
<label>Save screenshot automatically after it is taken</label>
<default>false</default>
</entry>
<entry name="copySaveLocation" type="Bool">
<label>Whether to copy the file path after saving to the clipboard</label>
<default>true</default>
</entry>
<entry name="useLightMaskColour" type="Bool">
<label>Whether to use a light color mask in the region selection dialog</label>
<default>false</default>
......@@ -87,11 +91,7 @@
QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)+QLatin1Char('/'))
</default>
</entry>
<entry name="copySaveLocation" type="Bool">
<label>Whether to copy the file path after saving to the clipboard</label>
<default>false</default>
</entry>
<entry name="compressionQuality" type="UInt">
<entry name="compressionQuality" type="UInt">
<label>Compression quality for lossy file formats</label>
<default>90</default>
</entry>
......
......@@ -143,6 +143,7 @@ void SpectacleCore::onActivateRequested(QStringList arguments, const QString& /*
case StartMode::DBus:
mCopyToClipboard = Settings::copyImageToClipboard();
qApp->setQuitOnLastWindowClosed(false);
mCopyToClipboard = Settings::copyImageToClipboard();
break;
case StartMode::Background: {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment