~ubuntu-branches/ubuntu/jaunty/quassel/jaunty

« back to all changes in this revision

Viewing changes to src/qtopia/qtopiamainwin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2008-11-17 15:22:46 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20081117152246-3lwlpnr4r08910kv
Tags: 0.3.1-0ubuntu1
* New upstream release (LP: #271403)
* Drop all patches originated from upstream (quassel_*)
* Compile with non-builtin quassel icons
  + Introduce new quassel-data package
  + quassel and quassel-client depend on quassel-data
  + Don't manually enforce icon installation for desktop files in debian/rules
  + Add quassel_01_fix_iconloader.patch
* Drop perl build dependency, I have no clue why it was added in the first
  place. Neither changelog nor Bazaar knows, and since quassel compiles just
  fine without it, removing it should be save.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2005-08 by the Quassel Project                          *
3
 
 *   devel@quassel-irc.org                                                 *
4
 
 *                                                                         *
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.                                           *
9
 
 *                                                                         *
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.                          *
14
 
 *                                                                         *
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
 
 ***************************************************************************/
20
 
 
21
 
#include "qtopiamainwin.h"
22
 
 
23
 
#include "networkmodel.h"
24
 
#include "bufferviewwidget.h"
25
 
#include "nicklistwidget.h"
26
 
#include "chatline.h"
27
 
#include "clientbacklogmanager.h"
28
 
#include "coreconnectdlg.h"
29
 
#include "global.h"
30
 
#include "mainwidget.h"
31
 
#include "message.h"
32
 
#include "network.h"
33
 
#include "qtopiaui.h"
34
 
#include "signalproxy.h"
35
 
 
36
 
#include "ui_aboutdlg.h"
37
 
 
38
 
#include <Qtopia>
39
 
#include <QSoftMenuBar>
40
 
 
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();
45
 
 
46
 
#include "../../version.inc"
47
 
 
48
 
  Global::runMode = Global::ClientOnly;
49
 
  Global::defaultPort = 4242;
50
 
  Global::DEBUG = true;
51
 
 
52
 
  Network::setDefaultCodecForServer("ISO-8859-1");
53
 
  Network::setDefaultCodecForEncoding("UTF-8");
54
 
  Network::setDefaultCodecForDecoding("ISO-8859-15");
55
 
 
56
 
  QCoreApplication::setOrganizationDomain("quassel-irc.org");
57
 
  QCoreApplication::setApplicationName("Quassel IRC");
58
 
  QCoreApplication::setOrganizationName("Quassel Project");
59
 
 
60
 
  QtopiaUi *gui = new QtopiaUi(this);
61
 
  Client::init(gui);
62
 
 
63
 
  setWindowTitle("Quassel IRC");
64
 
  setWindowIcon(QIcon(":icons/quassel-icon.png"));
65
 
  setWindowIconText("Quassel IRC");
66
 
 
67
 
  mainWidget = new MainWidget(this);
68
 
  mainWidget->setModel(Client::bufferModel());
69
 
  mainWidget->setSelectionModel(Client::bufferModel()->standardSelectionModel());
70
 
  setCentralWidget(mainWidget);
71
 
 
72
 
  toolBar = new QToolBar(this);
73
 
  toolBar->setIconSize(QSize(16, 16));
74
 
  toolBar->setWindowTitle(tr("Show Toolbar"));
75
 
  addToolBar(toolBar);
76
 
 
77
 
  //bufferViewWidget = new BufferViewWidget(this);
78
 
  bufferViewWidget = 0;  // delayed creation to avoid QPainter warnings
79
 
  nickListWidget = new NickListWidget(this);
80
 
 
81
 
  connect(mainWidget, SIGNAL(currentChanged(BufferId)), this, SLOT(showBuffer(BufferId)));
82
 
 
83
 
  setupActions();
84
 
 
85
 
  init();
86
 
  //gui->init();
87
 
 
88
 
}
89
 
 
90
 
// at this point, client is fully initialized
91
 
void QtopiaMainWin::init() {
92
 
  showMaximized();
93
 
  CoreConnectDlg *dlg = new CoreConnectDlg(this);
94
 
  //setCentralWidget(dlg);
95
 
  dlg->showMaximized();
96
 
  dlg->exec();
97
 
}
98
 
 
99
 
QtopiaMainWin::~QtopiaMainWin() {
100
 
 
101
 
 
102
 
}
103
 
 
104
 
void QtopiaMainWin::closeEvent(QCloseEvent *event) {
105
 
#ifndef DEVELMODE
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);
109
 
  box->exec();
110
 
  if(box->clickedButton() == quit) event->accept();
111
 
  else event->ignore();
112
 
  box->deleteLater();
113
 
#else
114
 
  event->accept();
115
 
#endif
116
 
}
117
 
 
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);
122
 
 
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()));
130
 
 
131
 
  QSoftMenuBar::addMenuTo(this, menu);
132
 
}
133
 
 
134
 
void QtopiaMainWin::connectedToCore() {
135
 
  foreach(BufferInfo id, Client::allBufferInfos()) {
136
 
    Client::backlogManager()->requestBacklog(id.bufferId(), 500, -1);
137
 
  }
138
 
}
139
 
 
140
 
void QtopiaMainWin::disconnectedFromCore() {
141
 
 
142
 
 
143
 
}
144
 
 
145
 
AbstractUiMsg *QtopiaMainWin::layoutMsg(const Message &msg) {
146
 
  return new ChatLine(msg);
147
 
  //return 0;
148
 
}
149
 
 
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!
154
 
 
155
 
}
156
 
 
157
 
void QtopiaMainWin::showBufferView() {
158
 
  if(!bufferViewWidget) {
159
 
    bufferViewWidget = new BufferViewWidget(this);
160
 
    connect(mainWidget, SIGNAL(currentChanged(BufferId)), bufferViewWidget, SLOT(accept()));
161
 
  }
162
 
  bufferViewWidget->showMaximized();
163
 
}
164
 
 
165
 
void QtopiaMainWin::showNickList() {
166
 
  nickListWidget->showMaximized();
167
 
}
168
 
 
169
 
void QtopiaMainWin::showAboutDlg() {
170
 
  QDialog *dlg = new QDialog(this);
171
 
  dlg->setAttribute(Qt::WA_DeleteOnClose);
172
 
  Ui::AboutDlg ui;
173
 
  ui.setupUi(dlg);
174
 
  dlg->showMaximized();
175
 
}
176