diff options
author | Weblate <noreply@weblate.org> | 2016-09-23 07:34:07 +0000 |
---|---|---|
committer | Weblate <noreply@weblate.org> | 2016-09-23 07:34:07 +0000 |
commit | c0d2b4d8d7c7c498ecd8b01fb3da0f93b53b3e60 (patch) | |
tree | 2c8d0d6eab74377d1d6645b90db9f430472212c6 /src-qt5/core-utils | |
parent | Translated using Weblate (lumina_DESKTOP@sv (generated)) (diff) | |
parent | Large update to how XDGDesktop files are created/used. (diff) | |
download | lumina-c0d2b4d8d7c7c498ecd8b01fb3da0f93b53b3e60.tar.gz lumina-c0d2b4d8d7c7c498ecd8b01fb3da0f93b53b3e60.tar.bz2 lumina-c0d2b4d8d7c7c498ecd8b01fb3da0f93b53b3e60.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/core-utils')
16 files changed, 149 insertions, 217 deletions
diff --git a/src-qt5/core-utils/lumina-config/AppDialog.h b/src-qt5/core-utils/lumina-config/AppDialog.h index 392dbe4d..ea7615e2 100644 --- a/src-qt5/core-utils/lumina-config/AppDialog.h +++ b/src-qt5/core-utils/lumina-config/AppDialog.h @@ -9,13 +9,7 @@ #ifndef _LUMINA_FILE_MANAGER_APP_SELECT_DIALOG_H #define _LUMINA_FILE_MANAGER_APP_SELECT_DIALOG_H -#include <QDialog> -#include <QString> -#include <QList> -#include <QPoint> -#include <QDesktopWidget> -#include <QCursor> -#include <LuminaXDG.h> +#include "globals.h" #include "ui_AppDialog.h" @@ -27,16 +21,15 @@ class AppDialog : public QDialog{ Q_OBJECT private: Ui::AppDialog *ui; - QList<XDGDesktop> APPS; public: - AppDialog(QWidget *parent = 0, QList<XDGDesktop> applist = QList<XDGDesktop>()) : QDialog(parent), ui(new Ui::AppDialog){ + AppDialog(QWidget *parent = 0) : QDialog(parent), ui(new Ui::AppDialog){ ui->setupUi(this); //load the designer file - APPS = applist; //save this for later appreset = false; ui->comboBox->clear(); + QList<XDGDesktop*> APPS = LXDG::sortDesktopNames(APPSLIST->apps(false,false)); //Don't show all/hidden for(int i=0; i<APPS.length(); i++){ - ui->comboBox->addItem( LXDG::findIcon(APPS[i].icon,"application-x-executable"), APPS[i].name ); + ui->comboBox->addItem( LXDG::findIcon(APPS[i]->icon,"application-x-executable"), APPS[i]->name, APPS[i]->filePath); } this->setWindowIcon( LXDG::findIcon("system-search","") ); if(parent!=0){ @@ -56,13 +49,14 @@ public: ui->buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); } } - XDGDesktop appselected; //selected application (empty template for cancelled/reset) + + QString appselected; //selected application bool appreset; //Did the user select to reset to defaults? private slots: void on_buttonBox_accepted(){ - appselected = APPS[ ui->comboBox->currentIndex() ]; + appselected = ui->comboBox->currentData().toString(); this->close(); } void on_buttonBox_rejected(){ diff --git a/src-qt5/core-utils/lumina-config/PanelWidget.cpp b/src-qt5/core-utils/lumina-config/PanelWidget.cpp index 7132dcf8..8b38f407 100644 --- a/src-qt5/core-utils/lumina-config/PanelWidget.cpp +++ b/src-qt5/core-utils/lumina-config/PanelWidget.cpp @@ -59,9 +59,8 @@ void PanelWidget::LoadSettings(QSettings *settings, int Dnum, int Pnum){ for(int i=0; i<plugs.length(); i++){ QString pid = plugs[i].section("---",0,0); if(pid.startsWith("applauncher")){ - bool ok = false; - XDGDesktop desk = LXDG::loadDesktopFile(pid.section("::",1,1),ok); - if(ok){ + XDGDesktop desk(pid.section("::",1,1)); + if(desk.type!=XDGDesktop::BAD){ //still need to allow invalid apps QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon(desk.icon,""), desk.name ); it->setWhatsThis(plugs[i]); //make sure to preserve the entire plugin ID (is the unique version) ui->list_plugins->addItem(it); @@ -121,17 +120,15 @@ void PanelWidget::reloadColorSample(){ ui->label_color_sample->setStyleSheet("background: "+ui->label_color_sample->whatsThis()); } -XDGDesktop PanelWidget::getSysApp(bool allowreset){ - AppDialog dlg(this, LXDG::sortDesktopNames( LXDG::systemDesktopFiles() ) ); +QString PanelWidget::getSysApp(bool allowreset){ + AppDialog dlg(this); dlg.allowReset(allowreset); dlg.exec(); - XDGDesktop desk; if(dlg.appreset && allowreset){ - desk.filePath = "reset"; //special internal flag + return "reset"; }else{ - desk = dlg.appselected; + return dlg.appselected; } - return desk; } QString PanelWidget::getColorStyle(QString current, bool allowTransparency){ @@ -183,10 +180,11 @@ void PanelWidget::on_tool_addplugin_clicked(){ QString pan = dlg.plugID; //getNewPanelPlugin(); if(pan == "applauncher"){ //Prompt for the application to add - XDGDesktop app =getSysApp(); - if(app.filePath.isEmpty()){ return; } //cancelled - pan.append("::"+app.filePath); - QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon(app.icon,""), app.name); + QString app =getSysApp(); + if(app.isEmpty()){ return; } //cancelled + pan.append("::"+app); + XDGDesktop desk(app); + QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon(desk.icon,""), desk.name); it->setWhatsThis(pan); ui->list_plugins->addItem(it); ui->list_plugins->setCurrentItem(it); diff --git a/src-qt5/core-utils/lumina-config/PanelWidget.h b/src-qt5/core-utils/lumina-config/PanelWidget.h index 3f3cb360..f4e67c2d 100644 --- a/src-qt5/core-utils/lumina-config/PanelWidget.h +++ b/src-qt5/core-utils/lumina-config/PanelWidget.h @@ -39,7 +39,7 @@ private: int dnum, pnum; void reloadColorSample(); - XDGDesktop getSysApp(bool allowreset = false); + QString getSysApp(bool allowreset = false); QString getColorStyle(QString current, bool allowTransparency = true); private slots: void on_tool_rm_clicked(); diff --git a/src-qt5/core-utils/lumina-config/globals.h b/src-qt5/core-utils/lumina-config/globals.h index c96aaaa3..2a863bda 100644 --- a/src-qt5/core-utils/lumina-config/globals.h +++ b/src-qt5/core-utils/lumina-config/globals.h @@ -22,6 +22,9 @@ #include <QMessageBox> #include <QShortcut> #include <QImageReader> +#include <QDialog> +#include <QPoint> +#include <QCursor> //Now the Lumina Library classes #include <LuminaXDG.h> @@ -31,3 +34,6 @@ #include <LuminaThemes.h> #endif + +//Now the global class for available system applications +extern XDGDesktopList *APPSLIST; diff --git a/src-qt5/core-utils/lumina-config/main.cpp b/src-qt5/core-utils/lumina-config/main.cpp index 856570c0..8df7db48 100644 --- a/src-qt5/core-utils/lumina-config/main.cpp +++ b/src-qt5/core-utils/lumina-config/main.cpp @@ -10,6 +10,9 @@ #include <LuminaUtils.h> #include <LuminaThemes.h> #include <LuminaSingleApplication.h> +#include <LuminaXDG.h> + +XDGDesktopList *APPSLIST = 0; int main(int argc, char ** argv) { diff --git a/src-qt5/core-utils/lumina-config/mainWindow.cpp b/src-qt5/core-utils/lumina-config/mainWindow.cpp index 5f465199..d6ada8f5 100644 --- a/src-qt5/core-utils/lumina-config/mainWindow.cpp +++ b/src-qt5/core-utils/lumina-config/mainWindow.cpp @@ -15,6 +15,8 @@ //============= mainWindow::mainWindow() : QMainWindow(), ui(new Ui::mainWindow()){ ui->setupUi(this); + APPSLIST = new XDGDesktopList(this, true); //keep this up to date while the app is open + QTimer::singleShot(100, APPSLIST, SLOT(updateList())); //don't let this hold up the initial application loading cpage = "somerandomjunktostartwith"; //Need to insert a spacer action in the toolbar QWidget *tmp = new QWidget(this); diff --git a/src-qt5/core-utils/lumina-config/pages/page_autostart.cpp b/src-qt5/core-utils/lumina-config/pages/page_autostart.cpp index b7c52fb7..371791e9 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_autostart.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_autostart.cpp @@ -32,19 +32,19 @@ page_autostart::~page_autostart(){ // PUBLIC SLOTS //================ void page_autostart::SaveSettings(){ - QList<XDGDesktop> STARTAPPS = LXDG::findAutoStartFiles(true); //also want invalid/disabled items + QList<XDGDesktop*> STARTAPPS = LXDG::findAutoStartFiles(true); //also want invalid/disabled items //bool newstartapps = false; for(int i=0; i<ui->list_session_start->count(); i++){ QString file = ui->list_session_start->item(i)->whatsThis(); bool enabled = ui->list_session_start->item(i)->checkState()==Qt::Checked; bool found = false; for(int i=0; i<STARTAPPS.length(); i++){ - if(STARTAPPS[i].filePath==file){ + if(STARTAPPS[i]->filePath==file){ found = true; - if(enabled != !STARTAPPS[i].isHidden){ + if(enabled != !STARTAPPS[i]->isHidden){ //value is different - qDebug() << "Setting Autostart:" << enabled << STARTAPPS[i].filePath; - LXDG::setAutoStarted(enabled, STARTAPPS[i]); + qDebug() << "Setting Autostart:" << enabled << STARTAPPS[i]->filePath; + STARTAPPS[i]->setAutoStarted(enabled); } break; } @@ -55,25 +55,29 @@ void page_autostart::SaveSettings(){ LXDG::setAutoStarted(enabled, file); //newstartapps = true; } - } + } //end loop over GUI items + //Now cleanup all the STARTAPPS data + for(int i=0; STARTAPPS.length(); i++){ STARTAPPS[i]->deleteLater(); } } void page_autostart::LoadSettings(int){ emit HasPendingChanges(false); emit ChangePageTitle( tr("Startup Services") ); - QList<XDGDesktop> STARTAPPS = LXDG::findAutoStartFiles(true); //also want invalid/disabled items + QList<XDGDesktop*> STARTAPPS = LXDG::findAutoStartFiles(true); //also want invalid/disabled items //qDebug() << "StartApps:"; ui->list_session_start->clear(); for(int i=0; i<STARTAPPS.length(); i++){ //qDebug() << STARTAPPS[i].filePath +" -> " +STARTAPPS[i].name << STARTAPPS[i].isHidden; - if( !LXDG::checkValidity(STARTAPPS[i],false) || !QFile::exists(STARTAPPS[i].filePath) ){ continue; } - QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon(STARTAPPS[i].icon,"application-x-executable"), STARTAPPS[i].name ); - it->setWhatsThis(STARTAPPS[i].filePath); //keep the file location - it->setToolTip(STARTAPPS[i].comment); - if(STARTAPPS[i].isHidden){ it->setCheckState( Qt::Unchecked); } + if( !STARTAPPS[i]->isValid() || !QFile::exists(STARTAPPS[i]->filePath) ){ continue; } + QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon(STARTAPPS[i]->icon,"application-x-executable"), STARTAPPS[i]->name ); + it->setWhatsThis(STARTAPPS[i]->filePath); //keep the file location + it->setToolTip(STARTAPPS[i]->comment); + if(STARTAPPS[i]->isHidden){ it->setCheckState( Qt::Unchecked); } else{it->setCheckState( Qt::Checked); } ui->list_session_start->addItem(it); } + //Now cleanup all the STARTAPPS data + for(int i=0; STARTAPPS.length(); i++){ STARTAPPS[i]->deleteLater(); } } void page_autostart::updateIcons(){ @@ -85,17 +89,15 @@ void page_autostart::updateIcons(){ //================= // PRIVATE //================= -XDGDesktop page_autostart::getSysApp(bool allowreset){ - AppDialog dlg(this, LXDG::sortDesktopNames( LXDG::systemDesktopFiles() ) ); +QString page_autostart::getSysApp(bool allowreset){ + AppDialog dlg(this); dlg.allowReset(allowreset); dlg.exec(); - XDGDesktop desk; if(dlg.appreset && allowreset){ - desk.filePath = "reset"; //special internal flag + return "reset"; }else{ - desk = dlg.appselected; + return dlg.appselected; } - return desk; } //================= @@ -109,8 +111,9 @@ void page_autostart::rmsessionstartitem(){ void page_autostart::addsessionstartapp(){ //Prompt for the application to start - XDGDesktop desk = getSysApp(false); //no reset - if(desk.filePath.isEmpty()){ return; } //cancelled + QString app = getSysApp(false); //no reset + if(app.isEmpty()){ return; } //cancelled + XDGDesktop desk(app); QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon(desk.icon,""), desk.name ); it->setWhatsThis(desk.filePath); it->setToolTip(desk.comment); diff --git a/src-qt5/core-utils/lumina-config/pages/page_autostart.h b/src-qt5/core-utils/lumina-config/pages/page_autostart.h index 88f1ef94..60868598 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_autostart.h +++ b/src-qt5/core-utils/lumina-config/pages/page_autostart.h @@ -27,7 +27,7 @@ public slots: private: Ui::page_autostart *ui; - XDGDesktop getSysApp(bool allowreset); + QString getSysApp(bool allowreset); private slots: void rmsessionstartitem(); diff --git a/src-qt5/core-utils/lumina-config/pages/page_defaultapps.cpp b/src-qt5/core-utils/lumina-config/pages/page_defaultapps.cpp index e55beba6..b2a0896c 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_defaultapps.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_defaultapps.cpp @@ -48,9 +48,8 @@ void page_defaultapps::LoadSettings(int){ if(tmp.isEmpty()){ tmp = "lumina-fm"; } if( !QFile::exists(tmp) && !LUtils::isValidBinary(tmp) ){ qDebug() << "Invalid Settings:" << tmp; tmp.clear(); } //invalid settings if(tmp.endsWith(".desktop")){ - bool ok = false; - XDGDesktop file = LXDG::loadDesktopFile(tmp, ok); - if(!ok || file.filePath.isEmpty()){ + XDGDesktop file(tmp); + if(file.type == XDGDesktop::BAD){ //Might be a binary - just print out the raw "path" ui->tool_default_filemanager->setText(tmp.section("/",-1)); ui->tool_default_filemanager->setIcon( LXDG::findIcon("application-x-executable","") ); @@ -70,9 +69,8 @@ void page_defaultapps::LoadSettings(int){ tmp =LXDG::findDefaultAppForMime("application/terminal"); //sessionsettings->value("default-terminal", "xterm").toString(); if( !QFile::exists(tmp) && !LUtils::isValidBinary(tmp) ){ qDebug() << "Invalid Settings:" << tmp; tmp.clear(); } //invalid settings if(tmp.endsWith(".desktop")){ - bool ok = false; - XDGDesktop file = LXDG::loadDesktopFile(tmp, ok); - if(!ok || file.filePath.isEmpty()){ + XDGDesktop file(tmp); + if(file.type == XDGDesktop::BAD){ //Might be a binary - just print out the raw "path" ui->tool_default_terminal->setText(tmp.section("/",-1)); ui->tool_default_terminal->setIcon( LXDG::findIcon("application-x-executable","") ); @@ -92,9 +90,8 @@ void page_defaultapps::LoadSettings(int){ tmp = LXDG::findDefaultAppForMime("x-scheme-handler/http"); //appsettings->value("default/webbrowser", "").toString(); if( !QFile::exists(tmp) && !LUtils::isValidBinary(tmp) ){ qDebug() << "Invalid Settings:" << tmp; tmp.clear(); } //invalid settings if(tmp.endsWith(".desktop")){ - bool ok = false; - XDGDesktop file = LXDG::loadDesktopFile(tmp, ok); - if(!ok || file.filePath.isEmpty()){ + XDGDesktop file(tmp); + if(file.type == XDGDesktop::BAD){ //Might be a binary - just print out the raw "path" ui->tool_default_webbrowser->setText(tmp.section("/",-1)); ui->tool_default_webbrowser->setIcon( LXDG::findIcon("application-x-executable","") ); @@ -114,9 +111,8 @@ void page_defaultapps::LoadSettings(int){ tmp = LXDG::findDefaultAppForMime("application/email"); //appsettings->value("default/email", "").toString(); if( !QFile::exists(tmp) && !LUtils::isValidBinary(tmp) ){ qDebug() << "Invalid Settings:" << tmp; tmp.clear(); } //invalid settings if(tmp.endsWith(".desktop")){ - bool ok = false; - XDGDesktop file = LXDG::loadDesktopFile(tmp, ok); - if(!ok || file.filePath.isEmpty()){ + XDGDesktop file(tmp); + if(file.type == XDGDesktop::BAD){ //Might be a binary - just print out the raw "path" ui->tool_default_email->setText(tmp.section("/",-1)); ui->tool_default_email->setIcon( LXDG::findIcon("application-x-executable","") ); @@ -165,9 +161,8 @@ void page_defaultapps::LoadSettings(int){ //Now load the default (if there is one) it->setWhatsThis(1,def); //save for later if(def.endsWith(".desktop")){ - bool ok = false; - XDGDesktop file = LXDG::loadDesktopFile(def, ok); - if(!ok || file.filePath.isEmpty()){ + XDGDesktop file(def); + if(file.type == XDGDesktop::BAD){ //Might be a binary - just print out the raw "path" it->setText(1,def.section("/",-1)); it->setIcon(1, LXDG::findIcon("application-x-executable","") ); @@ -199,150 +194,80 @@ void page_defaultapps::updateIcons(){ //================= // PRIVATE //================= -XDGDesktop page_defaultapps::getSysApp(bool allowreset){ - AppDialog dlg(this, LXDG::sortDesktopNames( LXDG::systemDesktopFiles() ) ); +QString page_defaultapps::getSysApp(bool allowreset){ + AppDialog dlg(this); dlg.allowReset(allowreset); dlg.exec(); - XDGDesktop desk; if(dlg.appreset && allowreset){ - desk.filePath = "reset"; //special internal flag + return "reset"; }else{ - desk = dlg.appselected; + return dlg.appselected; } - return desk; } -//================= -// PRIVATE SLOTS -//================= -void page_defaultapps::changeDefaultBrowser(){ - //Prompt for the new app - XDGDesktop desk = getSysApp(true); - if(desk.filePath.isEmpty()){ return; }//nothing selected - if(desk.filePath=="reset"){ - desk.filePath=""; - } - //save the new app setting and adjust the button appearance - //appsettings->setValue("default/webbrowser", desk.filePath); - LXDG::setDefaultAppForMime("x-scheme-handler/http", desk.filePath.section("/",-1)); - LXDG::setDefaultAppForMime("x-scheme-handler/https", desk.filePath.section("/",-1)); - QString tmp = desk.filePath; - if(tmp.endsWith(".desktop")){ - bool ok = false; - XDGDesktop file = LXDG::loadDesktopFile(tmp, ok); - if(!ok || file.filePath.isEmpty()){ +void page_defaultapps::updateDefaultButton(QToolButton *button, QString app){ + if(app.endsWith(".desktop")){ + XDGDesktop file(app); + if(file.type == XDGDesktop::BAD){ //Might be a binary - just print out the raw "path" - ui->tool_default_webbrowser->setText(tmp.section("/",-1)); - ui->tool_default_webbrowser->setIcon( LXDG::findIcon("application-x-executable","") ); + button->setText(app.section("/",-1)); + button->setIcon( LXDG::findIcon("application-x-executable","") ); }else{ - ui->tool_default_webbrowser->setText(desk.name); - ui->tool_default_webbrowser->setIcon(LXDG::findIcon(desk.icon,"") ); + button->setText(file.name); + button->setIcon(LXDG::findIcon(file.icon,"") ); } - }else if(tmp.isEmpty()){ - ui->tool_default_webbrowser->setText(tr("Click to Set")); - ui->tool_default_webbrowser->setIcon( LXDG::findIcon("system-help","") ); + }else if(app.isEmpty()){ + button->setText(tr("Click to Set")); + button->setIcon( LXDG::findIcon("system-help","") ); }else{ //Might be a binary - just print out the raw "path" - ui->tool_default_webbrowser->setText(tmp.section("/",-1)); - ui->tool_default_webbrowser->setIcon( LXDG::findIcon("application-x-executable","") ); + button->setText(app.section("/",-1)); + button->setIcon( LXDG::findIcon("application-x-executable","") ); } } +//================= +// PRIVATE SLOTS +//================= +void page_defaultapps::changeDefaultBrowser(){ + //Prompt for the new app + QString app = getSysApp(true); + if(app.isEmpty()){ return; }//nothing selected + if(app=="reset"){ app.clear(); } + //save the new app setting and adjust the button appearance + LXDG::setDefaultAppForMime("x-scheme-handler/http", app.section("/",-1)); + LXDG::setDefaultAppForMime("x-scheme-handler/https", app.section("/",-1)); + updateDefaultButton(ui->tool_default_webbrowser, app); +} + void page_defaultapps::changeDefaultEmail(){ //Prompt for the new app - XDGDesktop desk = getSysApp(true); //allow reset to default - if(desk.filePath.isEmpty()){ return; }//nothing selected - if(desk.filePath=="reset"){ - desk.filePath=""; - } + QString app = getSysApp(true); + if(app.isEmpty()){ return; }//nothing selected + if(app=="reset"){ app.clear(); } //save the new app setting and adjust the button appearance - LXDG::setDefaultAppForMime("application/email",desk.filePath); - // appsettings->setValue("default/email", desk.filePath); - QString tmp = desk.filePath; - if(tmp.endsWith(".desktop")){ - bool ok = false; - XDGDesktop file = LXDG::loadDesktopFile(tmp, ok); - if(!ok || file.filePath.isEmpty()){ - //Might be a binary - just print out the raw "path" - ui->tool_default_email->setText(tmp.section("/",-1)); - ui->tool_default_email->setIcon( LXDG::findIcon("application-x-executable","") ); - }else{ - ui->tool_default_email->setText(file.name); - ui->tool_default_email->setIcon(LXDG::findIcon(file.icon,"") ); - } - }else if(tmp.isEmpty()){ - ui->tool_default_email->setText(tr("Click to Set")); - ui->tool_default_email->setIcon( LXDG::findIcon("system-help","") ); - }else{ - //Might be a binary - just print out the raw "path" - ui->tool_default_email->setText(tmp.section("/",-1)); - ui->tool_default_email->setIcon( LXDG::findIcon("application-x-executable","") ); - } + LXDG::setDefaultAppForMime("application/email",app.section("/",-1)); + updateDefaultButton(ui->tool_default_email, app); } void page_defaultapps::changeDefaultFileManager(){ //Prompt for the new app - XDGDesktop desk = getSysApp(true); - if(desk.filePath.isEmpty()){ return; }//nothing selected - if(desk.filePath=="reset"){ - desk.filePath="lumina-fm"; - } + QString app = getSysApp(true); + if(app.isEmpty()){ return; }//nothing selected + if(app=="reset"){ app = "lumina-fm"; } //save the new app setting and adjust the button appearance - //appsettings->setValue("default/directory", desk.filePath); - //sessionsettings->setValue("default-filemanager", desk.filePath); - LXDG::setDefaultAppForMime("inode/directory", desk.filePath.section("/",-1)); - QString tmp = desk.filePath; - if(tmp.endsWith(".desktop")){ - bool ok = false; - XDGDesktop file = LXDG::loadDesktopFile(tmp, ok); - if(!ok || file.filePath.isEmpty()){ - //Might be a binary - just print out the raw "path" - ui->tool_default_filemanager->setText(tmp.section("/",-1)); - ui->tool_default_filemanager->setIcon( LXDG::findIcon("application-x-executable","") ); - }else{ - ui->tool_default_filemanager->setText(file.name); - ui->tool_default_filemanager->setIcon(LXDG::findIcon(file.icon,"") ); - } - }else if(tmp.isEmpty()){ - ui->tool_default_filemanager->setText(tr("Click to Set")); - ui->tool_default_filemanager->setIcon( LXDG::findIcon("system-help","") ); - }else{ - //Might be a binary - just print out the raw "path" - ui->tool_default_filemanager->setText(tmp.section("/",-1)); - ui->tool_default_filemanager->setIcon( LXDG::findIcon("application-x-executable","") ); - } + LXDG::setDefaultAppForMime("inode/directory", app.section("/",-1)); + updateDefaultButton(ui->tool_default_filemanager, app); } void page_defaultapps::changeDefaultTerminal(){ //Prompt for the new app - XDGDesktop desk = getSysApp(true); - if(desk.filePath.isEmpty()){ return; }//nothing selected - if(desk.filePath=="reset"){ - desk.filePath="xterm"; - } + QString app = getSysApp(true); + if(app.isEmpty()){ return; }//nothing selected + if(app=="reset"){ app = "xterm"; } //save the new app setting and adjust the button appearance - LXDG::setDefaultAppForMime("application/terminal",desk.filePath); - //sessionsettings->setValue("default-terminal", desk.filePath); - QString tmp = desk.filePath; - if(tmp.endsWith(".desktop")){ - bool ok = false; - XDGDesktop file = LXDG::loadDesktopFile(tmp, ok); - if(!ok || file.filePath.isEmpty()){ - //Might be a binary - just print out the raw "path" - ui->tool_default_terminal->setText(tmp.section("/",-1)); - ui->tool_default_terminal->setIcon( LXDG::findIcon("application-x-executable","") ); - }else{ - ui->tool_default_terminal->setText(file.name); - ui->tool_default_terminal->setIcon(LXDG::findIcon(file.icon,"") ); - } - }else if(tmp.isEmpty()){ - ui->tool_default_terminal->setText(tr("Click to Set")); - ui->tool_default_terminal->setIcon( LXDG::findIcon("system-help","") ); - }else{ - //Might be a binary - just print out the raw "path" - ui->tool_default_terminal->setText(tmp.section("/",-1)); - ui->tool_default_terminal->setIcon( LXDG::findIcon("application-x-executable","") ); - } + LXDG::setDefaultAppForMime("application/terminal", app.section("/",-1) ); + updateDefaultButton(ui->tool_default_terminal, app); } void page_defaultapps::cleardefaultitem(){ @@ -374,14 +299,15 @@ void page_defaultapps::setdefaultitem(){ } if(list.isEmpty()){ list << it; } //just do the current item //Prompt for which application to use - XDGDesktop desk = getSysApp(false); //no "reset" option - if(desk.filePath.isEmpty()){ return; }//nothing selected + QString app = getSysApp(false); //no "reset" option + if(app.isEmpty()){ return; }//nothing selected //Now set the items for(int i=0; i<list.length(); i++){ //Set it in the back end - LXDG::setDefaultAppForMime(list[i]->whatsThis(0), desk.filePath); + LXDG::setDefaultAppForMime(list[i]->whatsThis(0), app.section("/",-1)); //Set it in the UI - list[i]->setWhatsThis(1,desk.filePath); //app path + XDGDesktop desk(app); + list[i]->setWhatsThis(1,app); //app path list[i]->setIcon(1,LXDG::findIcon(desk.icon,"")); //reset the icon list[i]->setText(1,desk.name); //reset the name } diff --git a/src-qt5/core-utils/lumina-config/pages/page_defaultapps.h b/src-qt5/core-utils/lumina-config/pages/page_defaultapps.h index afe99d4b..f80ea1ab 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_defaultapps.h +++ b/src-qt5/core-utils/lumina-config/pages/page_defaultapps.h @@ -27,7 +27,9 @@ public slots: private: Ui::page_defaultapps *ui; - XDGDesktop getSysApp(bool allowreset); + QString getSysApp(bool allowreset); + + void updateDefaultButton(QToolButton *button, QString app); private slots: //Simple defaults tab diff --git a/src-qt5/core-utils/lumina-config/pages/page_interface_desktop.cpp b/src-qt5/core-utils/lumina-config/pages/page_interface_desktop.cpp index 7a52959a..fdcde804 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_interface_desktop.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_interface_desktop.cpp @@ -69,9 +69,8 @@ void page_interface_desktop::LoadSettings(int screennum){ dplugs[i] = dplugs[i].section("---",0,0); } if(dplugs[i].startsWith("applauncher::")){ - bool ok = false; - XDGDesktop app = LXDG::loadDesktopFile(dplugs[i].section("::",1,50), ok); - if(!ok){ continue; } //invalid for some reason + XDGDesktop app(dplugs[i].section("::",1,50)); + if(app.type == XDGDesktop::BAD){ continue; } //invalid for some reason //Now fill the item with the necessary info it->setText(app.name); it->setIcon(LXDG::findIcon(app.icon,"") ); @@ -97,17 +96,15 @@ void page_interface_desktop::updateIcons(){ //================= // PRIVATE //================= -XDGDesktop page_interface_desktop::getSysApp(bool allowreset){ - AppDialog dlg(this, LXDG::sortDesktopNames( LXDG::systemDesktopFiles() ) ); +QString page_interface_desktop::getSysApp(bool allowreset){ + AppDialog dlg(this); dlg.allowReset(allowreset); dlg.exec(); - XDGDesktop desk; if(dlg.appreset && allowreset){ - desk.filePath = "reset"; //special internal flag + return "reset"; }else{ - desk = dlg.appselected; + return dlg.appselected; } - return desk; } //================= @@ -122,14 +119,15 @@ void page_interface_desktop::deskplugadded(){ QListWidgetItem *it = new QListWidgetItem(); if(newplug=="applauncher"){ //Prompt for the application to add - XDGDesktop app = getSysApp(); - if(app.filePath.isEmpty()){ return; } //cancelled - newplug.append("::"+app.filePath); + QString app = getSysApp(); + if(app.isEmpty()){ return; } //cancelled + newplug.append("::"+app); + XDGDesktop desk(app); //Now fill the item with the necessary info it->setWhatsThis(newplug); - it->setText(app.name); - it->setIcon(LXDG::findIcon(app.icon,"") ); - it->setToolTip(app.comment); + it->setText(desk.name); + it->setIcon(LXDG::findIcon(desk.icon,"") ); + it->setToolTip(desk.comment); }else{ //Load the info for this plugin LPI info = PINFO->desktopPluginInfo(newplug); diff --git a/src-qt5/core-utils/lumina-config/pages/page_interface_desktop.h b/src-qt5/core-utils/lumina-config/pages/page_interface_desktop.h index e212182a..cfeb7f8c 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_interface_desktop.h +++ b/src-qt5/core-utils/lumina-config/pages/page_interface_desktop.h @@ -33,7 +33,7 @@ private: LPlugins *PINFO; //Get an application on the system - XDGDesktop getSysApp(bool allowreset = false); + QString getSysApp(bool allowreset = false); private slots: void deskplugadded(); diff --git a/src-qt5/core-utils/lumina-config/pages/page_interface_menu.cpp b/src-qt5/core-utils/lumina-config/pages/page_interface_menu.cpp index d211d380..370980d2 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_interface_menu.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_interface_menu.cpp @@ -53,9 +53,8 @@ QStringList items = settings.value("menu/itemlist", QStringList() ).toStringList ui->list_menu->clear(); for(int i=0; i<items.length(); i++){ if(items[i].startsWith("app::::")){ - bool ok = false; - XDGDesktop desk = LXDG::loadDesktopFile(items[i].section("::::",1,1), ok); - if(!ok){ continue; } //invalid application file (no longer installed?) + XDGDesktop desk(items[i].section("::::",1,1)); + if(desk.type == XDGDesktop::BAD){ continue; } //invalid application file (no longer installed?) QListWidgetItem *item = new QListWidgetItem(); item->setWhatsThis( items[i] ); item->setIcon( LXDG::findIcon(desk.icon) ); @@ -99,17 +98,15 @@ void page_interface_menu::updateIcons(){ //================= // PRIVATE //================= -XDGDesktop page_interface_menu::getSysApp(bool allowreset){ - AppDialog dlg(this, LXDG::sortDesktopNames( LXDG::systemDesktopFiles() ) ); +QString page_interface_menu::getSysApp(bool allowreset){ + AppDialog dlg(this); dlg.allowReset(allowreset); dlg.exec(); - XDGDesktop desk; if(dlg.appreset && allowreset){ - desk.filePath = "reset"; //special internal flag + return "reset"; }else{ - desk = dlg.appselected; + return dlg.appselected; } - return desk; } //================= @@ -127,9 +124,10 @@ void page_interface_menu::addmenuplugin(){ if(info.ID=="app"){ //Need to prompt for the exact application to add to the menu // Note: whatsThis() format: "app::::< *.desktop file path >" - XDGDesktop desk = getSysApp(); - if(desk.filePath.isEmpty()){ return; }//nothing selected + QString app = getSysApp(); + if(app.isEmpty()){ return; }//nothing selected //Create the item for the list + XDGDesktop desk(app); it = new QListWidgetItem(LXDG::findIcon(desk.icon,""), desk.name ); it->setWhatsThis(info.ID+"::::"+desk.filePath); it->setToolTip( desk.comment ); diff --git a/src-qt5/core-utils/lumina-config/pages/page_interface_menu.h b/src-qt5/core-utils/lumina-config/pages/page_interface_menu.h index f2a53007..16f80385 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_interface_menu.h +++ b/src-qt5/core-utils/lumina-config/pages/page_interface_menu.h @@ -29,7 +29,7 @@ private: Ui::page_interface_menu *ui; LPlugins *PINFO; //Get an application on the system - XDGDesktop getSysApp(bool allowreset = false); + QString getSysApp(bool allowreset = false); private slots: void addmenuplugin(); diff --git a/src-qt5/core-utils/lumina-search/MainUI.cpp b/src-qt5/core-utils/lumina-search/MainUI.cpp index 99b04b2b..93ee7411 100644 --- a/src-qt5/core-utils/lumina-search/MainUI.cpp +++ b/src-qt5/core-utils/lumina-search/MainUI.cpp @@ -169,8 +169,8 @@ void MainUI::foundSearchItem(QString path){ //Now setup the visuals if(path.simplified().endsWith(".desktop")){ bool ok = false; - XDGDesktop desk = LXDG::loadDesktopFile(path,ok); - if( !ok || !LXDG::checkValidity(desk) ){delete it; return; } //invalid file + XDGDesktop desk(path); + if( !desk.isValid() ){delete it; return; } //invalid file it->setText(desk.name); it->setIcon( LXDG::findIcon(desk.icon, "application-x-desktop") ); }else{ diff --git a/src-qt5/core-utils/lumina-search/Worker.cpp b/src-qt5/core-utils/lumina-search/Worker.cpp index b414a72f..025bcc1e 100644 --- a/src-qt5/core-utils/lumina-search/Worker.cpp +++ b/src-qt5/core-utils/lumina-search/Worker.cpp @@ -6,11 +6,13 @@ Worker::Worker(QObject *parent) : QObject(parent){ //Get the list of all applications and save them in an easily-searchable form - QList<XDGDesktop> apps = LXDG::systemDesktopFiles(); + QList<XDGDesktop*> apps = LXDG::systemDesktopFiles(); for(int i=0; i<apps.length(); i++){ - applist << ":::1:::"+apps[i].name+":::2:::"+apps[i].genericName+":::3:::"+apps[i].comment+":::4:::"+apps[i].filePath; + applist << ":::1:::"+apps[i]->name+":::2:::"+apps[i]->genericName+":::3:::"+apps[i]->comment+":::4:::"+apps[i]->filePath; } stopsearch = false; + //Clean up all the apps structures + for(int i=0; i<apps.length(); i++){ apps[i]->deleteLater(); } } Worker::~Worker(){ @@ -108,4 +110,4 @@ void Worker::beginsearch(){ } emit SearchUpdate( tr("Search Finished") ); emit SearchDone(); -}
\ No newline at end of file +} |