mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 13:33:50 +03:00
viewdialog:provide nice Repair for #W201
This commit is contained in:
parent
e9120d5507
commit
6234253342
@ -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<Plasma::Containment *> 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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -47,9 +47,9 @@
|
||||
#include <KMessageWidget>
|
||||
|
||||
#if KF5_VERSION_MINOR >= 71
|
||||
#include <KIO/OpenUrlJob>
|
||||
#include <KIO/OpenUrlJob>
|
||||
#else
|
||||
#include <KRun>
|
||||
#include <KRun>
|
||||
#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<QAction *> 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 <b>Validate</b> 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<int> orphaned;
|
||||
|
||||
//! construct message
|
||||
QString message = i18nc("warning id and title", "<b>Warning #%0: %1</b> <br/><br/>").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.<br/>");
|
||||
@ -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",
|
||||
" • <b>%0</b> [#%1] <br/>").arg(containmentname).arg(containmentstorageid);
|
||||
|
||||
orphaned << warning.information[i].containment.storageId.toInt();
|
||||
}
|
||||
|
||||
message += "<br/>";
|
||||
@ -781,14 +827,28 @@ void Views::messageForWarningOrphanedSubContainments(const Data::Warning &warnin
|
||||
message += i18n(" 1. Click <b>Repair</b> button in order to remove orphaned subcontainments<br/>");
|
||||
message += i18n(" 2. Remove manually orphaned subcontainments when the layout is <b>not active</b><br/>");
|
||||
|
||||
//! add extra action
|
||||
//! add extra repair action
|
||||
QAction *repairlayoutaction = new QAction(i18n("Repair"), this);
|
||||
repairlayoutaction->setIcon(QIcon::fromTheme("dialog-yes"));
|
||||
repairlayoutaction->setEnabled(false);
|
||||
QList<QAction *> 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; i<orphaned.count(); ++i) {
|
||||
centrallayout->removeOrphanedSubContainment(orphaned[i]);
|
||||
}
|
||||
|
||||
messagesForErrorsWarnings(centrallayout, true);
|
||||
});
|
||||
|
||||
//! show message
|
||||
showDefaultPersistentErrorWarningInlineMessage(message,
|
||||
KMessageWidget::Warning,
|
||||
extraactions);
|
||||
}
|
||||
|
||||
void Views::save()
|
||||
|
@ -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<QAction *> extraActions = QList<QAction *>(),
|
||||
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<QAction *> extraActions = QList<QAction *>(),
|
||||
const bool &showOpenLayoutAction = true);
|
||||
|
||||
void updateDoubledMoveDestinationRows();
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user