Allow minimize to tray.

This commit is contained in:
Black Hat 2018-08-19 14:51:09 +08:00
parent 4383dfa5a1
commit 4b2a33493f
4 changed files with 7 additions and 1 deletions

View File

@ -41,6 +41,8 @@ ApplicationWindow {
Controller { Controller {
id: matriqueController id: matriqueController
onToggleWindow: window.visible ? window.hide() : window.show()
} }
Popup { Popup {

View File

@ -13,6 +13,7 @@
Controller::Controller(QObject* parent) : QObject(parent) { Controller::Controller(QObject* parent) : QObject(parent) {
tray->setIcon(QIcon(":/asset/img/icon.png")); tray->setIcon(QIcon(":/asset/img/icon.png"));
tray->setToolTip("Matrique"); tray->setToolTip("Matrique");
trayMenu->addAction("Toggle Window", [=] { emit toggleWindow(); });
trayMenu->addAction("Quit", [=] { QApplication::quit(); }); trayMenu->addAction("Quit", [=] { QApplication::quit(); });
tray->setContextMenu(trayMenu); tray->setContextMenu(trayMenu);
tray->show(); tray->show();

View File

@ -6,9 +6,9 @@
#include <QApplication> #include <QApplication>
#include <QMediaPlayer> #include <QMediaPlayer>
#include <QMenu>
#include <QObject> #include <QObject>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QMenu>
using namespace QMatrixClient; using namespace QMatrixClient;
@ -101,6 +101,7 @@ class Controller : public QObject {
void homeserverChanged(); void homeserverChanged();
void busyChanged(); void busyChanged();
void errorOccured(); void errorOccured();
void toggleWindow();
public slots: public slots:
void joinRoom(const QString& alias); void joinRoom(const QString& alias);

View File

@ -23,6 +23,8 @@ int main(int argc, char *argv[]) {
QApplication app(argc, argv); QApplication app(argc, argv);
app.setQuitOnLastWindowClosed(false);
qRegisterMetaType<MatriqueRoom *>("MatriqueRoom*"); qRegisterMetaType<MatriqueRoom *>("MatriqueRoom*");
qRegisterMetaType<User *>("User*"); qRegisterMetaType<User *>("User*");
qRegisterMetaType<MessageEventType>("MessageEventType"); qRegisterMetaType<MessageEventType>("MessageEventType");