diff options
-rw-r--r-- | src-qt5/core-utils/lumina-config/globals.h | 1 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/mainWindow.cpp | 7 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/mainWindow.h | 1 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/mainWindow.ui | 4 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/PageWidget.h | 4 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/getPage.h | 7 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/page_autostart.cpp | 153 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/page_autostart.h | 38 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/page_autostart.ui | 128 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/page_main.cpp | 1 | ||||
-rw-r--r-- | src-qt5/core-utils/lumina-config/pages/pages.pri | 12 |
11 files changed, 292 insertions, 64 deletions
diff --git a/src-qt5/core-utils/lumina-config/globals.h b/src-qt5/core-utils/lumina-config/globals.h index 04c680f4..b7468970 100644 --- a/src-qt5/core-utils/lumina-config/globals.h +++ b/src-qt5/core-utils/lumina-config/globals.h @@ -20,6 +20,7 @@ #include <QFileDialog> #include <QColorDialog> #include <QMessageBox> +#include <QShortcut> //Now the Lumina Library classes #include <LuminaXDG.h> diff --git a/src-qt5/core-utils/lumina-config/mainWindow.cpp b/src-qt5/core-utils/lumina-config/mainWindow.cpp index 9121d295..3102fe7b 100644 --- a/src-qt5/core-utils/lumina-config/mainWindow.cpp +++ b/src-qt5/core-utils/lumina-config/mainWindow.cpp @@ -20,6 +20,8 @@ mainWindow::mainWindow() : QMainWindow(), ui(new Ui::mainWindow()){ QWidget *tmp = new QWidget(this); tmp->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); ui->toolBar->insertWidget(ui->actionSave, tmp); //after the save button + backShortcut = new QShortcut(Qt::Key_Escape, this); + connect(backShortcut, SIGNAL(activated()), this, SLOT(on_actionBack_triggered()) ); setupIcons(); loadMonitors(); changePage(""); //load the default main page @@ -37,6 +39,7 @@ void mainWindow::slotSingleInstance(){ } void mainWindow::setupIcons(){ + this->setWindowIcon( LXDG::findIcon("preferences-desktop") ); ui->actionSave->setIcon( LXDG::findIcon("document-save","") ); ui->actionBack->setIcon( LXDG::findIcon("go-previous-view","") ); ui->actionMonitor->setIcon(LXDG::findIcon("preferences-desktop-display","") ); @@ -81,12 +84,14 @@ void mainWindow::changePage(QString id){ connect(page, SIGNAL(HasPendingChanges(bool)), this, SLOT(pageCanSave(bool)) ); connect(page, SIGNAL(ChangePageTitle(QString)), this, SLOT(pageSetTitle(QString)) ); connect(page, SIGNAL(ChangePage(QString)), this, SLOT(page_change(QString)) ); + page->setFocus(); + ui->toolBar->setVisible( !cpage.isEmpty() ); } //Now load the new page page->LoadSettings(ui->actionMonitor->whatsThis().toInt()); //need to make this show the current screen as needed //Now update this UI a bit based on page settings ui->actionMonitor->setVisible( page->needsScreenSelector() && ui->actionMonitor->menu()->actions().length()>1 ); - + this->showNormal(); } //================ diff --git a/src-qt5/core-utils/lumina-config/mainWindow.h b/src-qt5/core-utils/lumina-config/mainWindow.h index 3e632f4d..14969473 100644 --- a/src-qt5/core-utils/lumina-config/mainWindow.h +++ b/src-qt5/core-utils/lumina-config/mainWindow.h @@ -25,6 +25,7 @@ public slots: private: Ui::mainWindow *ui; + QShortcut *backShortcut; QString cpage; //current page diff --git a/src-qt5/core-utils/lumina-config/mainWindow.ui b/src-qt5/core-utils/lumina-config/mainWindow.ui index 538d1864..0a9f6896 100644 --- a/src-qt5/core-utils/lumina-config/mainWindow.ui +++ b/src-qt5/core-utils/lumina-config/mainWindow.ui @@ -66,8 +66,8 @@ <property name="statusTip"> <string>Back to overall settings</string> </property> - <property name="shortcut"> - <string>Esc</string> + <property name="shortcutContext"> + <enum>Qt::ApplicationShortcut</enum> </property> </action> <action name="actionMonitor"> diff --git a/src-qt5/core-utils/lumina-config/pages/PageWidget.h b/src-qt5/core-utils/lumina-config/pages/PageWidget.h index 937e6692..bee27d24 100644 --- a/src-qt5/core-utils/lumina-config/pages/PageWidget.h +++ b/src-qt5/core-utils/lumina-config/pages/PageWidget.h @@ -28,7 +28,9 @@ class PageWidget : public QWidget{ public: //Main constructor/destructor (create/destroy any interface items) - PageWidget(QWidget *parent) : QWidget(parent){} + PageWidget(QWidget *parent) : QWidget(parent){ + //this->setFocusPolicy(Qt::NoFocus); + } ~PageWidget(){} virtual bool needsScreenSelector(){ return false; } //change this to true for pages which load/set options on a per-screen basis diff --git a/src-qt5/core-utils/lumina-config/pages/getPage.h b/src-qt5/core-utils/lumina-config/pages/getPage.h index 8d3feb0f..33b0e77a 100644 --- a/src-qt5/core-utils/lumina-config/pages/getPage.h +++ b/src-qt5/core-utils/lumina-config/pages/getPage.h @@ -26,8 +26,9 @@ static QList<PAGEINFO> KnownPages(){ // Valid Groups: ["appearance", "interface", "session", "apps"] QList<PAGEINFO> list; //Reminder: <ID>, <name>, <title>, <icon>, <comment>, <category>, <server subsytem list>, <search tags> - list << PageInfo("wallpaper", QObject::tr("Change Wallpaper"), QObject::tr("Wallpaper Settings"), "preferences-desktop-wallpaper",QObject::tr("Change background image(s)"), "appearance", QStringList(), QStringList() << "background" << "wallpaper" << "color" << "theme"); - list << PageInfo("theme", QObject::tr("Change Desktop Theme"), QObject::tr("Theme Settings"), "preferences-desktop-color",QObject::tr("Change interface fonts and colors"), "appearance", QStringList(), QStringList() << "background" << "interface" << "color" << "theme" << "plugins"); + list << PageInfo("wallpaper", QObject::tr("Change Wallpaper"), QObject::tr("Wallpaper Settings"), "preferences-desktop-wallpaper",QObject::tr("Change background image(s)"), "appearance", QStringList(), QStringList() << "background" << "wallpaper" << "color" << "image"); + list << PageInfo("theme", QObject::tr("Change Desktop Theme"), QObject::tr("Theme Settings"), "preferences-desktop-theme",QObject::tr("Change interface fonts and colors"), "appearance", QStringList(), QStringList() << "background" << "interface" << "color" << "theme" << "plugins"); + list << PageInfo("autostart", QObject::tr("Startup Services and Applications"), QObject::tr("Startup Settings"), "preferences-system-session-services",QObject::tr("Automatically start applications or services"), "session", QStringList(), QStringList() << "apps" << "autostart" << "services" << "xdg" << "startup" << "session"); return list; } @@ -35,11 +36,13 @@ static QList<PAGEINFO> KnownPages(){ #include "page_main.h" #include "page_wallpaper.h" #include "page_theme.h" +#include "page_autostart.h" static PageWidget* GetNewPage(QString id, QWidget *parent){ //Find the page that matches this "id" if(id=="wallpaper"){ return new page_wallpaper(parent); } else if(id=="theme"){ return new page_theme(parent); } + else if(id=="autostart"){ return new page_autostart(parent); } //Return the main control_panel page as the fallback/default return new page_main(parent); } diff --git a/src-qt5/core-utils/lumina-config/pages/page_autostart.cpp b/src-qt5/core-utils/lumina-config/pages/page_autostart.cpp new file mode 100644 index 00000000..b7c52fb7 --- /dev/null +++ b/src-qt5/core-utils/lumina-config/pages/page_autostart.cpp @@ -0,0 +1,153 @@ +//=========================================== +// Lumina Desktop Source Code +// Copyright (c) 2016, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "page_autostart.h" +#include "ui_page_autostart.h" +#include "getPage.h" + +#include "../AppDialog.h" +//========== +// PUBLIC +//========== +page_autostart::page_autostart(QWidget *parent) : PageWidget(parent), ui(new Ui::page_autostart()){ + ui->setupUi(this); + ui->list_session_start->setMouseTracking(true); + updateIcons(); + connect(ui->tool_session_addapp, SIGNAL(clicked()), this, SLOT(addsessionstartapp()) ); + connect(ui->tool_session_addbin, SIGNAL(clicked()), this, SLOT(addsessionstartbin()) ); + connect(ui->tool_session_addfile, SIGNAL(clicked()), this, SLOT(addsessionstartfile()) ); + connect(ui->list_session_start, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(settingChanged()) ); +} + +page_autostart::~page_autostart(){ + +} + + + +//================ +// PUBLIC SLOTS +//================ +void page_autostart::SaveSettings(){ + 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){ + found = true; + if(enabled != !STARTAPPS[i].isHidden){ + //value is different + qDebug() << "Setting Autostart:" << enabled << STARTAPPS[i].filePath; + LXDG::setAutoStarted(enabled, STARTAPPS[i]); + } + break; + } + } + if(!found && enabled){ + //New file/binary/app + qDebug() << "Adding new AutoStart File:" << file; + LXDG::setAutoStarted(enabled, file); + //newstartapps = true; + } + } +} + +void page_autostart::LoadSettings(int){ + emit HasPendingChanges(false); + emit ChangePageTitle( tr("Startup Services") ); + 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); } + else{it->setCheckState( Qt::Checked); } + ui->list_session_start->addItem(it); + } +} + +void page_autostart::updateIcons(){ + ui->tool_session_addapp->setIcon( LXDG::findIcon("system-run","") ); + ui->tool_session_addbin->setIcon( LXDG::findIcon("system-search","") ); + ui->tool_session_addfile->setIcon( LXDG::findIcon("run-build-file","") ); +} + +//================= +// PRIVATE +//================= +XDGDesktop page_autostart::getSysApp(bool allowreset){ + AppDialog dlg(this, LXDG::sortDesktopNames( LXDG::systemDesktopFiles() ) ); + dlg.allowReset(allowreset); + dlg.exec(); + XDGDesktop desk; + if(dlg.appreset && allowreset){ + desk.filePath = "reset"; //special internal flag + }else{ + desk = dlg.appselected; + } + return desk; +} + +//================= +// PRIVATE SLOTS +//================= +void page_autostart::rmsessionstartitem(){ + if(ui->list_session_start->currentRow() < 0){ return; } //no item selected + delete ui->list_session_start->takeItem(ui->list_session_start->currentRow()); + settingChanged(); +} + +void page_autostart::addsessionstartapp(){ + //Prompt for the application to start + XDGDesktop desk = getSysApp(false); //no reset + if(desk.filePath.isEmpty()){ return; } //cancelled + QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon(desk.icon,""), desk.name ); + it->setWhatsThis(desk.filePath); + it->setToolTip(desk.comment); + it->setCheckState(Qt::Checked); + + ui->list_session_start->addItem(it); + ui->list_session_start->setCurrentItem(it); + settingChanged(); +} + +void page_autostart::addsessionstartbin(){ + QString chkpath = LOS::AppPrefix() + "bin"; + if(!QFile::exists(chkpath)){ chkpath = QDir::homePath(); } + QString bin = QFileDialog::getOpenFileName(this, tr("Select Binary"), chkpath, tr("Application Binaries (*)") ); + if( bin.isEmpty() || !QFile::exists(bin) ){ return; } //cancelled + if( !QFileInfo(bin).isExecutable() ){ + QMessageBox::warning(this, tr("Invalid Binary"), tr("The selected file is not executable!")); + return; + } + QListWidgetItem *it = new QListWidgetItem( LXDG::findIcon("application-x-executable",""), bin.section("/",-1) ); + it->setWhatsThis(bin); //command to be saved/run + it->setToolTip(bin); + it->setCheckState(Qt::Checked); + ui->list_session_start->addItem(it); + ui->list_session_start->setCurrentItem(it); + settingChanged(); +} + +void page_autostart::addsessionstartfile(){ + QString chkpath = QDir::homePath(); + QString bin = QFileDialog::getOpenFileName(this, tr("Select File"), chkpath, tr("All Files (*)") ); + if( bin.isEmpty() || !QFile::exists(bin) ){ return; } //cancelled + QListWidgetItem *it = new QListWidgetItem( LXDG::findMimeIcon(bin), bin.section("/",-1) ); + it->setWhatsThis(bin); //file to be saved/run + it->setToolTip(bin); + it->setCheckState(Qt::Checked); + ui->list_session_start->addItem(it); + ui->list_session_start->setCurrentItem(it); + settingChanged(); +} diff --git a/src-qt5/core-utils/lumina-config/pages/page_autostart.h b/src-qt5/core-utils/lumina-config/pages/page_autostart.h new file mode 100644 index 00000000..88f1ef94 --- /dev/null +++ b/src-qt5/core-utils/lumina-config/pages/page_autostart.h @@ -0,0 +1,38 @@ +//=========================================== +// Lumina Desktop Source Code +// Copyright (c) 2016, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_CONFIG_PAGE_AUTOSTART_H +#define _LUMINA_CONFIG_PAGE_AUTOSTART_H +#include "../globals.h" +#include "PageWidget.h" + +namespace Ui{ + class page_autostart; +}; + +class page_autostart : public PageWidget{ + Q_OBJECT +public: + page_autostart(QWidget *parent); + ~page_autostart(); + +public slots: + void SaveSettings(); + void LoadSettings(int screennum); + void updateIcons(); + +private: + Ui::page_autostart *ui; + + XDGDesktop getSysApp(bool allowreset); + +private slots: + void rmsessionstartitem(); + void addsessionstartapp(); + void addsessionstartbin(); + void addsessionstartfile(); +}; +#endif diff --git a/src-qt5/core-utils/lumina-config/pages/page_autostart.ui b/src-qt5/core-utils/lumina-config/pages/page_autostart.ui index 0d49005d..b286b4a5 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_autostart.ui +++ b/src-qt5/core-utils/lumina-config/pages/page_autostart.ui @@ -15,71 +15,95 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <property name="leftMargin"> - <number>0</number> + <number>9</number> </property> <property name="topMargin"> - <number>0</number> + <number>6</number> </property> <property name="rightMargin"> - <number>0</number> + <number>9</number> </property> <property name="bottomMargin"> - <number>0</number> + <number>9</number> </property> <item> - <layout class="QHBoxLayout" name="horizontalLayout_18"> - <item> - <spacer name="horizontalSpacer_15"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QToolButton" name="tool_session_addapp_2"> - <property name="text"> - <string>Application</string> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonTextBesideIcon</enum> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="tool_session_addbin_2"> - <property name="text"> - <string>Binary</string> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonTextBesideIcon</enum> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="tool_session_addfile_2"> - <property name="text"> - <string>File</string> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonTextBesideIcon</enum> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QListWidget" name="list_session_start_2"> + <widget class="QListWidget" name="list_session_start"> <property name="sortingEnabled"> <bool>true</bool> </property> </widget> </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Add New Startup Service</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_18"> + <item> + <spacer name="horizontalSpacer_15"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QToolButton" name="tool_session_addapp"> + <property name="text"> + <string>Application</string> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_session_addbin"> + <property name="text"> + <string>Binary</string> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="tool_session_addfile"> + <property name="text"> + <string>File</string> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextBesideIcon</enum> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </item> </layout> </widget> <resources/> diff --git a/src-qt5/core-utils/lumina-config/pages/page_main.cpp b/src-qt5/core-utils/lumina-config/pages/page_main.cpp index 67e41cc4..f8168e0b 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_main.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_main.cpp @@ -84,6 +84,7 @@ void page_main::LoadSettings(int){ INFO.clear(); INFO = KnownPages(); UpdateItems(""); + ui->lineEdit->setFocus(); } void page_main::updateIcons(){ diff --git a/src-qt5/core-utils/lumina-config/pages/pages.pri b/src-qt5/core-utils/lumina-config/pages/pages.pri index 7fd3b19c..7610e946 100644 --- a/src-qt5/core-utils/lumina-config/pages/pages.pri +++ b/src-qt5/core-utils/lumina-config/pages/pages.pri @@ -3,8 +3,8 @@ HEADERS += $${PWD}/getPage.h \ $${PWD}/PageWidget.h \ $${PWD}/page_main.h \ $${PWD}/page_wallpaper.h \ - $${PWD}/page_theme.h -# $${PWD}/page_autostart.h \ + $${PWD}/page_theme.h \ + $${PWD}/page_autostart.h # $${PWD}/page_defaultapps.h \ # $${PWD}/page_fluxbox_keys.h \ # $${PWD}/page_fluxbox_settings.h \ @@ -17,8 +17,8 @@ HEADERS += $${PWD}/getPage.h \ SOURCES += $${PWD}/page_main.cpp \ $${PWD}/page_wallpaper.cpp \ - $${PWD}/page_theme.cpp -# $${PWD}/page_autostart.cpp \ + $${PWD}/page_theme.cpp \ + $${PWD}/page_autostart.cpp # $${PWD}/page_defaultapps.cpp \ # $${PWD}/page_fluxbox_keys.cpp \ # $${PWD}/page_fluxbox_settings.cpp \ @@ -31,8 +31,8 @@ SOURCES += $${PWD}/page_main.cpp \ FORMS += $${PWD}/page_main.ui \ $${PWD}/page_wallpaper.ui \ - $${PWD}/page_theme.ui -# $${PWD}/page_autostart.ui \ + $${PWD}/page_theme.ui \ + $${PWD}/page_autostart.ui # $${PWD}/page_defaultapps.ui \ # $${PWD}/page_fluxbox_keys.ui \ # $${PWD}/page_fluxbox_settings.ui \ |