diff options
author | ZackaryWelch <welch.zackary@gmail.com> | 2017-09-11 18:27:38 -0400 |
---|---|---|
committer | ZackaryWelch <welch.zackary@gmail.com> | 2017-09-11 18:27:38 -0400 |
commit | 09022703b189a3784ae7ed4c416ad5a08df2716f (patch) | |
tree | f21ab1478d9405763ade1de4f89fbebb64b40d4b /src-qt5/core | |
parent | Added video file detection and correct desktop file translation (diff) | |
parent | Rename the "stylesheets" tab and split it up into two tabs: (diff) | |
download | lumina-09022703b189a3784ae7ed4c416ad5a08df2716f.tar.gz lumina-09022703b189a3784ae7ed4c416ad5a08df2716f.tar.bz2 lumina-09022703b189a3784ae7ed4c416ad5a08df2716f.zip |
Merge branch 'master' of https://github.com/trueos/lumina
Diffstat (limited to 'src-qt5/core')
11 files changed, 104 insertions, 79 deletions
diff --git a/src-qt5/core/libLumina/LDesktopUtils.cpp b/src-qt5/core/libLumina/LDesktopUtils.cpp index 4c87ae22..fe4cfd30 100644 --- a/src-qt5/core/libLumina/LDesktopUtils.cpp +++ b/src-qt5/core/libLumina/LDesktopUtils.cpp @@ -143,6 +143,8 @@ void LDesktopUtils::upgradeFavorites(int){ //fromoldversionnumber void LDesktopUtils::LoadSystemDefaults(bool skipOS){ //Will create the Lumina configuration files based on the current system template (if any) qDebug() << "Loading System Defaults"; + bool skipmime = QFile::exists( QString(getenv("XDG_CONFIG_HOME"))+"/lumina-mimapps.list" ); + qDebug() << " - Skipping mimetype default apps" << skipmime; QStringList sysDefaults; if(!skipOS){ sysDefaults = LUtils::readFile(LOS::AppPrefix()+"etc/luminaDesktop.conf"); } if(sysDefaults.isEmpty() && !skipOS){ sysDefaults = LUtils::readFile(LOS::AppPrefix()+"etc/luminaDesktop.conf.dist"); } @@ -193,18 +195,18 @@ void LDesktopUtils::LoadSystemDefaults(bool skipOS){ if(var=="session_enablenumlock"){ sset = "EnableNumlock="+ istrue; } else if(var=="session_playloginaudio"){ sset = "PlayStartupAudio="+istrue; } else if(var=="session_playlogoutaudio"){ sset = "PlayLogoutAudio="+istrue; } - else if(var=="session_default_terminal"){ + else if(var=="session_default_terminal" && !skipmime){ LXDG::setDefaultAppForMime("application/terminal", val); //sset = "default-terminal="+val; - }else if(var=="session_default_filemanager"){ + }else if(var=="session_default_filemanager" && !skipmime){ LXDG::setDefaultAppForMime("inode/directory", val); //sset = "default-filemanager="+val; //loset = "directory="+val; - }else if(var=="session_default_webbrowser"){ + }else if(var=="session_default_webbrowser" && !skipmime){ //loset = "webbrowser="+val; LXDG::setDefaultAppForMime("x-scheme-handler/http", val); LXDG::setDefaultAppForMime("x-scheme-handler/https", val); - }else if(var=="session_default_email"){ + }else if(var=="session_default_email" && !skipmime){ LXDG::setDefaultAppForMime("application/email",val); //loset = "email="+val; } @@ -225,7 +227,7 @@ void LDesktopUtils::LoadSystemDefaults(bool skipOS){ // -- MIMETYPE DEFAULTS -- tmp = sysDefaults.filter("mime_default_"); - for(int i=0; i<tmp.length(); i++){ + for(int i=0; i<tmp.length() && !skipmime; i++){ if(tmp[i].startsWith("#") || !tmp[i].contains("=") ){ continue; } QString var = tmp[i].section("=",0,0).toLower().simplified(); QString val = tmp[i].section("=",1,1).section("#",0,0).simplified(); diff --git a/src-qt5/core/libLumina/LuminaSingleApplication.cpp b/src-qt5/core/libLumina/LuminaSingleApplication.cpp index 86248666..6811d147 100644 --- a/src-qt5/core/libLumina/LuminaSingleApplication.cpp +++ b/src-qt5/core/libLumina/LuminaSingleApplication.cpp @@ -107,17 +107,17 @@ void LSingleApplication::PerformLockChecks(){ QLocalSocket socket(this); socket.connectToServer(cfile); socket.waitForConnected(); - if(!socket.isValid() || socket.state()!=QLocalSocket::ConnectedState){ + if(!socket.isValid() || socket.state()!=QLocalSocket::ConnectedState){ //error - could not forward info for some reason qDebug() << " - Could not connect to locking process: exiting..."; - exit(1); - } - - qDebug() << " - Forwarding inputs to locking process and closing down this instance..."; + exit(1); + } + + qDebug() << " - Forwarding inputs to locking process and closing down this instance..."; socket.write( inputlist.join("::::").toLocal8Bit() ); socket.waitForDisconnected(500); //max out at 1/2 second (only hits this if no inputs) } - + } //New messages detected diff --git a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h index d0e7a653..dfc12e79 100644 --- a/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h +++ b/src-qt5/core/lumina-desktop-unified/src-screensaver/animations/Fireflies.h @@ -12,6 +12,7 @@ #include "global-includes.h" #include "BaseAnimGroup.h" #include <QSequentialAnimationGroup> +#include <QGraphicsOpacityEffect> class Firefly : public QSequentialAnimationGroup{ Q_OBJECT @@ -34,9 +35,12 @@ private slots: movement->setEndValue(pt); movement->setDuration( qrand() %500 + 1000); //between 1000->1500 ms animations for movements //Adjust the flash duration/size a bit - flash->setDuration(qrand() %300 + 700); //700-1000 ms - int sz = qrand()%4 + 6; //6-10 pixel square + flash->setDuration(qrand() %200 + 500); //500-700 ms + int sz = qrand()%4 + 4; //6-10 pixel square + //flash->setKeyValueAt(0.5, (qrand()%50) /100.0); + //fly->resize(sz,sz); flash->setKeyValueAt(0.5, QSize(sz,sz)); //half-way point for the flash + fly->show(); } void stopped(){ fly->hide(); } @@ -46,24 +50,41 @@ public: fly = new QWidget(parent); range = parent->size(); maxX = range.width()/4; maxY = range.height()/4; - fly->setStyleSheet("background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(215, 215, 143, 255), stop:0.83871 rgba(221, 235, 64, 140), stop:0.99 rgba(0, 0, 0, 255), stop:1 transparent);"); + QString B = QString::number(qrand()%70); + QString RY = QString::number(qrand()%200+50); + QString style = "background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, stop:0 rgba(245, 245, 143, 200), stop:0.83871 rgba(%1, %1, %2, 140), stop:0.99 rgba(0, 0, 0, 255), stop:1 transparent);"; + fly->setStyleSheet(style.arg(RY, B) ); //setup the movement animation movement = new QPropertyAnimation(fly); movement->setTargetObject(fly); movement->setPropertyName("pos"); movement->setEndValue( QPoint( qrand() % range.width(), qrand()%range.height()) ); //on anim start, this will become the starting point //setup the flashing animation - flash = new QPropertyAnimation(fly); + /*QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(parent); + fly->setGraphicsEffect(eff); + flash = new QPropertyAnimation(eff, "opacity");*/ + flash = new QPropertyAnimation(this); flash->setTargetObject(fly); flash->setPropertyName("size"); - flash->setStartValue(QSize(2,2)); + flash->setStartValue(QSize(0,0)); flash->setEndValue(flash->startValue()); + //fly->setProperty("opacity",0); + //flash->setPropertyName("opacity"); + //flash->setStartValue(0); + //flash->setEndValue(0); //now setup the order of the animations this->setLoopCount(100); //do this 100 times - this->addAnimation(movement); - this->addAnimation(flash); + //Roughly half the number of fireflies with start with movement/flash + if(qrand()%2 == 1){ + this->addAnimation(movement); + this->addAnimation(flash); + }else{ + this->addAnimation(flash); + this->addAnimation(movement); + } //Start up this firefly LoopChanged(); //load initial values + fly->setGeometry( QRect(movement->startValue().toPoint(), flash->startValue().toSize()) ); connect(this, SIGNAL(currentLoopChanged(int)), this, SLOT(LoopChanged()) ); connect(this, SIGNAL(finished()), this, SLOT(stopped()) ); diff --git a/src-qt5/core/lumina-desktop/LSession.cpp b/src-qt5/core/lumina-desktop/LSession.cpp index bbed6d79..2a1ec783 100644 --- a/src-qt5/core/lumina-desktop/LSession.cpp +++ b/src-qt5/core/lumina-desktop/LSession.cpp @@ -572,7 +572,7 @@ void LSession::SessionEnding(){ // SYSTEM ACCESS //=============== void LSession::LaunchApplication(QString cmd){ - LSession::setOverrideCursor(QCursor(Qt::BusyCursor)); + //LSession::setOverrideCursor(QCursor(Qt::BusyCursor)); ExternalProcess::launch(cmd); //QProcess::startDetached(cmd); } diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp index 1992db0f..e8df8390 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp @@ -35,15 +35,15 @@ StartMenu::StartMenu(QWidget *parent) : QWidget(parent), ui(new Ui::StartMenu){ } StartMenu::~StartMenu(){ - + } void StartMenu::UpdateAll(){ //Update all the icons/text on all the pages - + // Update Text ui->retranslateUi(this); - + //Update Icons ui->tool_goto_apps->setIcon(LXDG::findIcon("system-run","")); ui->tool_goto_settings->setIcon(LXDG::findIcon("preferences-system","")); @@ -53,7 +53,7 @@ void StartMenu::UpdateAll(){ ui->tool_goto_logout->setIcon(LXDG::findIcon("system-log-out","")); ui->tool_back->setIcon(LXDG::findIcon("go-previous","")); ui->tool_launch_deskinfo->setIcon(LXDG::findIcon("system-help","")); - + ui->tool_launch_mixer->setIcon( LXDG::findIcon("preferences-desktop-sound","") ); ui->label_bright_icon->setPixmap( LXDG::findIcon("preferences-desktop-brightness","").pixmap(ui->tool_goto_apps->iconSize()) ); ui->label_locale_icon->setPixmap( LXDG::findIcon("preferences-desktop-locale","").pixmap(ui->tool_goto_apps->iconSize()) ); @@ -63,7 +63,7 @@ void StartMenu::UpdateAll(){ ui->tool_restart->setIcon(LXDG::findIcon("system-reboot","")); ui->tool_shutdown->setIcon(LXDG::findIcon("system-shutdown","")); ui->tool_suspend->setIcon(LXDG::findIcon("system-suspend","")); - + //Update Visibility of system/session/OS options // -- Control Panel QString tmp = LOS::ControlPanelShortcut(); @@ -156,11 +156,11 @@ void StartMenu::UpdateQuickLaunch(QString path, bool keep){ // ========================== /*void StartMenu::deleteChildren(QWidget *obj){ if(obj->layout()==0){ - for(int i=0; i<obj->children().count(); i++){ - obj->children().at(i)->deleteLater(); + for(int i=0; i<obj->children().count(); i++){ + obj->children().at(i)->deleteLater(); } }else{ - + } }*/ @@ -174,7 +174,7 @@ void StartMenu::ClearScrollArea(QScrollArea *area){ if(area == ui->scroll_favs){ area->takeWidget()->deleteLater(); } - if(area->widget()==0){ + if(area->widget()==0){ area->setWidget( new QWidget(area) ); //create a new widget in the scroll area } if(area->widget()->layout()==0){ @@ -203,7 +203,7 @@ void StartMenu::SortScrollArea(QScrollArea *area){ for(int i=0; i<lay->count(); i++){ items << lay->itemAt(i)->widget()->whatsThis(); } - + items.sort(); //qDebug() << " - Sorted Items:" << items; for(int i=0; i<items.length(); i++){ @@ -223,10 +223,10 @@ void StartMenu::SortScrollArea(QScrollArea *area){ void StartMenu::do_search(QString search, bool force){ search = search.simplified(); //remove unneccesary whitespace - if(search == CSearch && !force){ + if(search == CSearch && !force){ //nothing new - just ensure the page is visible if(ui->stackedWidget->currentWidget()!=ui->page_search ){ ui->stackedWidget->setCurrentWidget(ui->page_search); } - return; + return; }else if(search.isEmpty()){ CSearch.clear(); if(ui->stackedWidget->currentWidget()==ui->page_search ){ on_tool_back_clicked(); } @@ -234,7 +234,7 @@ void StartMenu::do_search(QString search, bool force){ } //Got a search term - check it CSearch = search; //save this for comparison later - qDebug() << "Search for term:" << search; + //qDebug() << "Search for term:" << search; ClearScrollArea(ui->scroll_search); topsearch.clear(); //Now find any items which match the search @@ -275,7 +275,7 @@ void StartMenu::do_search(QString search, bool force){ connect(it, SIGNAL(RemovedShortcut()), this, SLOT(UpdateFavs()) ); connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) ); connect(it, SIGNAL(toggleQuickLaunch(QString, bool)), this, SLOT(UpdateQuickLaunch(QString, bool)) ); - if(i%3==0){ + if(i%3==0){ QApplication::processEvents(); if(searchTimer->isActive()){ return; } //search changed - go ahead and stop here } @@ -305,13 +305,13 @@ bool StartMenu::promptAboutUpdates(bool &skip){ // PRIVATE SLOTS // ======================== void StartMenu::LaunchItem(QString path, bool fix){ - if(path.startsWith("chcat::::")){ + if(path.startsWith("chcat::::")){ ChangeCategory(path.section("::::",1,50)); return; } - qDebug() << "Launching Item:" << path << fix; + //qDebug() << "Launching Item:" << path << fix; if(!path.isEmpty()){ - qDebug() << "Launch Application:" << path; + //qDebug() << "Launch Application:" << path; if( fix && !path.startsWith("lumina-open") ){ LSession::LaunchApplication("lumina-open \""+path+"\""); } else{ LSession::LaunchApplication(path); } emit CloseMenu(); //so the menu container will close @@ -355,7 +355,7 @@ void StartMenu::UpdateApps(){ connect(it, SIGNAL(toggleQuickLaunch(QString, bool)), this, SLOT(UpdateQuickLaunch(QString, bool)) ); } } - + }else if(ui->check_apps_showcats->checkState() == Qt::Checked){ //qDebug() << " - Checked"; //Only show categories to start with - and have the user click-into a cat to see apps @@ -378,7 +378,7 @@ void StartMenu::UpdateApps(){ ui->scroll_apps->widget()->layout()->addWidget(it); connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) ); //Show apps for this cat - QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value(CCat); + QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value(CCat); for(int i=0; i<apps.length(); i++){ //qDebug() << " - App:" << apps[i].name; ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), apps[i] ); @@ -390,11 +390,11 @@ void StartMenu::UpdateApps(){ connect(it, SIGNAL(toggleQuickLaunch(QString, bool)), this, SLOT(UpdateQuickLaunch(QString, bool)) ); } } - + }else{ //qDebug() << " - Not Checked"; //No categories at all - just alphabetize all the apps - QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All"); + QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All"); CCat.clear(); //Now add all the apps for this category for(int i=0; i<apps.length(); i++){ @@ -407,8 +407,7 @@ void StartMenu::UpdateApps(){ connect(it, SIGNAL(toggleQuickLaunch(QString, bool)), this, SLOT(UpdateQuickLaunch(QString, bool)) ); } } - - + } void StartMenu::UpdateFavs(){ @@ -427,31 +426,7 @@ void StartMenu::UpdateFavs(){ else{ tmp = rest; } //everything left over if(type==1){ SortScrollArea(ui->scroll_favs); - //Need to run a special routine for sorting the apps (already in the widget) - //qDebug() << "Sort App Widgets..."; - // Since each app actually might have a different name listed within the file - /*QLayout *lay = ui->scroll_favs->widget()->layout(); - QStringList items; - for(int i=0; i<lay->count(); i++){ - items << lay->itemAt(i)->widget()->whatsThis().toLower(); - } - - items.sort(); - // qDebug() << " - Sorted Items:" << items; - for(int i=0; i<items.length(); i++){ - if(items[i].isEmpty()){ continue; } - //QLayouts are weird in that they can only add items to the end - need to re-insert almost every item - for(int j=0; j<lay->count(); j++){ - //Find this item - if(lay->itemAt(j)->widget()->whatsThis().toLower()==items[i]){ - //Found it - now move it if necessary - //qDebug() << "Found Item:" << items[i] << i << j; - lay->addItem( lay->takeAt(j) ); - break; - } - } - }*/ - + }//end of special app sorting routine tmp.sort(); //Sort alphabetically by name (dirs/files) for(int i=0; i<tmp.length(); i++){ @@ -472,7 +447,6 @@ void StartMenu::UpdateFavs(){ connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) ); connect(it, SIGNAL(toggleQuickLaunch(QString, bool)), this, SLOT(UpdateQuickLaunch(QString, bool)) ); } - //QApplication::processEvents(); } //end loop over types ui->scroll_favs->update(); //qDebug() << "End updateFavs"; @@ -541,7 +515,7 @@ void StartMenu::on_stackedWidget_currentChanged(int val){ } ui->frame_leave_suspend->setVisible( LOS::systemCanSuspend() ); } - + } void StartMenu::catViewChanged(){ @@ -567,7 +541,7 @@ void StartMenu::on_tool_goto_apps_clicked(){ } void StartMenu::on_tool_goto_settings_clicked(){ - ui->stackedWidget->setCurrentWidget(ui->page_settings); + ui->stackedWidget->setCurrentWidget(ui->page_settings); } void StartMenu::on_tool_goto_logout_clicked(){ @@ -585,7 +559,7 @@ void StartMenu::on_tool_launch_controlpanel_clicked(){ } void StartMenu::on_tool_launch_fm_clicked(){ - LaunchItem(QDir::homePath()); + LaunchItem(QDir::homePath()); } void StartMenu::on_tool_launch_store_clicked(){ diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp index 453bde1d..692223c7 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/lthemeengineplatformtheme.cpp @@ -211,7 +211,9 @@ void lthemeenginePlatformTheme::readSettings(){ } //load style sheets #ifdef QT_WIDGETS_LIB - QStringList qssPaths = settings.value("stylesheets").toStringList(); + QStringList qssPaths; + if(qApp->applicationName()=="lumina-desktop"){ qssPaths << settings.value("desktop_stylesheets").toStringList(); } + qssPaths << settings.value("stylesheets").toStringList(); m_userStyleSheet = loadStyleSheets(qssPaths); #endif settings.endGroup(); diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.cpp index fdeb8966..701745c4 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.cpp @@ -53,6 +53,20 @@ QStringList lthemeengine::sharedStyleSheetPath(){ return dirs; } +QString lthemeengine::userDesktopStyleSheetPath(){ + return configPath() + "desktop_qss/"; +} + +QStringList lthemeengine::sharedDesktopStyleSheetPath(){ + QStringList dirs; + dirs << QString(getenv("XDG_CONFIG_HOME")); + dirs << QString(getenv("XDG_CONFIG_DIRS")).split(":"); + dirs << QString(getenv("XDG_DATA_DIRS")).split(":"); + for(int i=0; i<dirs.length(); i++){ dirs[i].append("/lthemeengine/desktop_qss/"); } + if(dirs.isEmpty()){ dirs << LTHEMEENGINE_DATADIR"/lthemeengine/desktop_qss/"; } //no XDG settings - use the hardcoded path + return dirs; + } + QString lthemeengine::userColorSchemePath(){ return configPath() + "colors/"; } diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.h b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.h index 8a466ed9..06dd3e09 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.h +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine.h @@ -21,6 +21,8 @@ public: static QStringList iconPaths(); static QString userStyleSheetPath(); static QStringList sharedStyleSheetPath(); + static QString userDesktopStyleSheetPath(); + static QStringList sharedDesktopStyleSheetPath(); static QString userColorSchemePath(); static QStringList sharedColorSchemePath(); static QString systemLanguageID(); diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/mainwindow.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/mainwindow.cpp index 719a0f49..91db14ee 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/mainwindow.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/mainwindow.cpp @@ -16,7 +16,8 @@ MainWindow::MainWindow(QWidget *parent) : QWidget(parent), m_ui(new Ui::MainWind m_ui->tabWidget->addTab(new IconThemePage(this), tr("Icon Theme")); m_ui->tabWidget->addTab(new InterfacePage(this), tr("Interface")); #ifdef USE_WIDGETS - m_ui->tabWidget->addTab(new QSSPage(this), tr("Style Sheets")); + m_ui->tabWidget->addTab(new QSSPage(this, false), tr("Application Theme")); + m_ui->tabWidget->addTab(new QSSPage(this, true), tr("Desktop Theme")); #endif QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); restoreGeometry(settings.value("SettingsWindow/geometry").toByteArray()); diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp index 2cf0f221..681de6c9 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.cpp @@ -12,8 +12,9 @@ #define QSS_FULL_PATH_ROLE (Qt::ItemDataRole(Qt::UserRole)) #define QSS_WRITABLE_ROLE (Qt::ItemDataRole(Qt::UserRole + 1)) -QSSPage::QSSPage(QWidget *parent) : TabPage(parent), m_ui(new Ui::QSSPage){ +QSSPage::QSSPage(QWidget *parent, bool desktop) : TabPage(parent), m_ui(new Ui::QSSPage){ m_ui->setupUi(this); + desktop_qss = desktop; QDir("/").mkpath(lthemeengine::userStyleSheetPath()); m_menu = new QMenu(this); m_menu->addAction(QIcon::fromTheme("accessories-text-editor"), tr("Edit"), this, SLOT(on_editButton_clicked())); @@ -37,7 +38,8 @@ void QSSPage::writeSettings(){ for(int i = 0; i < m_ui->qssListWidget->count(); ++i){ QListWidgetItem *item = m_ui->qssListWidget->item(i); if(item->checkState() == Qt::Checked){ styleSheets << item->data(QSS_FULL_PATH_ROLE).toString(); } - settings.setValue("Interface/stylesheets", styleSheets); + if(desktop_qss){ settings.setValue("Interface/desktop_stylesheets", styleSheets); } + else{ settings.setValue("Interface/stylesheets", styleSheets); } } } @@ -58,7 +60,9 @@ void QSSPage::on_createButton_clicked(){ QString name = QInputDialog::getText(this, tr("Enter Style Sheet Name"), tr("File name:")); if(name.isEmpty()){ return; } if(!name.endsWith(".qss", Qt::CaseInsensitive)){ name.append(".qss"); } - QString filePath = lthemeengine::userStyleSheetPath() + name; + QString filePath; + if(desktop_qss){ filePath = lthemeengine::userDesktopStyleSheetPath() + name; } + else{ filePath = lthemeengine::userStyleSheetPath() + name; } if(QFile::exists(filePath)){ QMessageBox::warning(this, tr("Error"), tr("The file \"%1\" already exists").arg(filePath)); return; @@ -95,9 +99,13 @@ void QSSPage::on_removeButton_clicked(){ void QSSPage::readSettings(){ //load stylesheets m_ui->qssListWidget->clear(); - findStyleSheets(QStringList() << lthemeengine::userStyleSheetPath() << lthemeengine::sharedStyleSheetPath()); + if(desktop_qss){ findStyleSheets(QStringList() << lthemeengine::userStyleSheetPath() << lthemeengine::sharedStyleSheetPath()); } + else{findStyleSheets(QStringList() << lthemeengine::userStyleSheetPath() << lthemeengine::sharedStyleSheetPath()); } QSettings settings(lthemeengine::configFile(), QSettings::IniFormat); - QStringList styleSheets = settings.value("Interface/stylesheets").toStringList(); + QStringList styleSheets; + if(desktop_qss){ styleSheets = settings.value("Interface/desktop_stylesheets").toStringList(); } + else{ styleSheets = settings.value("Interface/stylesheets").toStringList(); } + for(int i = 0; i < m_ui->qssListWidget->count(); ++i){ QListWidgetItem *item = m_ui->qssListWidget->item(i); if(styleSheets.contains(item->data(QSS_FULL_PATH_ROLE).toString())){ item->setCheckState(Qt::Checked); } diff --git a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h index 5e924ad9..76417ddf 100644 --- a/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h +++ b/src-qt5/core/lumina-theme-engine/src/lthemeengine/qsspage.h @@ -15,7 +15,7 @@ class QSSPage : public TabPage Q_OBJECT public: - explicit QSSPage(QWidget *parent = 0); + explicit QSSPage(QWidget *parent = 0, bool desktop = false); ~QSSPage(); void writeSettings(); @@ -33,6 +33,7 @@ private: void findStyleSheets(QStringList paths); Ui::QSSPage *m_ui; QMenu *m_menu; + bool desktop_qss; }; #endif // QSSPAGE_H |