/***************************************************************************
- * Copyright (C) 2005-07 by The Quassel IRC Development Team *
+ * Copyright (C) 2005-08 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
+ * (at your option) version 3. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
#include "qtopiamainwin.h"
-#include "buffertreemodel.h"
+#include "networkmodel.h"
#include "bufferviewwidget.h"
#include "nicklistwidget.h"
#include "chatline.h"
#include "qtopiaui.h"
#include "signalproxy.h"
+#include "ui_aboutdlg.h"
+
#include <Qtopia>
+#include <QSoftMenuBar>
// This constructor is the first thing to be called for a Qtopia app, so we do the init stuff
// here (rather than in a main.cpp).
QtopiaMainWin::QtopiaMainWin(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) {
- qRegisterMetaType<QVariant>("QVariant");
- qRegisterMetaType<Message>("Message");
- qRegisterMetaType<BufferInfo>("BufferInfo");
- qRegisterMetaTypeStreamOperators<QVariant>("QVariant");
- qRegisterMetaTypeStreamOperators<Message>("Message");
- qRegisterMetaTypeStreamOperators<BufferInfo>("BufferInfo");
+ Global::registerMetaTypes();
Global::runMode = Global::ClientOnly;
+ Global::defaultPort = 4242;
QCoreApplication::setOrganizationDomain("quassel-irc.org");
QCoreApplication::setApplicationName("Quassel IRC");
mainWidget = new MainWidget(this);
setCentralWidget(mainWidget);
- BufferTreeModel *model = Client::bufferModel();
+ NetworkModel *model = Client::networkModel();
connect(model, SIGNAL(bufferSelected(Buffer *)), this, SLOT(showBuffer(Buffer *)));
toolBar = new QToolBar(this);
toolBar->setIconSize(QSize(16, 16));
+ toolBar->setWindowTitle(tr("Show Toolbar"));
addToolBar(toolBar);
bufferViewWidget = new BufferViewWidget(this);
void QtopiaMainWin::init() {
Client::signalProxy()->attachSignal(this, SIGNAL(requestBacklog(BufferInfo, QVariant, QVariant)));
+ showMaximized();
CoreConnectDlg *dlg = new CoreConnectDlg(this);
//setCentralWidget(dlg);
dlg->showMaximized();
}
-void QtopiaMainWin::setupActions() {
- showBuffersAction = toolBar->addAction(QIcon(":icon/options-hide"), "Show Buffers", this, SLOT(showBufferView())); // FIXME provide real icon
- showNicksAction = toolBar->addAction(QIcon(":icon/list"), "Show Nicks", this, SLOT(showNickList()));
+void QtopiaMainWin::closeEvent(QCloseEvent *event) {
+#ifndef DEVELMODE
+ QMessageBox *box = new QMessageBox(QMessageBox::Question, tr("Quit Quassel IRC?"), tr("Do you really want to quit Quassel IRC?"),
+ QMessageBox::Cancel, this);
+ QAbstractButton *quit = box->addButton(tr("Quit"), QMessageBox::AcceptRole);
+ box->exec();
+ if(box->clickedButton() == quit) event->accept();
+ else event->ignore();
+ box->deleteLater();
+#else
+ event->accept();
+#endif
+}
+void QtopiaMainWin::setupActions() {
+ showBuffersAction = toolBar->addAction(QIcon(":icon/options-hide"), tr("Show Buffers"), this, SLOT(showBufferView())); // FIXME provide real icon
+ showNicksAction = toolBar->addAction(QIcon(":icon/list"), tr("Show Nicks"), this, SLOT(showNickList()));
+ showNicksAction->setEnabled(false);
+
+ QMenu *menu = new QMenu(this);
+ menu->addAction(showBuffersAction);
+ menu->addAction(showNicksAction);
+ menu->addSeparator();
+ menu->addAction(toolBar->toggleViewAction());
+ menu->addSeparator();
+ menu->addAction(tr("About..."), this, SLOT(showAboutDlg()));
+
+ QSoftMenuBar::addMenuTo(this, menu);
}
void QtopiaMainWin::connectedToCore() {
foreach(BufferInfo id, Client::allBufferInfos()) {
emit requestBacklog(id, 100, -1);
}
+
+#ifdef DEVELMODE
// FIXME just for testing: select first available buffer
if(Client::allBufferInfos().count() > 1) {
Buffer *b = Client::buffer(Client::allBufferInfos()[1]);
- Client::bufferModel()->selectBuffer(b);
+ Client::networkModel()->selectBuffer(b);
}
+#endif
}
void QtopiaMainWin::disconnectedFromCore() {
}
void QtopiaMainWin::showBuffer(Buffer *b) {
- mainWidget->setBuffer(b);
bufferViewWidget->hide();
- //nickListWidget->
+ mainWidget->setBuffer(b);
+ nickListWidget->setBuffer(b);
+ showNicksAction->setEnabled(b && b->bufferType() == Buffer::ChannelType);
}
void QtopiaMainWin::showBufferView() {
bufferViewWidget->showMaximized();
-
}
void QtopiaMainWin::showNickList() {
nickListWidget->showMaximized();
}
+void QtopiaMainWin::showAboutDlg() {
+ QDialog *dlg = new QDialog(this);
+ dlg->setAttribute(Qt::WA_DeleteOnClose);
+ Ui::AboutDlg ui;
+ ui.setupUi(dlg);
+ dlg->showMaximized();
+}