зеркало из https://github.com/nextcloud/desktop.git
Backend code separation & structure cleanup
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
This commit is contained in:
Родитель
bb45a5f67e
Коммит
6f8ffc0357
|
@ -188,7 +188,7 @@ void ownCloudGui::slotTrayClicked(QSystemTrayIcon::ActivationReason reason)
|
|||
raiseDialog(_settingsDialog.data());
|
||||
}
|
||||
#else
|
||||
UserModel::instance()->showWindow();
|
||||
_tray->showWindow();
|
||||
//slotOpenSettingsDialog();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ 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
|
||||
|
@ -45,10 +44,9 @@ Systray::Systray() // TODO: make singleton, provide ::instance()
|
|||
_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"));
|
||||
|
@ -60,7 +58,7 @@ Systray::Systray() // TODO: make singleton, provide ::instance()
|
|||
|
||||
//connect(AccountManager::instance(), &AccountManager::accountAdded,
|
||||
// this, &Systray::slotChangeActivityModel);
|
||||
UserModel::instance()->hideWindow();
|
||||
hideWindow();
|
||||
}
|
||||
|
||||
Systray::~Systray()
|
||||
|
|
|
@ -47,12 +47,13 @@ public:
|
|||
~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);
|
||||
|
||||
|
@ -60,7 +61,6 @@ private:
|
|||
AccountStatePtr _currentAccount;
|
||||
QQmlComponent *_trayComponent;
|
||||
QQmlContext *_trayContext;
|
||||
UserModel *_accountMenuModel;
|
||||
};
|
||||
|
||||
} // namespace OCC
|
||||
|
|
|
@ -72,9 +72,6 @@ signals:
|
|||
Q_INVOKABLE void newUserSelected();
|
||||
Q_INVOKABLE void refreshUserMenu();
|
||||
|
||||
Q_INVOKABLE void hideWindow();
|
||||
Q_INVOKABLE void showWindow();
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
|
||||
|
|
|
@ -29,15 +29,19 @@ Window {
|
|||
}
|
||||
|
||||
Connections {
|
||||
target: systrayBackend
|
||||
target: userModelBackend
|
||||
onRefreshCurrentUserGui: {
|
||||
currentAccountAvatar.source = systrayBackend.currentUserAvatar()
|
||||
currentAccountUser.text = systrayBackend.currentUserName()
|
||||
currentAccountServer.text = systrayBackend.currentUserServer()
|
||||
currentAccountAvatar.source = userModelBackend.currentUserAvatar()
|
||||
currentAccountUser.text = userModelBackend.currentUserName()
|
||||
currentAccountServer.text = userModelBackend.currentUserServer()
|
||||
}
|
||||
onNewUserSelected: {
|
||||
accountMenu.close()
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: systrayBackend
|
||||
onShowWindow: {
|
||||
trayWindow.show();
|
||||
trayWindow.requestActivate();
|
||||
|
@ -102,7 +106,7 @@ Window {
|
|||
}
|
||||
|
||||
Instantiator {
|
||||
model: systrayBackend
|
||||
model: userModelBackend
|
||||
delegate: UserLine {}
|
||||
onObjectAdded: accountMenu.insertItem(index, object)
|
||||
onObjectRemoved: accountMenu.removeItem(object)
|
||||
|
@ -111,22 +115,22 @@ Window {
|
|||
MenuSeparator { id: accountMenuSeparator }
|
||||
|
||||
MenuItem {
|
||||
text: (systrayBackend.isCurrentUserConnected() ? "Logout" : "Login")
|
||||
onClicked: (systrayBackend.isCurrentUserConnected()
|
||||
? systrayBackend.logout()
|
||||
: systrayBackend.login() )
|
||||
text: (userModelBackend.isCurrentUserConnected() ? "Logout" : "Login")
|
||||
onClicked: (userModelBackend.isCurrentUserConnected()
|
||||
? userModelBackend.logout()
|
||||
: userModelBackend.login() )
|
||||
}
|
||||
MenuItem {
|
||||
text: "Add Account"
|
||||
onClicked: systrayBackend.addAccount()
|
||||
onClicked: userModelBackend.addAccount()
|
||||
}
|
||||
MenuItem {
|
||||
text: "Remove Account"
|
||||
onClicked: systrayBackend.removeAccount()
|
||||
onClicked: userModelBackend.removeAccount()
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if(systrayBackend.numUsers() === 0) {
|
||||
if(userModelBackend.numUsers() === 0) {
|
||||
accountMenuSeparator.height = 0
|
||||
} else {
|
||||
accountMenuSeparator.height = 13
|
||||
|
@ -190,7 +194,7 @@ Window {
|
|||
id: currentAccountAvatar
|
||||
Layout.leftMargin: 8
|
||||
verticalAlignment: Qt.AlignCenter
|
||||
source: systrayBackend.currentUserAvatar()
|
||||
source: userModelBackend.currentUserAvatar()
|
||||
Layout.preferredHeight: (trayWindowHeaderBackground.height -16)
|
||||
Layout.preferredWidth: (trayWindowHeaderBackground.height -16)
|
||||
}
|
||||
|
@ -202,14 +206,14 @@ Window {
|
|||
Layout.leftMargin: 6
|
||||
Label {
|
||||
id: currentAccountUser
|
||||
text: systrayBackend.currentUserName()
|
||||
text: userModelBackend.currentUserName()
|
||||
color: "white"
|
||||
font.pointSize: 9
|
||||
font.bold: true
|
||||
}
|
||||
Label {
|
||||
id: currentAccountServer
|
||||
text: systrayBackend.currentUserServer()
|
||||
text: userModelBackend.currentUserServer()
|
||||
color: "white"
|
||||
font.pointSize: 8
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче