diff options
author | Ken Moore <moorekou@gmail.com> | 2015-07-09 12:36:54 -0400 |
---|---|---|
committer | Ken Moore <moorekou@gmail.com> | 2015-07-09 12:36:54 -0400 |
commit | b97033197ab9de92981890ab823a6e18ab5039dd (patch) | |
tree | f7813999f5296a23fe5e0bfe3c35ac5c5c96cd60 /lumina-desktop | |
parent | Update the lumina themes and the PC-BSD color scheme a bit, and a couple more... (diff) | |
download | lumina-b97033197ab9de92981890ab823a6e18ab5039dd.tar.gz lumina-b97033197ab9de92981890ab823a6e18ab5039dd.tar.bz2 lumina-b97033197ab9de92981890ab823a6e18ab5039dd.zip |
Large update to the usermanager:
1) Fix alphabetizing the list of favorites
2) Make all the menu updates happen in a non-blocking fashion (the user will see the items appear as they are loaded)
3) In the home dir browser, also load any files within the directory (and launch them when clicked)
4) Remember which dir was loaded in the browser last, and only refresh/change it as necessary on next menu open.
Diffstat (limited to 'lumina-desktop')
-rw-r--r-- | lumina-desktop/LSession.cpp | 4 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp | 19 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserWidget.cpp | 78 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserWidget.h | 1 |
4 files changed, 75 insertions, 27 deletions
diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 0d7e3808..99789ea3 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(){ 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..a16e9378 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); + items << homedir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name | QDir::DirsFirst); QString type = "dir"; 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); } - else{ it = new UserItemWidget(ui->scroll_home->widget(), homedir.absoluteFilePath(items[i]), type, false); } + else{ it = new UserItemWidget(ui->scroll_home->widget(), homedir.absoluteFilePath(items[i]), "", 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: |