- QtUi::registerNotificationBackend(new DesktopNotificationBackend(this));
-#endif
-
- QtUiApplication* app = qobject_cast<QtUiApplication*> qApp;
- connect(app, SIGNAL(saveStateToSession(const QString&)), SLOT(saveStateToSession(const QString&)));
- connect(app, SIGNAL(saveStateToSessionSettings(SessionSettings&)), SLOT(saveStateToSessionSettings(SessionSettings&)));
-}
-
-void MainWin::init() {
- QtUiSettings s;
- if(s.value("MainWinSize").isValid())
- resize(s.value("MainWinSize").toSize());
- else
- resize(QSize(800, 500));
-
- connect(QApplication::instance(), SIGNAL(aboutToQuit()), SLOT(saveLayout()));
- connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), SLOT(clientNetworkCreated(NetworkId)));
- connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), SLOT(clientNetworkRemoved(NetworkId)));
-
- // Setup Dock Areas
- setDockNestingEnabled(true);
- setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
- setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
- setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
- setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
-
- // Order is sometimes important
- setupActions();
- setupBufferWidget();
- setupMenus();
- setupViews();
- setupTopicWidget();
- setupChatMonitor();
- setupNickWidget();
- setupInputWidget();
- setupStatusBar();
- setupSystray();
- setupTitleSetter();
-
- // restore mainwin state
- restoreState(s.value("MainWinState").toByteArray());
-
- // restore locked state of docks
- QtUi::actionCollection("General")->action("LockDockPositions")->setChecked(s.value("LockDocks", false).toBool());
-
- setDisconnectedState(); // Disable menus and stuff
-
- show();
-
- showCoreConnectionDlg(true); // autoconnect if appropriate
-}
-
-MainWin::~MainWin() {
- QtUiSettings s;
- s.setValue("MainWinSize", size());
- s.setValue("MainWinPos", pos());
- s.setValue("MainWinState", saveState());
-}
-
-void MainWin::updateIcon() {
- QPixmap icon;
- if(Client::isConnected())
- icon = DesktopIcon("quassel", IconLoader::SizeEnormous);
- else
- icon = DesktopIcon("quassel_disconnected", IconLoader::SizeEnormous);
- setWindowIcon(icon);
- qApp->setWindowIcon(icon);
- systemTrayIcon()->setIcon(icon);
-}
-
-void MainWin::setupActions() {
- ActionCollection *coll = QtUi::actionCollection("General");
- // File
- coll->addAction("ConnectCore", new Action(SmallIcon("network-connect"), tr("&Connect to Core..."), coll,
- this, SLOT(showCoreConnectionDlg())));
- coll->addAction("DisconnectCore", new Action(SmallIcon("network-disconnect"), tr("&Disconnect from Core"), coll,
- Client::instance(), SLOT(disconnectFromCore())));
- coll->addAction("CoreInfo", new Action(SmallIcon("help-about"), tr("Core &Info..."), coll,
- this, SLOT(showCoreInfoDlg())));
- coll->addAction("EditNetworks", new Action(SmallIcon("configure"), tr("Edit &Networks..."), coll,
- this, SLOT(on_actionEditNetworks_triggered())));
- coll->addAction("Quit", new Action(SmallIcon("application-exit"), tr("&Quit"), coll,
- qApp, SLOT(quit()), tr("Ctrl+Q")));
-
- // View
- coll->addAction("ManageBufferViews", new Action(SmallIcon("view-tree"), tr("&Manage Buffer Views..."), coll,
- this, SLOT(on_actionManageViews_triggered())));
- Action *lockAct = coll->addAction("LockDockPositions", new Action(tr("&Lock Dock Positions"), coll));
- lockAct->setCheckable(true);
- connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockDockPositions_toggled(bool)));
-
- coll->addAction("ToggleSearchBar", new Action(SmallIcon("edit-find"), tr("Show &Search Bar"), coll,
- 0, 0, tr("Ctrl+F")))->setCheckable(true);
- coll->addAction("ToggleStatusBar", new Action(tr("Show Status &Bar"), coll,
- 0, 0))->setCheckable(true);
-
- // Settings
- coll->addAction("ConfigureQuassel", new Action(SmallIcon("configure"), tr("&Configure Quassel..."), coll,
- this, SLOT(showSettingsDlg()), tr("F7")));
-
- // Help
- coll->addAction("AboutQuassel", new Action(SmallIcon("quassel"), tr("&About Quassel..."), coll,
- this, SLOT(showAboutDlg())));
- coll->addAction("AboutQt", new Action(tr("About &Qt..."), coll,
- qApp, SLOT(aboutQt())));
- coll->addAction("DebugNetworkModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &NetworkModel"), coll,
- this, SLOT(on_actionDebugNetworkModel_triggered())));
-}
-
-void MainWin::setupMenus() {
- ActionCollection *coll = QtUi::actionCollection("General");
-
- _fileMenu = menuBar()->addMenu(tr("&File"));
- _fileMenu->addAction(coll->action("ConnectCore"));
- _fileMenu->addAction(coll->action("DisconnectCore"));
- _fileMenu->addAction(coll->action("CoreInfo"));
- _fileMenu->addSeparator();
- _networksMenu = _fileMenu->addMenu(tr("&Networks"));
- _networksMenu->addAction(coll->action("EditNetworks"));
- _networksMenu->addSeparator();
- _fileMenu->addSeparator();
- _fileMenu->addAction(coll->action("Quit"));
-
- _viewMenu = menuBar()->addMenu(tr("&View"));
- _bufferViewsMenu = _viewMenu->addMenu(tr("&Buffer Views"));
- _bufferViewsMenu->addAction(coll->action("ManageBufferViews"));
- _viewMenu->addSeparator();
- _viewMenu->addAction(coll->action("ToggleSearchBar"));
- _viewMenu->addAction(coll->action("ToggleStatusBar"));
- _viewMenu->addSeparator();
- _viewMenu->addAction(coll->action("LockDockPositions"));
-
- _settingsMenu = menuBar()->addMenu(tr("&Settings"));
- _settingsMenu->addAction(coll->action("ConfigureQuassel"));