From bcfc0269ae3da31f90c3c439cd54ff01faaf44e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 26 Nov 2012 10:05:17 +0100 Subject: [PATCH] Create the decoration listing after the KCModule has been shown If the decoration listing gets initialized directly in the ctor as it used to be, there is the chance of the list being not rendered in case that there are multiple KCMs in one container and one has to switch to the decoration KCM. This is the case for e.g. opening the KWin configuration through the Alt+F3 menu. But that never happened when going through Systemsettings as there (at least with English) it is listed as the first module. BUG: 310613 FIXED-IN: 4.10 --- kcmkwin/kwindecoration/kwindecoration.cpp | 63 +++++++++++++++-------- kcmkwin/kwindecoration/kwindecoration.h | 2 + 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/kcmkwin/kwindecoration/kwindecoration.cpp b/kcmkwin/kwindecoration/kwindecoration.cpp index 8be5c3898e..8e66099ff3 100644 --- a/kcmkwin/kwindecoration/kwindecoration.cpp +++ b/kcmkwin/kwindecoration/kwindecoration.cpp @@ -77,20 +77,13 @@ KWinDecorationModule::KWinDecorationModule(QWidget* parent, const QVariantList & : KCModule(KWinDecoFactory::componentData(), parent) , kwinConfig(KSharedConfig::openConfig("kwinrc")) , m_showTooltips(false) + , m_model(NULL) + , m_proxyModel(NULL) , m_configLoaded(false) , m_decorationButtons(new DecorationButtons(this)) , m_lastPreviewWidth(-1) , m_previewUpdateTimer(NULL) { - const QString mainQmlPath = KStandardDirs::locate("data", "kwin/kcm_kwindecoration/main.qml"); - if (mainQmlPath.isNull()) { - // TODO 4.10 i18n this - KMessageBox::error(this, "

Installation error

" - "The resource

kwin/kcm_kwindecoration/main.qml

could not be located in any application data path." - "

Please contact your distribution

" - "The application will now abort", "Installation Error"); - abort(); - } qmlRegisterType("org.kde.kwin.aurorae", 0, 1, "AuroraeTheme"); m_ui = new KWinDecorationForm(this); m_ui->configureDecorationButton->setIcon(KIcon("configure")); @@ -99,6 +92,41 @@ KWinDecorationModule::KWinDecorationModule(QWidget* parent, const QVariantList & QVBoxLayout* layout = new QVBoxLayout(this); layout->addWidget(m_ui); + KAboutData *about = + new KAboutData(I18N_NOOP("kcmkwindecoration"), 0, + ki18n("Window Decoration Control Module"), + 0, KLocalizedString(), KAboutData::License_GPL, + ki18n("(c) 2001 Karol Szwed")); + about->addAuthor(ki18n("Karol Szwed"), KLocalizedString(), "gallium@kde.org"); + setAboutData(about); +} + + +KWinDecorationModule::~KWinDecorationModule() +{ +} + +void KWinDecorationModule::showEvent(QShowEvent *ev) +{ + KCModule::showEvent(ev); + init(); +} + +void KWinDecorationModule::init() +{ + if (m_model) { + // init already called + return; + } + const QString mainQmlPath = KStandardDirs::locate("data", "kwin/kcm_kwindecoration/main.qml"); + if (mainQmlPath.isNull()) { + // TODO 4.11 i18n this + KMessageBox::error(this, "

Installation error

" + "The resource

kwin/kcm_kwindecoration/main.qml

could not be located in any application data path." + "

Please contact your distribution

" + "The application will now abort", "Installation Error"); + abort(); + } KConfigGroup style(kwinConfig, "Style"); // Set up the decoration lists and other UI settings @@ -140,20 +168,8 @@ KWinDecorationModule::KWinDecorationModule(QWidget* parent, const QVariantList & m_ui->decorationList->installEventFilter(this); m_ui->decorationList->viewport()->installEventFilter(this); - - KAboutData *about = - new KAboutData(I18N_NOOP("kcmkwindecoration"), 0, - ki18n("Window Decoration Control Module"), - 0, KLocalizedString(), KAboutData::License_GPL, - ki18n("(c) 2001 Karol Szwed")); - about->addAuthor(ki18n("Karol Szwed"), KLocalizedString(), "gallium@kde.org"); - setAboutData(about); QMetaObject::invokeMethod(this, "updatePreviews", Qt::QueuedConnection); -} - - -KWinDecorationModule::~KWinDecorationModule() -{ + updateScrollbarRange(); } int KWinDecorationModule::itemWidth() const @@ -476,6 +492,9 @@ bool KWinDecorationModule::eventFilter(QObject *o, QEvent *e) void KWinDecorationModule::updatePreviews() { + if (!m_model) { + return; + } m_ui->decorationList->rootContext()->setContextProperty("sliderWidth", m_ui->decorationList->verticalScrollBar()->width()); const int newWidth = m_ui->decorationList->rootObject()->property("width").toInt(); if (newWidth == m_lastPreviewWidth) diff --git a/kcmkwin/kwindecoration/kwindecoration.h b/kcmkwin/kwindecoration/kwindecoration.h index 07d84f6f0c..8aab67948f 100644 --- a/kcmkwin/kwindecoration/kwindecoration.h +++ b/kcmkwin/kwindecoration/kwindecoration.h @@ -107,6 +107,7 @@ signals: protected: bool eventFilter(QObject *o, QEvent *e); + virtual void showEvent(QShowEvent *ev); protected slots: // Allows us to turn "save" on @@ -116,6 +117,7 @@ protected slots: void slotConfigureDecoration(); private: + void init(); void readConfig(const KConfigGroup& conf); void writeConfig(KConfigGroup &conf); private slots: