diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,7 +6,6 @@
accountinfo.cpp
createavatarjob.cpp
passworddialog.cpp
- passwordedit.cpp
avatargallery.cpp
)
diff --git a/src/account.ui b/src/account.ui
--- a/src/account.ui
+++ b/src/account.ui
@@ -210,21 +210,12 @@
-
-
-
-
- 0
- 0
-
-
+
- MyPassword
-
-
- QLineEdit::Password
+ Change Password...
-
-
+
+
@@ -251,6 +242,7 @@
username
realName
email
+ changePasswordButton
administrator
automaticLogin
diff --git a/src/accountinfo.h b/src/accountinfo.h
--- a/src/accountinfo.h
+++ b/src/accountinfo.h
@@ -23,6 +23,7 @@
#include
#include
+#include
#include "lib/accountmodel.h"
class KJob;
@@ -70,7 +71,7 @@
QPixmap m_negative;
Ui::AccountInfo * m_info;
AccountModel* m_model;
- PasswordEdit *m_passwordEdit;
+ QPushButton *m_changePasswordButton;
QModelIndex m_index;
QMap m_infoToSave;
};
diff --git a/src/accountinfo.cpp b/src/accountinfo.cpp
--- a/src/accountinfo.cpp
+++ b/src/accountinfo.cpp
@@ -21,7 +21,6 @@
#include "createavatarjob.h"
#include "passworddialog.h"
#include "lib/accountmodel.h"
-#include "passwordedit.h"
#include "avatargallery.h"
#include
@@ -39,25 +38,21 @@
#include
#include
#include
+#include
AccountInfo::AccountInfo(AccountModel* model, QWidget* parent, Qt::WindowFlags f)
: QWidget(parent, f)
, m_info(new Ui::AccountInfo())
, m_model(model)
- , m_passwordEdit(new PasswordEdit(this))
{
m_info->setupUi(this);
- //If I remove this from the .ui file the layouting gets screwed...
- m_info->formLayout->removeWidget(m_info->passwordEdit);
- delete m_info->passwordEdit;
connect(m_info->username, &QLineEdit::textEdited, this, &AccountInfo::hasChanged);
connect(m_info->realName, &QLineEdit::textEdited, this, &AccountInfo::hasChanged);
connect(m_info->email, &QLineEdit::textEdited, this, &AccountInfo::hasChanged);
connect(m_info->administrator, &QAbstractButton::clicked, this, &AccountInfo::hasChanged);
connect(m_info->automaticLogin, &QAbstractButton::clicked, this, &AccountInfo::hasChanged);
- connect(m_passwordEdit, &PasswordEdit::focused, this, &AccountInfo::changePassword);
- connect(m_passwordEdit, &QLineEdit::textEdited, this, &AccountInfo::changePassword);
+ connect(m_info->changePasswordButton, &QPushButton::clicked, this, &AccountInfo::changePassword);
connect(m_model, &QAbstractItemModel::dataChanged, this, &AccountInfo::dataChanged);
m_info->face->setPopupMode(QToolButton::InstantPopup);
@@ -90,18 +85,6 @@
m_info->realName->setMinimumWidth(size);
m_info->email->setMinimumWidth(size);
- QWidget::setTabOrder(m_info->email, m_passwordEdit);
- QWidget::setTabOrder(m_passwordEdit, m_info->administrator);
-
- m_passwordEdit->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- m_passwordEdit->setMinimumWidth(size);
- m_passwordEdit->setEchoMode(QLineEdit::Password);
-
- int row;
- QFormLayout::ItemRole role;
- m_info->formLayout->getWidgetPosition(m_info->administrator, &row, &role);
- m_info->formLayout->insertRow(row, m_info->label_3, m_passwordEdit);
-
int pixmapSize = m_info->username->sizeHint().height();
m_negative = QIcon::fromTheme(QStringLiteral("dialog-cancel")).pixmap(pixmapSize, pixmapSize);
}
@@ -132,17 +115,18 @@
QString username = m_model->data(m_index, AccountModel::Username).toString();
if (!username.isEmpty()) {
m_info->username->setDisabled(true);//Do not allow to change the username
+ m_info->changePasswordButton->setText(i18nc("@label:button", "Change Password"));
} else {
m_info->username->setDisabled(false);
+ m_info->changePasswordButton->setText(i18nc("@label:button", "Set Password"));
}
m_info->username->setText(username);
m_info->face->setIcon(QIcon(m_model->data(m_index, AccountModel::Face).value()));
m_info->realName->setText(m_model->data(m_index, AccountModel::RealName).toString());
m_info->email->setText(m_model->data(m_index, AccountModel::Email).toString());
m_info->administrator->setChecked(m_model->data(m_index, AccountModel::Administrator).toBool());
m_info->automaticLogin->setChecked(m_model->data(m_index, AccountModel::AutomaticLogin).toBool());
- m_passwordEdit->clear();
}
bool AccountInfo::save()
@@ -312,7 +296,7 @@
errorTooltip.append(QStringLiteral("\n"));
}
- Q_FOREACH(const char c, userchar) {
+ for (const char c : userchar) {
valid = (
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ||
@@ -414,7 +398,8 @@
QStringList AccountInfo::imageFormats() const
{
QStringList result;
- for(const QByteArray &b: QImageReader::supportedMimeTypes()) {
+ const QList supportedMimes = QImageReader::supportedMimeTypes();
+ for (const QByteArray &b: supportedMimes) {
if (! b.isEmpty())
result.append(QString::fromLatin1(b));
}
@@ -480,6 +465,5 @@
}
m_infoToSave[AccountModel::Password] = dialog->password();
- m_passwordEdit->setText(dialog->password());
Q_EMIT changed(true);
}
diff --git a/src/avatargallery.cpp b/src/avatargallery.cpp
--- a/src/avatargallery.cpp
+++ b/src/avatargallery.cpp
@@ -52,9 +52,9 @@
}
const QString &systemFacesPath = locations.last() + QLatin1Char('/');
- QDir avatarsDir(systemFacesPath);
+ const QDir avatarsDir(systemFacesPath);
- foreach(const QString &avatarStyle, avatarsDir.entryList(QDir::Dirs | QDir::NoDotDot)) {
+ for (const QString &avatarStyle : avatarsDir.entryList(QDir::Dirs | QDir::NoDotDot)) {
QDir facesDir = (avatarsDir.filePath(avatarStyle));
const QStringList &avatarList = facesDir.entryList(QDir::Files);
for (auto it = avatarList.constBegin(), end = avatarList.constEnd(); it != end; ++it) {
diff --git a/src/lib/accountmodel.cpp b/src/lib/accountmodel.cpp
--- a/src/lib/accountmodel.cpp
+++ b/src/lib/accountmodel.cpp
@@ -88,8 +88,8 @@
return;
}
- QList users = reply.value();
- Q_FOREACH(const QDBusObjectPath& path, users) {
+ const QList users = reply.value();
+ for (const QDBusObjectPath& path : users) {
addAccount(path.path());
}
diff --git a/src/lib/usersessions.cpp b/src/lib/usersessions.cpp
--- a/src/lib/usersessions.cpp
+++ b/src/lib/usersessions.cpp
@@ -66,8 +66,8 @@
if (reply.isError()) {
qCWarning(USER_MANAGER_LOG) << reply.error().name() << reply.error().message();
} else {
- UserInfoList userList = reply.value();
- Q_FOREACH(const UserInfo &userInfo, userList) {
+ const UserInfoList userList = reply.value();
+ for (const UserInfo &userInfo : userList) {
UserNew(userInfo.id);
}
}
diff --git a/src/passwordedit.h b/src/passwordedit.h
deleted file mode 100644
--- a/src/passwordedit.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/*************************************************************************************
- * Copyright (C) 2013 by Alejandro Fiestas Olivares *
- * *
- * This program is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU General Public License *
- * as published by the Free Software Foundation; either version 2 *
- * of the License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
- *************************************************************************************/
-
-#ifndef PASSWORDEDIT_H
-#define PASSWORDEDIT_H
-
-#include
-#include
-
-class PasswordEdit : public QLineEdit
-{
- Q_OBJECT
-
- public:
- explicit PasswordEdit(QWidget* parent = nullptr);
-
- Q_SIGNALS:
- void focused();
-
- protected:
- void focusInEvent(QFocusEvent* e) override;
-};
-
-#endif
diff --git a/src/passwordedit.cpp b/src/passwordedit.cpp
deleted file mode 100644
--- a/src/passwordedit.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-/*************************************************************************************
- * Copyright (C) 2013 by Alejandro Fiestas Olivares *
- * *
- * This program is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU General Public License *
- * as published by the Free Software Foundation; either version 2 *
- * of the License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
- *************************************************************************************/
-
-#include "passwordedit.h"
-
-PasswordEdit::PasswordEdit(QWidget* parent) : QLineEdit(parent)
-{
-
-}
-
-void PasswordEdit::focusInEvent(QFocusEvent* e)
-{
- QLineEdit::focusInEvent(e);
- if (e->reason() != Qt::ActiveWindowFocusReason) {
- Q_EMIT focused();
- }
-}