1 /***************************************************************************
2 * Copyright (C) 2005 by The Quassel Team *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
27 #include "channelwidget.h"
28 #include "serverlist.h"
29 #include "coreconnectdlg.h"
31 MainWin::MainWin() : QMainWindow() {
33 setWindowTitle("Quassel IRC");
34 setWindowIcon(QIcon(":/qirc-icon.png"));
35 setWindowIconText("Quassel IRC");
38 s.beginGroup("Geometry");
39 resize(s.value("MainWinSize", QSize(500, 400)).toSize());
40 move(s.value("MainWinPos", QPoint(50, 50)).toPoint());
43 workspace = new QWorkspace(this);
44 setCentralWidget(workspace);
45 //ChannelWidget *cw = new ChannelWidget(this);
46 //workspace->addWindow(cw);
47 //setCentralWidget(cw);
48 statusBar()->showMessage(tr("Waiting for core..."));
53 serverListDlg = new ServerListDlg(this);
54 serverListDlg->setVisible(serverListDlg->showOnStartup());
56 //identitiesAct = settingsMenu->addAction(QIcon(":/default/identity.png"), tr("&Identities..."), serverListDlg, SLOT(editIdentities()));
58 ChannelWidget *cw = new ChannelWidget(this);
59 //setCentralWidget(cw);
60 workspace->addWindow(cw);
63 statusBar()->showMessage(tr("Ready."));
64 //QSystemTrayIcon *systray = new QSystemTrayIcon(QIcon(":/qirc-icon.png"));
65 //systray->showMessage("Quassel", "Started!");
68 void MainWin::syncToCore() {
69 if(global->getData("CoreReady").toBool()) return;
70 // ok, apparently we are running as standalone GUI
71 coreConnectDlg = new CoreConnectDlg(this);
72 if(coreConnectDlg->exec() != QDialog::Accepted) {
76 VarMap state = coreConnectDlg->getCoreState().toMap()["CoreData"].toMap();
77 delete coreConnectDlg;
79 foreach(key, state.keys()) {
80 global->updateData(key, state[key]);
82 if(!global->getData("CoreReady").toBool()) {
83 QMessageBox::critical(this, tr("Fatal Error"), tr("<b>Could not synchronize with Quassel Core!</b><br>Quassel GUI will be aborted."), QMessageBox::Abort);
89 void MainWin::setupMenus() {
90 fileMenu = menuBar()->addMenu(tr("&File"));
91 serverListAct = fileMenu->addAction(QIcon(":/default/server.png"), tr("&Server List..."), this, SLOT(showServerList()), tr("F7"));
92 fileMenu->addSeparator();
93 quitAct = fileMenu->addAction(QIcon(":/default/exit.png"), tr("&Quit"), qApp, SLOT(quit()), tr("CTRL+Q"));
95 editMenu = menuBar()->addMenu(tr("&Edit"));
96 editMenu->setEnabled(0);
98 ircMenu = menuBar()->addMenu(tr("&IRC"));
99 ircMenu->setEnabled(0);
101 serverMenu = menuBar()->addMenu(tr("Ser&ver"));
102 serverMenu->setEnabled(0);
104 windowMenu = menuBar()->addMenu(tr("&Window"));
105 windowMenu->setEnabled(0);
107 settingsMenu = menuBar()->addMenu(tr("&Settings"));
108 identitiesAct = settingsMenu->addAction(QIcon(":/default/identity.png"), tr("&Identities..."), serverListDlg, SLOT(editIdentities()));
109 settingsMenu->addSeparator();
110 configAct = settingsMenu->addAction(QIcon(":/default/configure.png"), tr("&Configure Quassel..."));
111 configAct->setEnabled(0);
113 helpMenu = menuBar()->addMenu(tr("&Help"));
114 aboutAct = helpMenu->addAction(tr("&About"));
115 aboutAct->setEnabled(0);
116 aboutQtAct = helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
118 //toolBar = new QToolBar("Test", this);
119 //toolBar->addAction(identitiesAct);
120 //addToolBar(Qt::TopToolBarArea, toolBar);
123 void MainWin::showServerList() {
124 // if(!serverListDlg) {
125 // serverListDlg = new ServerListDlg(this);
127 serverListDlg->show();
130 void MainWin::closeEvent(QCloseEvent *event)
132 //if (userReallyWantsToQuit()) {
134 s.beginGroup("Geometry");
135 s.setValue("MainWinSize", size());
136 s.setValue("MainWinPos", pos());