X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=gui%2Fmainwin.cpp;h=66b575480c506218af69440e1d1b18af53cb80f5;hp=d67309d458b4d504a04214a92b9e697adf9696c1;hb=a7afccdbf779b959a4ce3fe88ec42590e3df6cfe;hpb=e368a1672c4f917bfa6adb52dae3b5ebfcd0db18 diff --git a/gui/mainwin.cpp b/gui/mainwin.cpp index d67309d4..66b57548 100644 --- a/gui/mainwin.cpp +++ b/gui/mainwin.cpp @@ -19,31 +19,67 @@ ***************************************************************************/ #include +#include + +#include "global.h" #include "mainwin.h" #include "channelwidget.h" #include "serverlist.h" - -#include "core.h" -#include "server.h" +#include "coreconnectdlg.h" MainWin::MainWin() : QMainWindow() { setWindowTitle("Quassel IRC"); - setWindowIcon(QIcon(":/default/tux.png")); + setWindowIcon(QIcon(":/qirc-icon.png")); setWindowIconText("Quassel IRC"); + + QSettings s; + s.beginGroup("Geometry"); + resize(s.value("MainWinSize", QSize(500, 400)).toSize()); + move(s.value("MainWinPos", QPoint(50, 50)).toPoint()); + s.endGroup(); + //workspace = new QWorkspace(this); //setCentralWidget(workspace); - ChannelWidget *cw = new ChannelWidget(this); + //ChannelWidget *cw = new ChannelWidget(this); //workspace->addWindow(cw); - setCentralWidget(cw); + //setCentralWidget(cw); + statusBar()->showMessage(tr("Waiting for core...")); + setEnabled(false); + show(); + syncToCore(); + setEnabled(true); serverListDlg = new ServerListDlg(this); serverListDlg->setVisible(serverListDlg->showOnStartup()); - //showServerList(); - setupMenus(); - statusBar()->showMessage(tr("Ready")); + //identitiesAct = settingsMenu->addAction(QIcon(":/default/identity.png"), tr("&Identities..."), serverListDlg, SLOT(editIdentities())); + //showServerList(); + ChannelWidget *cw = new ChannelWidget(this); + setCentralWidget(cw); + //setEnabled(true); + statusBar()->showMessage(tr("Ready.")); +} +void MainWin::syncToCore() { + if(global->getData("CoreReady").toBool()) return; + // ok, apparently we are running as standalone GUI + coreConnectDlg = new CoreConnectDlg(this); + if(coreConnectDlg->exec() != QDialog::Accepted) { + //qApp->quit(); + exit(1); + } + VarMap state = coreConnectDlg->getCoreState().toMap()["CoreData"].toMap(); + delete coreConnectDlg; + QString key; + foreach(key, state.keys()) { + global->updateData(key, state[key]); + } + if(!global->getData("CoreReady").toBool()) { + QMessageBox::critical(this, tr("Fatal Error"), tr("Could not synchronize with Quassel Core!
Quassel GUI will be aborted."), QMessageBox::Abort); + //qApp->quit(); + exit(1); + } } void MainWin::setupMenus() { @@ -75,7 +111,6 @@ void MainWin::setupMenus() { aboutAct->setEnabled(0); aboutQtAct = helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt())); - //toolBar = new QToolBar("Test", this); //toolBar->addAction(identitiesAct); //addToolBar(Qt::TopToolBarArea, toolBar); @@ -88,3 +123,16 @@ void MainWin::showServerList() { serverListDlg->show(); } +void MainWin::closeEvent(QCloseEvent *event) +{ + //if (userReallyWantsToQuit()) { + QSettings s; + s.beginGroup("Geometry"); + s.setValue("MainWinSize", size()); + s.setValue("MainWinPos", pos()); + s.endGroup(); + event->accept(); + //} else { + //event->ignore(); + //} +}