1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 13:33:50 +03:00

settings:same infrastructure for information

--add GenericDialog class in order to provide
same implementation for all settings::dialogs.
As a first step GenericDialog provides a common
showInlineMessage api
This commit is contained in:
Michail Vourlakos 2020-04-14 21:47:52 +03:00
parent 3447e44f25
commit 0e7420037e
20 changed files with 288 additions and 183 deletions

View File

@ -486,10 +486,12 @@ void Layouts::loadLayouts()
if (brokenLayouts.count() > 0) {
if (brokenLayouts.count() == 1) {
m_handler->showInlineMessage(i18nc("settings:broken layout", "Layout <b>%0</b> <i>is broken</i>! Please <b>remove</b> to improve stability...").arg(brokenLayouts.join(",")),
KMessageWidget::Error);
KMessageWidget::Error,
true);
} else {
m_handler->showInlineMessage(i18nc("settings:broken layouts", "Layouts <b>%0</b> <i>are broken</i>! Please <b>remove</b> to improve stability...").arg(brokenLayouts.join(",")),
KMessageWidget::Error);
KMessageWidget::Error,
true);
}
}
}
@ -628,12 +630,10 @@ bool Layouts::importLayoutsFromV1ConfigFile(QString file)
if (importedlayouts.count() > 0) {
if (importedlayouts.count() == 1) {
m_handler->showInlineMessage(i18n("Layout <b>%0</b> imported successfully...").arg(importedlayouts[0]),
KMessageWidget::Information,
Settings::Dialog::INFORMATIONINTERVAL);
KMessageWidget::Information);
} else {
m_handler->showInlineMessage(i18n("Layouts <b>%0</b> imported successfully...").arg(importedlayouts.join(",")),
KMessageWidget::Information,
Settings::Dialog::INFORMATIONINTERVAL);
KMessageWidget::Information);
}
return true;
@ -921,8 +921,7 @@ void Layouts::on_nameDuplicatedFrom(const QString &provenId, const QString &tria
Data::Layout provenLayout = m_model->at(originalRow);
m_handler->showInlineMessage(i18nc("settings: layout name used","Layout <b>%0</b> is already used, please provide a different name...").arg(provenLayout.name),
KMessageWidget::Error,
Settings::Dialog::ERRORINTERVAL);
KMessageWidget::Error);
QModelIndex tIndex = m_proxyModel->index(tRow, Model::Layouts::NAMECOLUMN);

View File

@ -1,6 +1,7 @@
set(lattedock-app_SRCS
${lattedock-app_SRCS}
${CMAKE_CURRENT_SOURCE_DIR}/detailsdialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/genericdialog.cpp
${CMAKE_CURRENT_SOURCE_DIR}/settingsdialog.cpp
PARENT_SCOPE
)

View File

