summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-09-22 21:24:24 +0200
committerMontel Laurent <[email protected]>2015-09-22 22:49:44 +0200
commit0a9eda5ea6fb4f61ddb212ae3a1d9de4af1fb262 (patch)
treed6fad8ae935a1f918eee54152d95764ea94fe9b5
parente8a44a7360dcb558bca6982c449df101df6931b0 (diff)
Improve header style support
-rw-r--r--messageviewer/src/header/headerstyleinterface.cpp5
-rw-r--r--messageviewer/src/header/headerstyleinterface.h2
-rw-r--r--messageviewer/src/header/headerstylemenumanager.cpp31
-rw-r--r--messageviewer/src/header/headerstylemenumanager.h2
-rw-r--r--messageviewer/src/header/tests/headerstylemenu_gui.cpp3
5 files changed, 39 insertions, 4 deletions
diff --git a/messageviewer/src/header/headerstyleinterface.cpp b/messageviewer/src/header/headerstyleinterface.cpp
index a97a2f4..ea1f06b 100644
--- a/messageviewer/src/header/headerstyleinterface.cpp
+++ b/messageviewer/src/header/headerstyleinterface.cpp
@@ -56,6 +56,11 @@ void HeaderStyleInterface::addActionToMenu(KActionMenu *menu, QActionGroup *acti
}
}
+HeaderStylePlugin *HeaderStyleInterface::headerStylePlugin() const
+{
+ return mHeaderStylePlugin;
+}
+
void MessageViewer::HeaderStyleInterface::slotStyleChanged()
{
Q_EMIT styleChanged(mHeaderStylePlugin);
diff --git a/messageviewer/src/header/headerstyleinterface.h b/messageviewer/src/header/headerstyleinterface.h
index 87864626..c00f071 100644
--- a/messageviewer/src/header/headerstyleinterface.h
+++ b/messageviewer/src/header/headerstyleinterface.h
@@ -39,6 +39,8 @@ public:
QList<KToggleAction * > action() const;
virtual void createAction(KActionMenu *menu, QActionGroup *actionGroup, KActionCollection *ac) = 0;
virtual void activateAction() = 0;
+ HeaderStylePlugin *headerStylePlugin() const;
+
Q_SIGNALS:
void styleChanged(MessageViewer::HeaderStylePlugin *plugin);
void styleUpdated();
diff --git a/messageviewer/src/header/headerstylemenumanager.cpp b/messageviewer/src/header/headerstylemenumanager.cpp
index 16155a0..9112fad 100644
--- a/messageviewer/src/header/headerstylemenumanager.cpp
+++ b/messageviewer/src/header/headerstylemenumanager.cpp
@@ -29,6 +29,8 @@
#include <KLocalizedString>
#include <KToggleAction>
+#include <QDebug>
+
using namespace MessageViewer;
class MessageViewer::HeaderStyleMenuManagerPrivate
@@ -73,16 +75,35 @@ void HeaderStyleMenuManagerPrivate::setPluginName(const QString &pluginName)
interface->activateAction();
}
}
+ Q_EMIT q->styleChanged(interface->headerStylePlugin());
}
void HeaderStyleMenuManagerPrivate::readSettings()
{
QString headerStyleName = MessageViewer::GlobalSettings::self()->headerPluginStyleName();
if (headerStyleName.isEmpty()) {
- //TODO read old settings
const QString headerStyle = MessageViewer::GlobalSettings::self()->headerStyle();
const QString headerSetDisplayed = MessageViewer::GlobalSettings::self()->headerSetDisplayed();
- //if (headerStyle == )
+
+ if ((headerStyle == QLatin1String("custom")) && (headerSetDisplayed == QLatin1String("custom"))) { //Custom
+ headerStyleName = QStringLiteral("custom");
+ } else if ((headerStyle == QLatin1String("plain")) && (headerSetDisplayed == QLatin1String("all"))) { //all
+ headerStyleName = QStringLiteral("all-headers");
+ } else if ((headerStyle == QLatin1String("brief")) && (headerSetDisplayed == QLatin1String("brief"))) { //brief
+ headerStyleName = QStringLiteral("brief");
+ } else if ((headerStyle == QLatin1String("enterprise")) && (headerSetDisplayed == QLatin1String("rich"))) { //enterprise
+ headerStyleName = QStringLiteral("enterprise");
+ } else if ((headerStyle == QLatin1String("fancy")) && (headerSetDisplayed == QLatin1String("rich"))) { //fancy
+ headerStyleName = QStringLiteral("fancy");
+ } else if ((headerStyle == QLatin1String("grantlee")) && (headerSetDisplayed == QLatin1String("grantlee"))) { //grantlee
+ headerStyleName = QStringLiteral("grantlee");
+ } else if ((headerStyle == QLatin1String("plain")) && (headerSetDisplayed == QLatin1String("rich"))) { //longheader
+ headerStyleName = QStringLiteral("long-header");
+ } else if ((headerStyle == QLatin1String("plain")) && (headerSetDisplayed == QLatin1String("standard"))) { //Standard
+ headerStyleName = QStringLiteral("standards-header");
+ } else {
+ qDebug() << "unknown style : headerstyle "<< headerStyle << " headerstrategy :"<<headerSetDisplayed;
+ }
}
if (headerStyleName.isEmpty()) {
headerStyleName = QStringLiteral("fancy");
@@ -118,7 +139,6 @@ HeaderStyleMenuManager::HeaderStyleMenuManager(KActionCollection *ac, QObject *p
d(new MessageViewer::HeaderStyleMenuManagerPrivate(this))
{
d->initialize(ac);
- d->readSettings();
}
HeaderStyleMenuManager::~HeaderStyleMenuManager()
@@ -141,3 +161,8 @@ void HeaderStyleMenuManager::slotStyleChanged(MessageViewer::HeaderStylePlugin *
d->writeSettings(plugin->name());
Q_EMIT styleChanged(plugin);
}
+
+void HeaderStyleMenuManager::readConfig()
+{
+ d->readSettings();
+}
diff --git a/messageviewer/src/header/headerstylemenumanager.h b/messageviewer/src/header/headerstylemenumanager.h
index 40db814..c8a3d0d 100644
--- a/messageviewer/src/header/headerstylemenumanager.h
+++ b/messageviewer/src/header/headerstylemenumanager.h
@@ -37,6 +37,8 @@ public:
KActionMenu *menu() const;
void setPluginName(const QString &pluginName);
+ void readConfig();
+
public Q_SLOTS:
void slotStyleChanged(MessageViewer::HeaderStylePlugin *plugin);
Q_SIGNALS:
diff --git a/messageviewer/src/header/tests/headerstylemenu_gui.cpp b/messageviewer/src/header/tests/headerstylemenu_gui.cpp
index f758969..6aba3af 100644
--- a/messageviewer/src/header/tests/headerstylemenu_gui.cpp
+++ b/messageviewer/src/header/tests/headerstylemenu_gui.cpp
@@ -43,11 +43,12 @@ HeaderStyleMenuTest::HeaderStyleMenuTest(QWidget *parent)
QVBoxLayout *hbox = new QVBoxLayout(this);
hbox->addWidget(menu);
MessageViewer::HeaderStyleMenuManager *manager = new MessageViewer::HeaderStyleMenuManager(new KActionCollection(this), this);
- connect(manager, &MessageViewer::HeaderStyleMenuManager::styleChanged, this, &HeaderStyleMenuTest::styleChanged);
menu->addAction(manager->menu());
mTextEdit = new QTextEdit(this);
mTextEdit->setReadOnly(true);
hbox->addWidget(mTextEdit);
+ connect(manager, &MessageViewer::HeaderStyleMenuManager::styleChanged, this, &HeaderStyleMenuTest::styleChanged);
+ manager->readConfig();
}
HeaderStyleMenuTest::~HeaderStyleMenuTest()