~ubuntu-branches/ubuntu/vivid/quassel/vivid-updates

« back to all changes in this revision

Viewing changes to src/qtui/mainwin.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Michael Marley
  • Date: 2015-02-19 07:42:04 UTC
  • mfrom: (1.1.59)
  • Revision ID: package-import@ubuntu.com-20150219074204-vu1qv4i0devi2j2t
Tags: 0.12~beta1-0ubuntu1
[ Michael Marley ]
* New upstream kf5 based beta release
  - Drop patches debian/patches/CVE-2014-8483.patch,
    upstream_qca-qt5-cmake.patch and upstream_qca-qt5-code.patch
  - Add kf5 build-deps
  - Adjust install paths
* Fix upstart job to avoid race conditions on restart

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
 *   Copyright (C) 2005-2014 by the Quassel Project                        *
 
2
 *   Copyright (C) 2005-2015 by the Quassel Project                        *
3
3
 *   devel@quassel-irc.org                                                 *
4
4
 *                                                                         *
5
5
 *   This program is free software; you can redistribute it and/or modify  *
20
20
 
21
21
#include "mainwin.h"
22
22
 
 
23
#include <QIcon>
23
24
#include <QMenuBar>
24
25
#include <QMessageBox>
25
26
#include <QStatusBar>
26
27
#include <QToolBar>
 
28
#include <QInputDialog>
27
29
 
28
 
#ifdef HAVE_KDE
29
 
#  include <KAction>
30
 
#  include <KActionCollection>
 
30
#ifdef HAVE_KDE4
31
31
#  include <KHelpMenu>
32
32
#  include <KMenuBar>
33
33
#  include <KShortcutsDialog>
34
34
#  include <KStatusBar>
35
35
#  include <KToggleFullScreenAction>
36
36
#  include <KToolBar>
37
 
#  include <KWindowSystem>
 
37
#endif
 
38
 
 
39
#ifdef HAVE_KF5
 
40
#  include <KConfigWidgets/KStandardAction>
 
41
#  include <KXmlGui/KHelpMenu>
 
42
#  include <KXmlGui/KShortcutsDialog>
 
43
#  include <KXmlGui/KToolBar>
 
44
#  include <KWidgetsAddons/KToggleFullScreenAction>
38
45
#endif
39
46
 
40
47
#ifdef Q_WS_X11
74
81
#include "debuglogwidget.h"
75
82
#include "debugmessagemodelfilter.h"
76
83
#include "flatproxymodel.h"
77
 
#include "iconloader.h"
78
84
#include "inputwidget.h"
79
85
#include "irclistmodel.h"
80
86
#include "ircconnectionwizard.h"
146
152
 
147
153
MainWin::MainWin(QWidget *parent)
148
154
#ifdef HAVE_KDE
149
 
    : KMainWindow(parent),
150
 
    _kHelpMenu(new KHelpMenu(this, KGlobal::mainComponent().aboutData())),
 
155
    : KMainWindow(parent), _kHelpMenu(new KHelpMenu(this)),
151
156
#else
152
157
    : QMainWindow(parent),
153
158
#endif
192
197
    connect(Client::coreConnection(), SIGNAL(handleSslErrors(const QSslSocket *, bool *, bool *)), SLOT(handleSslErrors(const QSslSocket *, bool *, bool *)));
193
198
#endif
194
199
 
 
200
    connect(this, SIGNAL(changePassword(QString)), Client::instance(), SLOT(changePassword(QString)));
 
201
 
195
202
    // Setup Dock Areas
196
203
    setDockNestingEnabled(true);
197
204
    setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
337
344
 
