Diffstat (limited to 'noncore/securityplugins/notice') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/securityplugins/notice/noticeConfigWidget.cpp | 14 | ||||
-rw-r--r-- | noncore/securityplugins/notice/noticeplugin.cpp | 10 | ||||
-rw-r--r-- | noncore/securityplugins/notice/noticeplugin.h | 1 |
3 files changed, 10 insertions, 15 deletions
diff --git a/noncore/securityplugins/notice/noticeConfigWidget.cpp b/noncore/securityplugins/notice/noticeConfigWidget.cpp index e0468a7..02084f8 100644 --- a/noncore/securityplugins/notice/noticeConfigWidget.cpp +++ b/noncore/securityplugins/notice/noticeConfigWidget.cpp @@ -56,28 +56,26 @@ void NoticeConfigWidget::writeConfig() /// reset the notice text to the hard-coded example defaultNoticeText void NoticeConfigWidget::resetNotice() { noticeMLE->setText(QObject::tr(defaultNoticeText)); } /// get the notice text from the config file (with true new lines) /** * if no text has been defined yet returns defaultNoticeText */ QString NoticeConfigWidget::getNoticeText() { - m_config = new Config("Security"); - m_config->setGroup("NoticePlugin"); + Config config("Security"); + config.setGroup("NoticePlugin"); // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp - QString noticeText = m_config->readEntry("noticeText", QObject::tr(defaultNoticeText) ).replace( QRegExp("\\\\n"), "\n" ); - delete m_config; + QString noticeText = config.readEntry("noticeText", QObject::tr(defaultNoticeText) ).replace( QRegExp("\\\\n"), "\n" ); return noticeText; } /// set the notice text in our m_config config file (escaping new lines) void NoticeConfigWidget::setNoticeText(QString noticeText) { - m_config = new Config("Security"); - m_config->setGroup("NoticePlugin"); + Config config("Security"); + config.setGroup("NoticePlugin"); // since Config files do not allow true newlines, we replace them with litteral "\n" - m_config->writeEntry("noticeText", noticeText.replace( QRegExp("\n"), "\\n" )); - delete m_config; + config.writeEntry("noticeText", noticeText.replace( QRegExp("\n"), "\\n" )); } diff --git a/noncore/securityplugins/notice/noticeplugin.cpp b/noncore/securityplugins/notice/noticeplugin.cpp index 5617855..d3dc7a4 100644 --- a/noncore/securityplugins/notice/noticeplugin.cpp +++ b/noncore/securityplugins/notice/noticeplugin.cpp @@ -1,33 +1,29 @@ #include "noticeplugin.h" #include <opie2/oapplication.h> #include <qmessagebox.h> #include <qregexp.h> using Opie::Security::MultiauthPluginObject; using Opie::Security::MultiauthConfigWidget; /// creates and initializes the m_config Config object NoticePlugin::NoticePlugin() : MultiauthPluginObject(), m_noticeW(0) { - m_config = new Config("Security"); - m_config->setGroup("NoticePlugin"); } /// deletes the m_config Config object and noticeW if necessary NoticePlugin::~NoticePlugin() { - delete m_config; - if (m_noticeW != 0) - delete m_noticeW; + delete m_noticeW; } /// Simply return its name (Notice plugin) QString NoticePlugin::pluginName() const { return "Notice plugin"; } /// return the Notice widget configuration widget /** * \return noticeW, the NoticeConfigWidget */ MultiauthConfigWidget * NoticePlugin::configWidget(QWidget * parent) { @@ -72,15 +68,17 @@ int NoticePlugin::authenticate() { case QMessageBox::Yes: return MultiauthPluginObject::Success; } return 255; //should not be returned anyway } /// get the notice text from our m_config config file (with true new lines) /** * if no text has been defined yet returns defaultNoticeText */ QString NoticePlugin::getNoticeText() { // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp - return m_config->readEntry("noticeText", QObject::tr(defaultNoticeText)).replace( QRegExp("\\\\n"), "\n" ); + Config config("Security"); + config.setGroup("NoticePlugin"); + return config.readEntry("noticeText", QObject::tr(defaultNoticeText)).replace( QRegExp("\\\\n"), "\n" ); } diff --git a/noncore/securityplugins/notice/noticeplugin.h b/noncore/securityplugins/notice/noticeplugin.h index 2828f58..22b2322 100644 --- a/noncore/securityplugins/notice/noticeplugin.h +++ b/noncore/securityplugins/notice/noticeplugin.h @@ -48,17 +48,16 @@ class NoticePlugin : public QObject, public Opie::Security::MultiauthPluginObjec Q_OBJECT; public: NoticePlugin(); virtual ~NoticePlugin(); int authenticate(); Opie::Security::MultiauthConfigWidget * configWidget(QWidget * parent); QString pixmapNameConfig() const; QString pixmapNameWidget() const; QString pluginName() const; private: NoticeConfigWidget * m_noticeW; - Config * m_config; QString getNoticeText(); }; #endif |