aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src-qt5/core-utils/lumina-config/PanelWidget.cpp10
-rw-r--r--src-qt5/core-utils/lumina-config/PanelWidget.h2
-rw-r--r--src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp119
-rw-r--r--src-qt5/core-utils/lumina-config/pages/page_interface_panels.h4
-rw-r--r--src-qt5/core-utils/lumina-config/pages/page_interface_panels.ui36
5 files changed, 95 insertions, 76 deletions
diff --git a/src-qt5/core-utils/lumina-config/PanelWidget.cpp b/src-qt5/core-utils/lumina-config/PanelWidget.cpp
index d5d3d9bd..2b138fd0 100644
--- a/src-qt5/core-utils/lumina-config/PanelWidget.cpp
+++ b/src-qt5/core-utils/lumina-config/PanelWidget.cpp
@@ -23,7 +23,7 @@ PanelWidget::PanelWidget(QWidget *parent, QWidget *Main, LPlugins *Pinfo) : QWid
ui->combo_edge->addItem(tr("Bottom"), "bottom");
ui->combo_edge->addItem(tr("Left"), "left");
ui->combo_edge->addItem(tr("Right"), "right");
-
+
LoadIcons();
//Now connect any other signals/slots
connect(ui->combo_edge, SIGNAL(currentIndexChanged(int)), this, SLOT(ItemChanged()) );
@@ -32,11 +32,11 @@ PanelWidget::PanelWidget(QWidget *parent, QWidget *Main, LPlugins *Pinfo) : QWid
connect(ui->spin_pxthick, SIGNAL(valueChanged(int)), this, SLOT(ItemChanged()) );
connect(ui->check_autohide, SIGNAL(stateChanged(int)), this, SLOT(ItemChanged()) );
connect(ui->group_customcolor, SIGNAL(toggled(bool)), this, SLOT(ItemChanged()) );
-
+
}
PanelWidget::~PanelWidget(){
-
+
}
void PanelWidget::LoadSettings(QSettings *settings, int Dnum, int Pnum){
@@ -90,8 +90,8 @@ void PanelWidget::LoadSettings(QSettings *settings, int Dnum, int Pnum){
reloadColorSample();
}
-void PanelWidget::SaveSettings(QSettings *settings){//save the current settings
- QString screenID = QApplication::screens().at(dnum)->name();
+void PanelWidget::SaveSettings(QSettings *settings, QString screenID){//save the current settings
+ if(screenID.isEmpty()){ screenID = QApplication::screens().at(dnum)->name(); }
QString prefix = "panel_"+screenID+"."+QString::number(pnum)+"/";
qDebug() << "Saving panel settings:" << prefix;
settings->setValue(prefix+"location", ui->combo_edge->currentData().toString() );
diff --git a/src-qt5/core-utils/lumina-config/PanelWidget.h b/src-qt5/core-utils/lumina-config/PanelWidget.h
index f4e67c2d..8854a798 100644
--- a/src-qt5/core-utils/lumina-config/PanelWidget.h
+++ b/src-qt5/core-utils/lumina-config/PanelWidget.h
@@ -23,7 +23,7 @@ public:
~PanelWidget();
void LoadSettings(QSettings *settings, int Dnum, int Pnum);
- void SaveSettings(QSettings *settings); //save the current settings
+ void SaveSettings(QSettings *settings, QString screenID = ""); //save the current settings
int PanelNumber();
void ChangePanelNumber(int newnum);
diff --git a/src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp b/src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp
index 48f1d17c..61c089fa 100644
--- a/src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp
+++ b/src-qt5/core-utils/lumina-config/pages/page_interface_panels.cpp
@@ -6,6 +6,8 @@
//===========================================
#include "page_interface_panels.h"
#include "ui_page_interface_panels.h"
+#include <QInputDialog>
+
#include "../GetPluginDialog.h"
#include "../AppDialog.h"
@@ -19,7 +21,6 @@ page_interface_panels::page_interface_panels(QWidget *parent) : PageWidget(paren
settings = new QSettings("lumina-desktop","desktopsettings");
connect(ui->tool_panels_add, SIGNAL(clicked()), this, SLOT(newPanel()) );
updateIcons();
- setupProfiles();
//Create panels container
QHBoxLayout *panels_layout = new QHBoxLayout();
@@ -61,7 +62,7 @@ void page_interface_panels::LoadSettings(int screennum){
int panelnumber = settings->value(DPrefix+"panels",-1).toInt();
if(panelnumber<0){ panelnumber = 0; }
QHBoxLayout *panels_layout = static_cast<QHBoxLayout*>(ui->scroll_panels->widget()->layout());
-
+
//Remove extra panels (if any)
for(int i=panelnumber; i<PANELS.length(); i++){
PanelWidget *tmp = PANELS.takeAt(i);
@@ -87,20 +88,25 @@ void page_interface_panels::LoadSettings(int screennum){
QApplication::processEvents();
loading = false;
- setupImports();
+ setupProfiles();
}
void page_interface_panels::updateIcons(){
ui->tool_panels_add->setIcon( LXDG::findIcon("list-add","") );
- ui->tool_profile->setIcon( LXDG::findIcon("border-color","") );
- ui->tool_import->setIcon( LXDG::findIcon("document-import","") );
+ ui->tool_profile->setIcon( LXDG::findIcon("document-import","") );
}
//=================
-// PRIVATE
+// PRIVATE
//=================
void page_interface_panels::setupProfiles(){
- ui->tool_profile->setMenu( new QMenu(this) );
+ //qDebug() << "Start loading profiles";
+ if(ui->tool_profile->menu()==0){
+ ui->tool_profile->setMenu( new QMenu(this) );
+ connect(ui->tool_profile->menu(), SIGNAL(triggered(QAction*)), this, SLOT(applyProfile(QAction*)) );
+ }
+ else{ ui->tool_profile->menu()->clear(); }
+ ui->tool_profile->menu()->addSection("Profiles");
QAction *act = ui->tool_profile->menu()->addAction(tr("No Panels"));
act->setWhatsThis("none");
act = ui->tool_profile->menu()->addAction("Windows");
@@ -110,29 +116,39 @@ void page_interface_panels::setupProfiles(){
act = ui->tool_profile->menu()->addAction("XFCE");
act->setWhatsThis("xfce");
act = ui->tool_profile->menu()->addAction("Mac OSX");
- act->setWhatsThis("osx");
- connect(ui->tool_profile->menu(), SIGNAL(triggered(QAction*)), this, SLOT(applyProfile(QAction*)) );
-}
+ act->setWhatsThis("osx");
-void page_interface_panels::setupImports(){
- if(ui->tool_import->menu()==0){ ui->tool_import->setMenu( new QMenu(this) ); }
- else{ ui->tool_import->menu()->clear(); }
- //Read all the various disk settings currently saved
- QStringList other = settings->childGroups().filter("panel_");
- qDebug() << "Found Other Settings:" << other;
- for(int i=0; i<other.length(); i++){
- other[i] = other[i].section("_",1,-1).section(".",0,-2);
- }
- other.removeDuplicates();
+ //Add in any custom profiles
+ //qDebug() << " - read settings";
+ QStringList profilesAll = settings->childGroups().filter("panel_");
+ //qDebug() << " - get current screen";
QString current = QApplication::screens().at(cscreen)->name();
- for(int i=0; i<other.length(); i++){
- if(other[i]==current){ continue; } //don't show the current settings
- QAction *act = ui->tool_import->menu()->addAction(other[i]);
- act->setWhatsThis(other[i]);
+ //qDebug() << " - filter list";
+ for(int i=0; i<profilesAll.length(); i++){
+ profilesAll[i] = profilesAll[i].section("_",1,-1).section(".",0,-2);
+ }
+ //qDebug() << "Found Profiles:" << profilesAll;
+ profilesAll.removeDuplicates();
+ profilesAll.removeAll(current);
+ QStringList profiles = profilesAll.filter("profile_");
+ for(int p=0; p<2; p++){
+ if(p==1){ profiles = profilesAll; } //use whats left of the total list
+ ui->tool_profile->menu()->addSection( p==0 ? tr("Custom Profiles") : tr("Copy Screen") );
+ for(int i=0; i<profiles.length(); i++){
+ if(p==0){ profilesAll.removeAll(profiles[i]); } //handling it now
+ QString title = profiles[i];
+ if(title.startsWith("profile_")){ title = title.section("profile_",-1); }
+ QMenu *tmp = new QMenu(ui->tool_profile->menu());
+ tmp->setTitle(title);
+ tmp->addAction(LXDG::findIcon("dialog-ok-apply",""), tr("Apply"))->setWhatsThis("profile_apply::::"+profiles[i]);
+ tmp->addAction(LXDG::findIcon("list-remove",""), tr("Delete"))->setWhatsThis("profile_remove::::"+profiles[i]);
+ ui->tool_profile->menu()->addMenu(tmp);
+ }
+ if(p==0){
+ //Now add the option to create a new profile
+ ui->tool_profile->menu()->addAction(LXDG::findIcon("list-add",""), tr("Create Profile"))->setWhatsThis("profile_new");
+ }
}
-
- connect(ui->tool_import->menu(), SIGNAL(triggered(QAction*)), this, SLOT(applyImport(QAction*)) );
- ui->tool_import->setEnabled(!ui->tool_import->menu()->isEmpty());
}
//=================
@@ -161,7 +177,7 @@ void page_interface_panels::newPanel(){
panelValChanged();
}
-void page_interface_panels::removePanel(int pan){
+void page_interface_panels::removePanel(int pan){
//connected to a signal from the panel widget
bool changed = false;
for(int i=0; i<PANELS.length(); i++){
@@ -180,6 +196,35 @@ void page_interface_panels::removePanel(int pan){
}
void page_interface_panels::applyProfile(QAction *act){
+ QString wt = act->whatsThis();
+ if(wt.startsWith("profile_")){
+ //qDebug() << "Got Profile Action:" << wt;
+ if(wt=="profile_new"){
+ bool ok = false;
+ QString pname = QInputDialog::getText(this, tr("Create Profile"), tr("Name:"), QLineEdit::Normal, "", &ok,Qt::WindowFlags(), Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly );
+ if(!ok || pname.isEmpty()){ return; } //cancelled
+ pname = pname.replace(".","_").replace("/","_");
+ qDebug() << " - Make new profile:" << pname;
+ pname.prepend("profile_");
+ settings->setValue("desktop-"+pname+"/panels", PANELS.length());
+ for(int i=0; i<PANELS.length(); i++){
+ PANELS[i]->SaveSettings(settings, pname);
+ }
+ settings->sync(); //save to disk right now
+ setupProfiles();
+ }else if(wt.startsWith("profile_apply::::") ){
+ applyImport(wt.section("::::",-1) );
+ }else if(wt.startsWith("profile_remove::::") ){
+ QString pname = wt.section("::::",-1);
+ QStringList keys = settings->allKeys().filter(pname);
+ for(int i=0; i<keys.length(); i++){
+ if(keys[i].section("/",0,0).contains(pname)){ settings->remove(keys[i]); }
+ }
+ setupProfiles();
+ }
+ return;
+ }
+ //Manually saving settings based on built-in profile
QString screenID = QApplication::screens().at(cscreen)->name();
QString DPrefix = "desktop-"+screenID+"/";
QString PPrefix = "panel_"+screenID+"."; //NEED TO APPEND PANEL NUMBER (0+)
@@ -261,14 +306,22 @@ void page_interface_panels::applyProfile(QAction *act){
}
void page_interface_panels::applyImport(QAction *act){
+ applyImport(act->whatsThis());
+}
+
+void page_interface_panels::applyImport(QString fromID){
QString cID = QApplication::screens().at(cscreen)->name();
- QString fromID = act->whatsThis();
//QString DPrefix = "desktop-"+screenID+"/";
qDebug() << "Import Panels from " << fromID << " to " << cID;
- //First change the number of panels on the desktop settings
- settings->setValue("desktop-"+cID+"/panels", settings->value("desktop-"+fromID+"/panels"));
- //Now move over all the panels associated with the fromID
- QStringList pans = settings->allKeys().filter("panel_"+fromID);
+ //First find all the values associated with this ID
+ int pannum = settings->value("desktop-"+fromID+"/panels").toInt();
+ QStringList pans = settings->allKeys().filter("panel_"+fromID);
+ fromID.prepend("panel_");
+
+ //save the number of panels which is active
+ settings->setValue("desktop-"+cID+"/panels", pannum);
+ //Now move over all the panel settings associated with the fromID
+ cID.prepend("panel_");
for(int i=0; i<pans.length(); i++){
QString newvar = pans[i];
newvar.replace(fromID, cID);
diff --git a/src-qt5/core-utils/lumina-config/pages/page_interface_panels.h b/src-qt5/core-utils/lumina-config/pages/page_interface_panels.h
index 0008b75f..163fd9f4 100644
--- a/src-qt5/core-utils/lumina-config/pages/page_interface_panels.h
+++ b/src-qt5/core-utils/lumina-config/pages/page_interface_panels.h
@@ -2,7 +2,7 @@
// Lumina Desktop Source Code
// Copyright (c) 2016, Ken Moore
// Available under the 3-clause BSD license
-// See the LICENSE file for full details
+// See the LICENSE file for full details
//===========================================
#ifndef _LUMINA_CONFIG_PAGE_INTERFACE_PANELS_H
#define _LUMINA_CONFIG_PAGE_INTERFACE_PANELS_H
@@ -37,7 +37,6 @@ private:
QList<PanelWidget*> PANELS;
void setupProfiles();
- void setupImports();
private slots:
void panelValChanged();
@@ -45,5 +44,6 @@ private slots:
void removePanel(int); //connected to a signal from the panel widget
void applyProfile(QAction*);
void applyImport(QAction*);
+ void applyImport(QString fromID);
};
#endif
diff --git a/src-qt5/core-utils/lumina-config/pages/page_interface_panels.ui b/src-qt5/core-utils/lumina-config/pages/page_interface_panels.ui
index 412d19f6..e8c2a029 100644
--- a/src-qt5/core-utils/lumina-config/pages/page_interface_panels.ui
+++ b/src-qt5/core-utils/lumina-config/pages/page_interface_panels.ui
@@ -112,40 +112,6 @@
</property>
</widget>
</item>
- <item>
- <widget class="QToolButton" name="tool_import">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>0</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Import</string>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="iconSize">
- <size>
- <width>25</width>
- <height>25</height>
- </size>
- </property>
- <property name="popupMode">
- <enum>QToolButton::InstantPopup</enum>
- </property>
- <property name="toolButtonStyle">
- <enum>Qt::ToolButtonIconOnly</enum>
- </property>
- </widget>
- </item>
</layout>
</item>
<item>
@@ -164,7 +130,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>358</width>
+ <width>357</width>
<height>298</height>
</rect>
</property>
bgstack15