mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-21 20:45:51 +03:00
UserLine drafting, bugfixes, restuctures
Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com>
This commit is contained in:
parent
6ac1a4a353
commit
9c0221a0fa
6 changed files with 93 additions and 38 deletions
|
@ -232,8 +232,6 @@ void AccountSettings::createAccountToolbox()
|
|||
menu->addAction(action);
|
||||
|
||||
connect(action, &QAction::triggered, this, &AccountSettings::slotDeleteAccount);
|
||||
connect(UserModel::instance(), &UserModel::removeAccount,
|
||||
this, &AccountSettings::slotOpenAccountWizard);
|
||||
|
||||
_ui->_accountToolbox->setText(tr("Account") + QLatin1Char(' '));
|
||||
_ui->_accountToolbox->setMenu(menu);
|
||||
|
|
|
@ -110,12 +110,6 @@ ownCloudGui::ownCloudGui(Application *parent)
|
|||
this, &ownCloudGui::slotShowOptionalTrayMessage);
|
||||
connect(Logger::instance(), &Logger::guiMessage,
|
||||
this, &ownCloudGui::slotShowGuiMessage);
|
||||
|
||||
|
||||
connect(UserModel::instance(), &UserModel::login,
|
||||
this, &ownCloudGui::slotLogin);
|
||||
connect(UserModel::instance(), &UserModel::logout,
|
||||
this, &ownCloudGui::slotLogout);
|
||||
}
|
||||
|
||||
#ifdef WITH_LIBCLOUDPROVIDERS
|
||||
|
|
|
@ -4,33 +4,19 @@ import QtQuick.Controls 2.2
|
|||
import QtQuick.Layouts 1.2
|
||||
|
||||
MenuItem {
|
||||
|
||||
Connections {
|
||||
target: userModelBackend
|
||||
onRefreshUserMenu: {
|
||||
}
|
||||
}
|
||||
|
||||
id: userLine
|
||||
width: 220
|
||||
height: 60
|
||||
|
||||
Rectangle {
|
||||
id: userLineBackground
|
||||
height: userLine.height
|
||||
anchors.fill: parent
|
||||
color: "transparent"
|
||||
|
||||
RowLayout {
|
||||
id: userLineLayout
|
||||
spacing: 0
|
||||
anchors.fill: parent
|
||||
width: 220
|
||||
height: 60
|
||||
|
||||
Button {
|
||||
id: accountButton
|
||||
anchors.centerIn: parent
|
||||
Layout.preferredWidth: (userLine.width - 4)
|
||||
Layout.preferredHeight: (userLineBackground.height - 2)
|
||||
Layout.preferredWidth: (userLineLayout.width * (5/6))
|
||||
Layout.preferredHeight: (userLineLayout.height)
|
||||
display: AbstractButton.IconOnly
|
||||
flat: true
|
||||
|
||||
|
@ -49,21 +35,22 @@ MenuItem {
|
|||
spacing: 0
|
||||
Image {
|
||||
id: accountAvatar
|
||||
Layout.leftMargin: 2
|
||||
Layout.leftMargin: 4
|
||||
verticalAlignment: Qt.AlignCenter
|
||||
cache: false
|
||||
source: ("image://avatars/" + index)
|
||||
Layout.preferredHeight: (userLineBackground.height -16)
|
||||
Layout.preferredWidth: (userLineBackground.height -16)
|
||||
Layout.preferredHeight: (userLineLayout.height -16)
|
||||
Layout.preferredWidth: (userLineLayout.height -16)
|
||||
}
|
||||
|
||||
Column {
|
||||
id: accountLabels
|
||||
spacing: 4
|
||||
Layout.alignment: Qt.AlignLeft
|
||||
Layout.leftMargin: 12
|
||||
Layout.leftMargin: 6
|
||||
Label {
|
||||
id: accountUser
|
||||
width: 120
|
||||
width: 128
|
||||
text: name
|
||||
elide: Text.ElideRight
|
||||
color: "black"
|
||||
|
@ -72,7 +59,7 @@ MenuItem {
|
|||
}
|
||||
Label {
|
||||
id: accountServer
|
||||
width: 120
|
||||
width: 128
|
||||
text: server
|
||||
elide: Text.ElideRight
|
||||
color: "black"
|
||||
|
@ -81,6 +68,51 @@ MenuItem {
|
|||
}
|
||||
}
|
||||
} // accountButton
|
||||
|
||||
Button {
|
||||
id: userMoreButton
|
||||
Layout.preferredWidth: (userLineLayout.width * (1/6))
|
||||
Layout.preferredHeight: userLineLayout.height
|
||||
flat: true
|
||||
|
||||
icon.source: "qrc:///client/resources/more.svg"
|
||||
icon.color: "transparent"
|
||||
|
||||
MouseArea {
|
||||
id: userMoreButtonMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked:
|
||||
{
|
||||
userMoreButtonMenu.popup()
|
||||
}
|
||||
}
|
||||
background:
|
||||
Rectangle {
|
||||
color: userMoreButtonMouseArea.containsMouse ? "grey" : "transparent"
|
||||
opacity: 0.2
|
||||
}
|
||||
|
||||
Menu {
|
||||
id: userMoreButtonMenu
|
||||
width: 100
|
||||
|
||||
background: Rectangle {
|
||||
border.color: "#0082c9"
|
||||
radius: 2
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: userModelBackend.isCurrentUserConnected() ? "Log out" : "Log in"
|
||||
onClicked: {
|
||||
userModelBackend.isCurrentUserConnected() ? userModelBackend.logout(index) : userModelBackend.logout(index)
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: "Remove Account"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // Rectangle userLineBackground
|
||||
} // MenuItem userLine
|
||||
|
|
|
@ -43,6 +43,16 @@ void User::openLocalFolder()
|
|||
QDesktopServices::openUrl(this->getFolder()->path());
|
||||
}
|
||||
|
||||
void User::login() const
|
||||
{
|
||||
_account->signIn();
|
||||
}
|
||||
|
||||
void User::logout() const
|
||||
{
|
||||
_account->signOutByUi();
|
||||
}
|
||||
|
||||
QString User::name() const
|
||||
{
|
||||
// If davDisplayName is empty (can be several reasons, simplest is missing login at startup), fall back to username
|
||||
|
@ -208,6 +218,20 @@ Q_INVOKABLE void UserModel::switchCurrentUser(const int &id)
|
|||
emit refreshCurrentUserGui();
|
||||
}
|
||||
|
||||
Q_INVOKABLE void UserModel::login(const int &id) {
|
||||
_users[id].login();
|
||||
}
|
||||
|
||||
Q_INVOKABLE void UserModel::logout(const int &id)
|
||||
{
|
||||
_users[id].logout();
|
||||
}
|
||||
|
||||
Q_INVOKABLE void UserModel::removeAccount(const int &id)
|
||||
{
|
||||
_users[id].logout();
|
||||
}
|
||||
|
||||
int UserModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
|
|
|
@ -31,6 +31,8 @@ public:
|
|||
bool hasActivities() const;
|
||||
QImage avatar() const;
|
||||
QString id() const;
|
||||
void login() const;
|
||||
void logout() const;
|
||||
|
||||
private:
|
||||
AccountStatePtr _account;
|
||||
|
@ -65,6 +67,9 @@ public:
|
|||
Q_INVOKABLE bool currentUserHasActivities();
|
||||
Q_INVOKABLE bool currentServerHasTalk();
|
||||
Q_INVOKABLE void switchCurrentUser(const int &id);
|
||||
Q_INVOKABLE void login(const int &id);
|
||||
Q_INVOKABLE void logout(const int &id);
|
||||
Q_INVOKABLE void removeAccount(const int &id);
|
||||
|
||||
ActivityListModel *currentActivityModel();
|
||||
|
||||
|
@ -76,11 +81,7 @@ public:
|
|||
};
|
||||
|
||||
signals:
|
||||
Q_INVOKABLE void login();
|
||||
Q_INVOKABLE void logout();
|
||||
Q_INVOKABLE void addAccount();
|
||||
Q_INVOKABLE void removeAccount();
|
||||
|
||||
Q_INVOKABLE void refreshCurrentUserGui();
|
||||
Q_INVOKABLE void newUserSelected();
|
||||
Q_INVOKABLE void refreshUserMenu();
|
||||
|
|
|
@ -108,7 +108,7 @@ Window {
|
|||
id: accountMenu
|
||||
x: (currentAccountButton.x + 2)
|
||||
y: (currentAccountButton.y + currentAccountButton.height + 2)
|
||||
width: (currentAccountButton.width)
|
||||
width: (currentAccountButton.width - 2)
|
||||
closePolicy: "CloseOnPressOutside"
|
||||
|
||||
background: Rectangle {
|
||||
|
@ -116,7 +116,13 @@ Window {
|
|||
radius: 2
|
||||
}
|
||||
|
||||
onClosed: {
|
||||
userLineInstantiator.active = false;
|
||||
userLineInstantiator.active = true;
|
||||
}
|
||||
|
||||
Instantiator {
|
||||
id: userLineInstantiator
|
||||
model: userModelBackend
|
||||
delegate: UserLine {}
|
||||
onObjectAdded: accountMenu.insertItem(index, object)
|
||||
|
|
Loading…
Reference in a new issue