338
345
void MainWin::updateIcon()
339
346
{
340
 
#ifdef Q_OS_MAC
341
 
    const int size = 128;
342
 
#else
343
 
    const int size = 48;
344
 
#endif
345
 
 
346
 
    QPixmap icon;
 
347
    QIcon icon;
347
348
    if (Client::isConnected())
348
 
        icon = DesktopIcon("quassel", size);
 
349
        icon = QIcon::fromTheme("quassel", QIcon(":/icons/quassel-128.png"));
349
350
    else
350
 
        icon = DesktopIcon("quassel-inactive", size);
 
351
        icon = QIcon::fromTheme("quassel-inactive", QIcon(":/icons/quassel-128.png"));
351
352
    setWindowIcon(icon);
352
353
    qApp->setWindowIcon(icon);
353
354
}
357
358
{
358
359
    ActionCollection *coll = QtUi::actionCollection("General", tr("General"));
359
360
    // File
360
 
    coll->addAction("ConnectCore", new Action(SmallIcon("network-connect"), tr("&Connect to Core..."), coll,
 
361
    coll->addAction("ConnectCore", new Action(QIcon::fromTheme("network-connect"), tr("&Connect to Core..."), coll,
361
362
            this, SLOT(showCoreConnectionDlg())));
362
 
    coll->addAction("DisconnectCore", new Action(SmallIcon("network-disconnect"), tr("&Disconnect from Core"), coll,
 
363
    coll->addAction("DisconnectCore", new Action(QIcon::fromTheme("network-disconnect"), tr("&Disconnect from Core"), coll,
363
364
            Client::instance(), SLOT(disconnectFromCore())));
364
 
    coll->addAction("CoreInfo", new Action(SmallIcon("help-about"), tr("Core &Info..."), coll,
 
365
    coll->addAction("ChangePassword", new Action(QIcon::fromTheme("dialog-password"), tr("Change &Password..."), coll,
 
366
            this, SLOT(showChangePasswordDialog())));
 
367
    coll->addAction("CoreInfo", new Action(QIcon::fromTheme("help-about"), tr("Core &Info..."), coll,
365
368
            this, SLOT(showCoreInfoDlg())));
366
 
    coll->addAction("ConfigureNetworks", new Action(SmallIcon("configure"), tr("Configure &Networks..."), coll,
 
369
    coll->addAction("ConfigureNetworks", new Action(QIcon::fromTheme("configure"), tr("Configure &Networks..."), coll,
367
370
            this, SLOT(on_actionConfigureNetworks_triggered())));
368
371
    // FIXME: use QKeySequence::Quit once we depend on Qt 4.6
369
 
    coll->addAction("Quit", new Action(SmallIcon("application-exit"), tr("&Quit"), coll,
 
372
    coll->addAction("Quit", new Action(QIcon::fromTheme("application-exit"), tr("&Quit"), coll,
370
373
            this, SLOT(quit()), Qt::CTRL + Qt::Key_Q));
371
374
 
372
375
    // View
377
380
    lockAct->setCheckable(true);
378
381
    connect(lockAct, SIGNAL(toggled(bool)), SLOT(on_actionLockLayout_toggled(bool)));
379
382
 
380
 
    coll->addAction("ToggleSearchBar", new Action(SmallIcon("edit-find"), tr("Show &Search Bar"), coll,
 
383
    coll->addAction("ToggleSearchBar", new Action(QIcon::fromTheme("edit-find"), tr("Show &Search Bar"), coll,
381
384
            0, 0, QKeySequence::Find))->setCheckable(true);
382
385
    coll->addAction("ShowAwayLog", new Action(tr("Show Away Log"), coll,
383
386
            this, SLOT(showAwayLog())));
384
 
    coll->addAction("ToggleMenuBar", new Action(SmallIcon("show-menu"), tr("Show &Menubar"), coll,
 
387
    coll->addAction("ToggleMenuBar", new Action(QIcon::fromTheme("show-menu"), tr("Show &Menubar"), coll,
385
388
            0, 0, QKeySequence(Qt::CTRL + Qt::Key_M)))->setCheckable(true);
386
389
 
387
390
    coll->addAction("ToggleStatusBar", new Action(tr("Show Status &Bar"), coll,
388
391
            0, 0))->setCheckable(true);
389
392
 
390
393
#ifdef HAVE_KDE
391
 
    QAction *fullScreenAct = KStandardAction::fullScreen(this, SLOT(onFullScreenToggled()), this, coll);
 
394
    _fullScreenAction = KStandardAction::fullScreen(this, SLOT(onFullScreenToggled()), this, coll);
392
395
#else
393
 
    QAction *fullScreenAct = new Action(SmallIcon("view-fullscreen"), tr("&Full Screen Mode"), coll,
 
396
    _fullScreenAction = new Action(QIcon::fromTheme("view-fullscreen"), tr("&Full Screen Mode"), coll,
394
397
        this, SLOT(onFullScreenToggled()), QKeySequence(Qt::Key_F11));
395
 
    fullScreenAct->setCheckable(true);
 
398
    _fullScreenAction->setCheckable(true);
 
399
    coll->addAction("ToggleFullScreen", _fullScreenAction);
396
400
#endif
397
 
    coll->addAction("ToggleFullScreen", fullScreenAct);
398
401
 
399
402
    // Settings
400
 
    QAction *configureShortcutsAct = new Action(SmallIcon("configure-shortcuts"), tr("Configure &Shortcuts..."), coll,
 
403
    QAction *configureShortcutsAct = new Action(QIcon::fromTheme("configure-shortcuts"), tr("Configure &Shortcuts..."), coll,
401
404
        this, SLOT(showShortcutsDlg()));
402
405
    configureShortcutsAct->setMenuRole(QAction::NoRole);
403
406
    coll->addAction("ConfigureShortcuts", configureShortcutsAct);
404
407
 
405
 
  #ifdef Q_OS_MAC
406
 
    QAction *configureQuasselAct = new Action(SmallIcon("configure"), tr("&Configure Quassel..."), coll,
 
408
#ifdef Q_OS_MAC
 
409
    QAction *configureQuasselAct = new Action(QIcon::fromTheme("configure"), tr("&Configure Quassel..."), coll,
407
410
        this, SLOT(showSettingsDlg()));
408
411
    configureQuasselAct->setMenuRole(QAction::PreferencesRole);
409
 
  #else
410
 
    QAction *configureQuasselAct = new Action(SmallIcon("configure"), tr("&Configure Quassel..."), coll,
 
412
#else
 
413
    QAction *configureQuasselAct = new Action(QIcon::fromTheme("configure"), tr("&Configure Quassel..."), coll,
411
414
        this, SLOT(showSettingsDlg()), QKeySequence(Qt::Key_F7));
412
 
  #endif
 
415
#endif
413
416
    coll->addAction("ConfigureQuassel", configureQuasselAct);
414
417
 
415
418
    // Help
416
 
    QAction *aboutQuasselAct = new Action(SmallIcon("quassel"), tr("&About Quassel"), coll,
 
419
    QAction *aboutQuasselAct = new Action(QIcon(":/icons/quassel.png"), tr("&About Quassel"), coll,
417
420
        this, SLOT(showAboutDlg()));
418
421
    aboutQuasselAct->setMenuRole(QAction::AboutRole);
419
422
    coll->addAction("AboutQuassel", aboutQuasselAct);
422
425
        qApp, SLOT(aboutQt()));
423
426
    aboutQtAct->setMenuRole(QAction::AboutQtRole);
424
427
    coll->addAction("AboutQt", aboutQtAct);
425
 
    coll->addAction("DebugNetworkModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &NetworkModel"), coll,
 
428
    coll->addAction("DebugNetworkModel", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &NetworkModel"), coll,
426
429
            this, SLOT(on_actionDebugNetworkModel_triggered())));
427
 
    coll->addAction("DebugBufferViewOverlay", new Action(SmallIcon("tools-report-bug"), tr("Debug &BufferViewOverlay"), coll,
 
430
    coll->addAction("DebugBufferViewOverlay", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &BufferViewOverlay"), coll,
428
431
            this, SLOT(on_actionDebugBufferViewOverlay_triggered())));
429
 
    coll->addAction("DebugMessageModel", new Action(SmallIcon("tools-report-bug"), tr("Debug &MessageModel"), coll,
 
432
    coll->addAction("DebugMessageModel", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &MessageModel"), coll,
430
433
            this, SLOT(on_actionDebugMessageModel_triggered())));
431
 
    coll->addAction("DebugHotList", new Action(SmallIcon("tools-report-bug"), tr("Debug &HotList"), coll,
 
434
    coll->addAction("DebugHotList", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &HotList"), coll,
432
435
            this, SLOT(on_actionDebugHotList_triggered())));
433
 
    coll->addAction("DebugLog", new Action(SmallIcon("tools-report-bug"), tr("Debug &Log"), coll,
 
436
    coll->addAction("DebugLog", new Action(QIcon::fromTheme("tools-report-bug"), tr("Debug &Log"), coll,
434
437
            this, SLOT(on_actionDebugLog_triggered())));
435
 
    coll->addAction("ReloadStyle", new Action(SmallIcon("view-refresh"), tr("Reload Stylesheet"), coll,
 
438
    coll->addAction("ReloadStyle", new Action(QIcon::fromTheme("view-refresh"), tr("Reload Stylesheet"), coll,
436
439
            QtUi::style(), SLOT(reload()), QKeySequence::Refresh));
437
440
 
438
441
    coll->addAction("HideCurrentBuffer", new Action(tr("Hide Current Buffer"), coll,
496
499
            QKeySequence(jumpModifier + Qt::Key_9)))->setProperty("Index", 9);
497
500
 
498
501
    // Buffer navigation
499
 
    coll->addAction("NextBufferView", new Action(SmallIcon("go-next-view"), tr("Activate Next Chat List"), coll,
 
502
    coll->addAction("NextBufferView", new Action(QIcon::fromTheme("go-next-view"), tr("Activate Next Chat List"), coll,
500
503
            this, SLOT(nextBufferView()), QKeySequence(QKeySequence::Forward)));
501
 
    coll->addAction("PreviousBufferView", new Action(SmallIcon("go-previous-view"), tr("Activate Previous Chat List"), coll,
 
504
    coll->addAction("PreviousBufferView", new Action(QIcon::fromTheme("go-previous-view"), tr("Activate Previous Chat List"), coll,
502
505
            this, SLOT(previousBufferView()), QKeySequence::Back));
503
 
    coll->addAction("NextBuffer", new Action(SmallIcon("go-down"), tr("Go to Next Chat"), coll,
 
506
    coll->addAction("NextBuffer", new Action(QIcon::fromTheme("go-down"), tr("Go to Next Chat"), coll,
504
507
            this, SLOT(nextBuffer()), QKeySequence(Qt::ALT + Qt::Key_Down)));
505
 
    coll->addAction("PreviousBuffer", new Action(SmallIcon("go-up"), tr("Go to Previous Chat"), coll,
 
508
    coll->addAction("PreviousBuffer", new Action(QIcon::fromTheme("go-up"), tr("Go to Previous Chat"), coll,
506
509
            this, SLOT(previousBuffer()), QKeySequence(Qt::ALT + Qt::Key_Up)));
507
510
}
508
511
 
514
517
    _fileMenu = menuBar()->addMenu(tr("&File"));
515
518
 
516
519
    static const QStringList coreActions = QStringList()
517
 
                                           << "ConnectCore" << "DisconnectCore" << "CoreInfo";
 
520
        << "ConnectCore" << "DisconnectCore" << "ChangePassword" << "CoreInfo";
518
521
 
519
522
    QAction *coreAction;
520
523
    foreach(QString actionName, coreActions) {
556
559
#endif
557
560
    _settingsMenu->addAction(coll->action("ConfigureQuassel"));
558
561
 
 
562
 
559
563
    _helpMenu = menuBar()->addMenu(tr("&Help"));
 
564
 
560
565
    _helpMenu->addAction(coll->action("AboutQuassel"));
561
566
#ifndef HAVE_KDE
562
567
    _helpMenu->addAction(coll->action("AboutQt"));
564
569
    _helpMenu->addAction(KStandardAction::aboutKDE(_kHelpMenu, SLOT(aboutKDE()), this));
565
570
#endif
566
571
    _helpMenu->addSeparator();
567
 
    _helpDebugMenu = _helpMenu->addMenu(SmallIcon("tools-report-bug"), tr("Debug"));
 
572
    _helpDebugMenu = _helpMenu->addMenu(QIcon::fromTheme("tools-report-bug"), tr("Debug"));
568
573
    _helpDebugMenu->addAction(coll->action("DebugNetworkModel"));
569
574
    _helpDebugMenu->addAction(coll->action("DebugBufferViewOverlay"));
570
575
    _helpDebugMenu->addAction(coll->action("DebugMessageModel"));
733
738
}
734
739
 
735
740
 
 
741
void MainWin::showChangePasswordDialog()
 
742
{
 
743
    if((Client::coreFeatures() & Quassel::PasswordChange)) {
 
744
        bool ok;
 
745
        QString newPassword = QInputDialog::getText(this, tr("Set Core Password"), tr("New password for your Quassel Core:"), QLineEdit::Password, QString(), &ok);
 
746
        if (ok && !newPassword.isEmpty()) {
 
747
            emit changePassword(newPassword);
 
748
        }
 
749
    }
 
750
    else {
 
751
        QMessageBox box(QMessageBox::Warning, tr("Feature Not Supported"),
 
752
                        tr("<b>Your Quassel Core does not support this feature</b>"),
 
753
                        QMessageBox::Ok, this);
 
754
        box.setInformativeText(tr("You need a Quassel Core v0.12.0 or newer in order to be able to remotely change your password."));
 
755
        box.exec();
 
756
    }
 
757
}
 
758
 
 
759
 
736
760
void MainWin::changeActiveBufferView(bool backwards)
737
761
{
738
762
    BufferView *current = activeBufferView();
923
947
void MainWin::setupViewMenuTail()
924
948
{
925
949
    _viewMenu->addSeparator();
926
 
    _viewMenu->addAction(QtUi::actionCollection("General")->action("ToggleFullScreen"));
 
950
    _viewMenu->addAction(_fullScreenAction);
927
951
}
928
952
 
929
953
 
1055
1079
 
1056
1080
    coll->action("ConnectCore")->setEnabled(false);
1057
1081
    coll->action("DisconnectCore")->setEnabled(true);
 
1082
    coll->action("ChangePassword")->setEnabled(true);
1058
1083
    coll->action("CoreInfo")->setEnabled(true);
1059
1084
 
1060
1085
    foreach(QAction *action, _fileMenu->actions()) {
1171
1196
    coll->action("ConnectCore")->setEnabled(true);
1172
1197
    coll->action("DisconnectCore")->setEnabled(false);
1173
1198
    coll->action("CoreInfo")->setEnabled(false);
 
1199
    coll->action("ChangePassword")->setEnabled(false);
1174
1200
    //_viewMenu->setEnabled(false);
1175
1201
    statusBar()->showMessage(tr("Not connected to core."));
1176
1202
    if (_msgProcessorStatusWidget)
1373
1399
    KShortcutsDialog dlg(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsDisallowed, this);
1374
1400
    foreach(KActionCollection *coll, QtUi::actionCollections())
1375
1401
    dlg.addCollection(coll, coll->property("Category").toString());
1376
 
    dlg.exec();
 
1402
    dlg.configure(true);
1377
1403
#else
1378
1404
    SettingsPageDlg dlg(new ShortcutsSettingsPage(QtUi::actionCollections(), this), this);
1379
1405
    dlg.exec();
1393
1419
    // Relying on QWidget::isFullScreen is discouraged, see the KToggleFullScreenAction docs
1394
1420
    // Also, one should not use showFullScreen() or showNormal(), as those reset all other window flags
1395
1421
 
1396
 
    QAction *action = QtUi::actionCollection("General")->action("ToggleFullScreen");
1397
 
    if (!action)
1398
 
        return;
1399
 
 
1400
1422
#ifdef HAVE_KDE
1401
 
    KToggleFullScreenAction *kAct = static_cast<KToggleFullScreenAction *>(action);
1402
 
    kAct->setFullScreen(this, kAct->isChecked());
 
1423
    static_cast<KToggleFullScreenAction*>(_fullScreenAction)->setFullScreen(this, _fullScreenAction->isChecked());
1403
1424
#else
1404
 
    if (action->isChecked())
 
1425
    if (_fullScreenAction->isChecked())
1405
1426
        setWindowState(windowState() | Qt::WindowFullScreen);
1406
1427
    else
1407
1428
        setWindowState(windowState() & ~Qt::WindowFullScreen);
1564
1585
 
1565
1586
    switch (net->connectionState()) {
1566
1587
    case Network::Initialized:
1567
 
        action->setIcon(SmallIcon("network-connect"));
 
1588
        action->setIcon(QIcon::fromTheme("network-connect"));
1568
1589
        // if we have no currently selected buffer, jump to the first connecting statusbuffer
1569
1590
        if (!bufferWidget()->currentBuffer().isValid()) {
1570
1591
            QModelIndex idx = Client::networkModel()->networkIndex(net->networkId());
1575
1596
        }
1576
1597
        break;
1577
1598
    case Network::Disconnected:
1578
 
        action->setIcon(SmallIcon("network-disconnect"));
 
1599
        action->setIcon(QIcon::fromTheme("network-disconnect"));
1579
1600
        break;
1580
1601
    default:
1581
 
        action->setIcon(SmallIcon("network-wired"));
 
1602
        action->setIcon(QIcon::fromTheme("network-wired"));
1582
1603
    }
1583
1604
}
1584
1605