Polish the systray example.

- Port it to new connection syntax.
- Replace module include by class includes.

Change-Id: I1b8d682bb7bb2e05b6b2b77a9c0d01730ea09cf2
Reviewed-by: Topi Reiniö <topi.reinio@digia.com>
This commit is contained in:
Friedemann Kleint 2015-08-28 09:29:45 +02:00 committed by Jędrzej Nowacki
parent fe1ea010b9
commit 3363398802

View File

@ -42,11 +42,11 @@
#ifndef QT_NO_SYSTEMTRAYICON #ifndef QT_NO_SYSTEMTRAYICON
#include <QtGui>
#include <QAction> #include <QAction>
#include <QCheckBox> #include <QCheckBox>
#include <QComboBox> #include <QComboBox>
#include <QCoreApplication>
#include <QCloseEvent>
#include <QGroupBox> #include <QGroupBox>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
@ -68,12 +68,13 @@ Window::Window()
createActions(); createActions();
createTrayIcon(); createTrayIcon();
connect(showMessageButton, SIGNAL(clicked()), this, SLOT(showMessage())); connect(showMessageButton, &QAbstractButton::clicked, this, &Window::showMessage);
connect(showIconCheckBox, SIGNAL(toggled(bool)), trayIcon, SLOT(setVisible(bool))); connect(showIconCheckBox, &QAbstractButton::toggled, trayIcon, &QSystemTrayIcon::setVisible);
connect(iconComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setIcon(int))); typedef void (QComboBox::*QComboIntSignal)(int);
connect(trayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked())); connect(iconComboBox, static_cast<QComboIntSignal>(&QComboBox::currentIndexChanged),
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, &Window::setIcon);
this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); connect(trayIcon, &QSystemTrayIcon::messageClicked, this, &Window::messageClicked);
connect(trayIcon, &QSystemTrayIcon::activated, this, &Window::iconActivated);
QVBoxLayout *mainLayout = new QVBoxLayout; QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(iconGroupBox); mainLayout->addWidget(iconGroupBox);
@ -245,16 +246,16 @@ void Window::createMessageGroupBox()
void Window::createActions() void Window::createActions()
{ {
minimizeAction = new QAction(tr("Mi&nimize"), this); minimizeAction = new QAction(tr("Mi&nimize"), this);
connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide())); connect(minimizeAction, &QAction::triggered, this, &QWidget::hide);
maximizeAction = new QAction(tr("Ma&ximize"), this); maximizeAction = new QAction(tr("Ma&ximize"), this);
connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized())); connect(maximizeAction, &QAction::triggered, this, &QWidget::showMaximized);
restoreAction = new QAction(tr("&Restore"), this); restoreAction = new QAction(tr("&Restore"), this);
connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(restoreAction, &QAction::triggered, this, &QWidget::showNormal);
quitAction = new QAction(tr("&Quit"), this); quitAction = new QAction(tr("&Quit"), this);
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
} }
void Window::createTrayIcon() void Window::createTrayIcon()