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

settingsdialog:simplify import layout messages

This commit is contained in:
Michail Vourlakos 2021-05-03 20:05:13 +03:00
parent 5e9c838239
commit c02b5ab6b7
2 changed files with 4 additions and 44 deletions

View File

@ -466,40 +466,6 @@ void TabLayouts::duplicateLayout()
m_layoutsController->duplicateSelectedLayout(); 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 <b>%0</b> downloaded successfully...").arg(importedLayout.name) :
i18nc("settings:layout imported successfully","Layout <b>%0</b> imported successfully...").arg(importedLayout.name);
informationText += "<br/>";
if (m_corona->templatesManager()->hasCustomLayoutTemplate(layoutName)) {
informationText += i18nc("settings:layout import template", "Would you like to update your <b>%0</b> layout template?").arg(layoutName);
} else {
informationText += i18nc("settings:layout import template", "Would you like to add <b>%0</b> 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<QAction *> 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() void TabLayouts::downloadLayout()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
@ -519,7 +485,8 @@ void TabLayouts::downloadLayout()
if (version == Latte::Layouts::Importer::LayoutVersion2) { if (version == Latte::Layouts::Importer::LayoutVersion2) {
Latte::Data::Layout downloaded = m_layoutsController->addLayoutForFile(entryFile); Latte::Data::Layout downloaded = m_layoutsController->addLayoutForFile(entryFile);
installLayoutTemplate(downloaded, entryFile, DOWNLOADED); showInlineMessage(i18nc("settings:layout downloaded successfully","Layout <b>%0</b> downloaded successfully...").arg(downloaded.name),
KMessageWidget::Positive);
break; break;
} }
} }
@ -602,7 +569,8 @@ void TabLayouts::importLayout()
if (version == Latte::Layouts::Importer::LayoutVersion2) { if (version == Latte::Layouts::Importer::LayoutVersion2) {
Latte::Data::Layout importedlayout = m_layoutsController->addLayoutForFile(file); Latte::Data::Layout importedlayout = m_layoutsController->addLayoutForFile(file);
installLayoutTemplate(importedlayout, file, LOCALLY); showInlineMessage(i18nc("settings:layout imported successfully","Layout <b>%0</b> imported successfully...").arg(importedlayout.name),
KMessageWidget::Positive);
} else if (version == Latte::Layouts::Importer::ConfigVersion1) { } else if (version == Latte::Layouts::Importer::ConfigVersion1) {
if (!m_layoutsController->importLayoutsFromV1ConfigFile(file)) { if (!m_layoutsController->importLayoutsFromV1ConfigFile(file)) {
showInlineMessage(i18nc("settings:deprecated layouts import failed","Import layouts from deprecated version <b>failed</b>..."), showInlineMessage(i18nc("settings:deprecated layouts import failed","Import layouts from deprecated version <b>failed</b>..."),

View File

@ -67,12 +67,6 @@ public:
TabLayouts(Dialog::SettingsDialog *parent); TabLayouts(Dialog::SettingsDialog *parent);
~TabLayouts(); ~TabLayouts();
enum ImportedLayoutOrigin
{
LOCALLY = 0,
DOWNLOADED
};
bool hasChangedData() const override; bool hasChangedData() const override;
bool inDefaultValues() const override; bool inDefaultValues() const override;
bool isCurrentTab() const; bool isCurrentTab() const;
@ -131,8 +125,6 @@ private:
void initImportLayoutSubMenu(); void initImportLayoutSubMenu();
void initExportLayoutSubMenu(); void initExportLayoutSubMenu();
void installLayoutTemplate(Latte::Data::Layout importedLayout, QString templateFilePath, ImportedLayoutOrigin origin);
private: private:
Settings::Dialog::SettingsDialog *m_parentDialog{nullptr}; Settings::Dialog::SettingsDialog *m_parentDialog{nullptr};
Ui::SettingsDialog *m_ui{nullptr}; Ui::SettingsDialog *m_ui{nullptr};