diff options
-rw-r--r-- | libLumina/LuminaUtils.cpp | 34 | ||||
-rw-r--r-- | libLumina/LuminaUtils.h | 2 | ||||
-rw-r--r-- | libLumina/quickplugins/quick-sample.qml | 12 | ||||
-rw-r--r-- | libLumina/quickplugins/sample.qml | 7 | ||||
-rw-r--r-- | lumina-config/LPlugins.cpp | 14 | ||||
-rw-r--r-- | lumina-desktop/LSession.cpp | 9 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/LDPlugin.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/LDPluginContainer.h | 2 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp | 19 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserWidget.cpp | 80 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserWidget.h | 1 | ||||
-rw-r--r-- | port-files/pkg-plist | 2 |
12 files changed, 142 insertions, 42 deletions
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index 540598cf..42f36962 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -189,15 +189,43 @@ bool LUtils::validQuickPlugin(QString ID){ } QString LUtils::findQuickPluginFile(QString ID){ - if(ID.startsWith("quick-")){ ID = ID.section("-",1,50); } + if(ID.startsWith("quick-")){ ID = ID.section("-",1,50); } //just in case //Give preference to any user-supplied plugins (overwrites for system plugins) - QString path = QDir::homePath()+"/.lumina/quickplugins/"+ID+".qml"; + QString path = QDir::homePath()+"/.lumina/quickplugins/quick-"+ID+".qml"; if( QFile::exists(path) ){return path; } - path = LOS::LuminaShare()+"quickplugins/"+ID+".qml"; + path = LOS::LuminaShare()+"quickplugins/quick-"+ID+".qml"; if( QFile::exists(path) ){return path; } return ""; //could not be found } +QStringList LUtils::listQuickPlugins(){ + QDir dir(QDir::homePath()+"/.lumina/quickplugins"); + QStringList files = dir.entryList(QStringList() << "quick-*.qml", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); + dir.cd(LOS::LuminaShare()+"quickplugins"); + files << files = dir.entryList(QStringList() << "quick-*.qml", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); + for(int i=0; i<files.length(); i++){ + files[i] = files[i].section("quick-",1,100).section(".qml",0,0); //just grab the ID out of the middle of the filename + } + files.removeDuplicates(); + return files; +} + +QStringList LUtils::infoQuickPlugin(QString ID){ //Returns: [Name, Description, Icon] + QString path = findQuickPluginFile(ID); + if(path.isEmpty()){ return QStringList(); } //invalid ID + QStringList contents = LUtils::readFile(path).filter("//").filter("=").filter("Plugin"); + if(contents.isEmpty()){ return QStringList(); } //invalid file (unreadable) + QStringList info; info << "" << "" << ""; + for(int i=0; i<contents.length(); i++){ + if(contents[i].contains("Plugin-Name=")){ info[0] = contents[i].section("Plugin-Name=",1,1).simplified(); } + else if(contents[i].contains("Plugin-Description=")){ info[1] = contents[i].section("Plugin-Description=",1,1).simplified(); } + else if(contents[i].contains("Plugin-Icon=")){ info[2] = contents[i].section("Plugin-Icon=",1,1).simplified(); } + } + if(info[0].isEmpty()){ info[0]=ID; } + if(info[2].isEmpty()){ info[2]="preferences-plugin"; } + return info; +} + QStringList LUtils::listFavorites(){ static QDateTime lastRead; QDateTime cur = QDateTime::currentDateTime(); diff --git a/libLumina/LuminaUtils.h b/libLumina/LuminaUtils.h index 605f2653..188563dc 100644 --- a/libLumina/LuminaUtils.h +++ b/libLumina/LuminaUtils.h @@ -56,6 +56,8 @@ public: //Various function for finding valid QtQuick plugins on the system static bool validQuickPlugin(QString ID); static QString findQuickPluginFile(QString ID); + static QStringList listQuickPlugins(); //List of valid ID's + static QStringList infoQuickPlugin(QString ID); //Returns: [Name, Description, Icon] //Various functions for the favorites sub-system // Formatting Note: "<name>::::[dir/app/<mimetype>]::::<path>" diff --git a/libLumina/quickplugins/quick-sample.qml b/libLumina/quickplugins/quick-sample.qml new file mode 100644 index 00000000..18b10d77 --- /dev/null +++ b/libLumina/quickplugins/quick-sample.qml @@ -0,0 +1,12 @@ +// Plugin-Name=Sample +// Plugin-Description=A simple example for QtQuick/QML plugins +// Plugin-Icon=preferences-plugin +// Created: Ken Moore (ken@pcbsd.org) May 2015 + +import QtQuick.Controls 1.3 + +Label { + text: "Sample" + color: "blue" + font.bold: true +}
\ No newline at end of file diff --git a/libLumina/quickplugins/sample.qml b/libLumina/quickplugins/sample.qml deleted file mode 100644 index b12702ba..00000000 --- a/libLumina/quickplugins/sample.qml +++ /dev/null @@ -1,7 +0,0 @@ -import QtQuick.Controls 1.3 - -Label { - text: "Sample" - color: "blue" - font.bold: true -}
\ No newline at end of file diff --git a/lumina-config/LPlugins.cpp b/lumina-config/LPlugins.cpp index 31b189bb..16725259 100644 --- a/lumina-config/LPlugins.cpp +++ b/lumina-config/LPlugins.cpp @@ -6,6 +6,8 @@ //=========================================== #include "LPlugins.h" +#include <LuminaUtils.h> + LPlugins::LPlugins(){ LoadPanelPlugins(); LoadDesktopPlugins(); @@ -195,6 +197,18 @@ void LPlugins::LoadDesktopPlugins(){ info.ID = "systemmonitor"; info.icon = "cpu"; DESKTOP.insert(info.ID, info); + //Available QtQuick scripts + QStringList quickID = LUtils::listQuickPlugins(); + for(int i=0; i<quickID.length(); i++){ + QStringList quickinfo = LUtils::infoQuickPlugin(quickID[i]); //Returns: [name, description, icon] + if(quickinfo.length() < 3){ continue; } //invalid file (unreadable/other) + info = LPI(); + info.name = quickinfo[0]; + info.description = quickinfo[1]; + info.ID = "quick-"+quickID[i]; //the "quick-" prefix is required for the desktop plugin syntax + info.icon = quickinfo[2]; + DESKTOP.insert(info.ID, info); + } } void LPlugins::LoadMenuPlugins(){ diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 0d7e3808..aa1c1e0c 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -145,8 +145,10 @@ void LSession::setupSession(){ connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(watcherChange(QString)) ); connect(this, SIGNAL(aboutToQuit()), this, SLOT(SessionEnding()) ); if(DEBUG){ qDebug() << " - Init Finished:" << timer->elapsed(); delete timer;} - QTimer::singleShot(3000, this, SLOT(launchStartupApps()) ); //startup these processes in 3 seconds + //QTimer::singleShot(3000, this, SLOT(launchStartupApps()) ); //startup these processes in 3 seconds splash.close(); + QApplication::processEvents(); + launchStartupApps(); } void LSession::CleanupSession(){ @@ -338,6 +340,9 @@ void LSession::checkUserFiles(){ if(newversion || newrelease){ LUtils::upgradeFavorites(oldversion); } + //Remove/convert any old desktop plugin files (Change occured with 0.8.5) + // - TO-DO + //Convert to the XDG autostart spec as necessary (Change occured with 0.8.5) if(QFile::exists(QDir::homePath()+"/.lumina/startapps") ){ QStringList cmds = LUtils::readFile(QDir::homePath()+"/.lumina/startapps"); @@ -479,7 +484,7 @@ void LSession::adjustWindowGeom(WId win, bool maximize){ if(geom.x() < desk.x()){ geom.moveLeft(desk.x()); } //move right to the edge (left panel) //Adjust size for bottom margins (within reason, since window titles are on top normally) // if(geom.right() > desk.right() && (geom.width() > 100)){ geom.setRight(desk.right()); } - if(geom.bottom() > desk.bottom() && geom.height() > 100){ + if(geom.bottom() > desk.bottom() && geom.height() > 10){ //Also adjust the sizing for the frame (the moveResize fuction is for the base window only) geom.setBottom(desk.bottom()-frame[0]-frame[1]); } diff --git a/lumina-desktop/desktop-plugins/LDPlugin.cpp b/lumina-desktop/desktop-plugins/LDPlugin.cpp index 5db20232..cc07b747 100644 --- a/lumina-desktop/desktop-plugins/LDPlugin.cpp +++ b/lumina-desktop/desktop-plugins/LDPlugin.cpp @@ -22,7 +22,7 @@ void LDPlugin::setInitialSize(int width, int height){ // if the plugin is completely new (first time used), it will be this size if(settings->allKeys().filter(prefix+"location").isEmpty()){ //Brand new plugin: set initial size - qDebug() << "Setting Initial Size:" << PLUGID << width << height; + //qDebug() << "Setting Initial Size:" << PLUGID << width << height; settings->setValue(prefix+"location/width",width); settings->setValue(prefix+"location/height",height); settings->sync(); diff --git a/lumina-desktop/desktop-plugins/LDPluginContainer.h b/lumina-desktop/desktop-plugins/LDPluginContainer.h index da8ead6e..0bf40873 100644 --- a/lumina-desktop/desktop-plugins/LDPluginContainer.h +++ b/lumina-desktop/desktop-plugins/LDPluginContainer.h @@ -86,7 +86,7 @@ public: public slots: void loadInitialPosition(){ QRect set(PLUG->readSetting("location/x",-12345).toInt(), PLUG->readSetting("location/y",-12345).toInt(), PLUG->readSetting("location/width",PLUG->size().width()).toInt() +4, PLUG->readSetting("location/height",PLUG->size().height()).toInt()+4); - qDebug() << "Initial Plugin Location:" << set.x() << set.y() << set.width() << set.height(); + //qDebug() << "Initial Plugin Location:" << set.x() << set.y() << set.width() << set.height(); if(set.height() < 10){ set.setHeight(10); } //to prevent foot-shooting if(set.width() < 10){ set.setWidth(10); } //to prevent foot-shooting /*if(!locked){ diff --git a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp index 689bd8eb..ff77121e 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp @@ -7,6 +7,7 @@ #include "UserItemWidget.h" #include <LuminaUtils.h> +#define TEXTCUTOFF 165 UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type, bool goback) : QFrame(parent){ createWidget(); //Now fill it appropriately @@ -17,10 +18,10 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type, XDGDesktop item = LXDG::loadDesktopFile(itemPath, ok); if(ok){ icon->setPixmap( LXDG::findIcon(item.icon, "preferences-system-windows-actions").pixmap(32,32) ); - name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, 180) ); + name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, TEXTCUTOFF) ); }else{ icon->setPixmap( LXDG::findIcon("unknown","").pixmap(32,32) ); - name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, 180) ); + name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, TEXTCUTOFF) ); } }else if(type=="dir"){ if(itemPath.endsWith("/")){ itemPath.chop(1); } @@ -29,18 +30,22 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type, name->setText( tr("Go Back") ); }else{ icon->setPixmap( LXDG::findIcon("folder","").pixmap(32,32) ); - name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, 180) ); + name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, TEXTCUTOFF) ); } }else{ if(itemPath.endsWith("/")){ itemPath.chop(1); } - if(LUtils::imageExtensions().contains(itemPath.section("/",-1).section(".",-1).toLower()) ){ + if(QFileInfo(itemPath).isDir()){ + type = "dir"; + icon->setPixmap( LXDG::findIcon("folder","").pixmap(32,32) ); + }else if(LUtils::imageExtensions().contains(itemPath.section("/",-1).section(".",-1).toLower()) ){ icon->setPixmap( QIcon(itemPath).pixmap(32,32) ); }else{ icon->setPixmap( LXDG::findMimeIcon(type).pixmap(32,32) ); } - name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, 180) ); + name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, TEXTCUTOFF) ); } icon->setWhatsThis(itemPath); + if(!goback){ this->setWhatsThis(name->text()); } isDirectory = (type=="dir"); //save this for later if(LUtils::isFavorite(itemPath)){ linkPath = itemPath; @@ -67,7 +72,8 @@ UserItemWidget::UserItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent } //Now fill it appropriately icon->setPixmap( LXDG::findIcon(item.icon,"preferences-system-windows-actions").pixmap(32,32) ); - name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, 180) ); + name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, TEXTCUTOFF) ); + this->setWhatsThis(name->text()); icon->setWhatsThis(item.filePath); //Now setup the button appropriately setupButton(); @@ -154,5 +160,4 @@ void UserItemWidget::buttonClicked(){ void UserItemWidget::ItemClicked(){ if(!linkPath.isEmpty()){ emit RunItem(linkPath); } else{ emit RunItem(icon->whatsThis()); } - } diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp index 2c85caab..1ea1a864 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp @@ -108,9 +108,37 @@ void UserWidget::ClearScrollArea(QScrollArea *area){ layout->setSpacing(2); layout->setContentsMargins(3,1,3,1); layout->setDirection(QBoxLayout::TopToBottom); + layout->setAlignment(Qt::AlignTop); area->widget()->setLayout(layout); } +void UserWidget::SortScrollArea(QScrollArea *area){ + //qDebug() << "Sorting Scroll Area:"; + //Sort all the items in the scroll area alphabetically + QLayout *lay = area->widget()->layout(); + QStringList items; + 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++){ + 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()==items[i]){ + //Found it - now move it if necessary + //qDebug() << "Found Item:" << items[i] << i << j; + lay->addItem( lay->takeAt(j) ); + break; + } + } + } + +} + QIcon UserWidget::rotateIcon(QIcon ico){ //Rotate the given icon to appear vertical in the tab widget QPixmap pix = ico.pixmap(32,32); @@ -131,11 +159,18 @@ void UserWidget::UpdateMenu(){ ui->tool_fav_files->setChecked(false); cfav = 0; //favorite apps updateFavItems(); - ui->label_home_dir->setWhatsThis(QDir::homePath()); - updateHome(); + QString cdir = ui->label_home_dir->whatsThis(); + if(cdir.isEmpty() || !QFile::exists(cdir) ){ + //Directory deleted or nothing loaded yet + ui->label_home_dir->setWhatsThis(QDir::homePath()); + QTimer::singleShot(0,this, SLOT(updateHome()) ); + }else if( lastUpdate < QFileInfo(cdir).lastModified() ){ + //Directory contents changed - reload it + QTimer::singleShot(0,this, SLOT(updateHome()) ); + } if(lastUpdate < LSession::handle()->applicationMenu()->lastHashUpdate || lastUpdate.isNull()){ updateAppCategories(); - updateApps(); + QTimer::singleShot(0,this, SLOT(updateApps()) ); } lastUpdate = QDateTime::currentDateTime(); } @@ -214,16 +249,17 @@ void UserWidget::updateFavItems(bool newfilter){ } ClearScrollArea(ui->scroll_fav); //qDebug() << " - Sorting Items"; - favitems.sort(); //sort them alphabetically - //qDebug() << " - Creating Items:" << favitems; - for(int i=0; i<favitems.length(); i++){ - UserItemWidget *it = new UserItemWidget(ui->scroll_fav->widget(), favitems[i].section("::::",2,50), favitems[i].section("::::",1,1) ); - ui->scroll_fav->widget()->layout()->addWidget(it); - connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) ); - connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) ); - connect(it, SIGNAL(RemovedShortcut()), this, SLOT(updateFavItems()) ); - } - static_cast<QBoxLayout*>(ui->scroll_fav->widget()->layout())->addStretch(); + favitems.sort(); //sort them alphabetically + //qDebug() << " - Creating Items:" << favitems; + for(int i=0; i<favitems.length(); i++){ + UserItemWidget *it = new UserItemWidget(ui->scroll_fav->widget(), favitems[i].section("::::",2,50), favitems[i].section("::::",1,1) ); + ui->scroll_fav->widget()->layout()->addWidget(it); + connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) ); + connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) ); + connect(it, SIGNAL(RemovedShortcut()), this, SLOT(updateFavItems()) ); + QApplication::processEvents(); //keep the UI snappy - might be a number of these + } + SortScrollArea(ui->scroll_fav); //qDebug() << " - Done"; } @@ -263,8 +299,8 @@ void UserWidget::updateApps(){ connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) ); connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) ); connect(it, SIGNAL(RemovedShortcut()), this, SLOT(updateFavItems()) ); + QApplication::processEvents(); //keep the UI snappy - might be a number of these } - static_cast<QBoxLayout*>(ui->scroll_apps->widget()->layout())->addStretch(); } //Home Tab @@ -285,25 +321,29 @@ void UserWidget::updateHome(){ items << dir; } ui->label_home_dir->setToolTip(ui->label_home_dir->whatsThis()); - items << homedir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); - QString type = "dir"; + items << homedir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name | QDir::DirsFirst); + QString type = ""; if(homedir.absolutePath() == QDir::homePath()+"/Desktop"){ type.append("-home"); }//internal code for(int i=0; i<items.length(); i++){ //qDebug() << "New Home subdir:" << homedir.absoluteFilePath(items[i]); UserItemWidget *it; - if(items[i].startsWith("/")){ it = new UserItemWidget(ui->scroll_home->widget(), items[i], type, true); } + if(items[i].startsWith("/")){ it = new UserItemWidget(ui->scroll_home->widget(), items[i], "dir", true); } //go-back button else{ it = new UserItemWidget(ui->scroll_home->widget(), homedir.absoluteFilePath(items[i]), type, false); } ui->scroll_home->widget()->layout()->addWidget(it); connect(it, SIGNAL(RunItem(QString)), this, SLOT(slotGoToDir(QString)) ); connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) ); connect(it, SIGNAL(RemovedShortcut()), this, SLOT(updateFavItems()) ); + QApplication::processEvents(); //keep the UI snappy - may be a lot of these to load } - static_cast<QBoxLayout*>(ui->scroll_home->widget()->layout())->addStretch(); } void UserWidget::slotGoToDir(QString dir){ - ui->label_home_dir->setWhatsThis(dir); - updateHome(); + if(!QFileInfo(dir).isDir()){ + LaunchItem(dir); + }else{ + ui->label_home_dir->setWhatsThis(dir); + updateHome(); + } } void UserWidget::slotGoHome(){ diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.h b/lumina-desktop/panel-plugins/userbutton/UserWidget.h index 2dce25b4..c2df10bf 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.h +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.h @@ -47,6 +47,7 @@ private: QFileInfoList homefiles; int cfav; //current favorite category void ClearScrollArea(QScrollArea *area); + void SortScrollArea(QScrollArea *area); QIcon rotateIcon(QIcon); private slots: diff --git a/port-files/pkg-plist b/port-files/pkg-plist index 5972c518..ca840ac7 100644 --- a/port-files/pkg-plist +++ b/port-files/pkg-plist @@ -40,7 +40,7 @@ share/Lumina-DE/colors/Lumina-Glass.qss.colors share/Lumina-DE/colors/PCBSD10-Default.qss.colors share/Lumina-DE/themes/Lumina-default.qss.template share/Lumina-DE/themes/None.qss.template -share/Lumina-DE/quickplugins/sample.qml +share/Lumina-DE/quickplugins/quick-sample.qml share/wallpapers/Lumina-DE/Lumina_Wispy_gold_1920x1080.jpg share/wallpapers/Lumina-DE/Lumina_Wispy_green_1920x1080.jpg share/wallpapers/Lumina-DE/Lumina_Wispy_purple_1920x1080.jpg |