1
0
mirror of https://github.com/KDE/latte-dock.git synced 2025-08-29 17:49:28 +03:00

settingsdialogs:consistent button look for inlines

This commit is contained in:
Michail Vourlakos
2021-05-02 10:30:33 +03:00
parent 680174c389
commit 660cef280f
7 changed files with 58 additions and 83 deletions

View File

@ -234,6 +234,7 @@ void ExportTemplateHandler::onExport()
if (result) {
QAction *openUrlAction = new QAction(i18n("Open Location..."), this);
openUrlAction->setIcon(QIcon::fromTheme("document-open"));
openUrlAction->setData(c_filepath);
QList<QAction *> actions;
actions << openUrlAction;

View File

@ -119,7 +119,8 @@ void GenericDialog::showInlineMessage(const QString &msg, const KMessageWidget::
messagewidget->setCloseButtonVisible(actions.count()==0);
if (actions.count() > 0) {
QAction *cancelaction = new QAction(i18n("Cancel"), this);
QAction *cancelaction = new QAction(i18n("Hide"), this);
cancelaction->setIcon(QIcon::fromTheme("dialog-cancel"));
actions << cancelaction;
}

View File

@ -580,6 +580,7 @@ void Layouts::messageForErroredLayout(const Data::Layout &layout)
{
//! add actions
QAction *examineaction = new QAction(i18n("Examine..."), this);
examineaction->setIcon(QIcon::fromTheme("document-preview"));
examineaction->setData(layout.id);
QList<QAction *> actions;
actions << examineaction;

View File

@ -357,6 +357,7 @@ void SettingsDialog::exportFullConfiguration()
if (m_corona->layoutsManager()->importer()->exportFullConfiguration(file)) {
QAction *openUrlAction = new QAction(i18n("Open Location..."), this);
openUrlAction->setIcon(QIcon::fromTheme("document-open"));
openUrlAction->setData(file);
QList<QAction *> actions;
actions << openUrlAction;

View File

@ -478,7 +478,9 @@ void TabLayouts::installLayoutTemplate(Latte::Data::Layout importedLayout, QStri
}
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;
@ -715,6 +717,7 @@ void TabLayouts::exportLayoutForBackup()
if (m_corona->layoutsManager()->importer()->exportFullConfiguration(file)) {
QAction *openUrlAction = new QAction(i18n("Open Location..."), this);
openUrlAction->setIcon(QIcon::fromTheme("document-open"));
openUrlAction->setData(file);
QList<QAction *> actions;
actions << openUrlAction;

View File

@ -576,6 +576,41 @@ void Views::messagesForErrorsWarnings(const Latte::CentralLayout *centralLayout)
}
void Views::showDefaultPersistentErrorWarningInlineMessage(const QString &messageText,
const KMessageWidget::MessageType &messageType,
QList<QAction *> extraActions,
const bool &showOpenLayoutAction)
{
QList<QAction *> actions;
if (showOpenLayoutAction) {
//! add default action to open layout
QAction *openlayoutaction = new QAction(i18n("Open Layout"), this);
openlayoutaction->setIcon(QIcon::fromTheme("document-open"));
Data::Layout currentlayout = m_handler->currentData();
openlayoutaction->setData(currentlayout.id);
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();
}
});
}
actions << extraActions;
//! show message
m_handler->showInlineMessage(messageText,
messageType,
true,
actions);
}
void Views::messageForErrorAppletsWithSameId(const Data::Error &error)
{
if (error.id != Data::Error::APPLETSWITHSAMEID) {
@ -606,27 +641,7 @@ 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/>");
//! 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);
showDefaultPersistentErrorWarningInlineMessage(message, KMessageWidget::Error);
}
void Views::messageForErrorOrphanedParentAppletOfSubContainment(const Data::Error &error)
@ -674,27 +689,8 @@ void Views::messageForErrorOrphanedParentAppletOfSubContainment(const Data::Erro
message += i18n("&nbsp;&nbsp;1. Try to fix the situation by updating manually the subcontainment id in pseudo applet settings<br/>");
message += i18n("&nbsp;&nbsp;2. Remove this layout totally<br/>");
//! 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);
showDefaultPersistentErrorWarningInlineMessage(message, KMessageWidget::Error);
}
void Views::messageForWarningAppletAndContainmentWithSameId(const Data::Warning &warning)
@ -742,27 +738,8 @@ void Views::messageForWarningAppletAndContainmentWithSameId(const Data::Warning
message += i18n("&nbsp;&nbsp;1. Try to fix the situation by updating manually the containments or applets id <br/>");
message += i18n("&nbsp;&nbsp;2. Remove any of the containments or applets that conflict with each other<br/>");
//! 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::Warning,
true,
actions);
showDefaultPersistentErrorWarningInlineMessage(message, KMessageWidget::Warning);
}
void Views::messageForWarningOrphanedSubContainments(const Data::Warning &warning)
@ -793,30 +770,14 @@ void Views::messageForWarningOrphanedSubContainments(const Data::Warning &warnin
message += i18n("<b>Possible Solutions:</b><br/>");
message += i18n("&nbsp;&nbsp;1. Click <b>Repair</b> button in order to remove them automatically<br/>");
//! add actions
QAction *openlayoutaction = new QAction(i18n("Open Layout"), this);
//! add extra action
QAction *repairlayoutaction = new QAction(i18n("Repair"), this);
repairlayoutaction->setIcon(QIcon::fromTheme("dialog-yes"));
repairlayoutaction->setEnabled(false);
Data::Layout currentlayout = m_handler->currentData();
openlayoutaction->setData(currentlayout.id);
QList<QAction *> actions;
actions << repairlayoutaction;
actions << openlayoutaction;
QList<QAction *> extraactions;
extraactions << repairlayoutaction;
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::Warning,
true,
actions);
showDefaultPersistentErrorWarningInlineMessage(message, KMessageWidget::Warning, extraactions, false);
}
void Views::save()

View File

@ -37,6 +37,8 @@
#include <QSortFilterProxyModel>
#include <QTableView>
// KDE
#include <KMessageWidget>
namespace Latte {
class CentralLayout;
@ -124,6 +126,11 @@ 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: