mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-24 05:55:59 +03:00
Added folder search for User instance, added open folder button connection
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
This commit is contained in:
parent
d4b334636e
commit
36467c1e3a
3 changed files with 25 additions and 5 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "owncloudgui.h"
|
||||
#include "UserModel.h"
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QIcon>
|
||||
|
||||
namespace OCC {
|
||||
|
@ -22,6 +23,20 @@ void User::setCurrentUser(const bool &isCurrent)
|
|||
_isCurrentUser = isCurrent;
|
||||
}
|
||||
|
||||
Folder* User::getFolder()
|
||||
{
|
||||
foreach (Folder *folder, FolderMan::instance()->map()) {
|
||||
if (folder->accountState() == _account.data()) {
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void User::openLocalFolder()
|
||||
{
|
||||
QDesktopServices::openUrl(this->getFolder()->path());
|
||||
}
|
||||
|
||||
QString User::name() const
|
||||
{
|
||||
// If davDisplayName is empty (can be several reasons, simplest is missing login at startup), fall back to username
|
||||
|
@ -145,6 +160,11 @@ void UserModel::addUser(AccountStatePtr &user, const bool &isCurrent)
|
|||
endInsertRows();
|
||||
}
|
||||
|
||||
Q_INVOKABLE void UserModel::openCurrentAccountLocalFolder()
|
||||
{
|
||||
_users[_currentUserId].openLocalFolder();
|
||||
}
|
||||
|
||||
Q_INVOKABLE void UserModel::switchCurrentUser(const int &id)
|
||||
{
|
||||
_users[_currentUserId].setCurrentUser(false);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <QQuickImageProvider>
|
||||
|
||||
#include "accountmanager.h"
|
||||
#include "folderman.h"
|
||||
|
||||
namespace OCC {
|
||||
|
||||
|
@ -20,8 +21,8 @@ public:
|
|||
bool isConnected() const;
|
||||
bool isCurrentUser() const;
|
||||
void setCurrentUser(const bool &isCurrent);
|
||||
void login();
|
||||
void logout();
|
||||
Folder* getFolder();
|
||||
void openLocalFolder();
|
||||
QString name() const;
|
||||
QString server() const;
|
||||
QImage avatar() const;
|
||||
|
@ -47,6 +48,7 @@ public:
|
|||
|
||||
QImage avatarById(const int &id);
|
||||
|
||||
Q_INVOKABLE void openCurrentAccountLocalFolder();
|
||||
Q_INVOKABLE QImage currentUserAvatar();
|
||||
Q_INVOKABLE int numUsers();
|
||||
Q_INVOKABLE bool isCurrentUserConnected();
|
||||
|
@ -62,7 +64,6 @@ public:
|
|||
};
|
||||
|
||||
signals:
|
||||
Q_INVOKABLE void openLocalFolder();
|
||||
Q_INVOKABLE void login();
|
||||
Q_INVOKABLE void logout();
|
||||
Q_INVOKABLE void addAccount();
|
||||
|
|
|
@ -217,7 +217,6 @@ Window {
|
|||
Layout.alignment: Qt.AlignLeft
|
||||
verticalAlignment: Qt.AlignCenter
|
||||
Layout.margins: 12
|
||||
//source: "../../theme/white/caret-down.svg"
|
||||
source: "qrc:///client/theme/white/caret-down.svg"
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +235,6 @@ Window {
|
|||
Layout.preferredHeight: (trayWindowHeaderBackground.height)
|
||||
flat: true
|
||||
|
||||
//icon.source: "../../theme/white/folder.svg"
|
||||
icon.source: "qrc:///client/theme/white/folder.svg"
|
||||
icon.color: "transparent"
|
||||
|
||||
|
@ -246,6 +244,7 @@ Window {
|
|||
hoverEnabled: true
|
||||
onClicked:
|
||||
{
|
||||
userModelBackend.openCurrentAccountLocalFolder();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue