Commit 60a24e2a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Define default contact

parent 6141bd0d
......@@ -22,6 +22,7 @@ set(contactthemeeditor_SRCS
editorpage.cpp
contacteditorpage.cpp
contactconfigurationdialog.cpp
contacteditorutil.cpp
)
......
......@@ -16,6 +16,7 @@
*/
#include "contactconfigurationdialog.h"
#include "contacteditorutil.h"
#include "configurewidget.h"
......@@ -24,6 +25,7 @@
#include <KConfig>
#include <KGlobal>
#include <KConfigGroup>
#include <KTextEdit>
#include <QVBoxLayout>
#include <QLabel>
......@@ -43,6 +45,14 @@ ContactConfigureDialog::ContactConfigureDialog(QWidget *parent)
mConfigureWidget = new GrantleeThemeEditor::ConfigureWidget;
lay->addWidget(mConfigureWidget);
QLabel *lab = new QLabel(i18n("Default contact:"));
lay->addWidget(lab);
mDefaultContact = new KTextEdit;
mDefaultContact->setAcceptRichText(false);
lay->addWidget(mDefaultContact);
lay->addStretch();
setMainWidget(w);
......@@ -62,6 +72,7 @@ ContactConfigureDialog::~ContactConfigureDialog()
void ContactConfigureDialog::slotDefaultClicked()
{
mConfigureWidget->setDefault();
mDefaultContact->setPlainText(contacteditorutil::defaultContact());
}
void ContactConfigureDialog::slotOkClicked()
......@@ -72,6 +83,14 @@ void ContactConfigureDialog::slotOkClicked()
void ContactConfigureDialog::readConfig()
{
KSharedConfig::Ptr config = KGlobal::config();
if (config->hasGroup(QLatin1String("Global"))) {
KConfigGroup group = config->group(QLatin1String("Global"));
mDefaultContact->setPlainText(group.readEntry("defaultContact",contacteditorutil::defaultContact()));
} else {
mDefaultContact->setPlainText(contacteditorutil::defaultContact());
}
mConfigureWidget->readConfig();
KConfigGroup group = KConfigGroup( config, "ContactConfigureDialog" );
......@@ -85,6 +104,9 @@ void ContactConfigureDialog::readConfig()
void ContactConfigureDialog::writeConfig()
{
KSharedConfig::Ptr config = KGlobal::config();
KConfigGroup group = config->group(QLatin1String("Global"));
group.writeEntry("defaultContact", mDefaultContact->toPlainText());
mConfigureWidget->writeConfig();
}
......
......@@ -25,6 +25,7 @@ class ConfigureWidget;
}
class KUrlRequester;
class KTextEdit;
class ContactConfigureDialog : public KDialog
{
Q_OBJECT
......@@ -41,6 +42,7 @@ private Q_SLOTS:
private:
GrantleeThemeEditor::ConfigureWidget *mConfigureWidget;
KTextEdit *mDefaultContact;
};
#endif // CONTACTCONFIGUREDIALOG_H
/*
Copyright (c) 2013 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "contacteditorutil.h"
QString contacteditorutil::defaultContact()
{
//TODO fix me
const QString contact = QString::fromLatin1("From: montel@example.com\n"
"To: kde@example.com\n"
"Sender: montel@example.com\n"
"MIME-Version: 1.0\n"
"Date: 28 Apr 2013 23:58:21 -0000\n"
"Subject: Test message\n"
"Content-Type: text/plain\n"
"X-Length: 0\n"
"X-UID: 6161\n"
"\n"
"Hello this is a test mail\n");
return contact;
}
/*
Copyright (c) 2013 Montel Laurent <montel@kde.org>
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef CONTACTEDITORUTIL_H
#define CONTACTEDITORUTIL_H
#include <QString>
namespace contacteditorutil
{
QString defaultContact();
}
#endif
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