diff --git a/app/layouts/storage.cpp b/app/layouts/storage.cpp index a71678d7a..a41cdef88 100644 --- a/app/layouts/storage.cpp +++ b/app/layouts/storage.cpp @@ -265,7 +265,7 @@ void Storage::importToCorona(const Layout::GenericLayout *layout) current_containments.copyTo(©Group); - copyGroup.sync(); + newFile->reparseConfiguration(); //! update ids to unique ones QString temp2File = newUniqueIdsFile(temp1FilePath, layout); @@ -539,7 +539,7 @@ QString Storage::newUniqueIdsFile(QString originFile, const Layout::GenericLayou } } - fixedNewContainmets.sync(); + file2Ptr->reparseConfiguration(); return tempFile; } @@ -572,7 +572,7 @@ void Storage::syncToLayoutFile(const Layout::GenericLayout *layout, bool removeL newGroup.sync(); } - oldContainments.sync(); + filePtr->reparseConfiguration(); } QList Storage::importLayoutFile(const Layout::GenericLayout *layout, QString file) @@ -653,6 +653,8 @@ Data::View Storage::newView(const Layout::GenericLayout *destinationLayout, cons break; } } + + lFile->reparseConfiguration(); } Data::ViewsTable updatedNextViews = views(temp2File); @@ -740,7 +742,7 @@ bool Storage::exportTemplate(const QString &originFile, const QString &destinati KConfigGroup layoutSettingsGrp(destFilePtr, "LayoutSettings"); clearExportedLayoutSettings(layoutSettingsGrp); - containments.sync(); + destFilePtr->reparseConfiguration(); return true; } @@ -834,7 +836,7 @@ bool Storage::exportTemplate(const Layout::GenericLayout *layout, Plasma::Contai KConfigGroup layoutSettingsGrp(destFilePtr, "LayoutSettings"); clearExportedLayoutSettings(layoutSettingsGrp); - copied_conts.sync(); + destFilePtr->reparseConfiguration(); return true; } @@ -1603,7 +1605,7 @@ void Storage::removeContainment(const QString &filepath, const QString &containm } containmentGroups.group(containmentId).deleteGroup(); - containmentGroups.sync(); + lFile->reparseConfiguration(); } QString Storage::storedView(const Layout::GenericLayout *layout, const int &containmentId) @@ -1677,7 +1679,7 @@ QString Storage::storedView(const Layout::GenericLayout *layout, const int &cont } } - destinationContainments.sync(); + destinationPtr->reparseConfiguration(); return nextTmpStoredViewAbsolutePath; } diff --git a/app/settings/settingsdialog/layoutscontroller.cpp b/app/settings/settingsdialog/layoutscontroller.cpp index c96a12b8e..363d295dd 100644 --- a/app/settings/settingsdialog/layoutscontroller.cpp +++ b/app/settings/settingsdialog/layoutscontroller.cpp @@ -654,6 +654,18 @@ void Layouts::onLayoutAddedExternally(const Data::Layout &layout) m_model->appendOriginalLayout(layout); } +void Layouts::setLayoutCurrentErrorsWarnings(const QString &layoutCurrentId, const int &errors, const int &warnings) +{ + Latte::Data::Layout layout = m_model->currentData(layoutCurrentId); + + if (!layout.isNull()) { + layout.errors = errors; + layout.warnings = warnings; + setLayoutProperties(layout); + } + +} + void Layouts::sortByColumn(int column, Qt::SortOrder order) { m_view->sortByColumn(column, order); diff --git a/app/settings/settingsdialog/layoutscontroller.h b/app/settings/settingsdialog/layoutscontroller.h index 97cb429d8..8fccad888 100644 --- a/app/settings/settingsdialog/layoutscontroller.h +++ b/app/settings/settingsdialog/layoutscontroller.h @@ -104,6 +104,7 @@ public: void setOriginalLayoutForFreeActivities(const QString &id); void setOriginalInMultipleMode(const bool &inmultiple); + void setLayoutCurrentErrorsWarnings(const QString &layoutCurrentId, const int &errors, const int &warnings); void duplicateSelectedLayout(); const Latte::Data::Layout addLayoutForFile(QString file, QString layoutName = QString(), bool newTempDirectory = true); diff --git a/app/settings/viewsdialog/viewscontroller.cpp b/app/settings/viewsdialog/viewscontroller.cpp index 830e6f0c0..8c2460634 100644 --- a/app/settings/viewsdialog/viewscontroller.cpp +++ b/app/settings/viewsdialog/viewscontroller.cpp @@ -47,9 +47,9 @@ #include #if KF5_VERSION_MINOR >= 71 - #include +#include #else - #include +#include #endif namespace Latte { @@ -406,11 +406,7 @@ void Views::onCurrentLayoutChanged() QObject::disconnect(var); } - Data::Layout originlayoutdata = m_handler->layoutsController()->originalData(currentlayoutdata.id); - auto activelayout = m_handler->layoutsController()->isLayoutOriginal(currentlayoutdata.id) ? - m_handler->corona()->layoutsManager()->synchronizer()->centralLayout(originlayoutdata.name) : nullptr; - - Latte::CentralLayout *currentlayout = activelayout ? activelayout : new Latte::CentralLayout(this, currentlayoutdata.id); + Latte::CentralLayout *currentlayout = centralLayout(currentlayoutdata); if (currentlayout && currentlayout->isActive()) { m_currentLayoutConnections << connect(currentlayout, &Layout::GenericLayout::viewsCountChanged, this, [&, currentlayout](){ @@ -421,6 +417,17 @@ void Views::onCurrentLayoutChanged() messagesForErrorsWarnings(currentlayout); } +CentralLayout *Views::centralLayout(const Data::Layout ¤tLayout) +{ + Data::Layout originlayoutdata = m_handler->layoutsController()->originalData(currentLayout.id); + auto activelayout = m_handler->layoutsController()->isLayoutOriginal(currentLayout.id) ? + m_handler->corona()->layoutsManager()->synchronizer()->centralLayout(originlayoutdata.name) : nullptr; + + Latte::CentralLayout *centrallayout = activelayout ? activelayout : new Latte::CentralLayout(this, currentLayout.id); + + return centrallayout; +} + void Views::onSelectionsChanged() { bool hasselectedview = hasSelectedView(); @@ -498,7 +505,7 @@ void Views::updateDoubledMoveDestinationRows() { } } -void Views::messagesForErrorsWarnings(const Latte::CentralLayout *centralLayout) +void Views::messagesForErrorsWarnings(const Latte::CentralLayout *centralLayout, const bool &showNoErrorsMessage) { if (!centralLayout) { return; @@ -580,6 +587,14 @@ void Views::messagesForErrorsWarnings(const Latte::CentralLayout *centralLayout) } } + m_handler->layoutsController()->setLayoutCurrentErrorsWarnings(currentdata.id, currentdata.errors, currentdata.warnings); + + if (showNoErrorsMessage && currentdata.errors == 0 && currentdata.warnings == 0) { + m_handler->showInlineMessage(i18n("Really nice! You are good to go, your layout does not report any errors or warnings."), + KMessageWidget::Positive, + false); + } + } void Views::showDefaultPersistentErrorWarningInlineMessage(const QString &messageText, @@ -610,6 +625,7 @@ void Views::showDefaultPersistentErrorWarningInlineMessage(const QString &messag #else KRun::runUrl(QUrl::fromLocalFile(file), QStringLiteral("text/plain"), m_view); #endif + showDefaultInlineMessageValidator(); } }); } @@ -621,6 +637,32 @@ void Views::showDefaultPersistentErrorWarningInlineMessage(const QString &messag actions); } +void Views::showDefaultInlineMessageValidator() +{ + Data::Layout currentlayout = m_handler->currentData(); + + //! add default action to open layout + QAction *validateaction = new QAction(i18n("Validate"), this); + validateaction->setIcon(QIcon::fromTheme("view-refresh")); + validateaction->setData(currentlayout.id); + + QList actions; + actions << validateaction; + + connect(validateaction, &QAction::triggered, this, [&, currentlayout]() { + auto centrallayout = centralLayout(currentlayout); + messagesForErrorsWarnings(centrallayout, true); + }); + + QString messagetext = i18n("After you have made your layout file changes, please click Validate to confirm them."); + + //! show message + m_handler->showInlineMessage(messagetext, + KMessageWidget::Warning, + true, + actions); +} + void Views::messageForErrorAppletsWithSameId(const Data::Error &error) { if (error.id != Data::Error::APPLETSWITHSAMEID) { @@ -758,6 +800,8 @@ void Views::messageForWarningOrphanedSubContainments(const Data::Warning &warnin return; } + QList orphaned; + //! construct message QString message = i18nc("warning id and title", "Warning #%0: %1

