: _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
_trayComponent = new QQmlComponent(engine, QUrl(QStringLiteral("qrc:/qml/src/gui/tray/window.qml")));
_trayContext = engine->contextForObject(_trayComponent->create());
- _accountMenuModel = UserModel::instance();
-
engine->addImageProvider("avatars", new ImageProvider);
- engine->rootContext()->setContextProperty("systrayBackend", _accountMenuModel);
+ engine->rootContext()->setContextProperty("userModelBackend", UserModel::instance());
+ engine->rootContext()->setContextProperty("systrayBackend", this);
// TODO: hack to pass the icon to QML
//ctxt->setContextProperty("theme", QLatin1String("colored"));
//connect(AccountManager::instance(), &AccountManager::accountAdded,
// this, &Systray::slotChangeActivityModel);
- UserModel::instance()->hideWindow();
+ 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();
+ Q_INVOKABLE void hideWindow();
+ Q_INVOKABLE void showWindow();
+
private slots:
void slotChangeActivityModel(const AccountStatePtr account);
AccountStatePtr _currentAccount;
QQmlComponent *_trayComponent;
QQmlContext *_trayContext;
- UserModel *_accountMenuModel;
};
} // namespace OCC
}\r
\r
Connections {\r
- target: systrayBackend\r
+ target: userModelBackend\r
onRefreshCurrentUserGui: {\r
- currentAccountAvatar.source = systrayBackend.currentUserAvatar()\r
- currentAccountUser.text = systrayBackend.currentUserName()\r
- currentAccountServer.text = systrayBackend.currentUserServer()\r
+ currentAccountAvatar.source = userModelBackend.currentUserAvatar()\r
+ currentAccountUser.text = userModelBackend.currentUserName()\r
+ currentAccountServer.text = userModelBackend.currentUserServer()\r
}\r
onNewUserSelected: {\r
accountMenu.close()\r
}\r
+ }\r
+\r
+ Connections {\r
+ target: systrayBackend\r
onShowWindow: {\r
trayWindow.show();\r
trayWindow.requestActivate();\r
}\r
\r
Instantiator {\r
- model: systrayBackend\r
+ model: userModelBackend\r
delegate: UserLine {}\r
onObjectAdded: accountMenu.insertItem(index, object)\r
onObjectRemoved: accountMenu.removeItem(object)\r
MenuSeparator { id: accountMenuSeparator }\r
\r
MenuItem {\r
- text: (systrayBackend.isCurrentUserConnected() ? "Logout" : "Login")\r
- onClicked: (systrayBackend.isCurrentUserConnected()\r
- ? systrayBackend.logout()\r
- : systrayBackend.login() )\r
+ text: (userModelBackend.isCurrentUserConnected() ? "Logout" : "Login")\r
+ onClicked: (userModelBackend.isCurrentUserConnected()\r
+ ? userModelBackend.logout()\r
+ : userModelBackend.login() )\r
}\r
MenuItem {\r
text: "Add Account"\r
- onClicked: systrayBackend.addAccount()\r
+ onClicked: userModelBackend.addAccount()\r
}\r
MenuItem {\r
text: "Remove Account"\r
- onClicked: systrayBackend.removeAccount()\r
+ onClicked: userModelBackend.removeAccount()\r
}\r
\r
Component.onCompleted: {\r
- if(systrayBackend.numUsers() === 0) {\r
+ if(userModelBackend.numUsers() === 0) {\r
accountMenuSeparator.height = 0\r
} else {\r
accountMenuSeparator.height = 13\r
id: currentAccountAvatar\r
Layout.leftMargin: 8\r
verticalAlignment: Qt.AlignCenter\r
- source: systrayBackend.currentUserAvatar()\r
+ source: userModelBackend.currentUserAvatar()\r
Layout.preferredHeight: (trayWindowHeaderBackground.height -16)\r
Layout.preferredWidth: (trayWindowHeaderBackground.height -16)\r
}\r
Layout.leftMargin: 6\r
Label {\r
id: currentAccountUser\r
- text: systrayBackend.currentUserName()\r
+ text: userModelBackend.currentUserName()\r
color: "white"\r
font.pointSize: 9\r
font.bold: true\r
}\r
Label {\r
id: currentAccountServer\r
- text: systrayBackend.currentUserServer()\r
+ text: userModelBackend.currentUserServer()\r
color: "white"\r
font.pointSize: 8\r
}\r