Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

noticeConfigWidget.cpp

Go to the documentation of this file.
00001 #include "noticeConfigWidget.h"
00002 
00003 #include <opie2/odebug.h>
00004 
00005 #include <qwidget.h>
00006 #include <qlayout.h>
00007 #include <qlabel.h>
00008 #include <qregexp.h>
00009 #include <qgroupbox.h>
00010 
00011 using Opie::Security::MultiauthConfigWidget;
00012 
00014 NoticeConfigWidget::NoticeConfigWidget(QWidget* parent = 0, const char* name = "Notice configuration widget") : MultiauthConfigWidget(parent, name)
00015 {
00016     QVBoxLayout *baseLayout = new QVBoxLayout( this);
00017     baseLayout->setSpacing(11);
00018     baseLayout->setMargin(6);
00019     baseLayout->setAlignment( Qt::AlignTop );
00020 
00021     QGroupBox *configBox = new QGroupBox(0, Qt::Vertical, tr("Set the message the user must accept"), this);
00022     baseLayout->addWidget(configBox);
00023     QVBoxLayout *boxLayout = new QVBoxLayout( configBox->layout() );
00024 
00025     QLabel * comment1 = new QLabel("<p><em>" + tr("You may want to consult your legal department for proper wording here.") + "</em></p>", configBox);
00026     boxLayout->addWidget(comment1);
00027 
00028     // Set the multilineedit box text to getNoticeText()
00029     noticeMLE = new QMultiLineEdit(configBox, "notice text");
00030     noticeMLE->setWordWrap(QMultiLineEdit::WidgetWidth);
00031     noticeMLE->setFocus();
00032     noticeMLE->setText(getNoticeText());
00033     boxLayout->addWidget(noticeMLE);
00034 
00035     resetNoticeButton = new QPushButton( tr("Reset notice to default"), configBox, "reset Notice Button" );
00036     connect(resetNoticeButton, SIGNAL( clicked() ), this, SLOT( resetNotice() ));
00037     boxLayout->addWidget(resetNoticeButton, 0, Qt::AlignHCenter);
00038 
00039     QLabel * comment2 = new QLabel("<p>" + tr("Note: you can use HTML tags to improve its layout (example: text between &lt;em&gt; and &lt;/em&gt; will be <em>emphasized</em>)") + "</p>", configBox);
00040     boxLayout->addWidget(comment2);
00041 
00042 }
00043 
00045 NoticeConfigWidget::~NoticeConfigWidget()
00046 {}
00047 
00049 void NoticeConfigWidget::writeConfig()
00050 {
00051     if ( noticeMLE->edited() ) {
00052         odebug << "writing new notice text in Security.conf" << oendl;
00053         setNoticeText(noticeMLE->text());
00054     }
00055 }
00056 
00058 void NoticeConfigWidget::resetNotice()
00059 {
00060     noticeMLE->setText(QObject::tr(defaultNoticeText));
00061 }
00062 
00064 
00067 QString NoticeConfigWidget::getNoticeText() {
00068     Config config("Security");
00069     config.setGroup("NoticePlugin");
00070     // Note: C++ processes '\' character, so we have to type \\\\ to mean \\ to QRegExp
00071     QString noticeText = config.readEntry("noticeText", QObject::tr(defaultNoticeText) ).replace( QRegExp("\\\\n"), "\n" );
00072     return noticeText;
00073 }
00074 
00076 void NoticeConfigWidget::setNoticeText(QString noticeText) {
00077     Config config("Security");
00078     config.setGroup("NoticePlugin");
00079     // since Config files do not allow true newlines, we replace them with litteral "\n"
00080     config.writeEntry("noticeText", noticeText.replace( QRegExp("\n"), "\\n" ));
00081 }

Generated on Sat Nov 5 16:17:46 2005 for OPIE by  doxygen 1.4.2