aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core-utils
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core-utils')
-rw-r--r--src-qt5/core-utils/lumina-config/AppDialog.h6
-rw-r--r--src-qt5/core-utils/lumina-config/ColorDialog.cpp9
-rw-r--r--src-qt5/core-utils/lumina-config/GetPluginDialog.cpp10
-rw-r--r--src-qt5/core-utils/lumina-config/LPlugins.cpp10
-rw-r--r--src-qt5/core-utils/lumina-config/ScriptDialog.cpp90
-rw-r--r--src-qt5/core-utils/lumina-config/ScriptDialog.h41
-rw-r--r--src-qt5/core-utils/lumina-config/ScriptDialog.ui143
-rw-r--r--src-qt5/core-utils/lumina-config/lumina-config.pro3
-rw-r--r--src-qt5/core-utils/lumina-config/pages/page_interface_menu.cpp25
9 files changed, 327 insertions, 10 deletions
diff --git a/src-qt5/core-utils/lumina-config/AppDialog.h b/src-qt5/core-utils/lumina-config/AppDialog.h
index 8c35d9b7..392dbe4d 100644
--- a/src-qt5/core-utils/lumina-config/AppDialog.h
+++ b/src-qt5/core-utils/lumina-config/AppDialog.h
@@ -4,7 +4,7 @@
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
-// This is the dialog for catching keyboard events and converting them to X11 keycodes
+// This is the dialog for selecting an installed application
//===========================================
#ifndef _LUMINA_FILE_MANAGER_APP_SELECT_DIALOG_H
#define _LUMINA_FILE_MANAGER_APP_SELECT_DIALOG_H
@@ -40,7 +40,9 @@ public:
}
this->setWindowIcon( LXDG::findIcon("system-search","") );
if(parent!=0){
- QPoint center = parent->geometry().center();
+ QWidget *top = parent;
+ while(!top->isWindow()){ top = top->parentWidget(); }
+ QPoint center = top->geometry().center();
this->move(center.x()-(this->width()/2), center.y()-(this->height()/2) );
}
}
diff --git a/src-qt5/core-utils/lumina-config/ColorDialog.cpp b/src-qt5/core-utils/lumina-config/ColorDialog.cpp
index f984cf0d..860f6069 100644
--- a/src-qt5/core-utils/lumina-config/ColorDialog.cpp
+++ b/src-qt5/core-utils/lumina-config/ColorDialog.cpp
@@ -27,8 +27,12 @@ ColorDialog::ColorDialog(QWidget *parent, LPlugins *plugs, QString colorFilePath
//Now load the given file
loadColors();
//Now center the window on the parent
- QPoint cen = parent->geometry().center();
- this->move( cen.x() - (this->width()/2) , cen.y() - (this->height()/2) );
+if(parent!=0){
+ QWidget *top = parent;
+ while(!top->isWindow()){ top = top->parentWidget(); }
+ QPoint center = top->geometry().center();
+ this->move(center.x()-(this->width()/2), center.y()-(this->height()/2) );
+ }
}
void ColorDialog::loadColors(){
@@ -139,4 +143,3 @@ void ColorDialog::on_tool_editcolor_clicked(){
if(!ok || value.isEmpty()){ return; } //cancelled
updateItem(it, value);
}
-
diff --git a/src-qt5/core-utils/lumina-config/GetPluginDialog.cpp b/src-qt5/core-utils/lumina-config/GetPluginDialog.cpp
index 08359e2d..51ff718a 100644
--- a/src-qt5/core-utils/lumina-config/GetPluginDialog.cpp
+++ b/src-qt5/core-utils/lumina-config/GetPluginDialog.cpp
@@ -13,8 +13,12 @@ GetPluginDialog::GetPluginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::
ui->setupUi(this);
selected = false; //nothing selected by default
//Now center the window on the parent
- QPoint cen = parent->geometry().center();
- this->move( cen.x() - (this->width()/2) , cen.y() - (this->height()/2) );
+ if(parent!=0){
+ QWidget *top = parent;
+ while(!top->isWindow()){ top = top->parentWidget(); }
+ QPoint center = top->geometry().center();
+ this->move(center.x()-(this->width()/2), center.y()-(this->height()/2) );
+ }
//Load the icons
ui->push_cancel->setIcon( LXDG::findIcon("dialog-cancel","") );
ui->push_accept->setIcon( LXDG::findIcon("dialog-ok","") );
@@ -74,4 +78,4 @@ void GetPluginDialog::accept(){
plugID = ui->combo_list->currentData().toString().section("::::",1,1);
selected = true;
this->close();
-} \ No newline at end of file
+}
diff --git a/src-qt5/core-utils/lumina-config/LPlugins.cpp b/src-qt5/core-utils/lumina-config/LPlugins.cpp
index 03490216..cf0c11ac 100644
--- a/src-qt5/core-utils/lumina-config/LPlugins.cpp
+++ b/src-qt5/core-utils/lumina-config/LPlugins.cpp
@@ -58,6 +58,7 @@ LPI LPlugins::colorInfo(QString item){
//===================
// PLUGINS
//===================
+// PANEL PLUGINS
void LPlugins::LoadPanelPlugins(){
PANEL.clear();
//User Button
@@ -167,6 +168,7 @@ void LPlugins::LoadPanelPlugins(){
PANEL.insert(info.ID, info);
}
+// DESKTOP PLUGINS
void LPlugins::LoadDesktopPlugins(){
DESKTOP.clear();
//Calendar Plugin
@@ -232,6 +234,7 @@ void LPlugins::LoadDesktopPlugins(){
}*/
}
+// MENU PLUGINS
void LPlugins::LoadMenuPlugins(){
MENU.clear();
//Terminal
@@ -283,6 +286,13 @@ void LPlugins::LoadMenuPlugins(){
info.ID = "app";
info.icon = "application-x-desktop";
MENU.insert(info.ID, info);
+ //Custom Apps
+ info = LPI(); //clear it
+ info.name = QObject::tr("Menu Script");
+ info.description = QObject::tr("Run an external script to generate a menu");
+ info.ID = "jsonmenu";
+ info.icon = "text-x-script";
+ MENU.insert(info.ID, info);
}
void LPlugins::LoadColorItems(){
diff --git a/src-qt5/core-utils/lumina-config/ScriptDialog.cpp b/src-qt5/core-utils/lumina-config/ScriptDialog.cpp
new file mode 100644
index 00000000..3453486e
--- /dev/null
+++ b/src-qt5/core-utils/lumina-config/ScriptDialog.cpp
@@ -0,0 +1,90 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2014, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "ScriptDialog.h"
+#include "ui_ScriptDialog.h"
+
+//===========
+// PUBLIC
+//===========
+ScriptDialog::ScriptDialog(QWidget *parent) : QDialog(parent), ui(new Ui::ScriptDialog){
+ ui->setupUi(this);
+ ok = false;
+ connect(ui->line_name, SIGNAL(textEdited(QString)), this, SLOT(checkItems()) );
+ connect(ui->line_exec, SIGNAL(textEdited(QString)), this, SLOT(checkItems()) );
+ connect(ui->line_icon, SIGNAL(textEdited(QString)), this, SLOT(checkItems()) );
+ checkItems(true);
+}
+
+ScriptDialog::~ScriptDialog(){
+
+}
+
+//Main interaction functions
+bool ScriptDialog::isValid(){
+ return ok;
+}
+
+QString ScriptDialog::icon(){
+ return ui->line_icon->text();
+}
+
+QString ScriptDialog::name(){
+ return ui->line_name->text();
+}
+
+QString ScriptDialog::command(){
+ return ui->line_exec->text();
+}
+
+//==============
+// PRIVATE SLOTS
+//==============
+void ScriptDialog::on_pushApply_clicked(){
+ ok = true;
+ this->close();
+}
+
+void ScriptDialog::on_pushCancel_clicked(){
+ ok = false;
+ this->close();
+}
+
+void ScriptDialog::on_tool_getexec_clicked(){
+ QString file = QFileDialog::getOpenFileName( this, tr("Select a menu script"), QDir::homePath() );
+ if(file.isEmpty()){ return; } //cancelled
+ ui->line_exec->setText(file);
+ checkItems();
+}
+
+void ScriptDialog::on_tool_geticon_clicked(){
+ QString file = QFileDialog::getOpenFileName( this, tr("Select an icon file"), QDir::homePath() );
+ if(file.isEmpty()){ return; } //cancelled
+ ui->line_icon->setText(file);
+ checkItems();
+}
+
+void ScriptDialog::checkItems(bool firstrun){
+ if(firstrun){
+ ui->line_name->setFocus();
+ ui->label_sample->setPixmap( LXDG::findIcon("text-x-script","").pixmap(32,32) );
+ ui->tool_geticon->setIcon( LXDG::findIcon("system-search","") );
+ ui->tool_getexec->setIcon( LXDG::findIcon("system-search","") );
+ }
+ //Update the icon sample if needed
+ if(icon()!=ui->label_sample->whatsThis()){
+ ui->label_sample->setPixmap( LXDG::findIcon(icon(),"text-x-script").pixmap(32,32) );
+ ui->label_sample->setWhatsThis(icon());
+ }
+ bool good = true;
+ if(name().isEmpty()){ good = false; ui->line_name->setStyleSheet("color: red;"); }
+ else{ ui->line_name->setStyleSheet(""); }
+ QString cmd = command().section(" ",0,0).simplified();
+ if( !LUtils::isValidBinary(cmd) || cmd.isEmpty() ){ good = false; ui->line_exec->setStyleSheet("color: red;"); }
+ else{ ui->line_exec->setStyleSheet(""); }
+
+ ui->pushApply->setEnabled(good);
+}
diff --git a/src-qt5/core-utils/lumina-config/ScriptDialog.h b/src-qt5/core-utils/lumina-config/ScriptDialog.h
new file mode 100644
index 00000000..07ac15d4
--- /dev/null
+++ b/src-qt5/core-utils/lumina-config/ScriptDialog.h
@@ -0,0 +1,41 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2014, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This is the dialog for selecting an installed application
+//===========================================
+#ifndef _LUMINA_FILE_MANAGER_SCRIPT_SELECT_DIALOG_H
+#define _LUMINA_FILE_MANAGER_SCRIPT_SELECT_DIALOG_H
+
+#include "globals.h"
+
+namespace Ui{
+ class ScriptDialog;
+};
+
+class ScriptDialog : public QDialog{
+ Q_OBJECT
+public:
+ ScriptDialog(QWidget *parent = 0);
+ ~ScriptDialog();
+
+ //Main interaction functions
+ bool isValid();
+ QString icon();
+ QString name();
+ QString command();
+
+private:
+ Ui::ScriptDialog *ui;
+ bool ok;
+
+private slots:
+ void on_pushApply_clicked();
+ void on_pushCancel_clicked();
+ void on_tool_getexec_clicked();
+ void on_tool_geticon_clicked();
+ void checkItems(bool firstrun = false);
+};
+#endif
diff --git a/src-qt5/core-utils/lumina-config/ScriptDialog.ui b/src-qt5/core-utils/lumina-config/ScriptDialog.ui
new file mode 100644
index 00000000..a675f2bf
--- /dev/null
+++ b/src-qt5/core-utils/lumina-config/ScriptDialog.ui
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ScriptDialog</class>
+ <widget class="QDialog" name="ScriptDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>404</width>
+ <height>168</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Setup a JSON Menu Script</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout_2">
+ <property name="labelAlignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Visible Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Executable:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Icon:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="line_name"/>
+ </item>
+ <item row="1" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLineEdit" name="line_exec"/>
+ </item>
+ <item>
+ <widget class="QToolButton" name="tool_getexec">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label_sample">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>32</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="text">
+ <string notr="true"/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="line_icon"/>
+ </item>
+ <item>
+ <widget class="QToolButton" name="tool_geticon">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <spacer name="horizontalSpacer">
+ <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="QPushButton" name="pushCancel">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushApply">
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src-qt5/core-utils/lumina-config/lumina-config.pro b/src-qt5/core-utils/lumina-config/lumina-config.pro
index 2e950fe1..5d6e8db9 100644
--- a/src-qt5/core-utils/lumina-config/lumina-config.pro
+++ b/src-qt5/core-utils/lumina-config/lumina-config.pro
@@ -16,6 +16,7 @@ SOURCES += main.cpp \
ColorDialog.cpp \
ThemeDialog.cpp \
GetPluginDialog.cpp \
+ ScriptDialog.cpp \
PanelWidget.cpp
HEADERS += mainWindow.h \
@@ -24,6 +25,7 @@ HEADERS += mainWindow.h \
ColorDialog.h \
ThemeDialog.h \
GetPluginDialog.h \
+ ScriptDialog.h \
PanelWidget.h
FORMS += mainWindow.ui \
@@ -31,6 +33,7 @@ FORMS += mainWindow.ui \
ColorDialog.ui \
ThemeDialog.ui \
GetPluginDialog.ui \
+ ScriptDialog.ui \
PanelWidget.ui
include("pages/pages.pri")
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 742c5728..d211d380 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
@@ -9,7 +9,7 @@
#include "getPage.h"
#include "../AppDialog.h"
#include "../GetPluginDialog.h"
-
+#include "../ScriptDialog.h"
//==========
// PUBLIC
//==========
@@ -52,7 +52,6 @@ QStringList items = settings.value("menu/itemlist", QStringList() ).toStringList
//qDebug() << "Menu Items:" << items;
ui->list_menu->clear();
for(int i=0; i<items.length(); i++){
- LPI info = PINFO->menuPluginInfo(items[i]);
if(items[i].startsWith("app::::")){
bool ok = false;
XDGDesktop desk = LXDG::loadDesktopFile(items[i].section("::::",1,1), ok);
@@ -64,7 +63,20 @@ QStringList items = settings.value("menu/itemlist", QStringList() ).toStringList
item->setToolTip( desk.comment );
ui->list_menu->addItem(item);
continue; //now go to the next item
+ }else if(items[i].startsWith("jsonmenu::::")){
+ LPI info = PINFO->menuPluginInfo( items[i].section("::::",0,0) );
+ if(info.ID.isEmpty()){ continue; } //invalid plugin type (no longer available?)
+ QString exec = items[i].section("::::",1,1);
+
+ QListWidgetItem *item = new QListWidgetItem();
+ item->setWhatsThis( items[i] );
+ item->setIcon( LXDG::findIcon(items[i].section("::::",3,3),info.icon) );
+ item->setText( items[i].section("::::",2,2) +" ("+info.name+")" );
+ item->setToolTip( info.description );
+ ui->list_menu->addItem(item);
+ continue; //now go to the next item
}
+ LPI info = PINFO->menuPluginInfo(items[i]);
if(info.ID.isEmpty()){ continue; } //invalid plugin
//qDebug() << "Add Menu Item:" << info.ID;
QListWidgetItem *item = new QListWidgetItem();
@@ -121,6 +133,15 @@ void page_interface_menu::addmenuplugin(){
it = new QListWidgetItem(LXDG::findIcon(desk.icon,""), desk.name );
it->setWhatsThis(info.ID+"::::"+desk.filePath);
it->setToolTip( desk.comment );
+ }else if(info.ID=="jsonmenu"){
+ //Need to prompt for the script file, name, and icon to use
+ //new ID format: "jsonmenu"::::<exec to run>::::<name>::::<icon>
+ ScriptDialog SD(this);
+ SD.exec();
+ if(!SD.isValid()){ return; }
+ it = new QListWidgetItem( LXDG::findIcon(SD.icon(),"text-x-script"), SD.name()+" ("+info.ID+")" );
+ it->setWhatsThis(info.ID+"::::"+SD.command()+"::::"+SD.name()+"::::"+SD.icon());
+ it->setToolTip( info.description );
}else{
it = new QListWidgetItem( LXDG::findIcon(info.icon,""), info.name );
it->setWhatsThis(info.ID);
bgstack15