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 {
id: matriqueController
onToggleWindow: window.visible ? window.hide() : window.show()
}
Popup {

View File

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

View File

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

View File

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