error #103,provide action buttons for user

work/spdx
Michail Vourlakos 4 years ago
parent 6e2b2c1e37
commit cb44cd77c2

@ -101,7 +101,12 @@ void GenericDialog::showInlineMessage(const QString &msg, const KMessageWidget::
}
}
messagewidget->setCloseButtonVisible(!isPersistent || actions.count()==0);
messagewidget->setCloseButtonVisible(actions.count()==0);
if (actions.count() > 0) {
QAction *cancelaction = new QAction(i18n("Cancel"), this);
actions << cancelaction;
}
for (int i=0; i<actions.count(); ++i) {
connect(actions[i], &QAction::triggered, messagewidget, &KMessageWidget::animatedHide);

@ -578,23 +578,42 @@ void Layouts::initialMessageForWarningLayouts(const int &count)
void Layouts::messageForErroredLayout(const Data::Layout &layout)
{
//! add actions
QAction *examineaction = new QAction(i18n("Examine..."), this);
examineaction->setData(layout.id);
QList<QAction *> actions;
actions << examineaction;
connect(examineaction, &QAction::triggered, this, [&, examineaction]() {
QString currentid = examineaction->data().toString();
if (!currentid.isEmpty()) {
selectRow(currentid);
m_handler->showViewsDialog();
}
});
if (!layout.hasErrors() && layout.hasWarnings()) {
//! add only warnings first
m_handler->showInlineMessage(i18nc("settings:layout with warnings",
"<b>Warning: %0</b> layout has reported <b>%1 warning(s)</b> that need your attention.").arg(layout.name).arg(layout.warnings),
KMessageWidget::Warning);
KMessageWidget::Warning,
false,
actions);
} else if (layout.hasErrors() && !layout.hasWarnings()) {
//! add errors in the end in order to be read by the user
m_handler->showInlineMessage(i18nc("settings:layout with errors",
"<b>Error: %0</b> layout has reported <b>%1 error(s)</b> that you need to repair.").arg(layout.name).arg(layout.errors),
KMessageWidget::Error,
true);
true,
actions);
} else if (layout.hasErrors() && layout.hasWarnings()) {
//! add most important errors in the end in order to be read by the user
m_handler->showInlineMessage(i18nc("settings:layout with errors and warnings",
"<b>Error: %0</b> layout has reported <b>%1 error(s)</b> and <b>%2 warning(s)</b> that you need to repair.").arg(layout.name).arg(layout.errors).arg(layout.warnings),
KMessageWidget::Error,
true);
true,
actions);
}
}
@ -604,12 +623,14 @@ void Layouts::onCurrentRowChanged()
return;
}
if (!m_handler->isViewsDialogVisible()) {
Latte::Data::Layout selectedlayout = selectedLayoutCurrentData();
if (selectedlayout.hasErrors() || selectedlayout.hasWarnings()) {
messageForErroredLayout(selectedlayout);
}
}
}
void Layouts::onLayoutActivitiesChangedExternally(const Data::Layout &layout)
{

@ -193,14 +193,14 @@ void TabLayouts::initLayoutMenu()
m_viewsAction->setIcon(QIcon::fromTheme("window"));
m_viewsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
connectActionWithButton(m_ui->viewsBtn, m_viewsAction);
connect(m_viewsAction, &QAction::triggered, this, &TabLayouts::viewsLayout);
connect(m_viewsAction, &QAction::triggered, this, &TabLayouts::showViewsDialog);
m_detailsAction = m_layoutMenu->addAction(i18nc("layout details", "De&tails..."));
m_detailsAction->setToolTip(i18n("Show selected layout details"));
m_detailsAction->setIcon(QIcon::fromTheme("view-list-details"));
m_detailsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T));
connectActionWithButton(m_ui->detailsButton, m_detailsAction);
connect(m_detailsAction, &QAction::triggered, this, &TabLayouts::detailsLayout);
connect(m_detailsAction, &QAction::triggered, this, &TabLayouts::showDetailsDialog);
m_layoutMenu->addSeparator();
@ -335,6 +335,11 @@ bool TabLayouts::inDefaultValues() const
return true;
}
bool TabLayouts::isViewsDialogVisible() const
{
return m_isViewsDialogVisible;
}
void TabLayouts::reset()
{
m_layoutsController->reset();
@ -442,7 +447,7 @@ void TabLayouts::newLayout(const QString &templateName)
if (!tdata.isNull()) {
Data::Layout newlayout = m_layoutsController->addLayoutForFile(tdata.id, tdata.name, true);
showInlineMessage(i18nc("settings:layout added successfully","Layout <b>%0</b> added successfully...").arg(newlayout.name),
KMessageWidget::Information);
KMessageWidget::Positive);
}
}
@ -483,7 +488,7 @@ void TabLayouts::installLayoutTemplate(Latte::Data::Layout importedLayout, QStri
});
showInlineMessage(informationText,
KMessageWidget::Information,
KMessageWidget::Positive,
true,
actions);
}
@ -698,7 +703,7 @@ void TabLayouts::exportLayoutForBackup()
});
showInlineMessage(i18nc("settings:layout export success","Layout <b>%0</b> export succeeded...").arg(selectedLayout.name),
KMessageWidget::Information,
KMessageWidget::Positive,
false,
actions);
} else if (file.endsWith(".latterc")) {
@ -721,7 +726,7 @@ void TabLayouts::exportLayoutForBackup()
});
showInlineMessage(i18n("Full configuration export succeeded..."),
KMessageWidget::Information,
KMessageWidget::Positive,
false,
actions);
} else {
@ -734,7 +739,7 @@ void TabLayouts::exportLayoutForBackup()
exportFileDialog->selectFile(selectedLayout.name);
}
void TabLayouts::detailsLayout()
void TabLayouts::showDetailsDialog()
{
qDebug() << Q_FUNC_INFO;
@ -753,7 +758,7 @@ void TabLayouts::detailsLayout()
detailsDlg->deleteLater();
}
void TabLayouts::viewsLayout()
void TabLayouts::showViewsDialog()
{
qDebug() << Q_FUNC_INFO;
@ -768,7 +773,9 @@ void TabLayouts::viewsLayout()
Latte::Data::Layout selectedLayout = m_layoutsController->selectedLayoutCurrentData();
auto viewsDlg = new Settings::Dialog::ViewsDialog(m_parentDialog, m_layoutsController);
m_isViewsDialogVisible = true;
viewsDlg->exec();
m_isViewsDialogVisible = false;
viewsDlg->deleteLater();
}
@ -785,10 +792,10 @@ void TabLayouts::onLayoutFilesDropped(const QStringList &paths)
if (layoutNames.count() == 1) {
showInlineMessage(i18nc("settings:layout imported successfully","Layout <b>%0</b> imported successfully...").arg(layoutNames[0]),
KMessageWidget::Information);
KMessageWidget::Positive);
} else if (layoutNames.count() > 1) {
showInlineMessage(i18nc("settings:layouts imported successfully","Layouts <b>%0</b> imported successfully...").arg(layoutNames.join(", )")),
KMessageWidget::Information);
KMessageWidget::Positive);
}
}
@ -796,7 +803,7 @@ void TabLayouts::onRawLayoutDropped(const QString &rawLayout)
{
Latte::Data::Layout importedlayout = m_layoutsController->addLayoutByText(rawLayout);
showInlineMessage(i18nc("settings:layout imported successfully","Layout <b>%0</b> imported successfully...").arg(importedlayout.name),
KMessageWidget::Information);
KMessageWidget::Positive);
}
bool TabLayouts::isCurrentTab() const

