From 1f57a0dddaab3bc1db09bfb5d93715755b8dbda3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 17 Nov 2020 00:02:59 +0100 Subject: [PATCH] [plasmalnf] Very basic combo-box based UI --- src/modules/plasmalnf/Config.cpp | 2 ++ src/modules/plasmalnf/PlasmaLnfPage.cpp | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/modules/plasmalnf/Config.cpp b/src/modules/plasmalnf/Config.cpp index f5fa59b89..123adecdb 100644 --- a/src/modules/plasmalnf/Config.cpp +++ b/src/modules/plasmalnf/Config.cpp @@ -43,6 +43,8 @@ Config::Config( QObject* parent ) filter->setFilterRole( ThemesModel::ShownRole ); filter->setFilterFixedString( QStringLiteral( "true" ) ); filter->setSourceModel( m_themeModel ); + filter->setSortRole( ThemesModel::LabelRole ); + filter->sort( 0 ); m_filteredModel = filter; } diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 095bd3ec9..cf1330912 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -17,7 +17,8 @@ #include "utils/Logger.h" #include "utils/Retranslator.h" -#include +#include + #include #include @@ -42,4 +43,18 @@ PlasmaLnfPage::PlasmaLnfPage( Config* config, QWidget* parent ) "selection will give you a live preview of that look-and-feel." ) ); } ) connect( this, &PlasmaLnfPage::plasmaThemeSelected, config, &Config::setTheme ); + + QComboBox* box = new QComboBox(); + box->setModel( m_config->themeModel() ); + ui->verticalLayout->addWidget( box ); + + connect( box, QOverload< int >::of( &QComboBox::currentIndexChanged ), [this]( int index ) { + auto* model = m_config->themeModel(); + auto id = model->data( model->index( index, 0 ), ThemesModel::KeyRole ).toString(); + cDebug() << "ComboBox selected" << index << id; + if ( !id.isEmpty() ) + { + emit plasmaThemeSelected( id ); + } + } ); }