Commit addbc65d authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Show message info when we change setting

parent af9012e7
......@@ -38,10 +38,10 @@ void ConfigurePluginsWidgetTest::shouldHaveDefaultValue()
{
PimCommon::ConfigurePluginsWidget w;
KMessageWidget *messageWidget = w.findChild<KMessageWidget *>(QStringLiteral("messagewidget"));
QVERIFY(messageWidget);
QVERIFY(!messageWidget->isCloseButtonVisible());
QVERIFY(!messageWidget->text().isEmpty());
KMessageWidget *mMessageWidget = w.findChild<KMessageWidget *>(QStringLiteral("mMessageWidget"));
QVERIFY(mMessageWidget);
QVERIFY(!mMessageWidget->isCloseButtonVisible());
QVERIFY(!mMessageWidget->text().isEmpty());
QSplitter *mSplitter = w.findChild<QSplitter *>(QStringLiteral("splitter"));
QVERIFY(mSplitter);
......
......@@ -58,8 +58,10 @@ ConfigurePluginsListWidget::~ConfigurePluginsListWidget()
void ConfigurePluginsListWidget::slotItemChanged(QTreeWidgetItem *item, int column)
{
Q_UNUSED(item);
if (column == 0) {
Q_EMIT changed();
if (mInitializeDone) {
if (column == 0) {
Q_EMIT changed();
}
}
}
......@@ -78,6 +80,7 @@ void ConfigurePluginsListWidget::save()
void ConfigurePluginsListWidget::doLoadFromGlobalSettings()
{
initialize();
initializeDone();
}
void ConfigurePluginsListWidget::doResetToDefaultsOther()
......@@ -92,6 +95,11 @@ void ConfigurePluginsListWidget::initialize()
{
}
void ConfigurePluginsListWidget::initializeDone()
{
mInitializeDone = true;
}
void ConfigurePluginsListWidget::savePlugins(const QString &groupName, const QString &prefixSettingKey, const QVector<PluginItem *> &listItems)
{
if (listItems.isEmpty()) {
......
......@@ -43,6 +43,7 @@ public:
virtual void doResetToDefaultsOther();
virtual void defaults();
virtual void initialize();
void initializeDone();
Q_SIGNALS:
void descriptionChanged(const QString &description);
void changed();
......@@ -78,6 +79,7 @@ protected:
QTreeWidget *mListWidget = nullptr;
private:
void slotConfigureClicked(QAction *act);
bool mInitializeDone = false;
};
}
......
......@@ -52,11 +52,11 @@ void ConfigurePluginsWidget::initLayout(ConfigurePluginsListWidget *configurePlu
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
KMessageWidget *messageWidget = new KMessageWidget(this);
messageWidget->setObjectName(QStringLiteral("messagewidget"));
messageWidget->setText(i18n("Restart is necessary for applying the changes."));
messageWidget->setCloseButtonVisible(false);
layout->addWidget(messageWidget);
mMessageWidget = new KMessageWidget(i18n("Restart is necessary for applying the changes."), this);
mMessageWidget->setObjectName(QStringLiteral("mMessageWidget"));
mMessageWidget->setCloseButtonVisible(false);
mMessageWidget->setVisible(false);
layout->addWidget(mMessageWidget);
mSplitter = new QSplitter(this);
mSplitter->setObjectName(QStringLiteral("splitter"));
......@@ -78,12 +78,18 @@ void ConfigurePluginsWidget::initLayout(ConfigurePluginsListWidget *configurePlu
mSplitter->addWidget(mDescription);
connect(mConfigureListWidget, &ConfigurePluginsListWidget::descriptionChanged, mDescription, &QTextEdit::setText);
connect(mConfigureListWidget, &ConfigurePluginsListWidget::changed, this, &ConfigurePluginsWidget::changed);
connect(mConfigureListWidget, &ConfigurePluginsListWidget::changed, this, &ConfigurePluginsWidget::slotConfigChanged);
initialize();
readConfig();
}
void ConfigurePluginsWidget::slotConfigChanged()
{
mMessageWidget->animatedShow();
Q_EMIT changed();
}
void ConfigurePluginsWidget::save()
{
mConfigureListWidget->save();
......
......@@ -23,6 +23,7 @@
#include "pimcommon_export.h"
class QSplitter;
class QTextEdit;
class KMessageWidget;
namespace PimCommon {
class ConfigurePluginsListWidget;
/**
......@@ -49,11 +50,13 @@ private:
void initialize();
void readConfig();
void writeConfig();
void slotConfigChanged();
void initLayout(ConfigurePluginsListWidget *configurePluginListWidget = nullptr);
QSplitter *mSplitter = nullptr;
ConfigurePluginsListWidget *mConfigureListWidget = nullptr;
QTextEdit *mDescription = nullptr;
KMessageWidget *mMessageWidget = nullptr;
};
}
#endif // CONFIGUREPLUGINSWIDGET_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment