Commit 80eb5f3a authored by Laurent Montel's avatar Laurent Montel 😁

Fix compile with strict compile flags

parent 2fe71836
......@@ -23,6 +23,10 @@ include_directories(${PWQUALITY_INCLUDE_DIR})
# Set KI18n translation domain
add_definitions(-DTRANSLATION_DOMAIN=\"user_manager\")
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DQT_NO_CAST_FROM_ASCII)
add_definitions(-DQT_NO_CAST_TO_ASCII)
add_definitions(-DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT)
add_definitions(-DQT_USE_QSTRINGBUILDER)
add_subdirectory(src)
......
......@@ -103,7 +103,7 @@ AccountInfo::AccountInfo(AccountModel* model, QWidget* parent, Qt::WindowFlags f
m_info->formLayout->insertRow(row, m_info->label_3, m_passwordEdit);
int pixmapSize = m_info->username->sizeHint().height();
m_negative = QIcon::fromTheme("dialog-cancel").pixmap(pixmapSize, pixmapSize);
m_negative = QIcon::fromTheme(QStringLiteral("dialog-cancel")).pixmap(pixmapSize, pixmapSize);
}
AccountInfo::~AccountInfo()
......@@ -284,7 +284,7 @@ QString AccountInfo::cleanUsername(QString username)
username[0] = username[0].toLower();
}
username.remove(' ');
username.remove(QLatin1Char(' '));
m_info->username->setText(username);
return username;
}
......@@ -296,7 +296,7 @@ bool AccountInfo::validateUsername(QString username) const
}
QByteArray userchar = username.toUtf8();
if (getpwnam(userchar) != NULL) {
if (getpwnam(userchar) != nullptr) {
m_info->usernameValidation->setPixmap(m_negative);
m_info->usernameValidation->setToolTip(i18n("This username is already used"));
return false;
......@@ -309,7 +309,7 @@ bool AccountInfo::validateUsername(QString username) const
if (!valid) {
errorTooltip.append(i18n("The username must start with a letter"));
errorTooltip.append("\n");
errorTooltip.append(QStringLiteral("\n"));
}
Q_FOREACH(const char c, userchar) {
......@@ -327,7 +327,7 @@ bool AccountInfo::validateUsername(QString username) const
if (!valid) {
errorTooltip.append(i18n("The username can contain only letters, numbers, score, underscore and dot"));
errorTooltip.append("\n");
errorTooltip.append(QStringLiteral("\n"));
}
static const long MAX_USER_NAME_LENGTH = []() {
......@@ -358,7 +358,7 @@ QString AccountInfo::cleanEmail(QString email)
return email;
}
email = email.toLower().remove(' ');
email = email.toLower().remove(QLatin1Char(' '));
int pos = m_info->email->cursorPosition();
m_info->email->setText(email);
m_info->email->setCursorPosition(pos);
......@@ -372,7 +372,7 @@ bool AccountInfo::validateEmail(const QString& email) const
return false;
}
QString strPatt = "\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,63}\\b";
QString strPatt = QStringLiteral("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,63}\\b");
QRegExp rx(strPatt);
rx.setCaseSensitivity(Qt::CaseInsensitive);
rx.setPatternSyntax(QRegExp::RegExp);
......@@ -416,7 +416,7 @@ QStringList AccountInfo::imageFormats() const
QStringList result;
for(const QByteArray &b: QImageReader::supportedMimeTypes()) {
if (! b.isEmpty())
result.append(QString(b));
result.append(QString::fromLatin1(b));
}
return result;
}
......@@ -465,7 +465,7 @@ void AccountInfo::avatarModelChanged(KJob* job)
void AccountInfo::clearAvatar()
{
QSize icon(IconSize(KIconLoader::Dialog), IconSize(KIconLoader::Dialog));
m_info->face->setIcon(QIcon::fromTheme("user-identity").pixmap(48, 48));
m_info->face->setIcon(QIcon::fromTheme(QStringLiteral("user-identity")).pixmap(48, 48));
m_infoToSave.insert(AccountModel::Face, QString());
Q_EMIT changed(true);
}
......
......@@ -60,7 +60,7 @@ AvatarGallery::AvatarGallery(QWidget *parent) : QDialog(parent)
const QStringList &avatarList = facesDir.entryList(QDir::Files);
for (auto it = avatarList.constBegin(), end = avatarList.constEnd(); it != end; ++it) {
const QString iconPath = (facesDir.absoluteFilePath(*it));
auto *item = new QListWidgetItem(QIcon(iconPath), it->section('.', 0, 0), ui.m_FacesWidget);
auto *item = new QListWidgetItem(QIcon(iconPath), it->section(QLatin1Char('.'), 0, 0), ui.m_FacesWidget);
item->setData(Qt::UserRole, iconPath);
}
}
......
......@@ -53,14 +53,14 @@ QString AutomaticLoginSettings::autoLoginUser() const
bool AutomaticLoginSettings::setAutoLoginUser(const QString& username)
{
KAuth::Action saveAction(QString("org.kde.kcontrol.kcmsddm.save"));
saveAction.setHelperId("org.kde.kcontrol.kcmsddm");
KAuth::Action saveAction(QStringLiteral("org.kde.kcontrol.kcmsddm.save"));
saveAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm"));
QVariantMap args;
args["sddm.conf"] = SDDM_CONFIG_FILE;
args["sddm.conf/Autologin/User"] = username;
args[QStringLiteral("sddm.conf")] = QStringLiteral(SDDM_CONFIG_FILE);
args[QStringLiteral("sddm.conf/Autologin/User")] = username;
saveAction.setHelperId("org.kde.kcontrol.kcmsddm");
saveAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm"));
saveAction.setArguments(args);
auto job = saveAction.execute();
......@@ -79,7 +79,7 @@ AccountModel::AccountModel(QObject* parent)
: QAbstractListModel(parent)
, m_sessions(new UserSession(this))
{
m_dbus = new AccountsManager("org.freedesktop.Accounts", "/org/freedesktop/Accounts", QDBusConnection::systemBus(), this);
m_dbus = new AccountsManager(QStringLiteral("org.freedesktop.Accounts"), QStringLiteral("/org/freedesktop/Accounts"), QDBusConnection::systemBus(), this);
QDBusPendingReply <QList <QDBusObjectPath > > reply = m_dbus->ListCachedUsers();
reply.waitForFinished();
......@@ -94,7 +94,7 @@ AccountModel::AccountModel(QObject* parent)
}
// Adding fake "new user" directly into cache
addAccountToCache("new-user", nullptr);
addAccountToCache(QStringLiteral("new-user"), nullptr);
m_kEmailSettings.setProfile(m_kEmailSettings.defaultProfileName());
......@@ -147,7 +147,7 @@ QVariant AccountModel::data(const QModelIndex& index, int role) const
QFile file(acc->iconFile());
int size = IconSize(KIconLoader::Dialog);
if (!file.exists()) {
return QIcon::fromTheme("user-identity").pixmap(size, size);
return QIcon::fromTheme(QStringLiteral("user-identity")).pixmap(size, size);
}
return QPixmap(file.fileName()).scaled(size, size, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
......@@ -297,7 +297,7 @@ QVariant AccountModel::newUserData(int role) const
case Qt::DisplayRole || AccountModel::FriendlyName:
return i18n("New User");
case Qt::DecorationRole || AccountModel::Face:
return QIcon::fromTheme("list-add-user").pixmap(IconSize(KIconLoader::Dialog), IconSize(KIconLoader::Dialog));
return QIcon::fromTheme(QStringLiteral("list-add-user")).pixmap(IconSize(KIconLoader::Dialog), IconSize(KIconLoader::Dialog));
case AccountModel::Created:
return false;
}
......@@ -350,7 +350,7 @@ bool AccountModel::newUserSetData(const QModelIndex &index, const QVariant& valu
void AccountModel::addAccount(const QString& path)
{
Account *acc = new Account("org.freedesktop.Accounts", path, QDBusConnection::systemBus(), this);
Account *acc = new Account(QStringLiteral("org.freedesktop.Accounts"), path, QDBusConnection::systemBus(), this);
qulonglong uid = acc->uid();
if (!acc->isValid() || acc->lastError().isValid() || acc->systemAccount()) {
return;
......@@ -429,7 +429,7 @@ void AccountModel::UserAdded(const QDBusObjectPath& dbusPath)
return;
}
Account* acc = new Account("org.freedesktop.Accounts", path, QDBusConnection::systemBus(), this);
Account* acc = new Account(QStringLiteral("org.freedesktop.Accounts"), path, QDBusConnection::systemBus(), this);
if (acc->systemAccount()) {
return;
}
......@@ -443,7 +443,7 @@ void AccountModel::UserAdded(const QDBusObjectPath& dbusPath)
// Then we add new-user again.
beginInsertRows(QModelIndex(), row, row);
addAccountToCache("new-user", nullptr);
addAccountToCache(QStringLiteral("new-user"), nullptr);
endInsertRows();
}
......@@ -499,7 +499,7 @@ QString AccountModel::cryptPassword(const QString& password) const
salt.append(alpha.at((qrand() % len)));
}
return crypt(password.toUtf8(), salt);
return QString::fromUtf8(crypt(password.toUtf8().constData(), salt.constData()));
}
QDebug operator<<(QDebug debug, AccountModel::Role role)
......
......@@ -46,7 +46,7 @@ UserSession::UserSession(QObject* parent): QObject(parent)
qDBusRegisterMetaType<UserInfo>();
qDBusRegisterMetaType<UserInfoList>();
m_manager = new Manager("org.freedesktop.login1", "/org/freedesktop/login1", QDBusConnection::systemBus());
m_manager = new Manager(QStringLiteral("org.freedesktop.login1"), QStringLiteral("/org/freedesktop/login1"), QDBusConnection::systemBus());
connect(m_manager, SIGNAL(UserNew(uint,QDBusObjectPath)), SLOT(UserNew(uint)));
connect(m_manager, SIGNAL(UserRemoved(uint,QDBusObjectPath)), SLOT(UserRemoved(uint)));
......@@ -85,4 +85,4 @@ void UserSession::UserRemoved(uint id)
{
qCDebug(USER_MANAGER_LOG) << id;
Q_EMIT userLogged(id, false);
}
\ No newline at end of file
}
......@@ -124,7 +124,7 @@ void UserManager::removeUser()
QString warning = i18n("What do you want to do after deleting %1 ?", m_model->data(index, AccountModel::FriendlyName).toString());
if (!m_model->data(index, AccountModel::Logged).toBool()) {
warning.append("\n\n");
warning.append(QStringLiteral("\n\n"));
warning.append(i18n("This user is using the system right now, removing it will cause problems"));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment