author | drw <drw> | 2002-12-30 00:52:51 (UTC) |
---|---|---|
committer | drw <drw> | 2002-12-30 00:52:51 (UTC) |
commit | c7bbdeed0daeda9af5115ffa0f1fb1026a338e2d (patch) (unidiff) | |
tree | 641b0a344cc9e274c39df282c4478dd74644d813 /noncore/net/opieirc/ircsettings.cpp | |
parent | 9ec4adfb12bd5c92427a79c6b63a064a0033a67a (diff) | |
download | opie-c7bbdeed0daeda9af5115ffa0f1fb1026a338e2d.zip opie-c7bbdeed0daeda9af5115ffa0f1fb1026a338e2d.tar.gz opie-c7bbdeed0daeda9af5115ffa0f1fb1026a338e2d.tar.bz2 |
Use OTabWidget & OColorButtons in config dialog for consistency w/other apps (reduces executable size by ~4k as well).
Diffstat (limited to 'noncore/net/opieirc/ircsettings.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieirc/ircsettings.cpp | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/noncore/net/opieirc/ircsettings.cpp b/noncore/net/opieirc/ircsettings.cpp index 78eaed3..b110a5b 100644 --- a/noncore/net/opieirc/ircsettings.cpp +++ b/noncore/net/opieirc/ircsettings.cpp | |||
@@ -1,104 +1,101 @@ | |||
1 | #include <opie/ocolorbutton.h> | ||
2 | #include <opie/otabwidget.h> | ||
1 | #include <qlayout.h> | 3 | #include <qlayout.h> |
2 | #include <qvalidator.h> | 4 | #include <qvalidator.h> |
3 | #include <qscrollview.h> | 5 | #include <qscrollview.h> |
4 | #include <qwhatsthis.h> | 6 | #include <qwhatsthis.h> |
5 | #include "ircsettings.h" | 7 | #include "ircsettings.h" |
6 | #include "irctab.h" | 8 | #include "irctab.h" |
7 | #include "ircmisc.h" | 9 | #include "ircmisc.h" |
8 | 10 | ||
9 | IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { | 11 | IRCSettings::IRCSettings(QWidget* parent, const char* name, bool modal, WFlags) : QDialog(parent, name, modal, WStyle_ContextHelp) { |
10 | setCaption("Settings"); | 12 | setCaption("Settings"); |
11 | m_config = new Config("OpieIRC"); | 13 | m_config = new Config("OpieIRC"); |
12 | m_config->setGroup("OpieIRC"); | 14 | m_config->setGroup("OpieIRC"); |
13 | QHBoxLayout *l = new QHBoxLayout(this, 2, 2); | 15 | QHBoxLayout *l = new QHBoxLayout(this, 2, 2); |
14 | QTabWidget *tw = new QTabWidget(this); | 16 | OTabWidget *tw = new OTabWidget(this); |
15 | l->addWidget(tw); | 17 | l->addWidget(tw); |
16 | /* General Configuration */ | 18 | /* General Configuration */ |
17 | QWidget *widget = new QWidget(tw); | 19 | QWidget *genwidget = new QWidget(tw); |
18 | QGridLayout *layout = new QGridLayout(widget, 1, 2, 5, 0); | 20 | QGridLayout *layout = new QGridLayout(genwidget, 1, 2, 5, 0); |
19 | QLabel *label = new QLabel(tr("Lines displayed :"), widget); | 21 | QLabel *label = new QLabel(tr("Lines displayed :"), genwidget); |
20 | layout->addWidget(label, 0, 0); | 22 | layout->addWidget(label, 0, 0); |
21 | m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), widget); | 23 | m_lines = new QLineEdit(m_config->readEntry("Lines", "100"), genwidget); |
22 | 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")); | 24 | 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")); |
23 | QIntValidator *validator = new QIntValidator(this); | 25 | QIntValidator *validator = new QIntValidator(this); |
24 | validator->setTop(10000); | 26 | validator->setTop(10000); |
25 | validator->setBottom(0); | 27 | validator->setBottom(0); |
26 | m_lines->setValidator(validator); | 28 | m_lines->setValidator(validator); |
27 | layout->addWidget(m_lines, 0, 1); | 29 | layout->addWidget(m_lines, 0, 1); |
28 | tw->addTab(widget, tr("General")); | 30 | tw->addTab(genwidget, "opieirc/settings", tr("General")); |
29 | 31 | ||
30 | /* Color configuration */ | 32 | /* Color configuration */ |
31 | QScrollView *view = new QScrollView(tw); | 33 | QScrollView *view = new QScrollView(this); |
32 | view->setResizePolicy(QScrollView::AutoOneFit); | 34 | view->setResizePolicy(QScrollView::AutoOneFit); |
33 | widget = new QWidget(view->viewport()); | 35 | view->setFrameStyle( QFrame::NoFrame ); |
36 | QWidget *widget = new QWidget(view->viewport()); | ||
34 | view->addChild(widget); | 37 | view->addChild(widget); |
35 | layout = new QGridLayout(widget, 7, 2, 5, 0); | 38 | layout = new QGridLayout(widget, 7, 2, 5, 0); |
36 | label = new QLabel(tr("Background color :"), widget); | 39 | label = new QLabel(tr("Background color :"), widget); |
37 | layout->addWidget(label, 0, 0); | 40 | layout->addWidget(label, 0, 0); |
38 | m_background = new IRCFramedColorLabel(QColor(m_config->readEntry("BackgroundColor", "#FFFFFF")), widget); | 41 | m_background = new OColorButton(widget, m_config->readEntry("BackgroundColor", "#FFFFFF")); |
39 | QWhatsThis::add(m_background, tr("Background color to be used in chats")); | 42 | QWhatsThis::add(m_background, tr("Background color to be used in chats")); |
40 | layout->addWidget(m_background, 0, 1); | 43 | layout->addWidget(m_background, 0, 1); |
41 | label = new QLabel(tr("Normal text color :"), widget); | 44 | label = new QLabel(tr("Normal text color :"), widget); |
42 | layout->addWidget(label, 1, 0); | 45 | layout->addWidget(label, 1, 0); |
43 | m_text = new IRCFramedColorLabel(m_config->readEntry("TextColor", "#000000"), widget); | 46 | m_text = new OColorButton(widget, m_config->readEntry("TextColor", "#000000")); |
44 | QWhatsThis::add(m_text, tr("Text color to be used in chats")); | 47 | QWhatsThis::add(m_text, tr("Text color to be used in chats")); |
45 | layout->addWidget(m_text, 1, 1); | 48 | layout->addWidget(m_text, 1, 1); |
46 | label = new QLabel(tr("Error color :"), widget); | 49 | label = new QLabel(tr("Error color :"), widget); |
47 | layout->addWidget(label, 2, 0); | 50 | layout->addWidget(label, 2, 0); |
48 | m_error = new IRCFramedColorLabel(m_config->readEntry("ErrorColor", "#FF0000"), widget); | 51 | m_error = new OColorButton(widget, m_config->readEntry("ErrorColor", "#FF0000")); |
49 | QWhatsThis::add(m_error, tr("Text color to be used to display errors")); | 52 | QWhatsThis::add(m_error, tr("Text color to be used to display errors")); |
50 | layout->addWidget(m_error, 2, 1); | 53 | layout->addWidget(m_error, 2, 1); |
51 | label = new QLabel(tr("Text written by yourself :"), widget); | 54 | label = new QLabel(tr("Text written by yourself :"), widget); |
52 | layout->addWidget(label, 3, 0); | 55 | layout->addWidget(label, 3, 0); |
53 | m_self = new IRCFramedColorLabel(m_config->readEntry("SelfColor", "#CC0000"), widget); | 56 | m_self = new OColorButton(widget, m_config->readEntry("SelfColor", "#CC0000")); |
54 | QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself")); | 57 | QWhatsThis::add(m_self, tr("Text color to be used to identify text written by yourself")); |
55 | layout->addWidget(m_self, 3, 1); | 58 | layout->addWidget(m_self, 3, 1); |
56 | label = new QLabel(tr("Text written by others :"), widget); | 59 | label = new QLabel(tr("Text written by others :"), widget); |
57 | layout->addWidget(label, 4, 0); | 60 | layout->addWidget(label, 4, 0); |
58 | m_other = new IRCFramedColorLabel(m_config->readEntry("OtherColor", "#0000BB"), widget); | 61 | m_other = new OColorButton(widget, m_config->readEntry("OtherColor", "#0000BB")); |
59 | QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others")); | 62 | QWhatsThis::add(m_other, tr("Text color to be used to identify text written by others")); |
60 | layout->addWidget(m_other, 4, 1); | 63 | layout->addWidget(m_other, 4, 1); |
61 | label = new QLabel(tr("Text written by the server :"), widget); | 64 | label = new QLabel(tr("Text written by the server :"), widget); |
62 | layout->addWidget(label, 5, 0); | 65 | layout->addWidget(label, 5, 0); |
63 | m_server = new IRCFramedColorLabel(m_config->readEntry("ServerColor", "#0000FF"), widget); | 66 | m_server = new OColorButton(widget, m_config->readEntry("ServerColor", "#0000FF")); |
64 | QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server")); | 67 | QWhatsThis::add(m_server, tr("Text color to be used to identify text written by the server")); |
65 | layout->addWidget(m_server, 5, 1); | 68 | layout->addWidget(m_server, 5, 1); |
66 | label = new QLabel(tr("Notifications :"), widget); | 69 | label = new QLabel(tr("Notifications :"), widget); |
67 | layout->addWidget(label, 6, 0); | 70 | layout->addWidget(label, 6, 0); |
68 | m_notification = new IRCFramedColorLabel(m_config->readEntry("NotificationColor", "#AAE300"), widget); | 71 | m_notification = new OColorButton(widget, m_config->readEntry("NotificationColor", "#AAE300")); |
69 | QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); | 72 | QWhatsThis::add(m_notification, tr("Text color to be used to display notifications")); |
70 | layout->addWidget(m_notification, 6, 1); | 73 | layout->addWidget(m_notification, 6, 1); |
71 | tw->addTab(view, tr("Colors")); | 74 | tw->addTab(view, "opieirc/colors", tr("Colors")); |
75 | tw->setCurrentTab( genwidget ); | ||
72 | showMaximized(); | 76 | showMaximized(); |
73 | } | 77 | } |
74 | 78 | ||
75 | QString IRCSettings::getColorString(QWidget *widget) { | ||
76 | QColor color = ((IRCFramedColorLabel *)widget)->color(); | ||
77 | QString temp; | ||
78 | temp.sprintf("#%02x%02x%02x", color.red(), color.green(), color.blue()); | ||
79 | return temp; | ||
80 | } | ||
81 | |||
82 | void IRCSettings::accept() { | 79 | void IRCSettings::accept() { |
83 | IRCTab::m_backgroundColor = getColorString(m_background); | 80 | IRCTab::m_backgroundColor = m_background->color().name(); |
84 | IRCTab::m_textColor = getColorString(m_text); | 81 | IRCTab::m_textColor = m_text->color().name(); |
85 | IRCTab::m_errorColor = getColorString(m_error); | 82 | IRCTab::m_errorColor = m_error->color().name(); |
86 | IRCTab::m_selfColor = getColorString(m_self); | 83 | IRCTab::m_selfColor = m_self->color().name(); |
87 | IRCTab::m_otherColor = getColorString(m_other); | 84 | IRCTab::m_otherColor = m_other->color().name(); |
88 | IRCTab::m_serverColor = getColorString(m_server); | 85 | IRCTab::m_serverColor = m_server->color().name(); |
89 | IRCTab::m_notificationColor = getColorString(m_notification); | 86 | IRCTab::m_notificationColor = m_notification->color().name(); |
90 | IRCTab::m_maxLines = m_lines->text().toInt(); | 87 | IRCTab::m_maxLines = m_lines->text().toInt(); |
91 | m_config->writeEntry("BackgroundColor", getColorString(m_background)); | 88 | m_config->writeEntry("BackgroundColor", IRCTab::m_backgroundColor); |
92 | m_config->writeEntry("TextColor", getColorString(m_text)); | 89 | m_config->writeEntry("TextColor", IRCTab::m_textColor); |
93 | m_config->writeEntry("ErrorColor", getColorString(m_error)); | 90 | m_config->writeEntry("ErrorColor", IRCTab::m_errorColor); |
94 | m_config->writeEntry("SelfColor", getColorString(m_self)); | 91 | m_config->writeEntry("SelfColor", IRCTab::m_selfColor); |
95 | m_config->writeEntry("OtherColor", getColorString(m_other)); | 92 | m_config->writeEntry("OtherColor", IRCTab::m_otherColor); |
96 | m_config->writeEntry("ServerColor", getColorString(m_server)); | 93 | m_config->writeEntry("ServerColor", IRCTab::m_serverColor); |
97 | m_config->writeEntry("NotificationColor", getColorString(m_notification)); | 94 | m_config->writeEntry("NotificationColor", IRCTab::m_notificationColor); |
98 | m_config->writeEntry("Lines", m_lines->text()); | 95 | m_config->writeEntry("Lines", m_lines->text()); |
99 | QDialog::accept(); | 96 | QDialog::accept(); |
100 | } | 97 | } |
101 | 98 | ||
102 | IRCSettings::~IRCSettings() { | 99 | IRCSettings::~IRCSettings() { |
103 | delete m_config; | 100 | delete m_config; |
104 | } | 101 | } |