From ba6b33ad8f6431dace169d5cb04ba9e93e6f0b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Thu, 19 Jun 2014 04:52:11 +0200 Subject: [PATCH] Replace KMessageBox with KMessageWidget for missing language warnings Less modal dialogs, especially not in a loop. Also line-break tooltips: they'd otherwise not word-wrap which completely screws them up by forcing everything onto one line. They're now sensibly sized and readable. CCMAIL:mgraesslin@kde.org --- CMakeLists.txt | 1 + kcmtranslations.cpp | 43 +++++++++----- kcmtranslations.h | 10 ++-- kcmtranslationswidget.ui | 124 ++++++++++++++++++--------------------- 4 files changed, 93 insertions(+), 85 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 672b087a0..b165cb633 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ add_library(kcm_translations ${kcm_translations_PART_SRCS}) target_link_libraries(kcm_translations Qt5::Widgets + KF5::WidgetsAddons KF5::KCMUtils KF5::I18n ) diff --git a/kcmtranslations.cpp b/kcmtranslations.cpp index ced408edc..26ab6542f 100644 --- a/kcmtranslations.cpp +++ b/kcmtranslations.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -37,7 +38,8 @@ K_PLUGIN_FACTORY(KCMTranslationsFactory, registerPlugin();) KCMTranslations::KCMTranslations(QWidget *parent, const QVariantList &args) : KCModule(parent, args), - m_ui(new Ui::KCMTranslationsWidget) + m_ui(new Ui::KCMTranslationsWidget), + m_messageWidget(0) { KAboutData *about = new KAboutData(I18N_NOOP("KCMTranslations"), i18n("Translations"), @@ -110,15 +112,28 @@ void KCMTranslations::load() // Then update all the widgets to use the new settings initWidgets(); - // Now we have a ui built tell the user about the missing languages - foreach (const QString &languageCode, missingLanguages) { - KMessageBox::information(this, i18nc("%1 is the language code", - "You have the language with code '%1' in your list " - "of languages to use for translation but the " - "localization files for it could not be found. The " - "language has been removed from your configuration. " - "If you want to add it again please install the " - "localization files for it and add the language again.", languageCode)); + if (missingLanguages.count()) { + const QString txt = i18ncp("%1 is the language code", + "The translation files for the language with the code '%2' " + "could not be found. The " + "language has been removed from your configuration. " + "If you want to add it back, please install the " + "localization files for it and add the language again.", + + "The translation files for the languages with the codes " + "'%2' could not be found. These " + "languages have been removed from your configuration. " + "If you want to add them back, please install the " + "localization files for it and the languages again.", + missingLanguages.count(), + missingLanguages.join("', '")); + + m_messageWidget = new KMessageWidget(this); + m_messageWidget->setMessageType(KMessageWidget::Information); + m_messageWidget->setWordWrap(true); + m_messageWidget->setText(txt); + + m_ui->verticalLayout->insertWidget(0, m_messageWidget); } } @@ -193,9 +208,9 @@ void KCMTranslations::initTranslations() m_ui->m_selectTranslations->setAvailableLabel(i18n("Available Languages:")); QString availableHelp = i18n("This is the list of installed KDE Plasma language " - "translations not currently being used. To use a language " + "translations not currently being used.
To use a language " "translation move it to the 'Preferred Languages' list in " - "the order of preference. If no suitable languages are " + "the order of preference.
If no suitable languages are " "listed, then you may need to install more language packages " "using your usual installation method."); m_ui->m_selectTranslations->availableListWidget()->setToolTip(availableHelp); @@ -204,8 +219,8 @@ void KCMTranslations::initTranslations() m_ui->m_selectTranslations->setSelectedLabel(i18n("Preferred Languages:")); QString selectedHelp = i18n("This is the list of installed KDE Plasma language " "translations currently being used, listed in order of " - "preference. If a translation is not available for the " - "first language in the list, the next language will be used. " + "preference.
If a translation is not available for the " + "first language in the list, the next language will be used.
" "If no other translations are available then US English will " "be used."); m_ui->m_selectTranslations->selectedListWidget()->setToolTip(selectedHelp); diff --git a/kcmtranslations.h b/kcmtranslations.h index 30591795f..3457f3cf8 100644 --- a/kcmtranslations.h +++ b/kcmtranslations.h @@ -27,10 +27,11 @@ #include class QListWidgetItem; -class QCheckBox; -class KPushButton; -class KComboBox; -class KIntNumInput; +// class QCheckBox; +// class KPushButton; +// class KComboBox; +// class KIntNumInput; +class KMessageWidget; namespace Ui { @@ -82,6 +83,7 @@ private: KConfigGroup m_config; Ui::KCMTranslationsWidget *m_ui; + KMessageWidget *m_messageWidget; }; #endif //KCMTRANSLATIONS_H \ No newline at end of file diff --git a/kcmtranslationswidget.ui b/kcmtranslationswidget.ui index 4ad324281..fe19c80a8 100644 --- a/kcmtranslationswidget.ui +++ b/kcmtranslationswidget.ui @@ -6,8 +6,8 @@ 0 0 - 702 - 425 + 687 + 333 @@ -16,68 +16,62 @@ 0 - + - - - - - - - 0 - 0 - - - - Available Translations: - - - Preferred Translations: - - - - - - - - - false - - - Install more translations - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - + + + + + + 0 + 0 + + + + Available &Translations: + + + Preferred Trans&lations: + + + + + + + false + + + Install more translations + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + @@ -88,10 +82,6 @@
kactionselector.h
- - m_tabWidgetSettings - m_buttonTranslationsInstall -