Diffstat (limited to 'noncore/net/opieirc/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieirc/mainwindow.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/noncore/net/opieirc/mainwindow.cpp b/noncore/net/opieirc/mainwindow.cpp new file mode 100644 index 0000000..bc0b0d1 --- a/dev/null +++ b/noncore/net/opieirc/mainwindow.cpp | |||
@@ -0,0 +1,79 @@ | |||
1 | #include <qpe/qpemenubar.h> | ||
2 | #include <qpe/resource.h> | ||
3 | #include <qpe/config.h> | ||
4 | #include <qpopupmenu.h> | ||
5 | |||
6 | #include "mainwindow.h" | ||
7 | #include "ircservertab.h" | ||
8 | #include "ircserverlist.h" | ||
9 | |||
10 | MainWindow::MainWindow(QWidget *parent, const char *name, WFlags f) : QMainWindow(parent, name, f) { | ||
11 | setCaption(tr("IRC Client")); | ||
12 | m_tabWidget = new QTabWidget(this); | ||
13 | connect(m_tabWidget, SIGNAL(currentChanged(QWidget *)), this, SLOT(tabSelected(QWidget *))); | ||
14 | setCentralWidget(m_tabWidget); | ||
15 | setToolBarsMovable(FALSE); | ||
16 | QPEMenuBar *menuBar = new QPEMenuBar(this); | ||
17 | QPopupMenu *irc = new QPopupMenu(this); | ||
18 | menuBar->insertItem(tr("IRC"), irc); | ||
19 | QAction *a = new QAction(tr("New connection"), Resource::loadPixmap("pass"), QString::null, 0, this, 0); | ||
20 | connect(a, SIGNAL(activated()), this, SLOT(newConnection())); | ||
21 | a->addTo(irc); | ||
22 | |||
23 | m_joinAction = new QAction(tr("Join channel"), Resource::loadPixmap("forward"), QString::null, 0, this, 0); | ||
24 | m_joinAction->setEnabled(FALSE); | ||
25 | connect(m_joinAction, SIGNAL(activated()), this, SLOT(join())); | ||
26 | m_joinAction->addTo(irc); | ||
27 | } | ||
28 | |||
29 | void MainWindow::tabSelected(QWidget *) { | ||
30 | m_joinAction->setEnabled(TRUE); | ||
31 | } | ||
32 | |||
33 | void MainWindow::closeTab() { | ||
34 | /* Does not directly close the tab but triggers an action | ||
35 | which at some point will close the tab using a callback */ | ||
36 | IRCTab *tab = (IRCTab *)m_tabWidget->currentPage(); | ||
37 | if (tab) { | ||
38 | tab->remove(); | ||
39 | } | ||
40 | } | ||
41 | |||
42 | void MainWindow::join() { | ||
43 | IRCTab *tab = (IRCTab *)m_tabWidget->currentPage(); | ||
44 | if (tab) { | ||
45 | tab->session()->join("#opie.de"); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | void MainWindow::addTab(IRCTab *tab) { | ||
50 | m_tabWidget->addTab(tab, tab->title()); | ||
51 | m_tabWidget->showPage(tab); | ||
52 | tabSelected(tab); | ||
53 | } | ||
54 | |||
55 | void MainWindow::killTab(IRCTab *tab) { | ||
56 | m_tabWidget->removePage(tab); | ||
57 | /* there might be nicer ways to do this .. */ | ||
58 | delete tab; | ||
59 | } | ||
60 | |||
61 | void MainWindow::newConnection() { | ||
62 | IRCServer *server = new IRCServer(); | ||
63 | server->setHostname("irc.openprojects.net"); | ||
64 | server->setPort(6667); | ||
65 | server->setDescription("OpenProjects"); | ||
66 | server->setNick("opie-irc"); | ||
67 | server->setUsername("opie-irc"); | ||
68 | server->setRealname("opie-irc"); | ||
69 | IRCServerTab *serverTab = new IRCServerTab(server, this, m_tabWidget); | ||
70 | addTab(serverTab); | ||
71 | serverTab->doConnect(); | ||
72 | |||
73 | /* | ||
74 | * Serverlist : not functional yet | ||
75 | IRCServerList *list = new IRCServerList(this, "ServerList", TRUE); | ||
76 | list->exec(); | ||
77 | delete list; | ||
78 | */ | ||
79 | } | ||