From a1d4a91f8c344b539c561b4c6ed46a270b82c7e3 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Thu, 8 Oct 2015 15:18:28 -0400 Subject: Change the application selection widget in lumina-open. Now it is a combobox with clearly labelled categories of applications. --- lumina-open/LFileDialog.cpp | 27 +++++++++++++-------------- lumina-open/LFileDialog.ui | 36 +++++++++++------------------------- 2 files changed, 24 insertions(+), 39 deletions(-) (limited to 'lumina-open') diff --git a/lumina-open/LFileDialog.cpp b/lumina-open/LFileDialog.cpp index 673df3bd..d35a0fc7 100644 --- a/lumina-open/LFileDialog.cpp +++ b/lumina-open/LFileDialog.cpp @@ -18,7 +18,7 @@ LFileDialog::LFileDialog(QWidget *parent) : QDialog(parent), ui(new Ui::LFileDia QSettings::setPath(QSettings::NativeFormat, QSettings::UserScope, QDir::homePath()+"/.lumina"); settings = new QSettings("LuminaDE", "lumina-open",this); //Connect the signals/slots - connect(ui->tree_apps, SIGNAL(itemSelectionChanged()), this, SLOT(updateUI()) ); + connect(ui->combo_apps, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI()) ); connect(ui->radio_rec, SIGNAL(toggled(bool)), this, SLOT(radioChanged()) ); connect(ui->radio_avail, SIGNAL(toggled(bool)), this, SLOT(radioChanged()) ); connect(ui->radio_custom, SIGNAL(toggled(bool)), this, SLOT(radioChanged()) ); @@ -154,10 +154,8 @@ void LFileDialog::updateUI(){ else if(ui->radio_rec->isChecked()){ good = true; //a valid app is always selected on this page if it is available } - else if(ui->tree_apps->topLevelItemCount() > 0 && ui->tree_apps->currentItem()!=0 ){ - if(!ui->tree_apps->currentItem()->whatsThis(0).isEmpty()){ + else if(ui->combo_apps->count() > 0 && !ui->combo_apps->currentData().toString().isEmpty() ){ good=true; - } } ui->tool_ok->setEnabled(good); } @@ -172,10 +170,13 @@ void LFileDialog::generateAppList(bool shownetwork){ QHash< QString, QList > hash = LXDG::sortDesktopCats( LXDG::systemDesktopFiles() ); QStringList cat = hash.keys(); cat.sort(); //sort alphabetically - ui->tree_apps->clear(); + ui->combo_apps->clear(); for(int c=0; c app = hash[cat[c]]; - QTreeWidgetItem *ci = new QTreeWidgetItem(ui->tree_apps, QStringList() << translateCat(cat[c])); + if(app.length()<1){ continue; } + if(ui->combo_apps->count() >1){ ui->combo_apps->insertSeparator(ui->combo_apps->count()); } + ui->combo_apps->addItem(translateCat(cat[c])); + ui->combo_apps->insertSeparator(ui->combo_apps->count()); for(int a=0; asetWhatsThis(0, app[a].filePath); - ti->setIcon(0, LXDG::findIcon(app[a].icon, "application-x-desktop")); - ti->setToolTip(0, app[a].comment); - ci->addChild(ti); + ui->combo_apps->addItem(LXDG::findIcon(app[a].icon, "application-x-desktop"), app[a].name, app[a].filePath); //Check to see if this app matches the mime type if(app[a].mimeList.contains(mimetype) && !mimetype.isEmpty()){ // also put this app in the preferred list - PREFAPPS.append(app[a].filePath); + PREFAPPS.append(app[a].filePath); + //If this is the first preferred app found - select this app initially + if(ui->combo_apps->currentIndex()<=0){ ui->combo_apps->setCurrentIndex(ui->combo_apps->count()-1); } } } - ui->tree_apps->addTopLevelItem(ci); } + if(ui->combo_apps->currentIndex()<=0){ ui->combo_apps->setCurrentIndex(2); } //Start on the first "real" app - not the first category header //Now add all the preferred applications PREFAPPS.removeDuplicates(); for(int i=0; itree_apps->currentItem()->whatsThis(0), ok); + XDGDesktop app = LXDG::loadDesktopFile(ui->combo_apps->currentData().toString(), ok); //Set the output variables appExec = LXDG::getDesktopExec(app); appPath = app.path; diff --git a/lumina-open/LFileDialog.ui b/lumina-open/LFileDialog.ui index 833a5d6d..a6371cbc 100644 --- a/lumina-open/LFileDialog.ui +++ b/lumina-open/LFileDialog.ui @@ -7,7 +7,7 @@ 0 0 307 - 216 + 200 @@ -93,34 +93,20 @@ - - + + + + + + Qt::Vertical + + 20 - 20 + 40 - - Qt::ElideRight - - - 10 - - - false - - - false - - - true - - - - 1 - - - + -- cgit