~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to src/mainwin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-08-28 18:46:52 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080828184652-iiik12dl91nq7cdi
Tags: 0.12-2
Uploading to unstable (Closes: Bug#494352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "mainwin.h"
22
22
 
23
 
#include <QDesktopServices>
24
23
#include <qmessagebox.h>
25
24
#include <qicon.h>
26
25
#include <qapplication.h>
36
35
#include <QVBoxLayout>
37
36
#include <QMenu>
38
37
#include <QMenuItem>
 
38
#include <QtAlgorithms>
39
39
 
40
40
#ifdef Q_WS_WIN
41
41
#include <windows.h>
58
58
#include "tipdlg.h"
59
59
#include "mucjoindlg.h"
60
60
#include "psicontactlist.h"
 
61
#include "desktoputil.h"
61
62
 
62
63
#include "mainwin_p.h"
63
64
 
64
65
using namespace XMPP;
65
66
 
66
 
// deletes submenus in a popupmenu
67
 
/*void qpopupmenuclear(QMenu *p)
68
 
{
69
 
        while(p->count()) {
70
 
                QMenuItem *item = p->findItem(p->idAt(0));
71
 
                QMenu *popup = item->menu();
72
 
                p->removeItemAt(0);
73
 
 
74
 
                if(popup)
75
 
                        delete popup;
76
 
        }
77
 
}*/
78
 
 
79
 
        
 
67
 
80
68
//----------------------------------------------------------------------------
81
69
// MainWin::Private
82
70
//----------------------------------------------------------------------------
87
75
        Private(PsiCon *, MainWin *);
88
76
        ~Private();
89
77
 
90
 
        QVBoxLayout *vb_main;
 
78
        QVBoxLayout* vb_main;
91
79
        bool onTop, asTool;
92
 
        QMenu *mainMenu, *statusMenu, *optionsMenu, *toolsMenu;
 
80
        QMenu* mainMenu, *statusMenu, *optionsMenu, *toolsMenu;
93
81
        int sbState;
94
82
        QString nickname;
95
 
        PsiTrayIcon *tray;
96
 
        QMenu *trayMenu;
 
83
        PsiTrayIcon* tray;
 
84
        QMenu* trayMenu;
97
85
        QString statusTip;
98
86
 
99
 
        PopupAction *optionsButton, *statusButton;
100
 
        IconActionGroup *statusGroup;
101
 
        EventNotifierAction *eventNotifier;
102
 
        PsiCon *psi;
103
 
        MainWin *mainWin;
104
 
 
105
 
        QSignalMapper *statusMapper;
106
 
 
107
 
        PsiIcon *nextAnim;
 
87
        PopupAction* optionsButton, *statusButton;
 
88
        IconActionGroup* statusGroup;
 
89
        EventNotifierAction* eventNotifier;
 
90
        PsiCon* psi;
 
91
        MainWin* mainWin;
 
92
 
 
93
        QLineEdit* searchText;
 
94
        QToolButton* searchPb;
 
95
        QWidget* searchWidget;
 
96
 
 
97
        QSignalMapper* statusMapper;
 
98
 
 
99
        PsiIcon* nextAnim;
108
100
        int nextAmount;
109
101
 
110
102
        QMap<QAction *, int> statusActions;
111
103
 
112
104
        int lastStatus;
113
105
        bool old_trayicon;
 
106
        bool filterActive, prefilterShowOffline, prefilterShowAway;
114
107
 
115
108
        void registerActions();
116
 
        IconAction *getAction( QString name );
117
 
        void updateMenu(QStringList actions, QMenu *menu);
 
109
        IconAction* getAction( QString name );
 
110
        void updateMenu(QStringList actions, QMenu* menu);
118
111
};
119
112
 
120
 
MainWin::Private::Private(PsiCon *_psi, MainWin *_mainWin)
 
113
MainWin::Private::Private(PsiCon* _psi, MainWin* _mainWin) : psi(_psi), mainWin(_mainWin)
121
114
{
122
 
        psi = _psi;
123
 
        mainWin = _mainWin;
124
115
 
125
116
        statusGroup   = (IconActionGroup *)getAction("status_all");
126
117
        eventNotifier = (EventNotifierAction *)getAction("event_notifier");
130
121
 
131
122
        statusMapper = new QSignalMapper(mainWin, "statusMapper");
132
123
        mainWin->connect(statusMapper, SIGNAL(mapped(int)), mainWin, SLOT(activatedStatusAction(int)));
 
124
  
 
125
        filterActive = false;
 
126
        prefilterShowOffline = false;
 
127
        prefilterShowAway = false;  
133
128
}
134
129
 
135
130
MainWin::Private::~Private()
139
134
void MainWin::Private::registerActions()
140
135
{
141
136
        struct {
142
 
                const char *name;
 
137
                const char* name;
143
138
                int id;
144
139
        } statuslist[] = {
145
140
                { "status_chat",      STATUS_CHAT      },
155
150
        int i;
156
151
        QString aName;
157
152
        for ( i = 0; !(aName = QString(statuslist[i].name)).isEmpty(); i++ ) {
158
 
                IconAction *action = getAction( aName );
 
153
                IconAction* action = getAction( aName );
159
154
                connect (action, SIGNAL(activated()), statusMapper, SLOT(map()));
160
155
 
161
156
                statusMapper->setMapping(action, statuslist[i].id);
168
163
        QStringList names = actions.actions();
169
164
        QStringList::Iterator it = names.begin();
170
165
        for ( ; it != names.end(); ++it ) {
171
 
                IconAction *action = actions.action( *it );
172
 
                if ( action )
 
166
                IconAction* action = actions.action( *it );
 
167
                if ( action ) {
173
168
                        mainWin->registerAction( action );
 
169
                }
174
170
        }
175
171
}
176
172
 
177
 
IconAction *MainWin::Private::getAction( QString name )
 
173
IconAction* MainWin::Private::getAction( QString name )
178
174
{
179
175
        PsiActionList::ActionsType type = PsiActionList::ActionsType( PsiActionList::Actions_MainWin | PsiActionList::Actions_Common );
180
176
        ActionList actions = psi->actionList()->suitableActions( type );
181
 
        IconAction *action = actions.action( name );
 
177
        IconAction* action = actions.action( name );
182
178
 
183
 
        if ( !action )
 
179
        if ( !action ) {
184
180
                qWarning("MainWin::Private::getAction(): action %s not found!", name.latin1());
 
181
        }
185
182
        //else
186
183
        //      mainWin->registerAction( action );
187
184
 
188
185
        return action;
189
186
}
190
187
 
191
 
void MainWin::Private::updateMenu(QStringList actions, QMenu *menu)
 
188
void MainWin::Private::updateMenu(QStringList actions, QMenu* menu)
192
189
{
193
190
        menu->clear();
194
191
 
195
 
        IconAction *action;
 
192
        IconAction* action;
196
193
        foreach (QString name, actions) {
197
194
                // workind around Qt/X11 bug, which displays
198
195
                // actions's text and the separator bar in Qt 4.1.1
200
197
                        menu->insertSeparator();
201
198
                        continue;
202
199
                }
203
 
                
204
 
                if ( (action = getAction(name)) )
 
200
 
 
201
                if ( name == "diagnostics" ) {
 
202
                        QMenu* diagMenu = new QMenu(mainWin);
 
203
                        menu->insertItem(tr("Diagnostics"), diagMenu);
 
204
                        getAction("help_diag_qcaplugin")->addTo(diagMenu);
 
205
                        getAction("help_diag_qcakeystore")->addTo(diagMenu);
 
206
                        continue;
 
207
                }
 
208
 
 
209
                if ( (action = getAction(name)) ) {
205
210
                        action->addTo(menu);
 
211
                }
206
212
        }
207
213
}
208
214
 
222
228
#define TOOLW_FLAGS ((Qt::WFlags) 0)
223
229
#endif
224
230
 
225
 
MainWin::MainWin(bool _onTop, bool _asTool, PsiCon *psi, const char *name)
226
 
:AdvancedWidget<Q3MainWindow>(0, (_onTop ? Qt::WStyle_StaysOnTop : Qt::Widget) | (_asTool ? (Qt::WStyle_Tool |TOOLW_FLAGS) : Qt::Widget))
227
 
//: Q3MainWindow(0,name,(_onTop ? Qt::WStyle_StaysOnTop : Qt::Widget) | (_asTool ? (Qt::WStyle_Tool |TOOLW_FLAGS) : Qt::Widget))
 
231
MainWin::MainWin(bool _onTop, bool _asTool, PsiCon* psi, const char* name)
 
232
:AdvancedWidget<QMainWindow>(0, (_onTop ? Qt::WStyle_StaysOnTop : Qt::Widget) | (_asTool ? (Qt::WStyle_Tool |TOOLW_FLAGS) : Qt::Widget))
228
233
{
229
234
        setObjectName(name);
230
235
        setAttribute(Qt::WA_AlwaysShowToolTips);
231
 
        if ( option.brushedMetal ) {
 
236
        if ( PsiOptions::instance()->getOption("options.ui.mac.use-brushed-metal-windows").toBool() ) {
232
237
                setAttribute(Qt::WA_MacMetalStyle);
233
238
        }
234
239
        d = new Private(psi, this);
256
261
        d->old_trayicon = PsiOptions::instance()->getOption("options.ui.systemtray.use-old").toBool();
257
262
#endif
258
263
 
259
 
        QWidget *center = new QWidget (this, "Central widget");
 
264
        QWidget* center = new QWidget (this, "Central widget");
260
265
        setCentralWidget ( center );
261
266
 
262
267
        d->vb_main = new QVBoxLayout(center);
270
275
        d->vb_main->setMargin(layoutMargin);
271
276
        d->vb_main->setSpacing(layoutMargin);
272
277
 
 
278
        // create search bar
 
279
        d->searchWidget = new QWidget(centralWidget());
 
280
        d->vb_main->addWidget(d->searchWidget);
 
281
        QHBoxLayout* searchLayout = new QHBoxLayout(d->searchWidget);
 
282
        searchLayout->setMargin(0);
 
283
        searchLayout->setSpacing(0);
 
284
        d->searchText = new QLineEdit(d->searchWidget);
 
285
        connect(d->searchText,SIGNAL(textEdited(const QString&)),SLOT(searchTextEntered(const QString&)));
 
286
        searchLayout->addWidget(d->searchText);
 
287
        d->searchPb = new QToolButton(d->searchWidget);
 
288
        d->searchPb->setText("X");
 
289
        connect(d->searchPb,SIGNAL(clicked()),SLOT(searchClearClicked()));
 
290
        connect(cvlist, SIGNAL(searchInput(const QString&)), SLOT(searchTextStarted(const QString&)));
 
291
        searchLayout->addWidget(d->searchPb);
 
292
        d->searchWidget->setVisible(false);
 
293
        //add contact view
273
294
        d->vb_main->addWidget(cvlist);
274
295
 
275
296
#ifdef Q_WS_MAC
311
332
 
312
333
        // Mac-only menus
313
334
#ifdef Q_WS_MAC
314
 
        QMenu *mainMenu = new QMenu(this);
 
335
        QMenu* mainMenu = new QMenu(this);
315
336
        mainMenuBar()->insertItem(tr("Menu"), mainMenu);
316
 
        mainMenu->insertItem(tr("Preferences"), this, SIGNAL(doOptions()));
317
 
        mainMenu->insertItem(tr("Quit"), this, SLOT(try2tryCloseProgram()));
 
337
        d->getAction("menu_options")->addTo(mainMenu);
 
338
        d->getAction("menu_quit")->addTo(mainMenu);
318
339
        d->getAction("help_about")->addTo(mainMenu);
319
340
        d->getAction("help_about_qt")->addTo(mainMenu);
320
341
 
327
348
 
328
349
        mainMenuBar()->insertItem(tr("Status"), d->statusMenu);
329
350
 
330
 
        QMenu *viewMenu = new QMenu(this);
 
351
        QMenu* viewMenu = new QMenu(this);
331
352
        mainMenuBar()->insertItem(tr("View"), viewMenu);
332
353
        d->getAction("show_offline")->addTo(viewMenu);
333
 
        if (PsiOptions::instance()->getOption("options.ui.menu.view.show-away").toBool())
 
354
        if (PsiOptions::instance()->getOption("options.ui.menu.view.show-away").toBool()) {
334
355
                d->getAction("show_away")->addTo(viewMenu);
 
356
        }
335
357
        d->getAction("show_hidden")->addTo(viewMenu);
336
358
        d->getAction("show_agents")->addTo(viewMenu);
337
359
        d->getAction("show_self")->addTo(viewMenu);
344
366
        mainMenuBar()->insertItem(tr("Tools"), d->toolsMenu);
345
367
        connect(d->toolsMenu, SIGNAL(aboutToShow()), SLOT(buildToolsMenu()));
346
368
 
347
 
        QMenu *helpMenu = new QMenu(this);
 
369
        QMenu* helpMenu = new QMenu(this);
348
370
        mainMenuBar()->insertItem(tr("Help"), helpMenu);
349
371
        d->getAction("help_readme")->addTo (helpMenu);
350
372
        d->getAction("help_tip")->addTo (helpMenu);
354
376
        d->getAction("help_online_home")->addTo (helpMenu);
355
377
        d->getAction("help_psi_muc")->addTo (helpMenu);
356
378
        d->getAction("help_report_bug")->addTo (helpMenu);
 
379
        QMenu* diagMenu = new QMenu(this);
 
380
        helpMenu->insertItem(tr("Diagnostics"), diagMenu);
 
381
        d->getAction("help_diag_qcaplugin")->addTo (diagMenu);
 
382
        d->getAction("help_diag_qcakeystore")->addTo (diagMenu);
357
383
#else
358
 
        if (option.hideMenubar) 
 
384
        if (!PsiOptions::instance()->getOption("options.ui.contactlist.show-menubar").toBool())  {
359
385
                mainMenuBar()->hide();
 
386
        }
360
387
        //else 
361
388
        //      mainMenuBar()->show();
362
389
#endif
363
390
        d->optionsButton->setMenu( d->optionsMenu );
364
391
        d->statusButton->setMenu( d->statusMenu );
365
 
        
 
392
 
366
393
        buildToolbars();
367
 
        
368
 
        setWindowOpacity(double(qMax(MINIMUM_OPACITY,PsiOptions::instance()->getOption("options.ui.contactlist.opacity").toInt()))/100);
 
394
        // setUnifiedTitleAndToolBarOnMac(true);
369
395
 
370
396
        connect(qApp, SIGNAL(dockActivated()), SLOT(dockActivated()));
371
397
 
372
 
        connect(PsiOptions::instance(), SIGNAL(optionChanged(const QString&)), SLOT(optionsUpdate()));
 
398
        connect(psi, SIGNAL(emitOptionsUpdate()), SLOT(optionsUpdate()));
 
399
        optionsUpdate();
373
400
}
374
 
        
375
401
 
376
402
MainWin::~MainWin()
377
403
{
382
408
                d->tray = 0;
383
409
        }
384
410
 
385
 
        //saveToolbarsPositions();
386
 
        // need to find some workaround to case, when you're logging off. in that case
387
 
        // toobars are all disabled, and when you start psi again you need to enable
388
 
        // your toolbars
389
 
 
 
411
        saveToolbarsState();
390
412
        delete d;
391
413
}
392
414
 
393
 
void MainWin::registerAction( IconAction *action )
 
415
void MainWin::registerAction( IconAction* action )
394
416
{
395
417
        char activated[] = SIGNAL( activated() );
396
418
        char toggled[]   = SIGNAL( toggled(bool) );
397
419
        char setChecked[]     = SLOT( setChecked(bool) );
398
420
 
399
421
        struct {
400
 
                const char *name;
401
 
                const char *signal;
402
 
                QObject *receiver;
403
 
                const char *slot;
 
422
                const char* name;
 
423
                const char* signal;
 
424
                QObject* receiver;
 
425
                const char* slot;
404
426
        } actionlist[] = {
405
427
                { "show_offline", toggled, cvlist, SLOT( setShowOffline(bool) ) },
406
428
                { "show_away",    toggled, cvlist, SLOT( setShowAway(bool) ) },
440
462
                { "help_report_bug",  activated, this, SLOT( actBugReportActivated() ) },
441
463
                { "help_about",       activated, this, SLOT( actAboutActivated() ) },
442
464
                { "help_about_qt",    activated, this, SLOT( actAboutQtActivated() ) },
 
465
                { "help_diag_qcaplugin",   activated, this, SLOT( actDiagQCAPluginActivated() ) },
 
466
                { "help_diag_qcakeystore", activated, this, SLOT( actDiagQCAKeyStoreActivated() ) },
443
467
 
444
468
                { "", 0, 0, 0 }
445
469
        };
450
474
                if ( aName == action->name() ) {
451
475
#ifdef USE_PEP
452
476
                        // Check before connecting, otherwise we get a loop
453
 
                        if ( aName == "publish_tune")
 
477
                        if ( aName == "publish_tune") {
454
478
                                action->setChecked( PsiOptions::instance()->getOption("options.extended-presence.tune.publish").toBool() );
 
479
                        }
455
480
#endif
456
481
 
457
482
                        disconnect( action, actionlist[i].signal, actionlist[i].receiver, actionlist[i].slot ); // for safety
458
483
                        connect( action, actionlist[i].signal, actionlist[i].receiver, actionlist[i].slot );
459
484
 
460
485
                        // special cases
461
 
                        if ( aName == "menu_play_sounds" )
462
 
                                action->setChecked( useSound );
 
486
                        if ( aName == "menu_play_sounds" ) {
 
487
                                action->setChecked(PsiOptions::instance()->getOption("options.ui.notifications.sounds.enable").toBool());
 
488
                        }
463
489
                        //else if ( aName == "foobar" )
464
490
                        //      ;
465
491
                }
466
492
        }
467
493
 
468
494
        struct {
469
 
                const char *name;
470
 
                QObject *sender;
471
 
                const char *signal;
472
 
                const char *slot;
 
495
                const char* name;
 
496
                QObject* sender;
 
497
                const char* signal;
 
498
                const char* slot;
 
499
                bool checked;
473
500
        } reverseactionlist[] = {
474
 
                { "show_away",    cvlist, SIGNAL( showAway(bool) ), setChecked },
475
 
                { "show_hidden",  cvlist, SIGNAL( showHidden(bool) ), setChecked },
476
 
                { "show_offline", cvlist, SIGNAL( showOffline(bool) ), setChecked },
477
 
                { "show_self",    cvlist, SIGNAL( showSelf(bool) ), setChecked },
478
 
                { "show_agents",  cvlist, SIGNAL( showAgents(bool) ), setChecked },
479
 
                { "show_statusmsg", cvlist, SIGNAL( showStatusMsg(bool) ), setChecked },
480
 
                { "", 0, 0, 0 }
 
501
                { "show_away",    cvlist, SIGNAL( showAway(bool) ), setChecked, cvlist->isShowAway()},
 
502
                { "show_hidden",  cvlist, SIGNAL( showHidden(bool) ), setChecked, cvlist->isShowHidden()},
 
503
                { "show_offline", cvlist, SIGNAL( showOffline(bool) ), setChecked, cvlist->isShowOffline()},
 
504
                { "show_self",    cvlist, SIGNAL( showSelf(bool) ), setChecked, cvlist->isShowSelf()},
 
505
                { "show_agents",  cvlist, SIGNAL( showAgents(bool) ), setChecked, cvlist->isShowAgents()},
 
506
                { "show_statusmsg", cvlist, SIGNAL( showStatusMsg(bool) ), setChecked, cvlist->isShowStatusMsg()},
 
507
                { "", 0, 0, 0, false }
481
508
        };
482
509
 
483
510
        for ( i = 0; !(aName = QString(reverseactionlist[i].name)).isEmpty(); i++ ) {
489
516
                                action->setChecked( PsiOptions::instance()->getOption("options.ui.contactlist.status-messages.show").toBool() );
490
517
                        }
491
518
                        else
492
 
                                action->setChecked( true );
 
519
                                action->setChecked( reverseactionlist[i].checked );
493
520
                }