").arg(warning.id).arg(warning.name); message += i18n("In your layout there are orphaned subcontainments that are not used by any dock or panel. Such situation is not dangerous but it is advised to remove them in order to reduce memory usage.
"); @@ -774,6 +818,8 @@ void Views::messageForWarningOrphanedSubContainments(const Data::Warning &warnin QString containmentstorageid = warning.information[i].containment.storageId; message += i18nc("orphaned subcontainments, containment name, containment id", "  • %0 [#%1]
").arg(containmentname).arg(containmentstorageid); + + orphaned << warning.information[i].containment.storageId.toInt(); } message += "
"; @@ -781,14 +827,28 @@ void Views::messageForWarningOrphanedSubContainments(const Data::Warning &warnin message += i18n("  1. Click Repair button in order to remove orphaned subcontainments
"); message += i18n("  2. Remove manually orphaned subcontainments when the layout is not active
"); - //! add extra action + //! add extra repair action QAction *repairlayoutaction = new QAction(i18n("Repair"), this); repairlayoutaction->setIcon(QIcon::fromTheme("dialog-yes")); - repairlayoutaction->setEnabled(false); QList extraactions; extraactions << repairlayoutaction; - showDefaultPersistentErrorWarningInlineMessage(message, KMessageWidget::Warning, extraactions); + Latte::Data::Layout currentlayout = m_handler->currentData(); + + connect(repairlayoutaction, &QAction::triggered, this, [&, currentlayout, orphaned]() { + auto centrallayout = centralLayout(currentlayout); + + for (int i=0; iremoveOrphanedSubContainment(orphaned[i]); + } + + messagesForErrorsWarnings(centrallayout, true); + }); + + //! show message + showDefaultPersistentErrorWarningInlineMessage(message, + KMessageWidget::Warning, + extraactions); } void Views::save() diff --git a/app/settings/viewsdialog/viewscontroller.h b/app/settings/viewsdialog/viewscontroller.h index 966bf8b8a..dc6172052 100644 --- a/app/settings/viewsdialog/viewscontroller.h +++ b/app/settings/viewsdialog/viewscontroller.h @@ -103,6 +103,7 @@ private: bool hasValidOriginView(const Data::View &view); CentralLayout *originLayout(const Data::View &view); + CentralLayout *centralLayout(const Data::Layout ¤tLayout); int rowForId(QString id) const; QString uniqueViewName(QString name); @@ -111,12 +112,19 @@ private: Data::ViewsTable selectedViewsForClipboard(); //! errors/warnings - void messagesForErrorsWarnings(const Latte::CentralLayout *centralLayout); + void messagesForErrorsWarnings(const Latte::CentralLayout *centralLayout, const bool &showNoErrorsMessage = false); void messageForErrorAppletsWithSameId(const Data::Error &error); void messageForErrorOrphanedParentAppletOfSubContainment(const Data::Error &error); void messageForWarningOrphanedSubContainments(const Data::Warning &warning); void messageForWarningAppletAndContainmentWithSameId(const Data::Warning &warning); + void showDefaultInlineMessageValidator(); + void showDefaultPersistentErrorWarningInlineMessage(const QString &messageText, + const KMessageWidget::MessageType &messageType, + QList extraActions = QList(), + const bool &showOpenLayoutAction = true); + + private slots: void loadConfig(); void saveConfig(); @@ -126,11 +134,6 @@ private slots: void onCurrentLayoutChanged(); void onSelectionsChanged(); - void showDefaultPersistentErrorWarningInlineMessage(const QString &messageText, - const KMessageWidget::MessageType &messageType, - QList extraActions = QList(), - const bool &showOpenLayoutAction = true); - void updateDoubledMoveDestinationRows(); private: