mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-27 06:03:51 +03:00
viewsdialog:provide nice message for error #103
This commit is contained in:
parent
ae76e82297
commit
866a4f462b
@ -100,5 +100,10 @@ bool Applet::isValid() const
|
||||
return !id.isEmpty();
|
||||
}
|
||||
|
||||
QString Applet::visibleName() const
|
||||
{
|
||||
return name.isEmpty() ? id : name;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,8 @@ public:
|
||||
bool isInstalled() const;
|
||||
bool isValid() const;
|
||||
|
||||
QString visibleName() const;
|
||||
|
||||
//! Operators
|
||||
Applet &operator=(const Applet &rhs);
|
||||
Applet &operator=(Applet &&rhs);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "delegates/singletextdelegate.h"
|
||||
#include "../generic/generictools.h"
|
||||
#include "../settingsdialog/templateskeeper.h"
|
||||
#include "../../data/errorinformationdata.h"
|
||||
#include "../../layout/genericlayout.h"
|
||||
#include "../../layout/centrallayout.h"
|
||||
#include "../../layouts/manager.h"
|
||||
@ -373,41 +374,45 @@ void Views::selectRow(const QString &id)
|
||||
|
||||
void Views::onCurrentLayoutChanged()
|
||||
{
|
||||
Data::Layout layout = m_handler->currentData();
|
||||
Data::Layout currentlayoutdata = m_handler->currentData();
|
||||
|
||||
Data::ViewsTable clipboardviews = m_handler->layoutsController()->templatesKeeper()->clipboardContents();
|
||||
|
||||
if (!clipboardviews.isEmpty()) {
|
||||
//! clipboarded views needs to update the relevant flags to loaded views
|
||||
for (int i=0; i<layout.views.rowCount(); ++i) {
|
||||
QString vid = layout.views[i].id;
|
||||
for (int i=0; i<currentlayoutdata.views.rowCount(); ++i) {
|
||||
QString vid = currentlayoutdata.views[i].id;
|
||||
|
||||
if (!clipboardviews.containsId(vid)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (clipboardviews[vid].isMoveOrigin && (clipboardviews[vid].originLayout() == layout.id)) {
|
||||
layout.views[vid].isMoveOrigin = true;
|
||||
if (clipboardviews[vid].isMoveOrigin && (clipboardviews[vid].originLayout() == currentlayoutdata.id)) {
|
||||
currentlayoutdata.views[vid].isMoveOrigin = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_model->setOriginalData(layout.views);
|
||||
m_model->setOriginalData(currentlayoutdata.views);
|
||||
|
||||
//! track viewscountchanged signal for current active layout scenario
|
||||
for (const auto &var : m_currentLayoutConnections) {
|
||||
QObject::disconnect(var);
|
||||
}
|
||||
|
||||
Data::Layout originlayoutdata = m_handler->layoutsController()->originalData(layout.id);
|
||||
auto currentlayout = m_handler->layoutsController()->isLayoutOriginal(layout.id) ?
|
||||
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);
|
||||
|
||||
if (currentlayout && currentlayout->isActive()) {
|
||||
m_currentLayoutConnections << connect(currentlayout, &Layout::GenericLayout::viewsCountChanged, this, [&, currentlayout](){
|
||||
m_model->updateActiveStatesBasedOn(currentlayout);
|
||||
});
|
||||
}
|
||||
|
||||
messagesForErrorsWarnings(currentlayout);
|
||||
}
|
||||
|
||||
void Views::onSelectionsChanged()
|
||||
@ -487,6 +492,54 @@ void Views::updateDoubledMoveDestinationRows() {
|
||||
}
|
||||
}
|
||||
|
||||
void Views::messagesForErrorsWarnings(const Latte::CentralLayout *centralLayout)
|
||||
{
|
||||
if (!centralLayout) {
|
||||
return;
|
||||
}
|
||||
|
||||
Data::Layout currentdata = centralLayout->data();
|
||||
|
||||
//! show warnings
|
||||
if (currentdata.warnings > 0) {
|
||||
|
||||
}
|
||||
|
||||
//! show errors
|
||||
if (currentdata.errors > 0) {
|
||||
Data::ErrorsList errors = centralLayout->errors();
|
||||
|
||||
for (int i=0; i< errors.count(); ++i) {
|
||||
if (errors[i].id == Data::Error::APPLETSWITHSAMEID) {
|
||||
messageForErrorAppletsWithSameId(errors[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Views::messageForErrorAppletsWithSameId(const Data::Error &error)
|
||||
{
|
||||
if (error.id != Data::Error::APPLETSWITHSAMEID) {
|
||||
return;
|
||||
}
|
||||
|
||||
QString message = i18nc("error id and title", "<b>Error %0: %1</b> <br/><br/>").arg(error.id).arg(error.name);
|
||||
message += i18n("In your layout there are two or more applets with same id. Such situation can create crashes and abnormal behavior when you active the layout. It is suggested to remove the mentioned applets, fix the situation manually or remove the layout totally.<br/><br/>");
|
||||
message += i18n("<b>Applets:</b><br/>");
|
||||
for (int i=0; i<error.information.rowCount(); ++i) {
|
||||
QString appletname = error.information[i].applet.visibleName();
|
||||
QString appletstorageid = error.information[i].applet.storageId;
|
||||
QString viewname = visibleViewName(error.information[i].containment.storageId);
|
||||
QString containmentname = viewname.isEmpty() ? error.information[i].containment.visibleName() : viewname;
|
||||
QString containmentstorageid = error.information[i].containment.storageId;
|
||||
message += i18nc("applets with same id error, applet name, applet id, containment name, containment id",
|
||||
" • <b>%0</b> [#%1] inside <b>%2</b> [#%3]<br/>").arg(appletname).arg(appletstorageid).arg(containmentname).arg(containmentstorageid);
|
||||
}
|
||||
|
||||
m_handler->showInlineMessage(message, KMessageWidget::Error, true);
|
||||
}
|
||||
|
||||
void Views::save()
|
||||
{
|
||||
//! when this function is called we consider that removal has already been approved
|
||||
@ -660,6 +713,22 @@ QString Views::uniqueViewName(QString name)
|
||||
return name;
|
||||
}
|
||||
|
||||
QString Views::visibleViewName(const QString &id) const
|
||||
{
|
||||
if (id.isEmpty()) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
Data::View view = m_model->currentData(id);
|
||||
|
||||
if (view.isValid()) {
|
||||
return view.name;
|
||||
}
|
||||
|
||||
return QString();
|
||||
|
||||
}
|
||||
|
||||
void Views::applyColumnWidths()
|
||||
{
|
||||
m_view->horizontalHeader()->setSectionResizeMode(Model::Views::SUBCONTAINMENTSCOLUMN, QHeaderView::Stretch);
|
||||
|
@ -104,9 +104,14 @@ private:
|
||||
|
||||
int rowForId(QString id) const;
|
||||
QString uniqueViewName(QString name);
|
||||
QString visibleViewName(const QString &id) const;
|
||||
|
||||
Data::ViewsTable selectedViewsForClipboard();
|
||||
|
||||
//! errors/warnings
|
||||
void messagesForErrorsWarnings(const Latte::CentralLayout *centralLayout);
|
||||
void messageForErrorAppletsWithSameId(const Data::Error &error);
|
||||
|
||||
private slots:
|
||||
void loadConfig();
|
||||
void saveConfig();
|
||||
|
@ -85,8 +85,12 @@ const Latte::Data::View &Views::at(const int &row)
|
||||
return m_viewsTable[row];
|
||||
}
|
||||
|
||||
const Latte::Data::View &Views::currentData(const QString &id)
|
||||
const Latte::Data::View Views::currentData(const QString &id)
|
||||
{
|
||||
if (!m_viewsTable.containsId(id)) {
|
||||
return Latte::Data::View();
|
||||
}
|
||||
|
||||
return m_viewsTable[id];
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ public:
|
||||
int rowForId(const QString &id) const;
|
||||
|
||||
const Latte::Data::View &at(const int &row);
|
||||
const Latte::Data::View ¤tData(const QString &id);
|
||||
const Latte::Data::View currentData(const QString &id);
|
||||
const Latte::Data::View originalData(const QString &id);
|
||||
|
||||
const Latte::Data::ViewsTable ¤tViewsData();
|
||||
|
@ -1,6 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Latte
|
||||
Name=Latte Containment
|
||||
Name[az]=Latte
|
||||
Name[ca]=Latte
|
||||
Name[ca@valencia]=Latte
|
||||
@ -44,7 +44,7 @@ Comment[es]=Contención proporcionada para Latte Dock
|
||||
Comment[et]=Latte doki konteiner
|
||||
Comment[eu]=Konfinamendua hornitu da Latte Dockentzako
|
||||
Comment[fi]=Latte-telakalla tarjottu sisällytys
|
||||
Comment[fr]=Confinement fourni par le panneau « Latte »
|
||||
Comment[fr]=Confinement fourni par le panneau « Latte »
|
||||
Comment[gl]=Contedor fornecido para a doca Latte.
|
||||
Comment[id]=Kontainmen disediakan untuk Dock Latte
|
||||
Comment[it]=Contenitore fornito per Latte Dock
|
||||
|
@ -1,6 +1,6 @@
|
||||
[Desktop Entry]
|
||||
Encoding=UTF-8
|
||||
Name=Latte
|
||||
Name=Latte Containment
|
||||
Name[az]=Latte
|
||||
Name[ca]=Latte
|
||||
Name[ca@valencia]=Latte
|
||||
@ -44,7 +44,7 @@ Comment[es]=Contención proporcionada para Latte Dock
|
||||
Comment[et]=Latte doki konteiner
|
||||
Comment[eu]=Konfinamendua hornitu da Latte Dockentzako
|
||||
Comment[fi]=Latte-telakalla tarjottu sisällytys
|
||||
Comment[fr]=Confinement fourni par le panneau « Latte »
|
||||
Comment[fr]=Confinement fourni par le panneau « Latte »
|
||||
Comment[gl]=Contedor fornecido para a doca Latte.
|
||||
Comment[id]=Kontainmen disediakan untuk Dock Latte
|
||||
Comment[it]=Contenitore fornito per Latte Dock
|
||||
|
Loading…
x
Reference in New Issue
Block a user