1
/***************************************************************************
2
* Copyright (C) 2005-08 by the Quassel Project *
3
* devel@quassel-irc.org *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) version 3. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
21
#include "qtopiamainwin.h"
23
#include "networkmodel.h"
24
#include "bufferviewwidget.h"
25
#include "nicklistwidget.h"
27
#include "clientbacklogmanager.h"
28
#include "coreconnectdlg.h"
30
#include "mainwidget.h"
34
#include "signalproxy.h"
36
#include "ui_aboutdlg.h"
39
#include <QSoftMenuBar>
41
// This constructor is the first thing to be called for a Qtopia app, so we do the init stuff
42
// here (rather than in a main.cpp).
43
QtopiaMainWin::QtopiaMainWin(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) {
44
Global::registerMetaTypes();
46
#include "../../version.inc"
48
Global::runMode = Global::ClientOnly;
49
Global::defaultPort = 4242;
52
Network::setDefaultCodecForServer("ISO-8859-1");
53
Network::setDefaultCodecForEncoding("UTF-8");
54
Network::setDefaultCodecForDecoding("ISO-8859-15");
56
QCoreApplication::setOrganizationDomain("quassel-irc.org");
57
QCoreApplication::setApplicationName("Quassel IRC");
58
QCoreApplication::setOrganizationName("Quassel Project");
60
QtopiaUi *gui = new QtopiaUi(this);
63
setWindowTitle("Quassel IRC");
64
setWindowIcon(QIcon(":icons/quassel-icon.png"));
65
setWindowIconText("Quassel IRC");
67
mainWidget = new MainWidget(this);
68
mainWidget->setModel(Client::bufferModel());
69
mainWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
70
setCentralWidget(mainWidget);
72
toolBar = new QToolBar(this);
73
toolBar->setIconSize(QSize(16, 16));
74
toolBar->setWindowTitle(tr("Show Toolbar"));
77
//bufferViewWidget = new BufferViewWidget(this);
78
bufferViewWidget = 0; // delayed creation to avoid QPainter warnings
79
nickListWidget = new NickListWidget(this);
81
connect(mainWidget, SIGNAL(currentChanged(BufferId)), this, SLOT(showBuffer(BufferId)));
90
// at this point, client is fully initialized
91
void QtopiaMainWin::init() {
93
CoreConnectDlg *dlg = new CoreConnectDlg(this);
94
//setCentralWidget(dlg);
99
QtopiaMainWin::~QtopiaMainWin() {
104
void QtopiaMainWin::closeEvent(QCloseEvent *event) {
106
QMessageBox *box = new QMessageBox(QMessageBox::Question, tr("Quit Quassel IRC?"), tr("Do you really want to quit Quassel IRC?"),
107
QMessageBox::Cancel, this);
108
QAbstractButton *quit = box->addButton(tr("Quit"), QMessageBox::AcceptRole);
110
if(box->clickedButton() == quit) event->accept();
111
else event->ignore();
118
void QtopiaMainWin::setupActions() {
119
showBuffersAction = toolBar->addAction(QIcon(":icon/options-hide"), tr("Show Buffers"), this, SLOT(showBufferView())); // FIXME provide real icon
120
showNicksAction = toolBar->addAction(QIcon(":icon/list"), tr("Show Nicks"), this, SLOT(showNickList()));
121
showNicksAction->setEnabled(false);
123
QMenu *menu = new QMenu(this);
124
menu->addAction(showBuffersAction);
125
menu->addAction(showNicksAction);
126
menu->addSeparator();
127
menu->addAction(toolBar->toggleViewAction());
128
menu->addSeparator();
129
menu->addAction(tr("About..."), this, SLOT(showAboutDlg()));
131
QSoftMenuBar::addMenuTo(this, menu);
134
void QtopiaMainWin::connectedToCore() {
135
foreach(BufferInfo id, Client::allBufferInfos()) {
136
Client::backlogManager()->requestBacklog(id.bufferId(), 500, -1);
140
void QtopiaMainWin::disconnectedFromCore() {
145
AbstractUiMsg *QtopiaMainWin::layoutMsg(const Message &msg) {
146
return new ChatLine(msg);
150
void QtopiaMainWin::showBuffer(BufferId id) {
151
nickListWidget->setBuffer(id);
152
Buffer *b = Client::buffer(id);
153
//showNicksAction->setEnabled(b && b->bufferInfo().type() == BufferInfo::ChannelBuffer); FIXME enable again when we have a nicklist!
157
void QtopiaMainWin::showBufferView() {
158
if(!bufferViewWidget) {
159
bufferViewWidget = new BufferViewWidget(this);
160
connect(mainWidget, SIGNAL(currentChanged(BufferId)), bufferViewWidget, SLOT(accept()));
162
bufferViewWidget->showMaximized();
165
void QtopiaMainWin::showNickList() {
166
nickListWidget->showMaximized();
169
void QtopiaMainWin::showAboutDlg() {
170
QDialog *dlg = new QDialog(this);
171
dlg->setAttribute(Qt::WA_DeleteOnClose);
174
dlg->showMaximized();