X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=gui%2Fmainwin.cpp;h=66b575480c506218af69440e1d1b18af53cb80f5;hp=4dd5d2803c0d75cbf5fc5a4bd24dbf0ef72ee0a5;hb=a7afccdbf779b959a4ce3fe88ec42590e3df6cfe;hpb=925b072e5c7bc38949995902cf7af6e4644c2c55 diff --git a/gui/mainwin.cpp b/gui/mainwin.cpp index 4dd5d280..66b57548 100644 --- a/gui/mainwin.cpp +++ b/gui/mainwin.cpp @@ -19,28 +19,67 @@ ***************************************************************************/ #include +#include + +#include "global.h" #include "mainwin.h" #include "channelwidget.h" #include "serverlist.h" +#include "coreconnectdlg.h" MainWin::MainWin() : QMainWindow() { setWindowTitle("Quassel IRC"); - setWindowIcon(QIcon(":/default/tux.png")); + setWindowIcon(QIcon(":/qirc-icon.png")); setWindowIconText("Quassel IRC"); - workspace = new QWorkspace(this); - setCentralWidget(workspace); - ChannelWidget *cw = new ChannelWidget(this); - workspace->addWindow(cw); + + 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); + //workspace->addWindow(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() { @@ -72,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); @@ -85,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(); + //} +}