summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/ircsettings.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieirc/ircsettings.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opieirc/ircsettings.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp
new file mode 100644
index 0000000..d1fef67
--- a/dev/null
+++ b/noncore/net/opieirc/ircsettings.cpp
@@ -0,0 +1,71 @@
1#include <qlayout.h>
2#include "ircsettings.h"
3#include "irctab.h"
4#include "ircmisc.h"
5#include <stdio.h>
6
7IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags f) : QDialog(parent, name, modal, f) {
8 m_config = new Config("OpieIRC");
9 m_config->setGroup("OpieIRC");
10
11 setCaption("Settings");
12 QGridLayout *layout = new QGridLayout(this, 7, 2, 5, 0);
13 QLabel *label = new QLabel(tr("Background color :"), this);
14 layout->addWidget(label, 0, 0);
15 m_background = new IRCFramedColorLabel(QColor(m_config->readEntry("BackgroundColor", "#FFFFFF")), this);
16 layout->addWidget(m_background, 0, 1);
17 label = new QLabel(tr("Normal text color :"), this);
18 layout->addWidget(label, 1, 0);
19 m_text = new IRCFramedColorLabel(m_config->readEntry("TextColor", "#000000"), this);
20 layout->addWidget(m_text, 1, 1);
21 label = new QLabel(tr("Error color :"), this);
22 layout->addWidget(label, 2, 0);
23 m_error = new IRCFramedColorLabel(m_config->readEntry("ErrorColor", "#FF0000"), this);
24 layout->addWidget(m_error, 2, 1);
25 label = new QLabel(tr("Text written by yourself :"), this);
26 layout->addWidget(label, 3, 0);
27 m_self = new IRCFramedColorLabel(m_config->readEntry("SelfColor", "#CC0000"), this);
28 layout->addWidget(m_self, 3, 1);
29 label = new QLabel(tr("Text written by others :"), this);
30 layout->addWidget(label, 4, 0);
31 m_other = new IRCFramedColorLabel(m_config->readEntry("OtherColor", "#0000BB"), this);
32 layout->addWidget(m_other, 4, 1);
33 label = new QLabel(tr("Text written by the server :"), this);
34 layout->addWidget(label, 5, 0);
35 m_server = new IRCFramedColorLabel(m_config->readEntry("ServerColor", "#0000FF"), this);
36 layout->addWidget(m_server, 5, 1);
37 label = new QLabel(tr("Notifications :"), this);
38 layout->addWidget(label, 6, 0);
39 m_notification = new IRCFramedColorLabel(m_config->readEntry("NotificationColor", "#AAE300"), this);
40 layout->addWidget(m_notification, 6, 1);
41 showMaximized();
42}
43
44QString IRCSettings::getColorString(QWidget *widget) {
45 QColor color = ((IRCFramedColorLabel *)widget)->color();
46 QString temp;
47 temp.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue());
48 return temp;
49}
50
51void IRCSettings::accept() {
52 IRCTab::m_backgroundColor = getColorString(m_background);
53 IRCTab::m_textColor = getColorString(m_text);
54 IRCTab::m_errorColor = getColorString(m_error);
55 IRCTab::m_selfColor = getColorString(m_self);
56 IRCTab::m_otherColor = getColorString(m_other);
57 IRCTab::m_serverColor = getColorString(m_server);
58 IRCTab::m_notificationColor = getColorString(m_notification);
59 m_config->writeEntry("BackgroundColor", getColorString(m_background));
60 m_config->writeEntry("TextColor", getColorString(m_text));
61 m_config->writeEntry("ErrorColor", getColorString(m_error));
62 m_config->writeEntry("SelfColor", getColorString(m_self));
63 m_config->writeEntry("OtherColor", getColorString(m_other));
64 m_config->writeEntry("ServerColor", getColorString(m_server));
65 m_config->writeEntry("NotificationColor", getColorString(m_notification));
66 QDialog::accept();
67}
68
69IRCSettings::~IRCSettings() {
70 delete m_config;
71}