494
521
        }
495
522
}
496
523
 
497
 
PsiCon *MainWin::psiCon() const
 
524
PsiCon* MainWin::psiCon() const
498
525
{
499
526
        return d->psi;
500
527
}
501
528
 
502
529
void MainWin::setWindowOpts(bool _onTop, bool _asTool)
503
530
{
504
 
        if(_onTop == d->onTop && _asTool == d->asTool)
 
531
        if(_onTop == d->onTop && _asTool == d->asTool) {
505
532
                return;
 
533
        }
506
534
 
507
535
        d->onTop = _onTop;
508
536
        d->asTool = _asTool;
509
537
 
510
538
        Qt::WFlags flags = 0;
511
 
        if(d->onTop)
 
539
        if(d->onTop) {
512
540
                flags |= Qt::WStyle_StaysOnTop;
513
 
        if(d->asTool)
 
541
        }
 
542
        if(d->asTool) {
514
543
                flags |= Qt::WStyle_Tool | TOOLW_FLAGS;
 
544
        }
515
545
 
516
546
        QPoint p = pos();
517
547
        reparent(parentWidget(), flags, p, FALSE);
521
551
 
522
552
void MainWin::setUseDock(bool use)
523
553
{
524
 
        if(use == false || d->tray) {
525
 
                if(d->tray) {
526
 
                        delete d->tray;
527
 
                        d->tray = 0;
 
554
        if (use == (d->tray != 0)) {
 
555
                return;
 
556
        }
 
557
 
 
558
        if (d->tray) {
 
559
                delete d->tray;
 
560
                d->tray = 0;
 
561
        }
 
562
 
 
563
        Q_ASSERT(!d->tray);
 
564
        if (use) {
 
565
                d->tray = new PsiTrayIcon("Psi", d->trayMenu, d->old_trayicon);
 
566
                if (d->old_trayicon) {
 
567
                        connect(d->tray, SIGNAL(closed()), SLOT(dockActivated()));
 
568
                        connect(qApp, SIGNAL(trayOwnerDied()), SLOT(dockActivated()));
528
569
                }
529
 
 
530
 
                if (use == false)
531
 
                        return;
532
 
        }
533
 
 
534
 
        if(d->tray)
535
 
                return;
536
 
 
537
 
        d->tray = new PsiTrayIcon("Psi", d->trayMenu, d->old_trayicon);
538
 
        if (d->old_trayicon) {
539
 
                connect(d->tray, SIGNAL(closed()), SLOT(dockActivated()));
540
 
                connect(qApp, SIGNAL(trayOwnerDied()), SLOT(dockActivated()));
541
 
        }
542
 
        connect(d->tray, SIGNAL(clicked(const QPoint &, int)), SLOT(trayClicked(const QPoint &, int)));
543
 
        connect(d->tray, SIGNAL(doubleClicked(const QPoint &)), SLOT(trayDoubleClicked()));
544
 
        d->tray->setIcon( PsiIconset::instance()->statusPtr( STATUS_OFFLINE ));
545
 
        d->tray->setToolTip(ApplicationInfo::name());
546
 
 
547
 
        updateReadNext(d->nextAnim, d->nextAmount);
548
 
 
549
 
        d->tray->show();
 
570
                connect(d->tray, SIGNAL(clicked(const QPoint &, int)), SLOT(trayClicked(const QPoint &, int)));
 
571
                connect(d->tray, SIGNAL(doubleClicked(const QPoint &)), SLOT(trayDoubleClicked()));
 
572
                d->tray->setIcon(PsiIconset::instance()->statusPtr(STATUS_OFFLINE));
 
573
                d->tray->setToolTip(ApplicationInfo::name());
 
574
 
 
575
                updateReadNext(d->nextAnim, d->nextAmount);
 
576
 
 
577
                d->tray->show();
 
578
        }
550
579
}
551
580
 
552
581
void MainWin::buildStatusMenu()
553
582
{
554
583
        d->statusMenu->clear();
555
584
        d->getAction("status_online")->addTo(d->statusMenu);
556
 
        if (PsiOptions::instance()->getOption("options.ui.menu.status.chat").toBool())
 
585
        if (PsiOptions::instance()->getOption("options.ui.menu.status.chat").toBool()) {
557
586
                d->getAction("status_chat")->addTo(d->statusMenu);
 
587
        }
558
588
        d->statusMenu->insertSeparator();
559
589
        d->getAction("status_away")->addTo(d->statusMenu);
560
 
        if (PsiOptions::instance()->getOption("options.ui.menu.status.xa").toBool())
 
590
        if (PsiOptions::instance()->getOption("options.ui.menu.status.xa").toBool()) {
561
591
                d->getAction("status_xa")->addTo(d->statusMenu);
 
592
        }
562
593
        d->getAction("status_dnd")->addTo(d->statusMenu);
563
594
        if (PsiOptions::instance()->getOption("options.ui.menu.status.invisible").toBool()) {
564
595
                d->statusMenu->insertSeparator();
576
607
{
577
608
        QObjectList l = d->statusGroup->queryList( "IconAction" );
578
609
        for (QObjectList::Iterator it = l.begin() ; it != l.end(); ++it) {
579
 
                IconAction *action = (IconAction *)(*it);
 
610
                IconAction* action = (IconAction *)(*it);
580
611
                action->setChecked ( d->statusActions[action] == id );
581
612
        }
582
613
 
592
623
#endif
593
624
}
594
625
 
 
626
const QString toolbarsStateOptionPath = "options.ui.contactlist.toolbars-state";
 
627
 
 
628
void MainWin::saveToolbarsState()
 
629
{
 
630
        PsiOptions::instance()->setOption(toolbarsStateOptionPath, saveState());
 
631
}
 
632
 
 
633
void MainWin::loadToolbarsState()
 
634
{
 
635
        restoreState(PsiOptions::instance()->getOption(toolbarsStateOptionPath).toByteArray());
 
636
}
 
637
 
595
638
void MainWin::buildToolbars()
596
639
{
597
 
        while ( option.toolbars["mainWin"].count() < toolbars.count() && toolbars.count() ) {
598
 
                PsiToolBar *tb = toolbars.last();
599
 
                toolbars.removeLast();
600
 
                delete tb;
601
 
        }
602
 
 
603
 
        for (int i = 0; i < option.toolbars["mainWin"].count(); i++) {
604
 
                PsiToolBar *tb = 0;
605
 
                if ( i < toolbars.count() )
606
 
                        tb = toolbars.at(i);
607
 
 
608
 
                Options::ToolbarPrefs &tbPref = option.toolbars["mainWin"][i];
609
 
                if ( tb && !tbPref.dirty )
610
 
                        continue;
611
 
 
612
 
                if ( tb )
613
 
                        delete tb;
614
 
 
615
 
                tb = new PsiToolBar(tbPref.name, this, d->psi);
616
 
                moveDockWindow ( tb, tbPref.dock, tbPref.nl, tbPref.index, tbPref. extraOffset );
617
 
 
618
 
                tb->setGroup( "mainWin", i );
619
 
                tb->setType( PsiActionList::Actions_MainWin );
620
 
                //connect( tb, SIGNAL( registerAction( IconAction * ) ), SLOT( registerAction( IconAction * ) ) );
621
 
                tb->initialize( tbPref, false );
622
 
 
623
 
                if ( i < toolbars.count() )
624
 
                        toolbars.removeAt(i);
625
 
                toolbars.insert(i, tb);
626
 
        }
627
 
}
628
 
 
629
 
void MainWin::saveToolbarsPositions()
630
 
{
631
 
        for (int i = 0; i < toolbars.count(); i++) {
632
 
                Options::ToolbarPrefs &tbPref = option.toolbars["mainWin"][i];
633
 
                getLocation ( toolbars.at(i), tbPref.dock, tbPref.index, tbPref.nl, tbPref.extraOffset );
634
 
                tbPref.on = toolbars.at(i)->isVisible();
 
640
        setUpdatesEnabled(false);
 
641
        if (toolbars_.count() > 0) {
 
642
                saveToolbarsState();
 
643
        }
 
644
 
 
645
        qDeleteAll(toolbars_);
 
646
        toolbars_.clear();
 
647
 
 
648
        foreach(QString base, PsiOptions::instance()->getChildOptionNames("options.ui.contactlist.toolbars", true, true)) {
 
649
                PsiToolBar* tb = new PsiToolBar(base, this, d->psi->actionList());
 
650
                tb->initialize();
 
651
                connect(tb, SIGNAL(customize()), d->psi, SLOT(doToolbars()));
 
652
                toolbars_ << tb;
 
653
        }
 
654
 
 
655
        loadToolbarsState();
 
656
 
 
657
        // loadToolbarsState also restores correct toolbar visibility,
 
658
        // we might want to override that
 
659
        foreach(PsiToolBar* tb, toolbars_) {
 
660
                tb->updateVisibility();
 
661
        }
 
662
 
 
663
        // d->eventNotifier->updateVisibility();
 
664
        setUpdatesEnabled(true);
 
665
 
 
666
        // in case we have floating toolbars, they have inherited the 'no updates enabled'
 
667
        // state. now we need to explicitly re-enable updates.
 
668
        foreach(PsiToolBar* tb, toolbars_) {
 
669
                tb->setUpdatesEnabled(true);
635
670
        }
636
671
}
637
672
 
643
678
void MainWin::buildOptionsMenu()
644
679
{
645
680
        // help menu
646
 
        QMenu *helpMenu = new QMenu(d->optionsMenu);
 
681
        QMenu* helpMenu = new QMenu(d->optionsMenu);
647
682
 
648
683
        QStringList actions;
649
684
        actions << "help_readme"
654
689
                << "help_online_home"
655
690
                << "help_psi_muc"
656
691
                << "help_report_bug"
 
692
                << "diagnostics"
657
693
                << "separator"
658
694
                << "help_about"
659
695
                << "help_about_qt";
673
709
        // main menu
674
710
        QStringList actions;
675
711
        actions << "menu_add_contact";
676
 
        if (PsiOptions::instance()->getOption("options.ui.message.enabled").toBool())
 
712
        if (PsiOptions::instance()->getOption("options.ui.message.enabled").toBool()) {
677
713
                actions << "menu_new_message";
 
714
        }
678
715
        actions << "menu_disco"
679
716
                << "menu_join_groupchat"
680
717
                << "separator"
681
718
                << "menu_account_setup";
682
 
        if (PsiOptions::instance()->getOption("options.ui.menu.main.change-profile").toBool())
 
719
        if (PsiOptions::instance()->getOption("options.ui.menu.main.change-profile").toBool()) {
683
720
                actions << "menu_change_profile";
 
721
        }
684
722
        actions << "menu_play_sounds";
685
723
 
686
724
        d->updateMenu(actions, d->mainMenu);
696
734
        d->updateMenu(actions, d->toolsMenu);
697
735
}
698
736
        
699
 
void MainWin::buildGeneralMenu(QMenu *menu)
 
737
void MainWin::buildGeneralMenu(QMenu* menu)
700
738
{
701
739
        // options menu
702
740
        QStringList actions;
703
741
        actions << "menu_add_contact";
704
 
        if (PsiOptions::instance()->getOption("options.ui.message.enabled").toBool())
 
742
        if (PsiOptions::instance()->getOption("options.ui.message.enabled").toBool()) {
705
743
                actions << "menu_new_message";
 
744
        }
706
745
        actions << "menu_disco"
707
746
                << "menu_join_groupchat"
708
747
                << "menu_account_setup"
709
748
                << "menu_options"
710
749
                << "menu_file_transfer";
711
 
        if (PsiOptions::instance()->getOption("options.ui.menu.main.change-profile").toBool())
 
750
        if (PsiOptions::instance()->getOption("options.ui.menu.main.change-profile").toBool()) {
712
751
                actions << "menu_change_profile";
 
752
        }
713
753
        actions << "menu_play_sounds";
714
754
 
715
755
        d->updateMenu(actions, menu);
717
757
 
718
758
void MainWin::actReadmeActivated ()
719
759
{
720
 
        ShowTextDlg *w = new ShowTextDlg(":/README");
 
760
        ShowTextDlg* w = new ShowTextDlg(":/README");
721
761
        w->setWindowTitle(CAP(tr("ReadMe")));
722
762
        w->show();
723
763
}
724
764
 
725
765
void MainWin::actOnlineHelpActivated ()
726
766
{
727
 
        QDesktopServices::openUrl(QUrl("http://psi-im.org/wiki/User_Guide"));
 
767
        DesktopUtil::openUrl("http://psi-im.org/wiki/User_Guide");
728
768
}
729
769
 
730
770
void MainWin::actOnlineWikiActivated ()
731
771
{
732
 
        QDesktopServices::openUrl(QUrl("http://psi-im.org/wiki"));
 
772
        DesktopUtil::openUrl("http://psi-im.org/wiki");
733
773
}
734
774
 
735
775
void MainWin::actOnlineHomeActivated ()
736
776
{
737
 
        QDesktopServices::openUrl(QUrl("http://psi-im.org"));
 
777
        DesktopUtil::openUrl("http://psi-im.org");
738
778
}
739
779
 
740
780
void MainWin::actJoinPsiMUCActivated()
741
781
{
742
 
        PsiAccount *account = d->psi->contactList()->defaultAccount();
743
 
        if(!account)
 
782
        PsiAccount* account = d->psi->contactList()->defaultAccount();
 
783
        if(!account) {
744
784
                return;
 
785
        }
745
786
 
746
 
        MUCJoinDlg *w = new MUCJoinDlg(d->psi, account);
747
 
        w->le_host->setText("conference.psi-im.org");
748
 
        w->le_room->setText("psi");
749
 
        w->show();
 
787
        account->actionJoin("psi@conference.psi-im.org");
750
788
}
751
789
 
752
790
void MainWin::actBugReportActivated ()
753
791
{
754
 
        QDesktopServices::openUrl(QUrl("http://psi-im.org/forum/forum/2"));
 
792
        DesktopUtil::openUrl("http://psi-im.org/forum/forum/2");
755
793
}
756
794
 
757
795
void MainWin::actAboutActivated ()
758
796
{
759
 
        AboutDlg *about = new AboutDlg();
 
797
        AboutDlg* about = new AboutDlg();
760
798
        about->show();
761
799
}
762
800
 
770
808
        QMessageBox::aboutQt(this);
771
809
}
772
810
 
 
811
void MainWin::actDiagQCAPluginActivated()
 
812
{
 
813
        QString dtext = QCA::pluginDiagnosticText();
 
814
        ShowTextDlg* w = new ShowTextDlg(dtext, true, false, this);
 
815
        w->setWindowTitle(CAP(tr("Security Plugins Diagnostic Text")));
 
816
        w->resize(560, 240);
 
817
        w->show();
 
818
}
 
819
 
 
820
void MainWin::actDiagQCAKeyStoreActivated()
 
821
{
 
822
        QString dtext = QCA::KeyStoreManager::diagnosticText();
 
823
        ShowTextDlg* w = new ShowTextDlg(dtext, true, false, this);
 
824
        w->setWindowTitle(CAP(tr("Key Storage Diagnostic Text")));
 
825
        w->resize(560, 240);
 
826
        w->show();
 
827
}
 
828
 
773
829
void MainWin::actPlaySoundsActivated (bool state)
774
830
{
775
 
        useSound = state;
 
831
        PsiOptions::instance()->setOption("options.ui.notifications.sounds.enable", state);
776
832
}
777
833
 
778
834
void MainWin::actPublishTuneActivated (bool state)
780
836
        PsiOptions::instance()->setOption("options.extended-presence.tune.publish",state);
781
837
}
782
838
 
783
 
void MainWin::activatedAccOption(PsiAccount *pa, int x)
 
839
void MainWin::activatedAccOption(PsiAccount* pa, int x)
784
840
{
785
 
        if(x == 0)
 
841
        if(x == 0) {
786
842
                pa->openAddUserDlg();
787
 
        else if(x == 2)
 
843
        }
 
844
        else if(x == 2) {
788
845
                pa->showXmlConsole();
789
 
        else if(x == 3)
 
846
        }
 
847
        else if(x == 3) {
790
848
                pa->doDisco();
 
849
        }
791
850
}
792
851
 
793
852
void MainWin::buildTrayMenu()
800
859
                d->trayMenu->insertSeparator();
801
860
        }
802
861
 
803
 
        if(isHidden())
 
862
        if(isHidden()) {
804
863
                d->trayMenu->insertItem(tr("Un&hide"), this, SLOT(trayShow()));
805
 
        else
 
864
        }
 
865
        else {
806
866
                d->trayMenu->insertItem(tr("&Hide"), this, SLOT(trayHide()));
 
867
        }
807
868
        d->optionsButton->addTo(d->trayMenu);
808
869
        d->trayMenu->insertItem(tr("Status"), d->statusMenu);
809
870
        
815
876
 
816
877
void MainWin::setTrayToolTip(int status)
817
878
{
818
 
        if (!d->tray)
 
879
        if (!d->tray) {
819
880
                return;
 
881
        }
820
882
        d->tray->setToolTip(QString("Psi - " + status2txt(status)));
821
883
}
822
884
 
825
887
        // update the 'change status' buttons
826
888
        QObjectList l = d->statusGroup->queryList( "IconAction" );
827
889
        for (QObjectList::Iterator it = l.begin() ; it != l.end(); ++it) {
828
 
                IconAction *action = (IconAction *)(*it);
 
890
                IconAction* action = (IconAction *)(*it);
829
891
                action->setChecked ( d->statusActions[action] == status );
830
892
        }
831
893
 
832
 
        if(d->lastStatus == status)
 
894
        if(d->lastStatus == status) {
833
895
                return;
 
896
        }
834
897
        d->lastStatus = status;
835
898
 
836
899
        if(status == -1) {
837
900
                d->statusButton->setText(tr("Connecting"));
838
 
                if (option.alertStyle != 0) {
 
901
                if (PsiOptions::instance()->getOption("options.ui.notifications.alert-style").toString() != "no") {
839
902
                        d->statusButton->setAlert(IconsetFactory::iconPtr("psi/connect"));
840
903
                        d->statusGroup->setPsiIcon(IconsetFactory::iconPtr("psi/connect"));
841
904
                }
869
932
 
870
933
void MainWin::tryCloseProgram()
871
934
{
872
 
        if(askQuit())
 
935
        if(askQuit()) {
873
936
                closeProgram();
 
937
        }
874
938
}
875
939
 
876
 
void MainWin::closeEvent(QCloseEvent *e)
 
940
void MainWin::closeEvent(QCloseEvent* e)
877
941
{
878
942
#ifdef Q_WS_MAC
879
943
        trayHide();
885
949
                return;
886
950
        }
887
951
 
888
 
        if(!askQuit())
 
952
        if(!askQuit()) {
889
953
                return;
 
954
        }
890
955
 
891
 
        emit geomChanged(saveableGeometry());
892
956
        closeProgram();
893
957
 
894
958
        e->accept();
895
959
#endif
896
960
}
897
961
 
898
 
void MainWin::keyPressEvent(QKeyEvent *e)
 
962
void MainWin::keyPressEvent(QKeyEvent* e)
899
963
{
900
964
#ifdef Q_WS_MAC
901
965
        bool allowed = true;
904
968
#endif
905
969
 
906
970
        bool closekey = false;
907
 
        if(e->key() == Qt::Key_Escape)
908
 
                closekey = true;
 
971
        if(e->key() == Qt::Key_Escape) {
 
972
                if (d->searchWidget->isVisible()) {
 
973
                        searchClearClicked();
 
974
                } else {
 
975
                        closekey = true;
 
976
                }
 
977
        }
909
978
#ifdef Q_WS_MAC
910
 
        else if(e->key() == Qt::Key_W && e->modifiers() & Qt::ControlModifier)
 
979
        else if(e->key() == Qt::Key_W && e->modifiers() & Qt::ControlModifier) {
911
980
                closekey = true;
 
981
        }
912
982
#endif
913
983
 
914
984
        if(allowed && closekey) {
922
992
 
923
993
#ifdef Q_WS_WIN
924
994
#include <windows.h>
925
 
bool MainWin::winEvent(MSG *msg, long *result)
 
995
bool MainWin::winEvent(MSG* msg, long* result)
926
996
{
927
997
        if (d->asTool && msg->message == WM_SYSCOMMAND && msg->wParam == SC_MINIMIZE) {
928
998
                hide(); // minimized toolwindows look bad on Windows, so let's just hide it instead
938
1008
{
939
1009
        QString str = "";
940
1010
 
941
 
        if(d->nextAmount > 0)
 
1011
        if(d->nextAmount > 0) {
942
1012
                str += "* ";
 
1013
        }
943
1014
 
944
 
        if(d->nickname.isEmpty())
 
1015
        if(d->nickname.isEmpty()) {
945
1016
                str += ApplicationInfo::name();
946
 
        else
 
1017
        }
 
1018
        else {
947
1019
                str += d->nickname;
 
1020
        }
948
1021
 
949
 
        if(str == caption())
 
1022
        if(str == caption()) {
950
1023
                return;
 
1024
        }
951
1025
 
952
1026
        setWindowTitle(str);
953
1027
}
959
1033
        decorateButton(status);
960
1034
 
961
1035
#ifndef Q_WS_MAC
962
 
        if (option.hideMenubar) 
 
1036
        if (!PsiOptions::instance()->getOption("options.ui.contactlist.show-menubar").toBool()) {
963
1037
                mainMenuBar()->hide();
964
 
        else 
 
1038
        }
 
1039
        else {
965
1040
                mainMenuBar()->show();
 
1041
        }
966
1042
#endif
967
 
        
 
1043
 
968
1044
        setWindowOpacity(double(qMax(MINIMUM_OPACITY,PsiOptions::instance()->getOption("options.ui.contactlist.opacity").toInt()))/100);
969
1045
 
970
1046
        buildStatusMenu();
974
1050
 
975
1051
void MainWin::toggleVisible()
976
1052
{
977
 
        if(!isHidden())
 
1053
        if(!isHidden()) {
978
1054
                trayHide();
979
 
        else
 
1055
        }
 
1056
        else {
980
1057
                trayShow();
 
1058
        }
981
1059
}
982
1060
 
983
 
void MainWin::setTrayToolTip(const Status &status, bool)
 
1061
void MainWin::setTrayToolTip(const Status& status, bool)
984
1062
{
985
 
        if (!d->tray)
 
1063
        if (!d->tray) {
986
1064
                return;
 
1065
        }
987
1066
        QString s = "Psi";
988
1067
 
989
1068
        QString show = status.show();
993
1072
        }
994
1073
 
995
1074
        QString text = status.status();
996
 
        if(!text.isEmpty())
 
1075
        if(!text.isEmpty()) {
997
1076
                s += ": "+text;
 
1077
        }
998
1078
 
999
1079
        d->tray->setToolTip(s);
1000
1080
}
1001
1081
 
1002
1082
void MainWin::trayClicked(const QPoint &, int button)
1003
1083
{
1004
 
        if(option.dockDCstyle)
 
1084
        if(PsiOptions::instance()->getOption("options.ui.systemtray.use-double-click").toBool()) {
1005
1085
                return;
 
1086
        }
1006
1087
 
1007
1088
        if(button == Qt::MidButton) {
1008
1089
                doRecvNextEvent();
1009
1090
                return;
1010
1091
        }
1011
1092
 
1012
 
        if(!isHidden())
 
1093
        if(!isHidden()) {
1013
1094
                trayHide();
1014
 
        else
 
1095
        }
 
1096
        else {
1015
1097
                trayShow();
 
1098
        }
1016
1099
}
1017
1100
 
1018
1101
void MainWin::trayDoubleClicked()
1019
1102
{
1020
 
        if(!option.dockDCstyle)
 
1103
        if(!PsiOptions::instance()->getOption("options.ui.systemtray.use-double-click").toBool()) {
1021
1104
                return;
 
1105
        }
1022
1106
 
1023
1107
        if(d->nextAmount > 0) {
1024
1108
                doRecvNextEvent();
1026
1110
        }
1027
1111
 
1028
1112
 
1029
 
        if(!isHidden())
 
1113
        if(!isHidden()) {
1030
1114
                trayHide();
1031
 
        else
 
1115
        }
 
1116
        else {
1032
1117
                trayShow();
 
1118
        }
1033
1119
}
1034
1120
 
1035
1121
void MainWin::trayShow()
1039
1125
 
1040
1126
void MainWin::trayHide()
1041
1127
{
1042
 
        emit geomChanged(saveableGeometry());
1043
1128
        hide();
1044
1129
}
1045
1130
 
1046
 
void MainWin::updateReadNext(PsiIcon *anim, int amount)
 
1131
void MainWin::updateReadNext(PsiIcon* anim, int amount)
1047
1132
{
1048
1133
        d->nextAnim = anim;
1049
 
        if(anim == 0)
 
1134
        if(anim == 0) {
1050
1135
                d->nextAmount = 0;
1051
 
        else
 
1136
        }
 
1137
        else {
1052
1138
                d->nextAmount = amount;
 
1139
        }
1053
1140
 
1054
1141
        if(d->nextAmount <= 0) {
1055
1142
                d->eventNotifier->hide();
1056
 
                d->eventNotifier->setText("");
 
1143
                d->eventNotifier->setMessage("");
1057
1144
        }
1058
1145
        else {
1059
 
                d->eventNotifier->setText(QString("<b>") + numEventsString(d->nextAmount) + "</b>");
 
1146
                d->eventNotifier->setMessage(QString("<b>") + numEventsString(d->nextAmount) + "</b>");
1060
1147
                d->eventNotifier->show();
1061
1148
                // make sure it shows
1062
1149
                //qApp->processEvents();
1069
1156
QString MainWin::numEventsString(int x) const
1070
1157
{
1071
1158
        QString s;
1072
 
        if(x <= 0)
 
1159
        if(x <= 0) {
1073
1160
                s = "";
1074
 
        else if(x == 1)
 
1161
        }
 
1162
        else if(x == 1) {
1075
1163
                s = tr("1 event received");
1076
 
        else
 
1164
        }
 
1165
        else {
1077
1166
                s = tr("%1 events received").arg(x);
 
1167
        }
1078
1168
 
1079
1169
        return s;
1080
1170
}
1081
1171
 
1082
1172
void MainWin::updateTray()
1083
1173
{
1084
 
        if(!d->tray)
 
1174
        if(!d->tray) {
1085
1175
                return;
 
1176
        }
1086
1177
 
1087
 
        if ( d->nextAmount > 0 )
 
1178
        if ( d->nextAmount > 0 ) {
1088
1179
                d->tray->setAlert(d->nextAnim);
1089
 
        else if ( d->lastStatus == -1 )
 
1180
        }
 
1181
        else if ( d->lastStatus == -1 ) {
1090
1182
                d->tray->setAlert(IconsetFactory::iconPtr("psi/connect"));
1091
 
        else
 
1183
        }
 
1184
        else {
1092
1185
                d->tray->setIcon(PsiIconset::instance()->statusPtr(d->lastStatus));
 
1186
        }
1093
1187
        
1094
1188
        buildTrayMenu();
1095
1189
        d->tray->setContextMenu(d->trayMenu);
1102
1196
 
1103
1197
void MainWin::statusClicked(int x)
1104
1198
{
1105
 
        if(x == Qt::MidButton)
 
1199
        if(x == Qt::MidButton) {
1106
1200
                recvNextEvent();
 
1201
        }
1107
1202
}
1108
1203
 
1109
1204
void MainWin::numAccountsChanged()
1128
1223
 
1129
1224
void MainWin::dockActivated()
1130
1225
{
1131
 
        if(isHidden())
 
1226
        if(isHidden()) {
1132
1227
                show();
1133
 
}
1134
 
 
 
1228
        }
 
1229
}
 
1230
 
 
1231
/**
 
1232
 * Called when the cancel is clicked or the search becomes empty.
 
1233
 * Cancels the search.
 
1234
 */ 
 
1235
void MainWin::searchClearClicked()
 
1236
{
 
1237
        d->searchWidget->setVisible(false);
 
1238
        d->searchText->clear();
 
1239
        cvlist->clearFilter();
 
1240
        if (d->filterActive)
 
1241
        {
 
1242
                d->getAction("show_offline")->setChecked(d->prefilterShowOffline);
 
1243
                d->getAction("show_away")->setChecked(d->prefilterShowAway);  
 
1244
        }
 
1245
        d->filterActive=false;  
 
1246
}
 
1247
 
 
1248
/**
 
1249
 * Called when the contactview has a keypress.
 
1250
 * Starts the search/filter process
 
1251
 */ 
 
1252
void MainWin::searchTextStarted(QString const& text)
 
1253
{
 
1254
        d->searchWidget->setVisible(true);
 
1255
        d->searchText->setText(d->searchText->text() + text);
 
1256
        searchTextEntered(d->searchText->text());
 
1257
        d->searchText->setFocus();
 
1258
}
 
1259
 
 
1260
/**
 
1261
 * Called when the search input is changed.
 
1262
 * Updates the search.
 
1263
 */ 
 
1264
void MainWin::searchTextEntered(QString const& text)
 
1265
{
 
1266
        if (!d->filterActive)
 
1267
        {
 
1268
                d->filterActive = true;
 
1269
                d->prefilterShowOffline = d->getAction("show_offline")->isChecked();
 
1270
                d->prefilterShowAway = d->getAction("show_away")->isChecked();
 
1271
                d->getAction("show_offline")->setChecked(true);
 
1272
                d->getAction("show_away")->setChecked(true);
 
1273
        }
 
1274
        if (text.isEmpty()) {
 
1275
                searchClearClicked();
 
1276
        } else {
 
1277
                
 
1278
                cvlist->setFilter(text);
 
1279
        }
 
1280
}
1135
1281
 
1136
1282
#ifdef Q_WS_MAC
1137
1283
void MainWin::setWindowIcon(const QPixmap&)
1140
1286
#else
1141
1287
void MainWin::setWindowIcon(const QPixmap& p)
1142
1288
{
1143
 
        Q3MainWindow::setWindowIcon(p);
 
1289
        QMainWindow::setWindowIcon(p);
1144
1290
}
1145
1291
#endif
1146
1292
 
1204
1350
 
1205
1351
        if ( children() ) {
1206
1352
                QObjectListIt it(*children());
1207
 
                register QObject *object;
1208
 
                QWidget *widget;
 
1353
                register QObject* object;
 
1354
                QWidget* widget;
1209
1355
                while ( it ) {                          // show all widget children
1210
1356
                        object = it.current();          //   (except popups and other toplevels)
1211
1357
                        ++it;