#include <QMessageBox>
#include <QStatusBar>
#include <QToolBar>
+#include <QInputDialog>
-#ifdef HAVE_KDE
-# include <KAction>
-# include <KActionCollection>
+#ifdef HAVE_KDE4
# include <KHelpMenu>
# include <KMenuBar>
# include <KShortcutsDialog>
# include <KStatusBar>
# include <KToggleFullScreenAction>
# include <KToolBar>
-# include <KWindowSystem>
+#endif
+
+#ifdef HAVE_KF5
+# include <KConfigWidgets/KStandardAction>
+# include <KXmlGui/KHelpMenu>
+# include <KXmlGui/KShortcutsDialog>
+# include <KXmlGui/KToolBar>
+# include <KWidgetsAddons/KToggleFullScreenAction>
#endif
#ifdef Q_WS_X11
#include "legacysystemtray.h"
#include "msgprocessorstatuswidget.h"
#include "nicklistwidget.h"
+#include "passwordchangedlg.h"
#include "qtuiapplication.h"
#include "qtuimessageprocessor.h"
#include "qtuisettings.h"
# ifdef HAVE_PHONON
# include "phononnotificationbackend.h"
# endif
-# ifdef HAVE_LIBSNORE
-# include "snorenotificationbackend.h"
-# endif
# include "systraynotificationbackend.h"
# include "taskbarnotificationbackend.h"
#else /* HAVE_KDE */
# include "knotificationbackend.h"
#endif /* HAVE_KDE */
+
+#ifdef HAVE_LIBSNORE
+# include "snorenotificationbackend.h"
+#endif
+
#ifdef HAVE_SSL
# include "sslinfodlg.h"
#endif
MainWin::MainWin(QWidget *parent)
#ifdef HAVE_KDE
- : KMainWindow(parent),
- _kHelpMenu(new KHelpMenu(this, KGlobal::mainComponent().aboutData())),
+ : KMainWindow(parent), _kHelpMenu(new KHelpMenu(this)),
#else
: QMainWindow(parent),
#endif
_titleSetter(this),
_awayLog(0),
_layoutLoaded(false),
- _activeBufferViewIndex(-1)
+ _activeBufferViewIndex(-1),
+ _aboutToQuit(false)
{
setAttribute(Qt::WA_DeleteOnClose, false); // we delete the mainwin manually
# ifdef HAVE_PHONON
QtUi::registerNotificationBackend(new PhononNotificationBackend(this));
# endif
-# ifdef HAVE_LIBSNORE
- QtUi::registerNotificationBackend(new SnoreNotificationBackend(this));
-# elif !defined(QT_NO_SYSTEMTRAYICON)
- QtUi::registerNotificationBackend(new SystrayNotificationBackend(this));
-# endif
-
QtUi::registerNotificationBackend(new TaskbarNotificationBackend(this));
-
#else /* HAVE_KDE */
QtUi::registerNotificationBackend(new KNotificationBackend(this));
#endif /* HAVE_KDE */
+
+#ifdef HAVE_LIBSNORE
+ QtUi::registerNotificationBackend(new SnoreNotificationBackend(this));
+#elif !defined(QT_NO_SYSTEMTRAYICON) && !defined(HAVE_KDE)
+ QtUi::registerNotificationBackend(new SystrayNotificationBackend(this));
+#endif
+
#ifdef HAVE_INDICATEQT
QtUi::registerNotificationBackend(new IndicatorNotificationBackend(this));
#endif
show();
}
+QMenu *MainWin::createPopupMenu()
+{
+ QMenu *popupMenu = QMainWindow::createPopupMenu();
+ popupMenu->addSeparator();
+ ActionCollection *coll = QtUi::actionCollection("General");
+ popupMenu->addAction(coll->action("ToggleMenuBar"));
+ return popupMenu;
+}
+
void MainWin::updateIcon()
{
this, SLOT(showCoreConnectionDlg())));
coll->addAction("DisconnectCore", new Action(QIcon::fromTheme("network-disconnect"), tr("&Disconnect from Core"), coll,
Client::instance(), SLOT(disconnectFromCore())));
+ coll->addAction("ChangePassword", new Action(QIcon::fromTheme("dialog-password"), tr("Change &Password..."), coll,
+ this, SLOT(showPasswordChangeDlg())));
coll->addAction("CoreInfo", new Action(QIcon::fromTheme("help-about"), tr("Core &Info..."), coll,
this, SLOT(showCoreInfoDlg())));
coll->addAction("ConfigureNetworks", new Action(QIcon::fromTheme("configure"), tr("Configure &Networks..."), coll,
0, 0))->setCheckable(true);
#ifdef HAVE_KDE
- QAction *fullScreenAct = KStandardAction::fullScreen(this, SLOT(onFullScreenToggled()), this, coll);
+ _fullScreenAction = KStandardAction::fullScreen(this, SLOT(onFullScreenToggled()), this, coll);
#else
- QAction *fullScreenAct = new Action(QIcon::fromTheme("view-fullscreen"), tr("&Full Screen Mode"), coll,
+ _fullScreenAction = new Action(QIcon::fromTheme("view-fullscreen"), tr("&Full Screen Mode"), coll,
this, SLOT(onFullScreenToggled()), QKeySequence(Qt::Key_F11));
- fullScreenAct->setCheckable(true);
+ _fullScreenAction->setCheckable(true);
+ coll->addAction("ToggleFullScreen", _fullScreenAction);
#endif
- coll->addAction("ToggleFullScreen", fullScreenAct);
// Settings
QAction *configureShortcutsAct = new Action(QIcon::fromTheme("configure-shortcuts"), tr("Configure &Shortcuts..."), coll,
configureShortcutsAct->setMenuRole(QAction::NoRole);
coll->addAction("ConfigureShortcuts", configureShortcutsAct);
- #ifdef Q_OS_MAC
+#ifdef Q_OS_MAC
QAction *configureQuasselAct = new Action(QIcon::fromTheme("configure"), tr("&Configure Quassel..."), coll,
this, SLOT(showSettingsDlg()));
configureQuasselAct->setMenuRole(QAction::PreferencesRole);
- #else
+#else
QAction *configureQuasselAct = new Action(QIcon::fromTheme("configure"), tr("&Configure Quassel..."), coll,
this, SLOT(showSettingsDlg()), QKeySequence(Qt::Key_F7));
- #endif
+#endif
coll->addAction("ConfigureQuassel", configureQuasselAct);
// Help
_fileMenu = menuBar()->addMenu(tr("&File"));
static const QStringList coreActions = QStringList()
- << "ConnectCore" << "DisconnectCore" << "CoreInfo";
+ << "ConnectCore" << "DisconnectCore" << "ChangePassword" << "CoreInfo";
QAction *coreAction;
foreach(QString actionName, coreActions) {
#endif
_settingsMenu->addAction(coll->action("ConfigureQuassel"));
+
_helpMenu = menuBar()->addMenu(tr("&Help"));
+
_helpMenu->addAction(coll->action("AboutQuassel"));
#ifndef HAVE_KDE
_helpMenu->addAction(coll->action("AboutQt"));
}
+void MainWin::showPasswordChangeDlg()
+{
+ if((Client::coreFeatures() & Quassel::PasswordChange)) {
+ PasswordChangeDlg dlg(this);
+ dlg.exec();
+ }
+ else {
+ QMessageBox box(QMessageBox::Warning, tr("Feature Not Supported"),
+ tr("<b>Your Quassel Core does not support this feature</b>"),
+ QMessageBox::Ok, this);
+ box.setInformativeText(tr("You need a Quassel Core v0.12.0 or newer in order to be able to remotely change your password."));
+ box.exec();
+ }
+}
+
+
void MainWin::changeActiveBufferView(bool backwards)
{
BufferView *current = activeBufferView();
void MainWin::setupViewMenuTail()
{
_viewMenu->addSeparator();
- _viewMenu->addAction(QtUi::actionCollection("General")->action("ToggleFullScreen"));
+ _viewMenu->addAction(_fullScreenAction);
}
coll->action("ConnectCore")->setEnabled(false);
coll->action("DisconnectCore")->setEnabled(true);
+ coll->action("ChangePassword")->setEnabled(true);
coll->action("CoreInfo")->setEnabled(true);
foreach(QAction *action, _fileMenu->actions()) {
coll->action("ConnectCore")->setEnabled(true);
coll->action("DisconnectCore")->setEnabled(false);
coll->action("CoreInfo")->setEnabled(false);
+ coll->action("ChangePassword")->setEnabled(false);
//_viewMenu->setEnabled(false);
statusBar()->showMessage(tr("Not connected to core."));
if (_msgProcessorStatusWidget)
KShortcutsDialog dlg(KShortcutsEditor::AllActions, KShortcutsEditor::LetterShortcutsDisallowed, this);
foreach(KActionCollection *coll, QtUi::actionCollections())
dlg.addCollection(coll, coll->property("Category").toString());
- dlg.exec();
+ dlg.configure(true);
#else
SettingsPageDlg dlg(new ShortcutsSettingsPage(QtUi::actionCollections(), this), this);
dlg.exec();
// Relying on QWidget::isFullScreen is discouraged, see the KToggleFullScreenAction docs
// Also, one should not use showFullScreen() or showNormal(), as those reset all other window flags
- QAction *action = QtUi::actionCollection("General")->action("ToggleFullScreen");
- if (!action)
- return;
-
#ifdef HAVE_KDE
- KToggleFullScreenAction *kAct = static_cast<KToggleFullScreenAction *>(action);
- kAct->setFullScreen(this, kAct->isChecked());
+ static_cast<KToggleFullScreenAction*>(_fullScreenAction)->setFullScreen(this, _fullScreenAction->isChecked());
#else
- if (action->isChecked())
+ if (_fullScreenAction->isChecked())
setWindowState(windowState() | Qt::WindowFullScreen);
else
setWindowState(windowState() & ~Qt::WindowFullScreen);
QtUiSettings s;
QtUiApplication *app = qobject_cast<QtUiApplication *> qApp;
Q_ASSERT(app);
- if (!app->isAboutToQuit() && QtUi::haveSystemTray() && s.value("MinimizeOnClose").toBool()) {
+ // On OSX it can happen that the closeEvent occurs twice. (Especially if packaged with Frameworks)
+ // This messes up MainWinState/MainWinHidden save/restore.
+ // It's a bug in Qt: https://bugreports.qt.io/browse/QTBUG-43344
+ if (!_aboutToQuit && !app->isAboutToQuit() && QtUi::haveSystemTray() && s.value("MinimizeOnClose").toBool()) {
QtUi::hideMainWidget();
event->ignore();
}
- else {
+ else if(!_aboutToQuit) {
+ _aboutToQuit = true;
event->accept();
quit();
}
+ else {
+ event->ignore();
+ }
}