Commit 1e3b21c7 authored by David Redondo's avatar David Redondo 🏎
Browse files

Remove hack for QButtonBox

Summary: Use a flat groupbox which works out of the box

Test Plan: works

Reviewers: #spectacle, ervin, ngraham

Reviewed By: #spectacle, ngraham

Subscribers: ngraham

Tags: #spectacle

Differential Revision: https://phabricator.kde.org/D28080
parent 1a5ba095
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>463</width>
<height>442</height>
<height>446</height>
</rect>
</property>
<layout class="QFormLayout">
......@@ -26,39 +26,42 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QRadioButton" name="newScreenshotButton">
<property name="text">
<string>Take a new Screenshot</string>
<widget class="QGroupBox" name="kcfg_printKeyActionRunning">
<property name="title">
<string/>
</property>
<property name="checked">
<property name="flat">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">printKeyActionGroup</string>
</attribute>
</widget>
</item>
<item row="2" column="1">
<widget class="QRadioButton" name="newWindowButton">
<property name="text">
<string>Open a new Spectacle window</string>
</property>
<attribute name="buttonGroup">
<string notr="true">printKeyActionGroup</string>
</attribute>
</widget>
</item>
<item row="3" column="1">
<widget class="QRadioButton" name="activateWindowButton">
<property name="text">
<string>Return focus to Spectacle</string>
</property>
<attribute name="buttonGroup">
<string notr="true">printKeyActionGroup</string>
</attribute>
</widget>
</item>
<item row="4" column="0" colspan="2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="newScreenshotButton">
<property name="text">
<string>Take a new Screenshot</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="newWindowButton">
<property name="text">
<string>Open a new Spectacle window</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="activateWindowButton">
<property name="text">
<string>Return focus to Spectacle</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -74,28 +77,28 @@
</property>
</spacer>
</item>
<item row="5" column="0">
<item row="3" column="0">
<widget class="QLabel" name="afterScreenshotLabel">
<property name="text">
<string>After taking a screenshot:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<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="6" column="1">
<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="7" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -111,49 +114,49 @@
</property>
</spacer>
</item>
<item row="8" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="KTitleWidget" name="regionTitle">
<property name="text">
<string>Rectangular Region</string>
</property>
</widget>
</item>
<item row="9" column="0">
<item row="7" column="0">
<widget class="QLabel" name="generalLabel">
<property name="text">
<string>General:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="7" column="1">
<widget class="QCheckBox" name="kcfg_useLightMaskColour">
<property name="text">
<string>Use light background</string>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="8" column="1">
<widget class="QCheckBox" name="kcfg_showMagnifier">
<property name="text">
<string>Show magnifier</string>
</property>
</widget>
</item>
<item row="11" column="1">
<item row="9" column="1">
<widget class="QCheckBox" name="kcfg_useReleaseToCapture">
<property name="text">
<string>Accept on click-and-release</string>
</property>
</widget>
</item>
<item row="12" column="0">
<item row="10" column="0">
<widget class="QLabel" name="rememberLabel">
<property name="text">
<string>Remember selected area:</string>
</property>
</widget>
</item>
<item row="12" column="1">
<item row="10" column="1">
<widget class="QRadioButton" name="neverRemeberButton">
<property name="text">
<string>Never</string>
......@@ -163,14 +166,14 @@
</property>
</widget>
</item>
<item row="13" column="1">
<item row="11" column="1">
<widget class="QRadioButton" name="kcfg_alwaysRememberRegion">
<property name="text">
<string>Always</string>
</property>
</widget>
</item>
<item row="14" column="1">
<item row="12" column="1">
<widget class="QRadioButton" name="kcfg_rememberLastRectangularRegion">
<property name="text">
<string>Until Spectacle is closed</string>
......@@ -178,14 +181,6 @@
</widget>
</item>
</layout>
<widget class="QLineEdit" name="kcfg_printKeyActionRunning">
<property name="enabled">
<bool>true</bool>
</property>
<property name="visible">
<bool>false</bool>
</property>
</widget>
</widget>
<customwidgets>
<customwidget>
......@@ -196,7 +191,4 @@
</customwidgets>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="printKeyActionGroup"/>
</buttongroups>
</ui>
......@@ -44,30 +44,10 @@ GeneralOptionsPage::GeneralOptionsPage(QWidget *parent)
m_ui->runningTitle->setLevel(2);
m_ui->regionTitle->setLevel(2);
m_ui->printKeyActionGroup->setId(m_ui->newScreenshotButton, Settings::TakeNewScreenshot);
m_ui->printKeyActionGroup->setId(m_ui->newWindowButton, Settings::StartNewInstance);
m_ui->printKeyActionGroup->setId(m_ui->activateWindowButton, Settings::FocusWindow);
//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) {
m_ui->formLayout->removeRow(m_ui->activateWindowButton);
delete m_ui->activateWindowButton;
}
//Workaround because KConfigDialogManager doesn't support QButtonGroup (Bug 409037)
auto workaroundLabel = m_ui->kcfg_printKeyActionRunning;
connect(workaroundLabel, &QLineEdit::textChanged, this, [this](const QString& text){
auto button = m_ui->printKeyActionGroup->button(text.toInt());
// We are missing a button on Wayland
button ? button->setChecked(true) : m_ui->newScreenshotButton->setChecked(true);
});
connect(m_ui->printKeyActionGroup, qOverload<QAbstractButton *, bool>(&QButtonGroup::buttonToggled),
workaroundLabel, [workaroundLabel, this] (QAbstractButton *button, bool checked) {
if (checked) {
const int value = m_ui->printKeyActionGroup->id(button);
workaroundLabel->setText(QString::number(value));
}
});
// /Workaround
}
GeneralOptionsPage::~GeneralOptionsPage() = default;
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