X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtopia%2Fqtopiamainwin.cpp;h=63880587b78be978ca3f4f6ddf4e215027089d48;hp=f41cda92cbf8ea72e47663263bdbbc70a5f46349;hb=f6f6f3e368543f0a4dce1dae772f161d7e357064;hpb=4e9a619ab2a22ce3c933fbb36122632debfd415a diff --git a/src/qtopia/qtopiamainwin.cpp b/src/qtopia/qtopiamainwin.cpp index f41cda92..63880587 100644 --- a/src/qtopia/qtopiamainwin.cpp +++ b/src/qtopia/qtopiamainwin.cpp @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-07 by The Quassel IRC Development Team * + * Copyright (C) 2005-07 by the Quassel IRC Team * * 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 * @@ -20,34 +20,40 @@ #include "qtopiamainwin.h" +#include "networkmodel.h" +#include "bufferviewwidget.h" +#include "nicklistwidget.h" +#include "chatline.h" #include "coreconnectdlg.h" #include "global.h" #include "mainwidget.h" #include "message.h" -#include "qtopiagui.h" +#include "qtopiaui.h" #include "signalproxy.h" +#include "ui_aboutdlg.h" + +#include +#include + // 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"); qRegisterMetaType("Message"); - qRegisterMetaType("BufferId"); + qRegisterMetaType("BufferInfo"); qRegisterMetaTypeStreamOperators("QVariant"); qRegisterMetaTypeStreamOperators("Message"); - qRegisterMetaTypeStreamOperators("BufferId"); + qRegisterMetaTypeStreamOperators("BufferInfo"); Global::runMode = Global::ClientOnly; QCoreApplication::setOrganizationDomain("quassel-irc.org"); QCoreApplication::setApplicationName("Quassel IRC"); - QCoreApplication::setOrganizationName("Quassel IRC Development Team"); + QCoreApplication::setOrganizationName("Quassel IRC Team"); - //Style::init(); - QtopiaGui *gui = new QtopiaGui(this); + QtopiaUi *gui = new QtopiaUi(this); Client::init(gui); - init(); - //gui->init(); setWindowTitle("Quassel IRC"); setWindowIcon(QIcon(":/qirc-icon.png")); @@ -56,17 +62,29 @@ QtopiaMainWin::QtopiaMainWin(QWidget *parent, Qt::WFlags flags) : QMainWindow(pa mainWidget = new MainWidget(this); setCentralWidget(mainWidget); - QToolBar *toolBar = new QToolBar(this); + NetworkModel *model = Client::networkModel(); + connect(model, SIGNAL(bufferSelected(Buffer *)), this, SLOT(showBuffer(Buffer *))); + + toolBar = new QToolBar(this); toolBar->setIconSize(QSize(16, 16)); - toolBar->addAction(QIcon(":icon/trash"), "Trash"); + toolBar->setWindowTitle(tr("Show Toolbar")); addToolBar(toolBar); + bufferViewWidget = new BufferViewWidget(this); + nickListWidget = new NickListWidget(this); + + setupActions(); + + init(); + //gui->init(); + } // at this point, client is fully initialized void QtopiaMainWin::init() { - Client::signalProxy()->attachSignal(this, SIGNAL(requestBacklog(BufferId, QVariant, QVariant))); + Client::signalProxy()->attachSignal(this, SIGNAL(requestBacklog(BufferInfo, QVariant, QVariant))); + showMaximized(); CoreConnectDlg *dlg = new CoreConnectDlg(this); //setCentralWidget(dlg); dlg->showMaximized(); @@ -78,10 +96,48 @@ QtopiaMainWin::~QtopiaMainWin() { } +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(BufferId id, Client::allBufferIds()) { + 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::networkModel()->selectBuffer(b); + } +#endif } void QtopiaMainWin::disconnectedFromCore() { @@ -90,10 +146,31 @@ void QtopiaMainWin::disconnectedFromCore() { } AbstractUiMsg *QtopiaMainWin::layoutMsg(const Message &msg) { - //return new ChatLine(msg); - return 0; + return new ChatLine(msg); + //return 0; } void QtopiaMainWin::showBuffer(Buffer *b) { + bufferViewWidget->hide(); 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(); +} +