@ -31,7 +31,7 @@ namespace Settings {
namespace Dialog {
DetailsDialog::DetailsDialog(SettingsDialog *parent, Controller::Layouts *controller)
: QDialog(parent),
: GenericDialog(parent),
m_parentDlg(parent),
m_ui(new Ui::DetailsDialog),
m_layoutsController(controller)
@ -40,8 +40,6 @@ DetailsDialog::DetailsDialog(SettingsDialog *parent, Controller::Layouts *contro
m_ui->setupUi(this);
//! we must create handlers after creating/adjusting the ui
m_handler = new Handler::DetailsHandler(this);
m_ui->messageWidget->setVisible(false);
}
DetailsDialog::~DetailsDialog()

View File

@ -22,6 +22,7 @@
#define DETAILSDIALOG_H
// local
#include "genericdialog.h"
#include "settingsdialog.h"
// Qt
@ -47,7 +48,7 @@ namespace Latte {
namespace Settings {
namespace Dialog {
class DetailsDialog : public QDialog
class DetailsDialog : public GenericDialog
{
Q_OBJECT

View File

@ -15,7 +15,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="optionsLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -377,9 +377,6 @@
</property>
</spacer>
</item>
<item>
<widget class="KMessageWidget" name="messageWidget"/>
</item>
<item>
<widget class="QDialogButtonBox" name="mainButtonBox">
<property name="orientation">
@ -393,11 +390,6 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KMessageWidget</class>
<extends>QFrame</extends>
<header>kmessagewidget.h</header>
</customwidget>
<customwidget>
<class>Latte::Settings::Widget::PatternWidget</class>
<extends>QWidget</extends>

View File

@ -0,0 +1,156 @@
/*
* Copyright 2020 Michail Vourlakos <mvourlakos@gmail.com>
*
* This file is part of Latte-Dock
*
* Latte-Dock is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Latte-Dock is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "genericdialog.h"
// Qt
#include <QKeyEvent>
#include <QVBoxLayout>
static const int ERRORINTERVAL = 4000;
static const int INFORMATIONINTERVAL = 3000;
static const int INFORMATIONWITHACTIONINTERVAL = 5000;
static const int POSITIVEINTERVAL = 3000;
static const int WARNINGINTERVAL = 3500;
namespace Latte {
namespace Settings {
namespace Dialog {
GenericDialog::GenericDialog(QWidget *parent, Qt::WindowFlags f)
: QDialog(parent, f)
{
m_hideInlineMessageTimer.setSingleShot(true);
m_hideInlineMessageTimer.setInterval(2000);
}
GenericDialog::~GenericDialog()
{
}
void GenericDialog::initMessageWidget()
{
if (m_messageWidget) {
return;
}
QVBoxLayout *vLayout = qobject_cast<QVBoxLayout *>(layout());
if (!vLayout) {
return;
}
m_messageWidget = new KMessageWidget(this);
vLayout->insertWidget(vLayout->count()-1, m_messageWidget);
connect(&m_hideInlineMessageTimer, &QTimer::timeout, this, [&]() {
m_messageWidget->animatedHide();
});
connect(m_messageWidget, &KMessageWidget::hideAnimationFinished, this, [&]() {
clearCurrentMessageActions();
});
}
void GenericDialog::keyPressEvent(QKeyEvent *event)
{
if (event && event->key() == Qt::Key_Escape) {
if (m_messageWidget->isVisible()) {
m_hideInlineMessageTimer.stop();
m_messageWidget->animatedHide();
clearCurrentMessageActions();
return;
}
}
QDialog::keyPressEvent(event);
}
void GenericDialog::clearCurrentMessageActions()
{
while(m_currentMessageActions.count() > 0) {
QAction *action = m_currentMessageActions.takeAt(0);
m_messageWidget->removeAction(action);
action->deleteLater();
}
}
void GenericDialog::showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const bool &isPersistent, QList<QAction *> actions)
{
if (msg.isEmpty()) {
return;
}
if (!m_messageWidget) {
initMessageWidget();
}
int hideInterval = 0;
if (!isPersistent) {
if (type == KMessageWidget::Error) {
hideInterval = ERRORINTERVAL;
} else if (type == KMessageWidget::Warning) {
hideInterval = WARNINGINTERVAL;
} else if (type == KMessageWidget::Information) {
hideInterval = (actions.count() == 0 ? INFORMATIONINTERVAL : INFORMATIONWITHACTIONINTERVAL);
} else if (type == KMessageWidget::Positive) {
}
}
if (!m_currentMessageActions.isEmpty()) {
clearCurrentMessageActions();
}
m_currentMessageActions = actions;
for (int i=0; i<actions.count(); ++i) {
m_messageWidget->addAction(actions[i]);
}
m_hideInlineMessageTimer.stop();
if (m_messageWidget->isVisible()) {
m_messageWidget->animatedHide();
}
m_messageWidget->setText(msg);
// TODO: wrap at arbitrary character positions once QLabel can do this
// https://bugreports.qt.io/browse/QTBUG-1276
m_messageWidget->setWordWrap(true);
m_messageWidget->setMessageType(type);
m_messageWidget->setWordWrap(false);
const int unwrappedWidth = m_messageWidget->sizeHint().width();
m_messageWidget->setWordWrap(unwrappedWidth > size().width());
m_messageWidget->animatedShow();
if (hideInterval > 0) {
m_hideInlineMessageTimer.setInterval(hideInterval);
m_hideInlineMessageTimer.start();
}
}
}
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright 2020 Michail Vourlakos <mvourlakos@gmail.com>
*
* This file is part of Latte-Dock
*
* Latte-Dock is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Latte-Dock is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef SETTINGSGENERICDIALOG_H
#define SETTINGSGENERICDIALOG_H
// Qt
#include <QAction>
#include <QDialog>
#include <QObject>
#include <QTimer>
#include <QWidget>
// KDE
#include <KMessageWidget>
namespace Latte {
namespace Settings {
namespace Dialog {
class GenericDialog : public QDialog
{
Q_OBJECT
public:
GenericDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~GenericDialog();
void showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const bool &isPersistent = false, QList<QAction *> actions = QList<QAction *>());
protected:
void keyPressEvent(QKeyEvent *event) override;
private slots:
void initMessageWidget();
private:
void clearCurrentMessageActions();
private:
KMessageWidget *m_messageWidget{nullptr};
//! Current shown KMessageActions
QList<QAction *> m_currentMessageActions;
//! Timer to hide the inline message widget
QTimer m_hideInlineMessageTimer;
};
}
}
}
#endif

View File

@ -59,7 +59,7 @@ namespace Settings {
namespace Dialog {
SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
: QDialog(parent),
: GenericDialog(parent),
m_ui(new Ui::SettingsDialog),
m_corona(corona),
m_storage(KConfigGroup(KSharedConfig::openConfig(),"LatteSettingsDialog"))
@ -92,8 +92,6 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
loadConfig();
resize(m_windowSize);
m_ui->messageWidget->setVisible(false);
m_ui->buttonBox->button(QDialogButtonBox::Apply)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
m_ui->buttonBox->button(QDialogButtonBox::Reset)->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
@ -119,16 +117,6 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
connect(&m_activitiesTimer, &QTimer::timeout, this, &SettingsDialog::updateWindowActivities);
m_activitiesTimer.start();
m_hideInlineMessageTimer.setSingleShot(true);
m_hideInlineMessageTimer.setInterval(2000);
connect(&m_hideInlineMessageTimer, &QTimer::timeout, this, [&]() {
m_ui->messageWidget->animatedHide();
});
connect(m_ui->messageWidget, &KMessageWidget::hideAnimationFinished, this, [&]() {
clearCurrentMessageActions();
});
updateApplyButtonsState();
}
@ -367,7 +355,7 @@ void SettingsDialog::on_export_fullconfiguration()
connect(exportFileDialog, &QFileDialog::fileSelected, this, [&](const QString & file) {
auto showExportConfigurationError = [this]() {
showInlineMessage(i18n("Full configuration export <b>failed</b>..."), KMessageWidget::Error);
showInlineMessage(i18n("Full configuration export <b>failed</b>..."), KMessageWidget::Error, true);
};
if (m_corona->layoutsManager()->importer()->exportFullConfiguration(file)) {
@ -386,7 +374,7 @@ void SettingsDialog::on_export_fullconfiguration()
showInlineMessage(i18n("Full configuration export succeeded..."),
KMessageWidget::Information,
Settings::Dialog::INFORMATIONWITHACTIONINTERVAL,
false,
actions);
} else {
showExportConfigurationError();
@ -666,20 +654,6 @@ void SettingsDialog::dropEvent(QDropEvent *event)
}
}
void SettingsDialog::keyPressEvent(QKeyEvent *event)
{
if (event && event->key() == Qt::Key_Escape) {
if (m_ui->messageWidget->isVisible()) {
m_hideInlineMessageTimer.stop();
m_ui->messageWidget->animatedHide();
clearCurrentMessageActions();
return;
}
}
QDialog::keyPressEvent(event);
}
void SettingsDialog::keyReleaseEvent(QKeyEvent *event)
{
if (event && currentPage() == Types::LayoutPage){
@ -707,56 +681,6 @@ void SettingsDialog::save()
}
}
void SettingsDialog::clearCurrentMessageActions()
{
while(m_currentMessageActions.count() > 0) {
QAction *action = m_currentMessageActions.takeAt(0);
m_ui->messageWidget->removeAction(action);
action->deleteLater();
}
}
void SettingsDialog::showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval, QList<QAction *> actions)
{
if (msg.isEmpty()) {
return;
}
if (!m_currentMessageActions.isEmpty()) {
clearCurrentMessageActions();
}
m_currentMessageActions = actions;
for (int i=0; i<actions.count(); ++i) {
m_ui->messageWidget->addAction(actions[i]);
}
m_hideInlineMessageTimer.stop();
if (m_ui->messageWidget->isVisible()) {
m_ui->messageWidget->animatedHide();
}
m_ui->messageWidget->setText(msg);
// TODO: wrap at arbitrary character positions once QLabel can do this
// https://bugreports.qt.io/browse/QTBUG-1276
m_ui->messageWidget->setWordWrap(true);
m_ui->messageWidget->setMessageType(type);
m_ui->messageWidget->setWordWrap(false);
const int unwrappedWidth = m_ui->messageWidget->sizeHint().width();
m_ui->messageWidget->setWordWrap(unwrappedWidth > size().width());
m_ui->messageWidget->animatedShow();
if (hideInterval > 0) {
m_hideInlineMessageTimer.setInterval(hideInterval);
m_hideInlineMessageTimer.start();
}
}
void SettingsDialog::loadConfig()
{
//! remove old unneeded oprtions

View File

@ -23,6 +23,7 @@
#define SETTINGSDIALOG_H
// local
#include "genericdialog.h"
#include "../liblatte2/types.h"
#include "../controllers/layoutscontroller.h"
#include "../handlers/tablayoutshandler.h"
@ -39,7 +40,6 @@
// KDE
#include <KHelpMenu>
#include <KMessageWidget>
namespace Ui {
class SettingsDialog;
@ -58,12 +58,7 @@ namespace Latte {
namespace Settings {
namespace Dialog {
static const int INFORMATIONINTERVAL = 3000;
static const int INFORMATIONWITHACTIONINTERVAL = 5000;
static const int WARNINGINTERVAL = 3500;
static const int ERRORINTERVAL = 4000;
class SettingsDialog : public QDialog
class SettingsDialog : public GenericDialog
{
Q_OBJECT
public:
@ -89,14 +84,11 @@ public:
void requestImagesDialog(int row);
void requestColorsDialog(int row);
void showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval = 0, QList<QAction *> actions = QList<QAction *>());
protected:
void dragEnterEvent(QDragEnterEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void dropEvent(QDropEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void keyReleaseEvent(QKeyEvent *event) override;
private slots:
@ -112,9 +104,7 @@ private slots:
void showLayoutInformation();
void showScreensInformation();
void updateApplyButtonsState();
void updateWindowActivities();
void clearCurrentMessageActions();
void updateWindowActivities();
void loadConfig();
void saveConfig();
@ -163,18 +153,12 @@ private:
//! Help menu actions
KHelpMenu *m_helpMenu{nullptr};
//! Current shown KMessageActions
QList<QAction *> m_currentMessageActions;
//! storage
KConfigGroup m_deprecatedStorage;
KConfigGroup m_storage;
//! workaround to assign ALLACTIVITIES during startup
QTimer m_activitiesTimer;
//! Timer to hide the inline message widget
QTimer m_hideInlineMessageTimer;
};
}

View File

@ -1091,9 +1091,6 @@ This tracker is used in order to not lose any screen related update.</string>
</widget>
</widget>
</item>
<item>
<widget class="KMessageWidget" name="messageWidget"/>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
@ -1107,11 +1104,6 @@ This tracker is used in order to not lose any screen related update.</string>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KMessageWidget</class>
<extends>QFrame</extends>
<header>kmessagewidget.h</header>
</customwidget>
<customwidget>
<class>Latte::Settings::View::LayoutsTableView</class>
<extends>QTableView</extends>

View File

@ -31,7 +31,7 @@ DetailsHandler::DetailsHandler(Dialog::DetailsDialog *parentDialog)
: Generic(parentDialog),
m_parentDialog(parentDialog),
m_ui(m_parentDialog->ui()),
m_infoHandler(new DetailsInfoHandler(this, parentDialog))
m_infoHandler(new DetailsInfoHandler(parentDialog))
{
}
@ -64,10 +64,6 @@ void DetailsHandler::save()
{
}
void DetailsHandler::showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval, QList<QAction *> actions)
{
}
}
}
}

View File

@ -60,8 +60,6 @@ public:
void resetDefaults() override;
void save() override;
void showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval = 0, QList<QAction *> actions = QList<QAction *>()) override;
private:
Dialog::DetailsDialog *m_parentDialog{nullptr};
Ui::DetailsDialog *m_ui{nullptr};

View File

@ -30,8 +30,8 @@ namespace Latte {
namespace Settings {
namespace Handler {
DetailsInfoHandler::DetailsInfoHandler(QObject *parent, Dialog::DetailsDialog *parentDialog)
: Generic(parent),
DetailsInfoHandler::DetailsInfoHandler(Dialog::DetailsDialog *parentDialog)
: Generic(parentDialog),
m_parentDialog(parentDialog),
m_ui(m_parentDialog->ui())
{
@ -85,10 +85,6 @@ void DetailsInfoHandler::save()
{
}
void DetailsInfoHandler::showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval, QList<QAction *> actions)
{
}
}
}
}

View File

@ -51,7 +51,7 @@ class DetailsInfoHandler : public Generic
{
Q_OBJECT
public:
DetailsInfoHandler(QObject *parent, Dialog::DetailsDialog *parentDialog);
DetailsInfoHandler(Dialog::DetailsDialog *parentDialog);
~DetailsInfoHandler();
bool dataAreChanged() const override;
@ -61,8 +61,6 @@ public:
void resetDefaults() override;
void save() override;
void showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval = 0, QList<QAction *> actions = QList<QAction *>()) override;
private slots:
void init();

View File

@ -20,14 +20,16 @@
#include "generichandler.h"
// local
#include "../dialogs/genericdialog.h"
namespace Latte {
namespace Settings {
namespace Handler {
Generic::Generic(QObject *parent)
: QObject(parent)
Generic::Generic(Dialog::GenericDialog *parent)
: QObject(parent),
m_dialog(parent)
{
}
@ -64,6 +66,11 @@ void Generic::connectActionWithButton(QPushButton *button, QAction *action)
connect(button, &QPushButton::clicked, action, &QAction::trigger);
}
void Generic::showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const bool &isPersistent, QList<QAction *> actions)
{
m_dialog->showInlineMessage(msg, type, isPersistent, actions);
}
}
}
}

View File

@ -29,6 +29,15 @@
// KDE
#include <KMessageWidget>
namespace Latte {
namespace Settings {
namespace Dialog {
class GenericDialog;
}
}
}
namespace Latte {
namespace Settings {
namespace Handler {
@ -45,7 +54,7 @@ public:
static constexpr const char* TWINVISIBLE = "Visible";
static constexpr const char* TWINCHECKED = "Checked";
Generic(QObject *parent);
Generic(Dialog::GenericDialog *parent);
virtual bool dataAreChanged() const = 0;
virtual bool inDefaultValues() const = 0;
@ -54,7 +63,7 @@ public:
virtual void resetDefaults() = 0;
virtual void save() = 0;
virtual void showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval = 0, QList<QAction *> actions = QList<QAction *>()) = 0;
void showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const bool &isPersistent = false, QList<QAction *> actions = QList<QAction *>());
signals:
void dataChanged();
@ -68,6 +77,7 @@ private:
//! for simplicity reasons
QHash<QAction *, QPushButton *> m_twinActions;
Dialog::GenericDialog *m_dialog;
};

View File

@ -236,11 +236,6 @@ void TabLayouts::resetDefaults()
//do nothing because there are no defaults
}
void TabLayouts::showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval, QList<QAction *> actions)
{
m_parentDialog->showInlineMessage(msg, type, hideInterval, actions);
}
void TabLayouts::save()
{
m_layoutsController->save();
@ -258,8 +253,7 @@ void TabLayouts::on_switch_layout()
if (m_layoutsController->dataAreChanged()) {
showInlineMessage(i18nc("settings:not permitted switching layout","You need to <b>apply</b> your changes first to switch layout..."),
KMessageWidget::Warning,
Settings::Dialog::WARNINGINTERVAL);
KMessageWidget::Warning);
return;
}
@ -394,8 +388,7 @@ void TabLayouts::on_new_layout()
if (presetName == "Default") {
Settings::Data::Layout newlayout = m_layoutsController->addLayoutForFile(preset, presetName, true);
showInlineMessage(i18nc("settings:layout added successfully","Layout <b>%0</b> added successfully...").arg(newlayout.name),
KMessageWidget::Information,
Settings::Dialog::INFORMATIONINTERVAL);
KMessageWidget::Information);
break;
}
}
@ -432,8 +425,7 @@ void TabLayouts::on_download_layout()
if (version == Latte::Layouts::Importer::LayoutVersion2) {
Settings::Data::Layout downloaded = m_layoutsController->addLayoutForFile(entryFile);
showInlineMessage(i18nc("settings:layout downloaded successfully","Layout <b>%0</b> downloaded successfully...").arg(downloaded.name),
KMessageWidget::Information,
Settings::Dialog::INFORMATIONINTERVAL);
KMessageWidget::Information);
break;
}
}
@ -459,15 +451,13 @@ void TabLayouts::on_remove_layout()
if (selectedLayout.isActive) {
showInlineMessage(i18nc("settings: active layout remove","<b>Active</b> layouts can not be removed..."),
KMessageWidget::Error,
Settings::Dialog::WARNINGINTERVAL);
KMessageWidget::Error);
return;
}
if (selectedLayout.isLocked) {
showInlineMessage(i18nc("settings: locked layout remove","Locked layouts can not be removed..."),
KMessageWidget::Error,
Settings::Dialog::WARNINGINTERVAL);
KMessageWidget::Error);
return;
}
@ -532,12 +522,12 @@ void TabLayouts::on_import_layout()
if (version == Latte::Layouts::Importer::LayoutVersion2) {
Settings::Data::Layout importedlayout = m_layoutsController->addLayoutForFile(file);
showInlineMessage(i18nc("settings:layout imported successfully","Layout <b>%0</b> imported successfully...").arg(importedlayout.name),
KMessageWidget::Information,
Settings::Dialog::INFORMATIONINTERVAL);
KMessageWidget::Information);
} else if (version == Latte::Layouts::Importer::ConfigVersion1) {
if (!m_layoutsController->importLayoutsFromV1ConfigFile(file)) {
showInlineMessage(i18nc("settings:deprecated layouts import failed","Import layouts from deprecated version <b>failed</b>..."),
KMessageWidget::Error);
KMessageWidget::Error,
true);
}
}
});
@ -581,7 +571,8 @@ void TabLayouts::on_export_layout()
connect(exportFileDialog, &QFileDialog::fileSelected, this, [ &, selectedLayout](const QString & file) {
auto showExportLayoutError = [this](const Settings::Data::Layout &layout) {
showInlineMessage(i18nc("settings:layout export fail","Layout <b>%0</b> export <b>failed</b>...").arg(layout.name),
KMessageWidget::Error);
KMessageWidget::Error,
true);
};
if (QFile::exists(file) && !QFile::remove(file)) {
@ -620,11 +611,11 @@ void TabLayouts::on_export_layout()
showInlineMessage(i18nc("settings:layout export success","Layout <b>%0</b> export succeeded...").arg(selectedLayout.name),
KMessageWidget::Information,
Settings::Dialog::INFORMATIONWITHACTIONINTERVAL,
false,
actions);
} else if (file.endsWith(".latterc")) {
auto showExportConfigurationError = [this]() {
showInlineMessage(i18n("Full configuration export <b>failed</b>..."), KMessageWidget::Error);
showInlineMessage(i18n("Full configuration export <b>failed</b>..."), KMessageWidget::Error, true);
};
if (m_corona->layoutsManager()->importer()->exportFullConfiguration(file)) {
@ -643,7 +634,7 @@ void TabLayouts::on_export_layout()
showInlineMessage(i18n("Full configuration export succeeded..."),
KMessageWidget::Information,
Settings::Dialog::INFORMATIONWITHACTIONINTERVAL,
false,
actions);
} else {
showExportConfigurationError();
@ -687,12 +678,10 @@ void TabLayouts::on_layoutFilesDropped(const QStringList &paths)
if (layoutNames.count() == 1) {
showInlineMessage(i18nc("settings:layout imported successfully","Layout <b>%0</b> imported successfully...").arg(layoutNames[0]),
KMessageWidget::Information,
Settings::Dialog::INFORMATIONINTERVAL);
KMessageWidget::Information);
} else if (layoutNames.count() > 1) {
showInlineMessage(i18nc("settings:layouts imported successfully","Layouts <b>%0</b> imported successfully...").arg(layoutNames.join(", )")),
KMessageWidget::Information,
Settings::Dialog::INFORMATIONINTERVAL);
KMessageWidget::Information);
}
}

View File

@ -77,8 +77,6 @@ public:
Dialog::SettingsDialog *dialog() const;
Ui::SettingsDialog *ui() const;
void showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval = 0, QList<QAction *> actions = QList<QAction *>()) override;
public slots:
void on_dragEnterEvent(QDragEnterEvent *event);
void on_dragLeaveEvent(QDragLeaveEvent *event);

View File

@ -164,11 +164,6 @@ void TabPreferences::resetDefaults()
updateUi();
}
void TabPreferences::showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval, QList<QAction *> actions)
{
m_parentDialog->showInlineMessage(msg, type, hideInterval, actions);
}
void TabPreferences::save()
{
m_corona->universalSettings()->setMouseSensitivity(m_preferences.mouseSensitivity);

View File

@ -65,8 +65,6 @@ public:
void resetDefaults() override;
void save() override;
void showInlineMessage(const QString &msg, const KMessageWidget::MessageType &type, const int &hideInterval = 0, QList<QAction *> actions = QList<QAction *>()) override;
signals:
void borderlessMaximizedChanged();