summaryrefslogtreecommitdiff
path: root/noncore/net/opieirc/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/net/opieirc/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opieirc/mainwindow.cpp40
1 files changed, 28 insertions, 12 deletions
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp
index af4ce78..d78e5ab 100644
--- a/noncore/net/opieirc/mainwindow.cpp
+++ b/noncore/net/opieirc/mainwindow.cpp
@@ -6,11 +6,11 @@
6#include "mainwindow.h" 6#include "mainwindow.h"
7#include "ircservertab.h" 7#include "ircservertab.h"
8#include "ircserverlist.h" 8#include "ircserverlist.h"
9#include "ircsettings.h"
9 10
10MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { 11MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) {
11 setCaption(tr("IRC Client")); 12 setCaption(tr("IRC Client"));
12 m_tabWidget = new QTabWidget(this); 13 m_tabWidget = new QTabWidget(this);
13 connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(tabSelected(QWidget *)));
14 setCentralWidget(m_tabWidget); 14 setCentralWidget(m_tabWidget);
15 setToolBarsMovable(FALSE); 15 setToolBarsMovable(FALSE);
16 QPEMenuBar *menuBar = new QPEMenuBar(this); 16 QPEMenuBar *menuBar = new QPEMenuBar(this);
@@ -19,28 +19,33 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindo
19 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); 19 QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0);
20 connect(a, SIGNAL(activated()), this, SLOT(newConnection())); 20 connect(a, SIGNAL(activated()), this, SLOT(newConnection()));
21 a->addTo(irc); 21 a->addTo(irc);
22 a = new QAction(tr("Settings"), Resource::loadPixmap("SettingsIcon"), QString::null, 0, this, 0);
23 connect(a, SIGNAL(activated()), this, SLOT(settings()));
24 a->addTo(irc);
25 loadSettings();
22} 26}
23 27
24void MainWindow::tabSelected(QWidget *) { 28void MainWindow::loadSettings() {
25} 29 Config config("OpieIRC");
26 30 config.setGroup("OpieIRC");
27void MainWindow::closeTab() { 31 IRCTab::m_backgroundColor = config.readEntry("BackgroundColor", "#FFFFFF");
28 /* Does not directly close the tab but triggers an action 32 IRCTab::m_textColor = config.readEntry("TextColor", "#000000");
29 which at some point will close the tab using a callback */ 33 IRCTab::m_errorColor = config.readEntry("ErrorColor", "#FF0000");
30 IRCTab *tab = (IRCTab *)m_tabWidget->currentPage(); 34 IRCTab::m_selfColor = config.readEntry("SelfColor", "#CC0000");
31 if (tab) { 35 IRCTab::m_otherColor = config.readEntry("OtherColor", "#0000BB");
32 tab->remove(); 36 IRCTab::m_serverColor = config.readEntry("ServerColor", "#0000FF");
33 } 37 IRCTab::m_notificationColor = config.readEntry("NotificationColor", "#AA3300");
34} 38}
35 39
36void MainWindow::addTab(IRCTab *tab) { 40void MainWindow::addTab(IRCTab *tab) {
37 m_tabWidget->addTab(tab, tab->title()); 41 m_tabWidget->addTab(tab, tab->title());
38 m_tabWidget->showPage(tab); 42 m_tabWidget->showPage(tab);
39 tabSelected(tab); 43 m_tabs.append(tab);
40} 44}
41 45
42void MainWindow::killTab(IRCTab *tab) { 46void MainWindow::killTab(IRCTab *tab) {
43 m_tabWidget->removePage(tab); 47 m_tabWidget->removePage(tab);
48 m_tabs.remove(tab);
44 /* there might be nicer ways to do this .. */ 49 /* there might be nicer ways to do this .. */
45 delete tab; 50 delete tab;
46} 51}
@@ -53,3 +58,14 @@ void MainWindow::newConnection() {
53 serverTab->doConnect(); 58 serverTab->doConnect();
54 } 59 }
55} 60}
61
62void MainWindow::settings() {
63 IRCSettings settings(this, "Settings", TRUE);
64 if (settings.exec() == QDialog::Accepted) {
65 QListIterator<IRCTab> it(m_tabs);
66 for (; it.current(); ++it) {
67 /* Inform all tabs about the new settings */
68 it.current()->settingsChanged();
69 }
70 }
71}