improve settings window Esc key handling

pull/11/head
Michail Vourlakos 5 years ago
parent b6b34b06de
commit 7a11aa93c0

@ -250,6 +250,13 @@ SettingsDialog::~SettingsDialog()
m_corona->universalSettings()->setLayoutsWindowSize(size());
}
Types::LatteConfigPage SettingsDialog::currentPage()
{
Types::LatteConfigPage cPage= static_cast<Types::LatteConfigPage>(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()) {

@ -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();

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>941</width>
<height>703</height>
<height>727</height>
</rect>
</property>
<property name="windowTitle">
@ -113,6 +113,9 @@
<property name="showGrid">
<bool>false</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderVisible">
<bool>true</bool>
</attribute>
@ -123,7 +126,7 @@
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>false</bool>
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>

Loading…
Cancel
Save