raiseDialog(_settingsDialog.data());
}
#else
- slotOpenSettingsDialog();
+ UserModel::instance()->showWindow();
+ //slotOpenSettingsDialog();
#endif
}
}
Systray::Systray() // TODO: make singleton, provide ::instance()
: _currentAccount(nullptr)
+ , _trayComponent(nullptr)
, _trayContext(nullptr)
, _accountMenuModel(nullptr)
{
// Create QML tray engine, build component, set C++ backend context used in window.qml
// Use pointer instead of engine() helper function until Qt 5.12 is minimum standard
QQmlEngine *engine = new QQmlEngine;
- QQmlComponent systray(engine, QUrl(QStringLiteral("qrc:/qml/src/gui/tray/window.qml")));
- _trayContext = engine->contextForObject(systray.create());
+ _trayComponent = new QQmlComponent(engine, QUrl(QStringLiteral("qrc:/qml/src/gui/tray/window.qml")));
+ _trayContext = engine->contextForObject(_trayComponent->create());
_accountMenuModel = UserModel::instance();
//ctxt->setContextProperty("filename", "state-offline");
if (!AccountManager::instance()->accounts().isEmpty()) {
-
slotChangeActivityModel(AccountManager::instance()->accounts().first());
}
//connect(AccountManager::instance(), &AccountManager::accountAdded,
// this, &Systray::slotChangeActivityModel);
+ UserModel::instance()->hideWindow();
}
Systray::~Systray()
~Systray();
void showMessage(const QString &title, const QString &message, MessageIcon icon = Information, int millisecondsTimeoutHint = 10000);
void setToolTip(const QString &tip);
+ void showWindow();
+ void hideWindow();
signals:
void currentUserChanged();
private:
AccountStatePtr _currentAccount;
+ QQmlComponent *_trayComponent;
QQmlContext *_trayContext;
UserModel *_accountMenuModel;
};
return _users[_currentUserId].isConnected();
}
-QImage UserModel::currentUserAvatar()
+Q_INVOKABLE QImage UserModel::currentUserAvatar()
{
return _users[_currentUserId].avatar();
}
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- QImage currentUserAvatar();
QImage avatarById(const int &id);
+ Q_INVOKABLE QImage currentUserAvatar();
Q_INVOKABLE int numUsers();
Q_INVOKABLE bool isCurrentUserConnected();
Q_INVOKABLE QString currentUserName();
Q_INVOKABLE void newUserSelected();
Q_INVOKABLE void refreshUserMenu();
+ Q_INVOKABLE void hideWindow();
+ Q_INVOKABLE void showWindow();
+
protected:
QHash<int, QByteArray> roleNames() const;
color: "transparent"\r
flags: Qt.FramelessWindowHint\r
\r
+ onActiveChanged: {\r
+ if(!active) {\r
+ trayWindow.hide();\r
+ }\r
+ }\r
+\r
Component.onCompleted: {\r
/* desktopAvailableWidth and Height doesn't include the system tray bar\r
but breaks application anyway on windows when using multi monitor setup,\r
onNewUserSelected: {\r
accountMenu.close()\r
}\r
+ onShowWindow: {\r
+ trayWindow.show();\r
+ trayWindow.requestActivate();\r
+ }\r
+ onHideWindow: {\r
+ trayWindow.hide();\r
+ }\r
}\r
\r
Rectangle {\r