[plasmalnf] Replace combobox with a view
This commit is contained in:
parent
3909459563
commit
0a88273e0d
@ -17,8 +17,7 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QListView>
|
||||||
|
|
||||||
|
|
||||||
#include <KPackage/Package>
|
#include <KPackage/Package>
|
||||||
#include <KPackage/PackageLoader>
|
#include <KPackage/PackageLoader>
|
||||||
@ -44,17 +43,24 @@ PlasmaLnfPage::PlasmaLnfPage( Config* config, QWidget* parent )
|
|||||||
} )
|
} )
|
||||||
connect( this, &PlasmaLnfPage::plasmaThemeSelected, config, &Config::setTheme );
|
connect( this, &PlasmaLnfPage::plasmaThemeSelected, config, &Config::setTheme );
|
||||||
|
|
||||||
QComboBox* box = new QComboBox();
|
QListView* view = new QListView( this );
|
||||||
box->setModel( m_config->themeModel() );
|
view->setUniformItemSizes( true );
|
||||||
ui->verticalLayout->addWidget( box );
|
view->setModel( m_config->themeModel() );
|
||||||
|
ui->verticalLayout->addWidget( view );
|
||||||
|
|
||||||
connect( box, QOverload< int >::of( &QComboBox::currentIndexChanged ), [this]( int index ) {
|
connect( view->selectionModel(),
|
||||||
|
&QItemSelectionModel::selectionChanged,
|
||||||
|
[this]( const QItemSelection& selected, const QItemSelection& ) {
|
||||||
|
auto i = selected.indexes();
|
||||||
|
if ( !i.isEmpty() )
|
||||||
|
{
|
||||||
auto* model = m_config->themeModel();
|
auto* model = m_config->themeModel();
|
||||||
auto id = model->data( model->index( index, 0 ), ThemesModel::KeyRole ).toString();
|
auto id = model->data( i.first(), ThemesModel::KeyRole ).toString();
|
||||||
cDebug() << "ComboBox selected" << index << id;
|
cDebug() << "View selected" << selected << id;
|
||||||
if ( !id.isEmpty() )
|
if ( !id.isEmpty() )
|
||||||
{
|
{
|
||||||
emit plasmaThemeSelected( id );
|
emit plasmaThemeSelected( id );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user