#include "global.h"
#include "qtuistyle.h"
+
MainWin::MainWin(QtUi *_gui, QWidget *parent)
: QMainWindow(parent),
gui(_gui),
sslLabel(new QLabel()),
+ _titleSetter(this),
systray(new QSystemTrayIcon(this)),
activeTrayIcon(":/icons/quassel-icon-active.png"),
onlineTrayIcon(":/icons/quassel-icon.png"),
ui.setupUi(this);
setWindowTitle("Quassel IRC");
setWindowIcon(offlineTrayIcon);
+ qApp->setWindowIcon(offlineTrayIcon);
systray->setIcon(offlineTrayIcon);
setWindowIconText("Quassel IRC");
Client::signalProxy()->attachSignal(this, SIGNAL(requestBacklog(BufferInfo, QVariant, QVariant)));
+ connect(QApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(saveLayout()));
+
connect(Client::instance(), SIGNAL(networkCreated(NetworkId)), this, SLOT(clientNetworkCreated(NetworkId)));
connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), this, SLOT(clientNetworkRemoved(NetworkId)));
//ui.bufferWidget->init();
// restore mainwin state
restoreState(s.value("MainWinState").toByteArray());
- disconnectedFromCore(); // Disable menus and stuff
+ setDisconnectedState(); // Disable menus and stuff
showCoreConnectionDlg(true); // autoconnect if appropriate
// attach the BufferWidget to the BufferModel and the default selection
ui.bufferWidget->setModel(Client::bufferModel());
ui.bufferWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
+ _titleSetter.setModel(Client::bufferModel());
+ _titleSetter.setSelectionModel(Client::bufferModel()->standardSelectionModel());
}
MainWin::~MainWin() {
addDockWidget(Qt::RightDockWidgetArea, nickDock);
ui.menuViews->addAction(nickDock->toggleViewAction());
- connect(nickDock->toggleViewAction(), SIGNAL(triggered(bool)), nickListWidget, SLOT(showWidget(bool)));
+ // See NickListDock::NickListDock();
+ // connect(nickDock->toggleViewAction(), SIGNAL(triggered(bool)), nickListWidget, SLOT(showWidget(bool)));
// attach the NickListWidget to the BufferModel and the default selection
nickListWidget->setModel(Client::bufferModel());
foreach(BufferInfo id, Client::allBufferInfos()) {
Client::backlogManager()->requestBacklog(id.bufferId(), 500, -1);
}
+ setConnectedState();
+}
+void MainWin::setConnectedState() {
ui.menuViews->setEnabled(true);
//ui.menuCore->setEnabled(true);
ui.actionConnectCore->setEnabled(false);
ui.bufferWidget->show();
statusBar()->showMessage(tr("Connected to core."));
setWindowIcon(onlineTrayIcon);
+ qApp->setWindowIcon(onlineTrayIcon);
systray->setIcon(onlineTrayIcon);
if(sslLabel->width() == 0)
sslLabel->setPixmap(QPixmap::fromImage(QImage(":/16x16/status/no-ssl")));
restoreState(s.value(QString("MainWinState-%1").arg(accountId)).toByteArray(), accountId);
}
+void MainWin::saveLayout() {
+ QtUiSettings s;
+ int accountId = Client::currentCoreAccount().toInt();
+ if(accountId > 0) s.setValue(QString("MainWinState-%1").arg(accountId) , saveState(accountId));
+}
+
void MainWin::securedConnection() {
// todo: make status bar entry
qDebug() << "secured the connection";
void MainWin::disconnectedFromCore() {
// save core specific layout and remove bufferviews;
- QtUiSettings s;
- int accountId = Client::currentCoreAccount().toInt();
- s.setValue(QString("MainWinState-%1").arg(accountId) , saveState(accountId));
+ saveLayout();
QVariant actionData;
BufferViewDock *dock;
foreach(QAction *action, ui.menuViews->actions()) {
dock->deleteLater();
}
}
+ QtUiSettings s;
+ restoreState(s.value("MainWinState").toByteArray());
+ setDisconnectedState();
+}
+void MainWin::setDisconnectedState() {
ui.menuViews->setEnabled(false);
//ui.menuCore->setEnabled(false);
ui.actionDisconnectCore->setEnabled(false);
// nickListWidget->reset();
statusBar()->showMessage(tr("Not connected to core."));
setWindowIcon(offlineTrayIcon);
+ qApp->setWindowIcon(offlineTrayIcon);
systray->setIcon(offlineTrayIcon);
sslLabel->setPixmap(QPixmap());
}
}
+
void MainWin::clientNetworkCreated(NetworkId id) {
const Network *net = Client::network(id);
QAction *act = new QAction(net->networkName(), this);