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

ircsettings.cpp

Go to the documentation of this file.
00001 
00002 #include "ircsettings.h"
00003 #include "irctab.h"
00004 #include "ircmisc.h"
00005 
00006 /* OPIE */
00007 #include <opie2/ocolorbutton.h>
00008 #include <opie2/otabwidget.h>
00009 #include <opie2/okeyconfigwidget.h>
00010 #include <qpe/qpeapplication.h>
00011 
00012 /* QT */
00013 #include <qvalidator.h>
00014 #include <qwhatsthis.h>
00015 #include <qcheckbox.h>
00016 
00017 using namespace Opie;
00018 using namespace Opie::Ui;
00019 IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp)
00020 {
00021     setCaption(tr("Settings") );
00022     m_config = new Config("OpieIRC");
00023     m_config->setGroup("OpieIRC");
00024     QHBoxLayout *l = new QHBoxLayout(this, 2, 2);
00025     OTabWidget *tw = new OTabWidget(this);
00026     l->addWidget(tw);
00027     /* General Configuration */
00028     QWidget *genwidget = new QWidget(tw);
00029     QGridLayout *layout = new QGridLayout(genwidget, 1, 4, 5, 0);
00030     QLabel *label = new QLabel(tr("Lines displayed :"), genwidget);
00031     layout->addWidget(label, 0, 0);
00032     m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget);
00033     QWhatsThis::add(m_lines, tr("Amount of lines to be displayed in chats before old lines get deleted - this is necessary to restrain memory consumption. Set to 0 if you don't need this"));
00034     QIntValidator *validator = new QIntValidator(this);
00035     validator->setTop(10000);
00036     validator->setBottom(0);
00037     m_lines->setValidator(validator);
00038     layout->addWidget(m_lines, 0, 1);
00039 
00040     /*
00041      * include timestamp
00042      */
00043     m_displayTime = new QCheckBox( tr("Display time in chat log"), genwidget );
00044     m_displayTime->setChecked( m_config->readBoolEntry("DisplayTime", false) );
00045     layout->addMultiCellWidget(m_displayTime, 1, 1, 0, 4 );
00046 
00047     // add a spacer
00048     layout->addItem( new QSpacerItem(1,1, QSizePolicy::Minimum,
00049                                      QSizePolicy::MinimumExpanding),
00050                      2, 0 );
00051 
00052     tw->addTab(genwidget, "opieirc/settings", tr("General"));
00053 
00054     /* Color configuration */
00055     QScrollView *view = new QScrollView(this);
00056     view->setResizePolicy(QScrollView::AutoOneFit);
00057     view->setFrameStyle( QFrame::NoFrame );
00058     QWidget *widget = new QWidget(view->viewport());
00059     view->addChild(widget);
00060     layout = new QGridLayout(widget, 7, 2, 5, 0);
00061     label = new QLabel(tr("Background color :"), widget);
00062     layout->addWidget(label, 0, 0);
00063     m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF"));
00064     QWhatsThis::add(m_background, tr("Background color to be used in chats"));
00065     layout->addWidget(m_background, 0, 1);
00066     label = new QLabel(tr("Normal text color :"), widget);
00067     layout->addWidget(label, 1, 0);
00068     m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000"));
00069     QWhatsThis::add(m_text, tr("Text color to be used in chats"));
00070     layout->addWidget(m_text, 1, 1);
00071     label = new QLabel(tr("Error color :"), widget);
00072     layout->addWidget(label, 2, 0);
00073     m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000"));
00074     QWhatsThis::add(m_error, tr("Text color to be used to display errors"));
00075     layout->addWidget(m_error, 2, 1);
00076     label = new QLabel(tr("Text written by yourself :"), widget);
00077     layout->addWidget(label, 3, 0);
00078     m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000"));
00079     QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself"));
00080     layout->addWidget(m_self, 3, 1);
00081     label = new QLabel(tr("Text written by others :"), widget);
00082     layout->addWidget(label, 4, 0);
00083     m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB"));
00084     QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others"));
00085     layout->addWidget(m_other, 4, 1);
00086     label = new QLabel(tr("Text written by the server :"), widget);
00087     layout->addWidget(label, 5, 0);
00088     m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF"));
00089     QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server"));
00090     layout->addWidget(m_server, 5, 1);
00091     label = new QLabel(tr("Notifications :"), widget);
00092     layout->addWidget(label, 6, 0);
00093     m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#006400"));
00094     QWhatsThis::add(m_notification, tr("Text color to be used to display notifications"));
00095     layout->addWidget(m_notification, 6, 1);
00096     tw->addTab(view, "opieirc/colors", tr("Colors"));
00097 
00098 
00099     /*
00100      * IRC EditLine KeyConfiguration
00101      */
00102     m_keyConf = new Opie::Ui::OKeyConfigWidget(tw, "KEyConfig GUI" );
00103     m_keyConf->setChangeMode( OKeyConfigWidget::Queue );
00104     m_keyConf->insert( tr("Keyboard Shortcuts"),
00105                        IRCHistoryLineEdit::keyConfigInstance() );
00106     m_keyConf->load();
00107     tw->addTab(m_keyConf, "SettingsIcon", tr("Keyboard Shortcuts") );
00108 
00109     tw->setCurrentTab( genwidget );
00110     QPEApplication::showDialog( this );
00111 }
00112 
00113 void IRCSettings::accept()
00114 {
00115     IRCTab::m_backgroundColor = m_background->color().name();
00116     IRCTab::m_textColor = m_text->color().name();
00117     IRCTab::m_errorColor = m_error->color().name();
00118     IRCTab::m_selfColor = m_self->color().name();
00119     IRCTab::m_otherColor = m_other->color().name();
00120     IRCTab::m_serverColor = m_server->color().name();
00121     IRCTab::m_notificationColor = m_notification->color().name();
00122     IRCTab::m_maxLines = m_lines->text().toInt();
00123     m_keyConf->save();
00124 
00125 
00126     m_config->writeEntry("BackgroundColor", IRCTab::m_backgroundColor);
00127     m_config->writeEntry("TextColor", IRCTab::m_textColor);
00128     m_config->writeEntry("ErrorColor", IRCTab::m_errorColor);
00129     m_config->writeEntry("SelfColor", IRCTab::m_selfColor);
00130     m_config->writeEntry("OtherColor", IRCTab::m_otherColor);
00131     m_config->writeEntry("ServerColor", IRCTab::m_serverColor);
00132     m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor);
00133     m_config->writeEntry("Lines", m_lines->text());
00134     m_config->writeEntry("DisplayTime", m_displayTime->isChecked() );
00135     IRCTab::setUseTimeStamps(m_displayTime->isChecked());
00136     IRCHistoryLineEdit::keyConfigInstance()->save();
00137 
00138     QDialog::accept();
00139 }
00140 
00141 IRCSettings::~IRCSettings()
00142 {
00143     delete m_config;
00144 }

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