Commit 67ab368c authored by Laurent Montel's avatar Laurent Montel 😁

Make compile with strict compile flags (I found a missing i18n too)

parent 064a30f4
......@@ -41,6 +41,10 @@ find_package(XCB
add_definitions(-DTRANSLATION_DOMAIN=\"kcm_sddm\")
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)
install(FILES kcm_sddm.desktop DESTINATION ${CMAKE_INSTALL_KSERVICES5DIR})
......
......@@ -49,9 +49,9 @@ static QSharedPointer<KConfig> openConfig(const QString &filePath)
ActionReply SddmAuthHelper::save(const QVariantMap &args)
{
ActionReply reply = ActionReply::HelperErrorReply();
QSharedPointer<KConfig> sddmConfig = openConfig(args["sddm.conf"].toString());
QSharedPointer<KConfig> sddmConfig = openConfig(args[QLatin1String("sddm.conf")].toString());
QSharedPointer<KConfig> themeConfig;
QString themeConfigFile = args["theme.conf.user"].toString();
QString themeConfigFile = args[QLatin1String("theme.conf.user")].toString();
if (!themeConfigFile.isEmpty()) {
themeConfig = openConfig(themeConfigFile);
......@@ -60,10 +60,10 @@ ActionReply SddmAuthHelper::save(const QVariantMap &args)
QMap<QString, QVariant>::const_iterator iterator;
for (iterator = args.constBegin() ; iterator != args.constEnd() ; ++iterator) {
if (iterator.key() == "sddm.conf" || iterator.key() == "theme.conf.user")
if (iterator.key() == QLatin1String("sddm.conf") || iterator.key() == QLatin1String("theme.conf.user"))
continue;
QStringList configFields = iterator.key().split('/');
QStringList configFields = iterator.key().split(QLatin1Char('/'));
if (configFields.size() != 3) {
continue;
}
......@@ -73,13 +73,13 @@ ActionReply SddmAuthHelper::save(const QVariantMap &args)
QString groupName = configFields[1];
QString keyName = configFields[2];
if (fileName == "sddm.conf") {
if (fileName == QLatin1String("sddm.conf")) {
sddmConfig->group(groupName).writeEntry(keyName, iterator.value());
} else if (fileName == "theme.conf.user" && !themeConfig.isNull()) {
} else if (fileName == QLatin1String("theme.conf.user") && !themeConfig.isNull()) {
QFileInfo themeConfigFileInfo(themeConfigFile);
QDir configRootDirectory = themeConfigFileInfo.absoluteDir();
if (keyName == "background") {
if (keyName == QLatin1String("background")) {
QFileInfo newBackgroundFileInfo(iterator.value().toString());
QString previousBackground = themeConfig->group(groupName).readEntry(keyName);
......@@ -119,12 +119,12 @@ ActionReply SddmAuthHelper::save(const QVariantMap &args)
ActionReply SddmAuthHelper::installtheme(const QVariantMap &args)
{
const QString filePath = args["filePath"].toString();
const QString filePath = args[QStringLiteral("filePath")].toString();
if (filePath.isEmpty()) {
return ActionReply::HelperErrorReply();
}
const QString themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "sddm/themes", QStandardPaths::LocateDirectory);
const QString themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sddm/themes"), QStandardPaths::LocateDirectory);
QDir dir(themesBaseDir);
if (!dir.exists()) {
return ActionReply::HelperErrorReply();
......@@ -162,7 +162,7 @@ ActionReply SddmAuthHelper::installtheme(const QVariantMap &args)
if (!archive->open(QIODevice::ReadOnly)) {
auto e = ActionReply::HelperErrorReply();
e.setErrorDescription("Could not open file");
e.setErrorDescription(i18n("Could not open file"));
return e;
}
......@@ -181,13 +181,13 @@ ActionReply SddmAuthHelper::installtheme(const QVariantMap &args)
return e;
}
auto subDirectory = static_cast<const KArchiveDirectory*>(entry);
auto metadataFile = subDirectory->file("metadata.desktop");
auto metadataFile = subDirectory->file(QStringLiteral("metadata.desktop"));
if(!metadataFile || !metadataFile->data().contains("[SddmGreeterTheme]")) {
auto e = ActionReply::HelperErrorReply();
e.setErrorDescription(i18n("Invalid theme package"));
return e;
}
installedPaths.append(themesBaseDir + '/' + name);
installedPaths.append(themesBaseDir + QLatin1Char('/') + name);
}
if (!directory->copyTo(themesBaseDir)) {
......@@ -203,8 +203,8 @@ ActionReply SddmAuthHelper::installtheme(const QVariantMap &args)
ActionReply SddmAuthHelper::uninstalltheme(const QVariantMap &args)
{
const QString themePath = args["filePath"].toString();
const QString themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "sddm/themes", QStandardPaths::LocateDirectory);
const QString themePath = args[QStringLiteral("filePath")].toString();
const QString themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sddm/themes"), QStandardPaths::LocateDirectory);
QDir dir(themePath);
if (!dir.exists()) {
......
......@@ -41,14 +41,14 @@ int main(int argc, char **argv)
const QString description = i18n("SDDM theme installer");
const char version[] = "1.0";
app.setApplicationVersion(version);
app.setApplicationVersion(QString::fromLatin1(version));
parser.addVersionOption();
parser.addHelpOption();
parser.setApplicationDescription(description);
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("i") << QStringLiteral("install"), i18n("Install a theme.")));
parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("u") << QStringLiteral("uninstall"), i18n("Uninstall a theme.")));
parser.addPositionalArgument("themefile", i18n("The theme to install, must be an existing archive file."));
parser.addPositionalArgument(QStringLiteral("themefile"), i18n("The theme to install, must be an existing archive file."));
parser.process(app);
......@@ -66,7 +66,7 @@ int main(int argc, char **argv)
}
KAuth::Action action(QStringLiteral("org.kde.kcontrol.kcmsddm.installtheme"));
action.setHelperId("org.kde.kcontrol.kcmsddm");
action.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm"));
action.addArgument(QStringLiteral("filePath"), themefile.absoluteFilePath());
KAuth::ExecuteJob *job = action.execute();
......@@ -78,7 +78,7 @@ int main(int argc, char **argv)
}
KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("sddmthemeinstallerrc"), KConfig::SimpleConfig), "DownloadedThemes");
cg.writeEntry(themefile.absoluteFilePath(), job->data().value("installedPaths").toStringList());
cg.writeEntry(themefile.absoluteFilePath(), job->data().value(QStringLiteral("installedPaths")).toStringList());
return 0;
}
if (parser.isSet(QLatin1String("uninstall"))) {
......@@ -86,7 +86,7 @@ int main(int argc, char **argv)
const QStringList installed = cg.readEntry(args.first(), QStringList());
for (const QString &installedTheme: installed) {
KAuth::Action action(QStringLiteral("org.kde.kcontrol.kcmsddm.uninstalltheme"));
action.setHelperId("org.kde.kcontrol.kcmsddm");
action.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm"));
action.addArgument(QStringLiteral("filePath"), installedTheme);
KAuth::ExecuteJob *job = action.execute();
job->exec();
......
......@@ -118,24 +118,24 @@ QVariantMap AdvanceConfig::save()
if (cursorIndex.isValid()) {
const CursorTheme *cursorTheme = proxyCursorModel->theme(cursorIndex);
if (cursorTheme)
args["sddm.conf/Theme/CursorTheme"] = cursorTheme->name();
args[QStringLiteral("sddm.conf/Theme/CursorTheme")] = cursorTheme->name();
}
args["sddm.conf/Autologin/User"] = ( configUi->autoLogin->isChecked() ) ? configUi->userList->currentText() : "";
args["sddm.conf/Autologin/Session"] = ( configUi->autoLogin->isChecked() ) ? configUi->sessionList->currentData() : "";
args[QStringLiteral("sddm.conf/Autologin/User")] = ( configUi->autoLogin->isChecked() ) ? configUi->userList->currentText() : QString();
args[QStringLiteral("sddm.conf/Autologin/Session")] = ( configUi->autoLogin->isChecked() ) ? configUi->sessionList->currentData() : QString();
args["sddm.conf/Autologin/Relogin"] = configUi->reloginAfterQuit->isChecked();
args[QStringLiteral("sddm.conf/Autologin/Relogin")] = configUi->reloginAfterQuit->isChecked();
//TODO session
int minUid = configUi->minimumUid->text().toInt();
int maxUid = configUi->maximumUid->text().toInt();
if (isUidRangeValid(minUid, maxUid)) {
args["sddm.conf/Users/MinimumUid"] = configUi->minimumUid->text();
args["sddm.conf/Users/MaximumUid"] = configUi->maximumUid->text();
args[QStringLiteral("sddm.conf/Users/MinimumUid")] = configUi->minimumUid->text();
args[QStringLiteral("sddm.conf/Users/MaximumUid")] = configUi->maximumUid->text();
}
args["sddm.conf/General/HaltCommand"] = configUi->haltCommand->url().toLocalFile();
args["sddm.conf/General/RebootCommand"] = configUi->rebootCommand->url().toLocalFile();
args[QStringLiteral("sddm.conf/General/HaltCommand")] = configUi->haltCommand->url().toLocalFile();
args[QStringLiteral("sddm.conf/General/RebootCommand")] = configUi->rebootCommand->url().toLocalFile();
return args;
}
......
......@@ -73,7 +73,7 @@ QString SelectImageButton::imagePath() const {
void SelectImageButton::onLoadImageFromFile()
{
QUrl fileUrl = QFileDialog::getOpenFileUrl(this, i18nc("@title:window", "Select Image"), QUrl(), "image/*", nullptr, 0, QStringList() << "file");
QUrl fileUrl = QFileDialog::getOpenFileUrl(this, i18nc("@title:window", "Select Image"), QUrl(), QStringLiteral("image/*"), nullptr, nullptr, QStringList() << QStringLiteral("file"));
if (!fileUrl.isEmpty()) {
setImagePath(fileUrl.path());
......
......@@ -38,7 +38,7 @@ CursorTheme::CursorTheme(const QString &title, const QString &description)
{
setTitle(title);
setDescription(description);
setSample("left_ptr");
setSample(QStringLiteral("left_ptr"));
setIsHidden(false);
setIsWritable(false);
}
......@@ -127,8 +127,8 @@ QPixmap CursorTheme::createIcon(int size) const
QPixmap pixmap;
QImage image = loadImage(sample(), size);
if (image.isNull() && sample() != "left_ptr")
image = loadImage("left_ptr", size);
if (image.isNull() && sample() != QLatin1String("left_ptr"))
image = loadImage(QStringLiteral("left_ptr"), size);
if (!image.isNull())
{
......
......@@ -178,11 +178,11 @@ const QStringList CursorThemeModel::searchPaths()
path = xcursorPath;
#else
// Get the search path from Xcursor
QString path = XcursorLibraryPath();
QString path = QString::fromLatin1(XcursorLibraryPath());
#endif
// Separate the paths
baseDirs = path.split(':', QString::SkipEmptyParts);
baseDirs = path.split(QLatin1Char(':'), QString::SkipEmptyParts);
// Remove duplicates
QMutableStringListIterator i(baseDirs);
......@@ -196,7 +196,7 @@ const QStringList CursorThemeModel::searchPaths()
}
// Expand all occurrences of ~/ to the home dir
baseDirs.replaceInStrings(QRegExp("^~\\/"), QDir::home().path() + '/');
baseDirs.replaceInStrings(QRegExp(QLatin1String("^~\\/")), QDir::home().path() + QLatin1Char('/'));
return baseDirs;
}
......@@ -227,15 +227,15 @@ bool CursorThemeModel::isCursorTheme(const QString &theme, const int depth)
continue;
// If there's a cursors subdir, we'll assume this is a cursor theme
if (dir.exists("cursors"))
if (dir.exists(QStringLiteral("cursors")))
return true;
// If the theme doesn't have an index.theme file, it can't inherit any themes.
if (!dir.exists("index.theme"))
if (!dir.exists(QStringLiteral("index.theme")))
continue;
// Open the index.theme file, so we can get the list of inherited themes
KConfig config(dir.path() + "/index.theme", KConfig::NoGlobals);
KConfig config(dir.path() + QStringLiteral("/index.theme"), KConfig::NoGlobals);
KConfigGroup cg(&config, "Icon Theme");
// Recurse through the list of inherited themes, to check if one of them
......@@ -271,10 +271,10 @@ bool CursorThemeModel::handleDefault(const QDir &themeDir)
}
// If there's no cursors subdir, or if it's empty
if (!themeDir.exists("cursors") || QDir(themeDir.path() + "/cursors")
if (!themeDir.exists(QStringLiteral("cursors")) || QDir(themeDir.path() + QStringLiteral("/cursors"))
.entryList(QDir::Files | QDir::NoDotAndDotDot ).isEmpty())
{
if (themeDir.exists("index.theme"))
if (themeDir.exists(QStringLiteral("index.theme")))
{
XCursorTheme theme(themeDir);
if (!theme.inherits().isEmpty())
......@@ -290,12 +290,12 @@ bool CursorThemeModel::handleDefault(const QDir &themeDir)
void CursorThemeModel::processThemeDir(const QDir &themeDir)
{
bool haveCursors = themeDir.exists("cursors");
bool haveCursors = themeDir.exists(QStringLiteral("cursors"));
// Special case handling of "default", since it's usually either a
// symlink to another theme, or an empty theme that inherits another
// theme.
if (defaultName.isNull() && themeDir.dirName() == "default")
if (defaultName.isNull() && themeDir.dirName() == QLatin1String("default"))
{
if (handleDefault(themeDir))
return;
......@@ -303,7 +303,7 @@ void CursorThemeModel::processThemeDir(const QDir &themeDir)
// If the directory doesn't have a cursors subdir and lacks an
// index.theme file it can't be a cursor theme.
if (!themeDir.exists("index.theme") && !haveCursors)
if (!themeDir.exists(QStringLiteral("index.theme")) && !haveCursors)
return;
// Create a cursor theme object for the theme dir
......
......@@ -43,10 +43,10 @@ XCursorTheme::XCursorTheme(const QDir &themeDir)
setPath(themeDir.path());
setIsWritable(QFileInfo(themeDir.path()).isWritable()); // ### perhaps this shouldn't be cached
if (themeDir.exists("index.theme"))
if (themeDir.exists(QStringLiteral("index.theme")))
parseIndexFile();
QString cursorFile = path() + "/cursors/left_ptr";
QString cursorFile = path() + QStringLiteral("/cursors/left_ptr");
QList<int> sizeList;
XcursorImages *images = XcursorFilenameLoadAllImages(qPrintable(cursorFile));
if (images)
......@@ -65,7 +65,7 @@ XCursorTheme::XCursorTheme(const QDir &themeDir)
QString sizeListString = QString::number(sizeList.takeFirst());
while (!sizeList.isEmpty())
{
sizeListString.append(", ");
sizeListString.append(QStringLiteral(", "));
sizeListString.append(QString::number(sizeList.takeFirst()));
};
QString tempString = i18nc(
......@@ -76,14 +76,14 @@ XCursorTheme::XCursorTheme(const QDir &themeDir)
if (m_description.isEmpty())
m_description = tempString;
else
m_description = m_description + ' ' + tempString;
m_description = m_description + QLatin1Char(' ') + tempString;
};
}
void XCursorTheme::parseIndexFile()
{
KConfig config(path() + "/index.theme", KConfig::NoGlobals);
KConfig config(path() + QStringLiteral("/index.theme"), KConfig::NoGlobals);
KConfigGroup cg(&config, "Icon Theme");
m_title = cg.readEntry("Name", m_title);
......@@ -104,27 +104,27 @@ QString XCursorTheme::findAlternative(const QString &name) const
// If Xcursor fails to load the cursor, Qt creates it with the correct name using the
// core protcol instead (which in turn calls Xcursor). We emulate that process here.
// Note that there's a core cursor called cross, but it's not the one Qt expects.
alternatives.insert("cross", "crosshair");
alternatives.insert("up_arrow", "center_ptr");
alternatives.insert("wait", "watch");
alternatives.insert("ibeam", "xterm");
alternatives.insert("size_all", "fleur");
alternatives.insert("pointing_hand", "hand2");
alternatives.insert(QStringLiteral("cross"), QStringLiteral("crosshair"));
alternatives.insert(QStringLiteral("up_arrow"), QStringLiteral("center_ptr"));
alternatives.insert(QStringLiteral("wait"), QStringLiteral("watch"));
alternatives.insert(QStringLiteral("ibeam"), QStringLiteral("xterm"));
alternatives.insert(QStringLiteral("size_all"), QStringLiteral("fleur"));
alternatives.insert(QStringLiteral("pointing_hand"), QStringLiteral("hand2"));
// Precomputed MD5 hashes for the hardcoded bitmap cursors in Qt and KDE.
// Note that the MD5 hash for left_ptr_watch is for the KDE version of that cursor.
alternatives.insert("size_ver", "00008160000006810000408080010102");
alternatives.insert("size_hor", "028006030e0e7ebffc7f7070c0600140");
alternatives.insert("size_bdiag", "fcf1c3c7cd4491d801f1e1c78f100000");
alternatives.insert("size_fdiag", "c7088f0f3e6c8088236ef8e1e3e70000");
alternatives.insert("whats_this", "d9ce0ab605698f320427677b458ad60b");
alternatives.insert("split_h", "14fef782d02440884392942c11205230");
alternatives.insert("split_v", "2870a09082c103050810ffdffffe0204");
alternatives.insert("forbidden", "03b6e0fcb3499374a867c041f52298f0");
alternatives.insert("left_ptr_watch", "3ecb610c1bf2410f44200f48c40d3599");
alternatives.insert("hand2", "e29285e634086352946a0e7090d73106");
alternatives.insert("openhand", "9141b49c8149039304290b508d208c40");
alternatives.insert("closedhand", "05e88622050804100c20044008402080");
alternatives.insert(QStringLiteral("size_ver"), QStringLiteral("00008160000006810000408080010102"));
alternatives.insert(QStringLiteral("size_hor"), QStringLiteral("028006030e0e7ebffc7f7070c0600140"));
alternatives.insert(QStringLiteral("size_bdiag"), QStringLiteral("fcf1c3c7cd4491d801f1e1c78f100000"));
alternatives.insert(QStringLiteral("size_fdiag"), QStringLiteral("c7088f0f3e6c8088236ef8e1e3e70000"));
alternatives.insert(QStringLiteral("whats_this"), QStringLiteral("d9ce0ab605698f320427677b458ad60b"));
alternatives.insert(QStringLiteral("split_h"), QStringLiteral("14fef782d02440884392942c11205230"));
alternatives.insert(QStringLiteral("split_v"), QStringLiteral("2870a09082c103050810ffdffffe0204"));
alternatives.insert(QStringLiteral("forbidden"), QStringLiteral("03b6e0fcb3499374a867c041f52298f0"));
alternatives.insert(QStringLiteral("left_ptr_watch"), QStringLiteral("3ecb610c1bf2410f44200f48c40d3599"));
alternatives.insert(QStringLiteral("hand2"), QStringLiteral("e29285e634086352946a0e7090d73106"));
alternatives.insert(QStringLiteral("openhand"), QStringLiteral("9141b49c8149039304290b508d208c40"));
alternatives.insert(QStringLiteral("closedhand"), QStringLiteral("05e88622050804100c20044008402080"));
}
return alternatives.value(name, QString());
......
......@@ -40,29 +40,28 @@
#include <kauthexecutejob.h>
K_PLUGIN_FACTORY(SddmKcmFactory, registerPlugin<SddmKcm>();)
K_EXPORT_PLUGIN(SddmKcmFactory("kcm_sddm"))
SddmKcm::SddmKcm(QWidget *parent, const QVariantList &args) :
KCModule(parent, args)
{
KAboutData* aboutData = new KAboutData("kcmsddm", i18n("SDDM KDE Config"), PROJECT_VERSION);
KAboutData* aboutData = new KAboutData(QStringLiteral("kcmsddm"), i18n("SDDM KDE Config"), QString::fromLatin1(PROJECT_VERSION));
aboutData->setShortDescription(i18n("Login screen using the SDDM"));
aboutData->setLicense(KAboutLicense::GPL_V2);
aboutData->setHomepage("https://projects.kde.org/projects/kde/workspace/sddm-kcm");
aboutData->setHomepage(QStringLiteral("https://projects.kde.org/projects/kde/workspace/sddm-kcm"));
aboutData->addAuthor("Reza Fatahilah Shah", i18n("Author"), "rshah0385@kireihana.com");
aboutData->addAuthor("David Edmundson", i18n("Author"), "davidedmundson@kde.org");
aboutData->addAuthor(QStringLiteral("Reza Fatahilah Shah"), i18n("Author"), QStringLiteral("rshah0385@kireihana.com"));
aboutData->addAuthor(QStringLiteral("David Edmundson"), i18n("Author"), QStringLiteral("davidedmundson@kde.org"));
setAboutData(aboutData);
setNeedsAuthorization(true);
mSddmConfig = KSharedConfig::openConfig(SDDM_CONFIG_FILE, KConfig::CascadeConfig);
mSddmConfig = KSharedConfig::openConfig(QString::fromLatin1(SDDM_CONFIG_FILE), KConfig::CascadeConfig);
// This does not listen for new config files in the directory.
QStringList configFiles = QDir(SDDM_CONFIG_DIR).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware),
systemConfigFiles = QDir(SDDM_SYSTEM_CONFIG_DIR).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware);
QStringList configFiles = QDir(QString::fromLatin1(SDDM_CONFIG_DIR)).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware),
systemConfigFiles = QDir(QString::fromLatin1(SDDM_SYSTEM_CONFIG_DIR)).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware);
std::transform(systemConfigFiles.begin(), systemConfigFiles.end(), systemConfigFiles.begin(),
[](const QString &filename) { return QStringLiteral(SDDM_SYSTEM_CONFIG_DIR "/") + filename; });
std::transform(configFiles.begin(), configFiles.end(), configFiles.begin(),
......@@ -81,19 +80,19 @@ void SddmKcm::save()
{
QVariantMap args;
args["sddm.conf"] = SDDM_CONFIG_FILE;
args[QStringLiteral("sddm.conf")] = QString::fromLatin1(SDDM_CONFIG_FILE);
if (!mThemeConfig->themeConfigPath().isEmpty()) {
args["theme.conf.user"] = mThemeConfig->themeConfigPath() + ".user";
args[QStringLiteral("theme.conf.user")] = QString(mThemeConfig->themeConfigPath() + QLatin1String(".user"));
}
qDebug() << "Ovr:" << args["theme.conf.user"].toString();
qDebug() << "Ovr:" << args[QStringLiteral("theme.conf.user")].toString();
args.unite(mThemeConfig->save());
args.unite(mAdvanceConfig->save());
KAuth::Action saveAction = authAction();
saveAction.setHelperId("org.kde.kcontrol.kcmsddm");
saveAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm"));
saveAction.setArguments(args);
auto job = saveAction.execute();
......
......@@ -46,8 +46,8 @@ public:
};
SessionModel::SessionModel(QObject *parent) : QAbstractListModel(parent), d(new SessionModelPrivate()) {
loadDir("/usr/share/xsessions", SessionTypeX);
loadDir("/usr/share/wayland-sessions", SessionTypeWayland);
loadDir(QStringLiteral("/usr/share/xsessions"), SessionTypeX);
loadDir(QStringLiteral("/usr/share/wayland-sessions"), SessionTypeWayland);
}
SessionModel::~SessionModel() {
......@@ -57,14 +57,14 @@ SessionModel::~SessionModel() {
void SessionModel::loadDir(const QString &path, SessionType type)
{
QDir dir(path);
dir.setNameFilters(QStringList() << "*.desktop");
dir.setNameFilters(QStringList() << QLatin1String("*.desktop"));
dir.setFilter(QDir::Files);
// read session
foreach(const QString &session, dir.entryList()) {
QFile inputFile(dir.absoluteFilePath(session));
if (!inputFile.open(QIODevice::ReadOnly))
continue;
SessionPtr si { new Session { session, "", "", "" } };
SessionPtr si { new Session { session, QString(), QString(), QString() } };
bool isHidden = false;
QString current_section;
QTextStream in(&inputFile);
......@@ -81,16 +81,16 @@ void SessionModel::loadDir(const QString &path, SessionType type)
if (current_section != QLatin1String("Desktop Entry"))
continue; // We are only interested in the "Desktop Entry" section
if (line.startsWith("Name=")) {
if (line.startsWith(QLatin1String("Name="))) {
si->name = line.mid(5);
if (type == SessionTypeWayland) {
//we want to exactly match the SDDM prompt which is formatted in this way
si->name = i18nc("%1 is the name of a session", "%1 (Wayland)", si->name);
}
}
if (line.startsWith("Exec="))
if (line.startsWith(QLatin1String("Exec=")))
si->exec = line.mid(5);
if (line.startsWith("Comment="))
if (line.startsWith(QLatin1String("Comment=")))
si->comment = line.mid(8);
if (line.startsWith(QLatin1String("Hidden=")))
isHidden = line.mid(7).toLower() == QLatin1String("true");
......
......@@ -80,14 +80,14 @@ QVariantMap ThemeConfig::save()
QVariantMap args;
args["sddm.conf/Theme/Current"] = index.data(ThemesModel::IdRole);
args[QStringLiteral("sddm.conf/Theme/Current")] = index.data(ThemesModel::IdRole);
if (!mThemeConfigPath.isEmpty()) {
if (!mBackgroundPath.isEmpty()) {
args["theme.conf.user/General/background"] = mBackgroundPath;
args["theme.conf.user/General/type"] = QStringLiteral("image");
args[QStringLiteral("theme.conf.user/General/background")] = mBackgroundPath;
args[QStringLiteral("theme.conf.user/General/type")] = QStringLiteral("image");
} else {
args["theme.conf.user/General/type"] = QStringLiteral("color");
args[QStringLiteral("theme.conf.user/General/type")] = QStringLiteral("color");
}
}
return args;
......@@ -128,7 +128,7 @@ QModelIndex ThemeConfig::findThemeIndex(const QString &id) const
void ThemeConfig::themeSelected(const QModelIndex &index)
{
if (!configUi->quickWidget->source().isValid()) {
const QString mainQmlPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "sddm-kcm/main.qml");
const QString mainQmlPath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sddm-kcm/main.qml"));
configUi->quickWidget->setSource(QUrl::fromLocalFile(mainQmlPath));
}
......@@ -165,7 +165,7 @@ void ThemeConfig::prepareConfigurationUi(const QString &configPath)
QFile configFile(configPath);
if (configFile.exists()) {
KSharedConfigPtr themeConfig = KSharedConfig::openConfig(configFile.fileName() + ".user", KConfig::CascadeConfig);
KSharedConfigPtr themeConfig = KSharedConfig::openConfig(configFile.fileName() + QStringLiteral(".user"), KConfig::CascadeConfig);
themeConfig->addConfigSources({configFile.fileName()});
configUi->customizeBox->setVisible(true);
......@@ -202,7 +202,7 @@ void ThemeConfig::installFromFileClicked()
if (files.count() == 1) {
QString file = files.first();
KAuth::Action saveAction(QStringLiteral("org.kde.kcontrol.kcmsddm.installtheme"));
saveAction.setHelperId("org.kde.kcontrol.kcmsddm");
saveAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm"));
saveAction.addArgument(QStringLiteral("filePath"), file);
auto job = saveAction.execute();
if (!job->exec()) {
......@@ -225,7 +225,7 @@ void ThemeConfig::removeThemeClicked()
const QString path = configUi->themesListView->currentIndex().data(ThemesModel::PathRole).toString();
KAuth::Action saveAction(QStringLiteral("org.kde.kcontrol.kcmsddm.uninstalltheme"));
saveAction.setHelperId("org.kde.kcontrol.kcmsddm");
saveAction.setHelperId(QStringLiteral("org.kde.kcontrol.kcmsddm"));
saveAction.addArgument(QStringLiteral("filePath"), path);
auto job = saveAction.execute();
if (!job->exec()) {
......
......@@ -45,8 +45,8 @@ public:
ThemeMetadata::ThemeMetadata(const QString &id, const QString &path)
: d(new ThemeMetadataPrivate)
{
d->path = path + "/";
read(d->path + "metadata.desktop");
d->path = path + QLatin1Char('/');
read(d->path + QStringLiteral("metadata.desktop"));
d->themeid = id;
}
......
......@@ -99,7 +99,7 @@ void ThemesDelegate::paint(QPainter *painter,
//Use a QTextDocument to layout the text
QTextDocument document;
QString html = QString("<strong>%1</strong>").arg(title);
QString html = QStringLiteral("<strong>%1</strong>").arg(title);
//Set the text color according to the item state
QPalette::ColorGroup cg = QPalette::Active;
......@@ -115,7 +115,7 @@ void ThemesDelegate::paint(QPainter *painter,
color = QApplication::palette().brush(cg, QPalette::Text).color();
}
html = QString("<div style=\"color: %1\" align=\"center\">%2</div>").arg(color.name()).arg(html);
html = QStringLiteral("<div style=\"color: %1\" align=\"center\">%2</div>").arg(color.name()).arg(html);
document.setHtml(html);
......@@ -147,7 +147,7 @@ QSize ThemesDelegate::sizeHint(const QStyleOptionViewItem &option,
//Generate a sample complete entry (with the real title) to calculate sizes
QTextDocument document;
QString html = QString("<strong>%1</strong><br />").arg(title);
const QString html = QStringLiteral("<strong>%1</strong><br />").arg(title);
document.setHtml(html);
document.setTextWidth(m_maxWidth);
......
......@@ -90,10 +90,10 @@ void ThemesModel::populate()
endResetModel();
}
QString themesBaseDir = KSharedConfig::openConfig(SDDM_CONFIG_FILE, KConfig::SimpleConfig)->group("Theme").readEntry("ThemeDir");
QString themesBaseDir = KSharedConfig::openConfig(QString::fromLatin1(SDDM_CONFIG_FILE), KConfig::SimpleConfig)->group("Theme").readEntry("ThemeDir");
if (themesBaseDir.isEmpty()) {
themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "sddm/themes", QStandardPaths::LocateDirectory);
themesBaseDir = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sddm/themes"), QStandardPaths::LocateDirectory);
}
QDir dir(themesBaseDir);
......@@ -103,9 +103,9 @@ void ThemesModel::populate()
}
foreach (const QString &theme, dir.entryList(QDir::AllDirs | QDir::Readable)) {
QString path = themesBaseDir + '/' + theme;
QString path = themesBaseDir + QLatin1Char('/') + theme;
if (QFile::exists(path + "/metadata.desktop" )) {
if (QFile::exists(path + QStringLiteral("/metadata.desktop") )) {
add(theme, path);
}
}
......
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