diff --git a/src/accountinfo.cpp b/src/accountinfo.cpp --- a/src/accountinfo.cpp +++ b/src/accountinfo.cpp @@ -38,6 +38,7 @@ #include #include #include +#include AccountInfo::AccountInfo(AccountModel* model, QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f) @@ -103,6 +104,10 @@ return; } + if (!m_infoToSave.isEmpty()) { + if (KMessageBox::questionYesNo(this,i18n("You modified the current user, do want to save that change now ?"),QString(),KStandardGuiItem::save(),KStandardGuiItem::discard())==KMessageBox::Yes) save(); + } + m_index = index; m_infoToSave.clear(); loadFromModel(); @@ -248,7 +253,7 @@ m_infoToSave = infoToSave; - Q_EMIT changed(!m_infoToSave.isEmpty()); + emit changed(!m_infoToSave.isEmpty()); } QString AccountInfo::cleanName(QString name) const @@ -361,7 +366,7 @@ bool AccountInfo::validateEmail(const QString& email) const { if (email.isEmpty()) { - return false; + return true; } QString strPatt = QStringLiteral("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,63}\\b"); @@ -400,7 +405,7 @@ QString path = gallery->url().toLocalFile(); m_info->face->setIcon(QIcon(path)); m_infoToSave.insert(AccountModel::Face, path); - Q_EMIT changed(true); + emit changed(true); } QStringList AccountInfo::imageFormats() const @@ -440,7 +445,7 @@ CreateAvatarJob *aJob = qobject_cast(job); m_info->face->setIcon(QIcon(aJob->avatarPath())); m_infoToSave.insert(AccountModel::Face, aJob->avatarPath()); - Q_EMIT changed(true); + emit changed(true); } } @@ -459,7 +464,7 @@ { m_info->face->setIcon(QIcon::fromTheme(QStringLiteral("user-identity")).pixmap(48, 48)); m_infoToSave.insert(AccountModel::Face, QString()); - Q_EMIT changed(true); + emit changed(true); } void AccountInfo::changePassword() @@ -472,5 +477,5 @@ } m_infoToSave[AccountModel::Password] = dialog->password(); - Q_EMIT changed(true); + emit changed(true); } diff --git a/src/usermanager.cpp b/src/usermanager.cpp --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -41,7 +41,11 @@ , m_widget(new AccountInfo(m_model, this)) , m_ui(new Ui::KCMUserManager) { - Q_UNUSED(args); + Q_UNUSED(args) + + // No default button + setButtons( Apply | Help); + QVBoxLayout *layout = new QVBoxLayout(); m_ui->setupUi(this); m_ui->accountInfo->setLayout(layout); @@ -61,7 +65,7 @@ connect(m_ui->addBtn, &QAbstractButton::clicked, this, &UserManager::addNewUser); connect(m_ui->removeBtn, &QAbstractButton::clicked, this, &UserManager::removeUser); - connect(m_widget, SIGNAL(changed(bool)), SIGNAL(changed(bool))); + connect(m_widget, &AccountInfo::changed, this, &KCModule::changed); connect(m_model, &QAbstractItemModel::dataChanged, this, &UserManager::dataChanged); } @@ -82,7 +86,7 @@ void UserManager::currentChanged(const QModelIndex& selected, const QModelIndex& previous) { - Q_UNUSED(previous); + Q_UNUSED(previous) m_widget->setModelIndex(selected); bool enabled = false; @@ -97,7 +101,7 @@ void UserManager::dataChanged(const QModelIndex& topLeft, const QModelIndex& topRight) { - Q_UNUSED(topRight); + Q_UNUSED(topRight) if (m_selectionModel->currentIndex() != topLeft) { return; } @@ -133,7 +137,7 @@ bool deleteFiles = result == KMessageBox::Yes ? false : true; m_model->removeAccountKeepingFiles(index.row(), deleteFiles); - Q_EMIT changed(false); + emit changed(false); } #include "usermanager.moc"