mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-28 03:49:20 +03:00
Added popup show/hide logic
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
This commit is contained in:
parent
438a445353
commit
bb45a5f67e
6 changed files with 27 additions and 6 deletions
|
@ -188,7 +188,8 @@ void ownCloudGui::slotTrayClicked(QSystemTrayIcon::ActivationReason reason)
|
|||
raiseDialog(_settingsDialog.data());
|
||||
}
|
||||
#else
|
||||
slotOpenSettingsDialog();
|
||||
UserModel::instance()->showWindow();
|
||||
//slotOpenSettingsDialog();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,14 +35,15 @@ namespace OCC {
|
|||
|
||||
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();
|
||||
|
||||
|
@ -54,12 +55,12 @@ Systray::Systray() // TODO: make singleton, provide ::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()
|
||||
|
|
|
@ -47,6 +47,8 @@ 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();
|
||||
|
@ -56,6 +58,7 @@ private slots:
|
|||
|
||||
private:
|
||||
AccountStatePtr _currentAccount;
|
||||
QQmlComponent *_trayComponent;
|
||||
QQmlContext *_trayContext;
|
||||
UserModel *_accountMenuModel;
|
||||
};
|
||||
|
|
|
@ -114,7 +114,7 @@ Q_INVOKABLE bool UserModel::isCurrentUserConnected()
|
|||
return _users[_currentUserId].isConnected();
|
||||
}
|
||||
|
||||
QImage UserModel::currentUserAvatar()
|
||||
Q_INVOKABLE QImage UserModel::currentUserAvatar()
|
||||
{
|
||||
return _users[_currentUserId].avatar();
|
||||
}
|
||||
|
|
|
@ -45,9 +45,9 @@ public:
|
|||
|
||||
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();
|
||||
|
@ -72,6 +72,9 @@ signals:
|
|||
Q_INVOKABLE void newUserSelected();
|
||||
Q_INVOKABLE void refreshUserMenu();
|
||||
|
||||
Q_INVOKABLE void hideWindow();
|
||||
Q_INVOKABLE void showWindow();
|
||||
|
||||
protected:
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
|
||||
|
|
|
@ -14,6 +14,12 @@ Window {
|
|||
color: "transparent"
|
||||
flags: Qt.FramelessWindowHint
|
||||
|
||||
onActiveChanged: {
|
||||
if(!active) {
|
||||
trayWindow.hide();
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
/* desktopAvailableWidth and Height doesn't include the system tray bar
|
||||
but breaks application anyway on windows when using multi monitor setup,
|
||||
|
@ -32,6 +38,13 @@ Window {
|
|||
onNewUserSelected: {
|
||||
accountMenu.close()
|
||||
}
|
||||
onShowWindow: {
|
||||
trayWindow.show();
|
||||
trayWindow.requestActivate();
|
||||
}
|
||||
onHideWindow: {
|
||||
trayWindow.hide();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
|
|
Loading…
Reference in a new issue