diff --git a/app/settings/settingsdialog.cpp b/app/settings/settingsdialog.cpp index 6fa68951a..0778676bb 100644 --- a/app/settings/settingsdialog.cpp +++ b/app/settings/settingsdialog.cpp @@ -250,6 +250,13 @@ SettingsDialog::~SettingsDialog() m_corona->universalSettings()->setLayoutsWindowSize(size()); } +Types::LatteConfigPage SettingsDialog::currentPage() +{ + Types::LatteConfigPage cPage= static_cast(ui->tabWidget->currentIndex()); + + return cPage; +} + void SettingsDialog::toggleCurrentPage() { if (ui->tabWidget->currentIndex() == 0) { @@ -318,6 +325,26 @@ void SettingsDialog::on_downloadButton_clicked() void SettingsDialog::on_removeButton_clicked() { + if (!m_layoutsController->hasSelectedLayout()) { + return; + } + + Settings::Data::Layout selectedLayout = m_layoutsController->selectedLayout(); + + if (selectedLayout.isActive) { + showInlineMessage(i18nc("settings: active layout remove","Active layouts can not be removed..."), + KMessageWidget::Error, + SettingsDialog::WARNINGINTERVAL); + return; + } + + if (selectedLayout.isLocked) { + showInlineMessage(i18nc("settings: locked layout remove","Locked layouts can not be removed..."), + KMessageWidget::Error, + SettingsDialog::WARNINGINTERVAL); + return; + } + qDebug() << Q_FUNC_INFO; m_layoutsController->removeSelected(); @@ -778,11 +805,11 @@ void SettingsDialog::updatePerLayoutButtonsState() } //! Remove Layout Button - if (selectedLayout.isActive || selectedLayout.isLocked) { + /* if (selectedLayout.isActive || selectedLayout.isLocked) { ui->removeButton->setEnabled(false); } else { ui->removeButton->setEnabled(true); - } + }*/ //! Layout Locked Button if (selectedLayout.isLocked) { @@ -850,6 +877,29 @@ void SettingsDialog::showScreensInformation() msg->open();*/ } +void SettingsDialog::keyPressEvent(QKeyEvent *event) +{ + if (event && event->key() == Qt::Key_Escape) { + if (ui->messageWidget->isVisible()) { + m_hideInlineMessageTimer.stop(); + ui->messageWidget->animatedHide(); + ui->messageWidget->removeAction(m_openUrlAction); + return; + } + } + + QDialog::keyPressEvent(event); +} + +void SettingsDialog::keyReleaseEvent(QKeyEvent *event) +{ + if (event && event->key() == Qt::Key_Delete && currentPage() == Types::LayoutPage){ + on_removeButton_clicked(); + } + + QDialog::keyReleaseEvent(event); +} + void SettingsDialog::updateWindowActivities() { if (KWindowSystem::isPlatformX11()) { diff --git a/app/settings/settingsdialog.h b/app/settings/settingsdialog.h index 1efb1ee33..c35bd5a88 100644 --- a/app/settings/settingsdialog.h +++ b/app/settings/settingsdialog.h @@ -65,6 +65,8 @@ public: SettingsDialog(QWidget *parent, Latte::Corona *corona); ~SettingsDialog(); + Types::LatteConfigPage currentPage(); + void toggleCurrentPage(); void setCurrentPage(int page); @@ -73,6 +75,10 @@ public: void showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval = 0); +protected: + void keyPressEvent(QKeyEvent *event) override; + void keyReleaseEvent(QKeyEvent *event) override; + private slots: // auto connections void on_newButton_clicked(); diff --git a/app/settings/settingsdialog.ui b/app/settings/settingsdialog.ui index b1b854a40..05e0832fa 100644 --- a/app/settings/settingsdialog.ui +++ b/app/settings/settingsdialog.ui @@ -7,7 +7,7 @@ 0 0 941 - 703 + 727 @@ -113,6 +113,9 @@ false + + true + true @@ -123,7 +126,7 @@ false - false + true false