From c02b5ab6b7d17a194d70711261e15350048b72a2 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 3 May 2021 20:05:13 +0300 Subject: [PATCH] settingsdialog:simplify import layout messages --- .../settingsdialog/tablayoutshandler.cpp | 40 ++----------------- .../settingsdialog/tablayoutshandler.h | 8 ---- 2 files changed, 4 insertions(+), 44 deletions(-) diff --git a/app/settings/settingsdialog/tablayoutshandler.cpp b/app/settings/settingsdialog/tablayoutshandler.cpp index 5e0e59cca..8db8c35cf 100644 --- a/app/settings/settingsdialog/tablayoutshandler.cpp +++ b/app/settings/settingsdialog/tablayoutshandler.cpp @@ -466,40 +466,6 @@ void TabLayouts::duplicateLayout() m_layoutsController->duplicateSelectedLayout(); } -void TabLayouts::installLayoutTemplate(Latte::Data::Layout importedLayout, QString templateFilePath, ImportedLayoutOrigin origin) -{ - QString layoutName = QFileInfo(templateFilePath).fileName(); - layoutName = layoutName.remove("layout.latte"); - - QString informationText = origin == ImportedLayoutOrigin::DOWNLOADED ? i18nc("settings:layout downloaded successfully","Layout %0 downloaded successfully...").arg(importedLayout.name) : - i18nc("settings:layout imported successfully","Layout %0 imported successfully...").arg(importedLayout.name); - - informationText += "
"; - - if (m_corona->templatesManager()->hasCustomLayoutTemplate(layoutName)) { - informationText += i18nc("settings:layout import template", "Would you like to update your %0 layout template?").arg(layoutName); - } else { - informationText += i18nc("settings:layout import template", "Would you like to add %0 in your layout templates?").arg(layoutName); - } - - QAction *yesAction = new QAction(i18n("Yes"), this); - yesAction->setIcon(QIcon::fromTheme("dialog-yes")); - QAction *noAction = new QAction(i18n("No"), this); - noAction->setIcon(QIcon::fromTheme("dialog-no")); - QList actions; - actions << yesAction; - actions << noAction; - - connect(yesAction, &QAction::triggered, this, [&, templateFilePath]() { - m_corona->templatesManager()->installCustomLayoutTemplate(templateFilePath); - }); - - showInlineMessage(informationText, - KMessageWidget::Positive, - true, - actions); -} - void TabLayouts::downloadLayout() { qDebug() << Q_FUNC_INFO; @@ -519,7 +485,8 @@ void TabLayouts::downloadLayout() if (version == Latte::Layouts::Importer::LayoutVersion2) { Latte::Data::Layout downloaded = m_layoutsController->addLayoutForFile(entryFile); - installLayoutTemplate(downloaded, entryFile, DOWNLOADED); + showInlineMessage(i18nc("settings:layout downloaded successfully","Layout %0 downloaded successfully...").arg(downloaded.name), + KMessageWidget::Positive); break; } } @@ -602,7 +569,8 @@ void TabLayouts::importLayout() if (version == Latte::Layouts::Importer::LayoutVersion2) { Latte::Data::Layout importedlayout = m_layoutsController->addLayoutForFile(file); - installLayoutTemplate(importedlayout, file, LOCALLY); + showInlineMessage(i18nc("settings:layout imported successfully","Layout %0 imported successfully...").arg(importedlayout.name), + KMessageWidget::Positive); } else if (version == Latte::Layouts::Importer::ConfigVersion1) { if (!m_layoutsController->importLayoutsFromV1ConfigFile(file)) { showInlineMessage(i18nc("settings:deprecated layouts import failed","Import layouts from deprecated version failed..."), diff --git a/app/settings/settingsdialog/tablayoutshandler.h b/app/settings/settingsdialog/tablayoutshandler.h index 4a0559ef8..efbbc7cdc 100644 --- a/app/settings/settingsdialog/tablayoutshandler.h +++ b/app/settings/settingsdialog/tablayoutshandler.h @@ -67,12 +67,6 @@ public: TabLayouts(Dialog::SettingsDialog *parent); ~TabLayouts(); - enum ImportedLayoutOrigin - { - LOCALLY = 0, - DOWNLOADED - }; - bool hasChangedData() const override; bool inDefaultValues() const override; bool isCurrentTab() const; @@ -131,8 +125,6 @@ private: void initImportLayoutSubMenu(); void initExportLayoutSubMenu(); - void installLayoutTemplate(Latte::Data::Layout importedLayout, QString templateFilePath, ImportedLayoutOrigin origin); - private: Settings::Dialog::SettingsDialog *m_parentDialog{nullptr}; Ui::SettingsDialog *m_ui{nullptr};