Commit 8acacca1 authored by Alexander Lohnau's avatar Alexander Lohnau 💬
Browse files

Avoid empty message dialogs, cleanup

- Choose better QString overloads
- Remove unused variables
- Add missing emit keywords
- Avoid multi-arg method call
- Avoid detaching in loop
- Do not show empty error messages, for exmple when the user clicks the
  cancel button

BUG: 407686
FIXED-IN: 5.20
parent e47246e2
......@@ -225,7 +225,7 @@ ActionReply SddmAuthHelper::save(const QVariantMap &args)
{
ActionReply reply = ActionReply::HelperErrorReply();
QSharedPointer<KConfig> sddmConfig = openConfig(QString {QLatin1String(SDDM_CONFIG_DIR "/") + QStringLiteral("kde_settings.conf")});
QSharedPointer<KConfig> sddmOldConfig = openConfig(QLatin1String(SDDM_CONFIG_FILE));
QSharedPointer<KConfig> sddmOldConfig = openConfig(QStringLiteral(SDDM_CONFIG_FILE));
QSharedPointer<KConfig> themeConfig;
QString themeConfigFile = args[QStringLiteral("theme.conf.user")].toString();
......@@ -354,7 +354,8 @@ ActionReply SddmAuthHelper::installtheme(const QVariantMap &args)
//some basic validation
//the top level should only have folders, and those folders should contain a valid metadata.desktop file
//if we get anything else, abort everything before copying
for(const QString &name: directory->entries()) {
const auto entries = directory->entries();
for (const QString &name: entries) {
auto entry = directory->entry(name);
if (!entry->isDirectory()) {
auto e = ActionReply::HelperErrorReply();
......
......@@ -72,8 +72,9 @@ int main(int argc, char **argv)
bool rc = job->exec();
if (!rc) {
QString errorString = job->errorString();
qWarning() << job->error() << errorString;
KMessageBox::sorry(nullptr, errorString, i18n("Unable to install theme"));
if (!errorString.isEmpty()) {
KMessageBox::sorry(nullptr, errorString, i18n("Unable to install theme"));
}
return -1;
}
......
......@@ -240,9 +240,11 @@ void AdvancedConfig::syncSettingsChanged()
qDebug() << "Synchronization failed";
qDebug() << job->errorString();
qDebug() << job->errorText();
KMessageBox::error(this, job->errorText());
if (!job->errorText().isEmpty()) {
KMessageBox::error(this, job->errorText());
}
} else {
changed(false);
Q_EMIT changed(false);
qDebug() << "Synchronization successful";
}
}
......@@ -282,9 +284,11 @@ void AdvancedConfig::resetSettingsChanged()
qDebug() << "Reset failed";
qDebug() << job->errorString();
qDebug() << job->errorText();
KMessageBox::error(this, job->errorText());
if (!job->errorText().isEmpty()) {
KMessageBox::error(this, job->errorText());
}
} else {
changed(false);
Q_EMIT changed(false);
qDebug() << "Reset successful";
}
}
......@@ -40,7 +40,7 @@ K_PLUGIN_FACTORY(SddmKcmFactory, registerPlugin<SddmKcm>();)
SddmKcm::SddmKcm(QWidget *parent, const QVariantList &args) :
KCModule(parent, args)
{
KAboutData* aboutData = new KAboutData(QStringLiteral("kcmsddm"), i18n("SDDM KDE Config"), QLatin1String(PROJECT_VERSION));
KAboutData* aboutData = new KAboutData(QStringLiteral("kcmsddm"), i18n("SDDM KDE Config"), QStringLiteral(PROJECT_VERSION));
aboutData->setShortDescription(i18n("Login screen using the SDDM"));
aboutData->setLicense(KAboutLicense::GPL_V2);
......@@ -55,8 +55,8 @@ SddmKcm::SddmKcm(QWidget *parent, const QVariantList &args) :
mSddmConfig = KSharedConfig::openConfig(QStringLiteral(SDDM_CONFIG_FILE), KConfig::CascadeConfig);
// This does not listen for new config files in the directory.
QStringList configFiles = QDir(QLatin1String(SDDM_CONFIG_DIR)).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware),
systemConfigFiles = QDir(QLatin1String(SDDM_SYSTEM_CONFIG_DIR)).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware);
QStringList configFiles = QDir(QStringLiteral(SDDM_CONFIG_DIR)).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware),
systemConfigFiles = QDir(QStringLiteral(SDDM_SYSTEM_CONFIG_DIR)).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware);
// QStringBuilder keeps dangling references, so force return of QString (QTBUG-47066)
std::transform(systemConfigFiles.begin(), systemConfigFiles.end(), systemConfigFiles.begin(),
......@@ -98,7 +98,7 @@ void SddmKcm::save()
qDebug() << job->errorString();
qDebug() << job->errorText();
} else {
changed(false);
Q_EMIT changed(false);
qDebug() << "Option saved";
}
......
......@@ -51,8 +51,6 @@ void ThemesDelegate::paint(QPainter *painter,
previewFilename += model->data(index, ThemesModel::PreviewRole).toString();
const QString title = model->data(index, Qt::DisplayRole).toString();
const QString author = model->data(index, ThemesModel::AuthorRole).toString();
const QString website = model->data(index, ThemesModel::WebsiteRole).toString();
QPixmap originalPix(previewFilename);
QColor color = option.palette.color(QPalette::Base);
......@@ -116,7 +114,7 @@ void ThemesDelegate::paint(QPainter *painter,
color = QApplication::palette().brush(cg, QPalette::Text).color();
}
html = QStringLiteral("<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(), html);
document.setHtml(html);
......@@ -143,8 +141,6 @@ QSize ThemesDelegate::sizeHint(const QStyleOptionViewItem &option,
const QAbstractItemModel *model = index.model();
const QString title = model->data(index, Qt::DisplayRole).toString();
const QString author = model->data(index, ThemesModel::AuthorRole).toString();
const QString website = model->data(index, ThemesModel::WebsiteRole).toString();
//Generate a sample complete entry (with the real title) to calculate sizes
QTextDocument document;
......
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