@ -77,6 +77,8 @@ public:
bool inDefaultValues() const override;
bool isCurrentTab() const;
bool isViewsDialogVisible() const;
Latte::Corona *corona() const;
Dialog::SettingsDialog *dialog() const;
Ui::SettingsDialog *ui() const;
@ -87,6 +89,8 @@ public slots:
void onDragMoveEvent(QDragMoveEvent *event);
void onDropEvent(QDropEvent *event);
void showViewsDialog();
void reset() override;
void resetDefaults() override;
void save() override;
@ -108,8 +112,7 @@ private slots:
void removeLayout();
void toggleActivitiesManager();
void toggleEnabledLayout();
void detailsLayout();
void viewsLayout();
void showDetailsDialog();
void onCurrentPageChanged(int page);
void onLayoutFilesDropped(const QStringList &paths);
@ -136,6 +139,8 @@ private:
KConfigGroup m_storage;
bool m_isViewsDialogVisible{false};
QButtonGroup *m_inMemoryButtons;
//! Layout menu actions

@ -44,7 +44,7 @@
// KDE
#include <KMessageWidget>
#include <KIO/OpenUrlJob>
namespace Latte {
namespace Settings {
@ -524,6 +524,7 @@ void Views::messageForErrorAppletsWithSameId(const Data::Error &error)
return;
}
//! construct message
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 activate and use this layout.<br/><br/>");
message += i18n("<b>Applets:</b><br/>");
@ -543,7 +544,24 @@ void Views::messageForErrorAppletsWithSameId(const Data::Error &error)
message += i18n("&nbsp;&nbsp;3. Try to fix the situation by updating manually the applets id<br/>");
message += i18n("&nbsp;&nbsp;4. Remove this layout totally<br/>");
m_handler->showInlineMessage(message, KMessageWidget::Error, true);
//! add actions
QAction *openlayoutaction = new QAction(i18n("Open Layout"), this);
Data::Layout currentlayout = m_handler->currentData();
openlayoutaction->setData(currentlayout.id);
QList<QAction *> actions;
actions << openlayoutaction;
connect(openlayoutaction, &QAction::triggered, this, [&, openlayoutaction]() {
QString file = openlayoutaction->data().toString();
if (!file.isEmpty()) {
auto job = new KIO::OpenUrlJob(QUrl::fromLocalFile(file), QStringLiteral("text/plain"), this);
job->start();
}
});
//! show message
m_handler->showInlineMessage(message, KMessageWidget::Error, true, actions);
}
void Views::save()

Loading…
Cancel
Save