this, &ownCloudGui::slotLogin);
connect(UserModel::instance(), &UserModel::logout,
this, &ownCloudGui::slotLogout);
+ connect(UserModel::instance(), &UserModel::addAccount,
+ this, &ownCloudGui::slotNewAccountWizard);
}
#ifdef WITH_LIBCLOUDPROVIDERS
anchors.fill: parent
Button {
- id: currentAccountButton
+ id: accountButton
Layout.preferredWidth: 220
Layout.preferredHeight: (userLineBackground.height)
display: AbstractButton.IconOnly
MouseArea {
id: accountBtnMouseArea
- anchors.fill: parent
+ anchors.centerIn: parent
+ Layout.preferredWidth: (accountButton.width - 4)
+ Layout.preferredHeight: (accountButton.height - 4)
hoverEnabled: true
onClicked:
{
RowLayout {
id: accountControlRowLayout
- height: currentAccountButton.height
- width: currentAccountButton.width
+ height: accountButton.height
+ width: accountButton.width
spacing: 0
Image {
- id: currentAccountAvatar
+ id: accountAvatar
Layout.leftMargin: 6
verticalAlignment: Qt.AlignCenter
source: avatar
Layout.alignment: Qt.AlignLeft
Layout.leftMargin: 12
Label {
- id: currentAccountUser
+ id: accountUser
text: name
color: "black"
font.pointSize: 9
font.bold: true
}
Label {
- id: currentAccountServer
+ id: accountServer
text: server
color: "black"
font.pointSize: 8
QString User::name() const
{
// If davDisplayName is empty (can be several reasons, simplest is missing login at startup), fall back to username
- return (_account->account()->davDisplayName() == "") ? _account->account()->credentials()->user() : _account->account()->davDisplayName();
+ QString name = _account->account()->davDisplayName();
+ if (name == "") {
+ name = _account->account()->credentials()->user();
+ }
+ if (name.size() > 19) {
+ name.truncate(17);
+ name.append("...");
+ }
+ return name;
}
QString User::server() const
QString serverUrl = _account->account()->url().toString();
serverUrl.replace(QLatin1String("https://"), QLatin1String(""));
serverUrl.replace(QLatin1String("http://"), QLatin1String(""));
+ if (serverUrl.size() > 24) {
+ serverUrl.truncate(22);
+ serverUrl.append("...");
+ }
return serverUrl;
}
return (_account->connectionStatus() == AccountState::ConnectionStatus::Connected);
}
-void User::login()
-{
- _account->account()->resetRejectedCertificates();
- _account->signIn();
-}
-
-void User::logout()
-{
- _account->signOutByUi();
-}
-
/*-------------------------------------------------------------------------------------*/
UserModel* UserModel::_instance = nullptr;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
-
- Q_INVOKABLE void logout();
-
Q_INVOKABLE int numUsers();
Q_INVOKABLE bool isCurrentUserConnected();
Q_INVOKABLE QString currentUserAvatar();
signals:
Q_INVOKABLE void login();
Q_INVOKABLE void logout();
+ Q_INVOKABLE void addAccount();
+ Q_INVOKABLE void removeAccount();
protected:
QHash<int, QByteArray> roleNames() const;
background: Rectangle {
border.color: "#0082c9"
- radius: 4
+ radius: 2
}
Instantiator {
? systrayBackend.logout()
: systrayBackend.login() )
}
- MenuItem { text: "Add Account" }
- MenuItem { text: "Remove Account" }
+ MenuItem {
+ text: "Add Account"
+ onClicked: systrayBackend.addAccount()
+ }
+ MenuItem {
+ text: "Remove Account"
+ onClicked: systrayBackend.removeAccount()
+ }
Component.onCompleted: {
if(systrayBackend.numUsers() === 0) {