Changeset View
Changeset View
Standalone View
Standalone View
src/Gui/SettingsDialog/GeneralOptionsPage.cpp
Show All 38 Lines | 38 | GeneralOptionsPage::GeneralOptionsPage(QWidget *parent) | |||
---|---|---|---|---|---|
39 | : QWidget(parent) | 39 | : QWidget(parent) | ||
40 | , m_ui(new Ui_GeneralOptions) | 40 | , m_ui(new Ui_GeneralOptions) | ||
41 | { | 41 | { | ||
42 | m_ui->setupUi(this); | 42 | m_ui->setupUi(this); | ||
43 | 43 | | |||
44 | m_ui->runningTitle->setLevel(2); | 44 | m_ui->runningTitle->setLevel(2); | ||
45 | m_ui->regionTitle->setLevel(2); | 45 | m_ui->regionTitle->setLevel(2); | ||
46 | 46 | | |||
47 | m_ui->printKeyActionGroup->setId(m_ui->newScreenshotButton, Settings::TakeNewScreenshot); | | |||
48 | m_ui->printKeyActionGroup->setId(m_ui->newWindowButton, Settings::StartNewInstance); | | |||
49 | m_ui->printKeyActionGroup->setId(m_ui->activateWindowButton, Settings::FocusWindow); | | |||
50 | | ||||
51 | //On Wayland we can't programmatically raise and focus the window so we have to hide the option | 47 | //On Wayland we can't programmatically raise and focus the window so we have to hide the option | ||
52 | if (KWindowSystem::isPlatformWayland() || qstrcmp(qgetenv("XDG_SESSION_TYPE"), "wayland") == 0) { | 48 | if (KWindowSystem::isPlatformWayland() || qstrcmp(qgetenv("XDG_SESSION_TYPE"), "wayland") == 0) { | ||
53 | m_ui->formLayout->removeRow(m_ui->activateWindowButton); | 49 | delete m_ui->activateWindowButton; | ||
54 | } | | |||
55 | //Workaround because KConfigDialogManager doesn't support QButtonGroup (Bug 409037) | | |||
56 | auto workaroundLabel = m_ui->kcfg_printKeyActionRunning; | | |||
57 | connect(workaroundLabel, &QLineEdit::textChanged, this, [this](const QString& text){ | | |||
58 | auto button = m_ui->printKeyActionGroup->button(text.toInt()); | | |||
59 | // We are missing a button on Wayland | | |||
60 | button ? button->setChecked(true) : m_ui->newScreenshotButton->setChecked(true); | | |||
61 | }); | | |||
62 | connect(m_ui->printKeyActionGroup, qOverload<QAbstractButton *, bool>(&QButtonGroup::buttonToggled), | | |||
63 | workaroundLabel, [workaroundLabel, this] (QAbstractButton *button, bool checked) { | | |||
64 | if (checked) { | | |||
65 | const int value = m_ui->printKeyActionGroup->id(button); | | |||
66 | workaroundLabel->setText(QString::number(value)); | | |||
67 | } | 50 | } | ||
68 | }); | | |||
69 | // /Workaround | | |||
70 | | ||||
71 | } | 51 | } | ||
72 | 52 | | |||
73 | GeneralOptionsPage::~GeneralOptionsPage() = default; | 53 | GeneralOptionsPage::~GeneralOptionsPage() = default; |