diff options
42 files changed, 1214 insertions, 718 deletions
@@ -12,10 +12,12 @@ Latest Stable Versions ---- Qt4 - 0.7.2 (Beta): Use the qt4/0.7.2 branch of the source tree to fetch this version. -Qt5 - 0.8.3 (Beta): Use the qt5/0.8.3 branch of the source tree to fetch this version. +Qt5 - 0.8.4 (Beta): Use the qt5/0.8.4 branch of the source tree to fetch this version. The master branch is where all development is performed and tested before the next release version is branched off. +NOTE: Starting with version 0.8.4, you may also find packaged versions of the source code for the individual releases of Lumina here on GitHub. Please go to the "Releases" page here on GitHub for additional information. + Translations ---- All the translation files for Lumina are available through the PC-BSD pootle translations systems, which are then auto-committed to the pcbsd/lumina-i18n repo (Qt5+ only). This provides an easy interface through which to contribute translations while also ensuring that the translation files are kept in sync with the Lumina source files, and it is highly recommended that translators use this interface. diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index 8d4e0d08..dd498559 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -22,7 +22,7 @@ // LUtils Functions //============= QString LUtils::LuminaDesktopVersion(){ - return "0.8.4-devel"; + return "0.8.5-devel"; } int LUtils::runCmd(QString cmd, QStringList args){ diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp index eed9fa9c..5e61db8a 100644 --- a/lumina-desktop/LDesktop.cpp +++ b/lumina-desktop/LDesktop.cpp @@ -64,6 +64,14 @@ void LDesktop::prepareToClose(){ for(int i=0; i<PANELS.length(); i++){ PANELS[i]->prepareToClose(); delete PANELS.takeAt(i); i--; } //Now close down any desktop plugins desktoplocked = true; //make sure that plugin settings are preserved during removal + //Remove all the current containers + QList<QMdiSubWindow*> wins = bgDesktop->subWindowList(); + for(int i=0; i<wins.length(); i++){ + wins[i]->setWhatsThis(""); //clear this so it knows it is being temporarily removed + bgDesktop->removeSubWindow(wins[i]->widget()); //unhook plugin from container + bgDesktop->removeSubWindow(wins[i]); //remove container from screen + delete wins[i]; //delete old container + } for(int i=0; i<PLUGINS.length(); i++){delete PLUGINS.takeAt(i); i--; } } @@ -416,13 +424,26 @@ void LDesktop::AlignDesktopPlugins(){ } void LDesktop::DesktopPluginRemoved(QString ID){ - //Close down that plugin instance (NOTE: the container was already closed by the user) + //Close down that plugin instance (NOTE: the container might have already closed by the user) + if(DEBUG){ qDebug() << "Desktop Plugin Removed:" << ID; } + //First look for the container (just in case) + QList<QMdiSubWindow*> wins = bgDesktop->subWindowList(); + for(int i=0; i<wins.length(); i++){ + if(wins[i]->whatsThis() == ID){ + if(DEBUG){ qDebug() << " - Removing Plugin Container"; } + //wins[i]->setWhatsThis(""); //clear this so it knows it is being temporarily removed + bgDesktop->removeSubWindow(wins[i]->widget()); //unhook plugin from container + bgDesktop->removeSubWindow(wins[i]); //remove container from screen + delete wins[i]; //delete old container + break; + } + } //qDebug() << "PLUGINS:" << PLUGINS.length() << ID; for(int i=0; i<PLUGINS.length(); i++){ if(PLUGINS[i]->ID() == ID){ //qDebug() << "- found ID"; - if(DEBUG){ qDebug() << "Deleting Desktop Plugin:" << ID; } + if(DEBUG){ qDebug() << " - Deleting Desktop Plugin:" << ID; } delete PLUGINS.takeAt(i); break; } @@ -433,9 +454,12 @@ void LDesktop::DesktopPluginRemoved(QString ID){ if(DEBUG){ qDebug() << " - Also removing plugin from future list"; } plugins.removeAll(ID); issyncing = true; + if(DEBUG){ qDebug() << " - Save modified plugins list"; } settings->setValue(DPREFIX+"pluginlist", plugins); - settings->sync(); + if(DEBUG){ qDebug() << " - Unlock settings file in 200 ms"; } + //settings->sync(); QTimer::singleShot(200, this, SLOT(UnlockSettings()) ); + if(DEBUG){ qDebug() << " - Done removing plugin"; } } void LDesktop::UpdatePanels(){ @@ -476,13 +500,24 @@ void LDesktop::UpdatePanels(){ void LDesktop::UpdateDesktopPluginArea(){ QRegion visReg( bgWindow->geometry() ); //visible region (not hidden behind a panel) + QRect rawRect = visReg.boundingRect(); //initial value (screen size) for(int i=0; i<PANELS.length(); i++){ QRegion shifted = visReg; QString loc = settings->value(PANELS[i]->prefix()+"location","top").toString().toLower(); - if(loc=="top"){ shifted.translate(0, PANELS[i]->visibleWidth()); } - else if(loc=="bottom"){ shifted.translate(0, 0-PANELS[i]->visibleWidth()); } - else if(loc=="left"){ shifted.translate(PANELS[i]->visibleWidth(),0); } - else{ shifted.translate(0-PANELS[i]->visibleWidth(),0); } + int vis = PANELS[i]->visibleWidth(); + if(loc=="top"){ + if(!shifted.contains(QRect(rawRect.x(), rawRect.y(), rawRect.width(), vis))){ continue; } + shifted.translate(0, (rawRect.top()+vis)-shifted.boundingRect().top() ); + }else if(loc=="bottom"){ + if(!shifted.contains(QRect(rawRect.x(), rawRect.bottom()-vis, rawRect.width(), vis))){ continue; } + shifted.translate(0, (rawRect.bottom()-vis)-shifted.boundingRect().bottom()); + }else if(loc=="left"){ + if( !shifted.contains(QRect(rawRect.x(), rawRect.y(), vis,rawRect.height())) ){ continue; } + shifted.translate((rawRect.left()+vis)-shifted.boundingRect().left() ,0); + }else{ //right + if(!shifted.contains(QRect(rawRect.right()-vis, rawRect.y(), vis,rawRect.height())) ){ continue; } + shifted.translate((rawRect.right()-vis)-shifted.boundingRect().right(),0); + } visReg = visReg.intersected( shifted ); } //Now make sure the desktop plugin area is only the visible area @@ -492,11 +527,14 @@ void LDesktop::UpdateDesktopPluginArea(){ globalWorkRect = rec; //save this for later rec.moveTopLeft( QPoint( rec.x()-desktop->screenGeometry(desktopnumber).x() , rec.y() ) ); //qDebug() << "DPlug Area:" << rec.x() << rec.y() << rec.width() << rec.height(); + if(rec == bgDesktop->geometry()){return; } //nothing changed bgDesktop->setGeometry( rec ); bgDesktop->setBackground( QBrush(Qt::NoBrush) ); bgDesktop->update(); //Re-paint the panels (just in case a plugin was underneath it and the panel is transparent) for(int i=0; i<PANELS.length(); i++){ PANELS[i]->update(); } + //Also need to re-arrange any desktop plugins to ensure that nothing is out of the screen area + AlignDesktopPlugins(); } void LDesktop::UpdateBackground(){ diff --git a/lumina-desktop/LPanel.cpp b/lumina-desktop/LPanel.cpp index 84c18bf2..3755e9a6 100644 --- a/lumina-desktop/LPanel.cpp +++ b/lumina-desktop/LPanel.cpp @@ -335,9 +335,12 @@ void LPanel::leaveEvent(QEvent *event){ if( !this->geometry().contains(QCursor::pos()) ){ //Move the panel back to it's "hiding" spot if(hidden){ this->move(hidepoint); } - //Only re-activate the old window if the panel is still currently active - if(tmpID!=0 && (this->winId()==LSession::handle()->XCB->ActiveWindow()) ){ LSession::handle()->XCB->ActivateWindow(tmpID); } - tmpID = 0; + //Only re-activate the old window if the panel is still currently active and the old window is still visible + if(tmpID!=0){ + LXCB::WINDOWSTATE state = LSession::handle()->XCB->WindowState(tmpID); + if( state!=LXCB::IGNORE && state !=LXCB::INVISIBLE && (this->winId()==LSession::handle()->XCB->ActiveWindow()) ){ LSession::handle()->XCB->ActivateWindow(tmpID); } + tmpID = 0; + } } event->accept(); //just to quiet the compile warning diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 5b223ad7..17434181 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -41,6 +41,7 @@ LSession::LSession(int &argc, char ** argv) : QApplication(argc, argv){ //this->setAttribute(Qt::AA_UseHighDpiPixmaps); //allow pixmaps to be scaled up as well as down //this->setStyle( new MenuProxyStyle); //QMenu icon size override SystemTrayID = 0; VisualTrayID = 0; + sysWindow = 0; TrayDmgEvent = 0; TrayDmgError = 0; cleansession = true; @@ -111,6 +112,8 @@ void LSession::setupSession(){ appmenu = new AppMenu(); if(DEBUG){ qDebug() << " - Init SettingsMenu:" << timer->elapsed();} settingsmenu = new SettingsMenu(); + if(DEBUG){ qDebug() << " - Init SystemWindow:" << timer->elapsed();} + sysWindow = new SystemWindow(); //Now setup the system watcher for changes qDebug() << " - Initialize file system watcher"; @@ -128,6 +131,7 @@ 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 } void LSession::CleanupSession(){ @@ -315,8 +319,10 @@ void LSession::watcherChange(QString changed){ void LSession::checkUserFiles(){ //internal version conversion examples: // [1.0.0 -> 1000000], [1.2.3 -> 1002003], [0.6.1 -> 6001] - int oldversion = VersionStringToNumber(sessionsettings->value("DesktopVersion","0").toString()); - bool newversion = ( oldversion < VersionStringToNumber(this->applicationVersion()) ); + QString OVS = sessionsettings->value("DesktopVersion","0").toString(); //Old Version String + int oldversion = VersionStringToNumber(OVS); + bool newversion = ( oldversion < VersionStringToNumber(this->applicationVersion()) ); //increasing version number + bool newrelease = ( OVS.contains("-devel", Qt::CaseInsensitive) && this->applicationVersion().contains("-release", Qt::CaseInsensitive) ); //Moving from devel to release //Check for the desktop settings file QString dset = QDir::homePath()+"/.lumina/LuminaDE/desktopsettings.conf"; @@ -331,10 +337,10 @@ void LSession::checkUserFiles(){ }*/ LUtils::LoadSystemDefaults(); } - /*if(oldversion <= 8003){ - //Convert the old->new favorites framework (Not implemented yet) - - }*/ + if(newversion || newrelease){ + //Convert the favorites framework as necessary + LUtils::upgradeFavorites(oldversion); + } //Check for the default applications file for lumina-open dset = QDir::homePath()+"/.lumina/LuminaDE/lumina-open.conf"; @@ -493,8 +499,11 @@ QSettings* LSession::sessionSettings(){ } void LSession::systemWindow(){ - SystemWindow win; - win.exec(); + if(sysWindow==0){ sysWindow = new SystemWindow(); } + else{ sysWindow->updateWindow(); } + sysWindow->show(); + /*SystemWindow win; + win.exec();*/ LSession::processEvents(); } diff --git a/lumina-desktop/LSession.h b/lumina-desktop/LSession.h index 5baf72c4..cdd91899 100644 --- a/lumina-desktop/LSession.h +++ b/lumina-desktop/LSession.h @@ -95,9 +95,9 @@ private: //Internal variable for global usage AppMenu *appmenu; SettingsMenu *settingsmenu; + SystemWindow *sysWindow; QTranslator *currTranslator; QMediaPlayer *mediaObj; - //QThread *audioThread; QSettings *sessionsettings; bool cleansession; diff --git a/lumina-desktop/SystemWindow.cpp b/lumina-desktop/SystemWindow.cpp index 02de54b9..18e65291 100644 --- a/lumina-desktop/SystemWindow.cpp +++ b/lumina-desktop/SystemWindow.cpp @@ -27,48 +27,55 @@ SystemWindow::SystemWindow() : QDialog(), ui(new Ui::SystemWindow){ connect(ui->tool_suspend, SIGNAL(clicked()), this, SLOT(sysSuspend()) ); connect(ui->push_cancel, SIGNAL(clicked()), this, SLOT(sysCancel()) ); connect(ui->push_lock, SIGNAL(clicked()), this, SLOT(sysLock()) ); - //Disable the shutdown/restart buttons if necessary - if( !LOS::userHasShutdownAccess() ){ - ui->tool_restart->setEnabled(false); - ui->tool_shutdown->setEnabled(false); - - } - ui->tool_suspend->setVisible(LOS::systemCanSuspend()); - //Center this window on the screen - QPoint center = QApplication::desktop()->screenGeometry(QCursor::pos()).center(); //get the center of the current screen - this->move(center.x() - this->width()/2, center.y() - this->height()/2); - this->show(); + //Disable buttons if necessary + updateWindow(); + ui->tool_suspend->setVisible(LOS::systemCanSuspend()); //does not change with time - just do a single check } SystemWindow::~SystemWindow(){ } +void SystemWindow::updateWindow(){ + //Disable the shutdown/restart buttons if necessary + bool ok = LOS::userHasShutdownAccess(); + ui->tool_restart->setEnabled(ok); + ui->tool_shutdown->setEnabled(ok); + //Center this window on the current screen + QPoint center = QApplication::desktop()->screenGeometry(QCursor::pos()).center(); //get the center of the current screen + this->move(center.x() - this->width()/2, center.y() - this->height()/2); +} + void SystemWindow::sysLogout(){ + this->hide(); + LSession::processEvents(); QTimer::singleShot(0, LSession::handle(), SLOT(StartLogout()) ); - this->close(); } void SystemWindow::sysRestart(){ + this->hide(); + LSession::processEvents(); QTimer::singleShot(0, LSession::handle(), SLOT(StartReboot()) ); - this->close(); } void SystemWindow::sysShutdown(){ + this->hide(); + LSession::processEvents(); QTimer::singleShot(0, LSession::handle(), SLOT(StartShutdown()) ); - this->close(); } void SystemWindow::sysSuspend(){ + this->hide(); + LSession::processEvents(); //Make sure to lock the system first (otherwise anybody can access it again) LUtils::runCmd("xscreensaver-command -lock"); //Now suspend the system LOS::systemSuspend(); - this->close(); } void SystemWindow::sysLock(){ + this->hide(); + LSession::processEvents(); qDebug() << "Locking the desktop..."; QProcess::startDetached("xscreensaver-command -lock"); - this->close(); } diff --git a/lumina-desktop/SystemWindow.h b/lumina-desktop/SystemWindow.h index 4b1fab44..bf7a6b94 100644 --- a/lumina-desktop/SystemWindow.h +++ b/lumina-desktop/SystemWindow.h @@ -26,6 +26,8 @@ public: SystemWindow(); ~SystemWindow(); + void updateWindow(); + private: Ui::SystemWindow *ui; diff --git a/lumina-desktop/desktop-plugins/LDPlugin.h b/lumina-desktop/desktop-plugins/LDPlugin.h index 38cfa433..10c0d2ea 100644 --- a/lumina-desktop/desktop-plugins/LDPlugin.h +++ b/lumina-desktop/desktop-plugins/LDPlugin.h @@ -41,7 +41,7 @@ public: } ~LDPlugin(){ - delete settings; + } QString ID(){ diff --git a/lumina-desktop/desktop-plugins/LDPluginContainer.h b/lumina-desktop/desktop-plugins/LDPluginContainer.h index 55cc9d12..14b87585 100644 --- a/lumina-desktop/desktop-plugins/LDPluginContainer.h +++ b/lumina-desktop/desktop-plugins/LDPluginContainer.h @@ -33,6 +33,7 @@ private: private slots: void saveGeometry(){ + if(settings==0){ return; } settings->setValue("location/x", this->pos().x()); settings->setValue("location/y", this->pos().y()); settings->setValue("location/width", this->size().width()); @@ -45,14 +46,15 @@ public: locked = islocked; setup=true; syncTimer = new QTimer(this); - syncTimer->setInterval(1000); //save settings 1 second after it is moved + syncTimer->setInterval(500); //save settings 1 second after it is moved syncTimer->setSingleShot(true); //no repeats connect(syncTimer, SIGNAL(timeout()), this, SLOT(saveGeometry()) ); this->setWhatsThis(plugin->ID()); if(locked){ this->setWindowFlags(Qt::FramelessWindowHint); } - else{ this->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); } + else{ this->setWindowFlags(Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); } settings = plugin->settings; //save this pointer for access later - if(settings->allKeys().isEmpty()){ + if(settings!=0){ + if(settings->allKeys().isEmpty()){ //Brand new plugin - no location/size info saved yet //save the initial size of the plugin - the initial location will be set automatically QSize sz = plugin->sizeHint(); @@ -60,7 +62,8 @@ public: settings->setValue("location/width", sz.width()); settings->setValue("location/height", sz.height()); settings->sync(); - } + } + } this->setContentsMargins(0,0,0,0); if(!locked){ this->setWindowTitle( plugin->ID().replace("---"," - ") ); @@ -115,14 +118,16 @@ protected: } void closeEvent(QCloseEvent *event){ - if( !this->whatsThis().isEmpty() ){ + //qDebug() << "Desktop Plugin Close Event:" << this->whatsThis(); + if( !this->whatsThis().isEmpty() && !locked){ //Plugin removed by the user - delete the settings file locked = true; //ensure that the save settings routines don't do anything during the close if(syncTimer->isActive()){ syncTimer->stop(); } //prevent save routine from running in a moment QFile::remove( settings->fileName() ); emit PluginRemoved( this->whatsThis() ); } - event->accept(); //continue closing the widget + settings = 0; //ensure we don't touch the settings file after a close event + event->accept(); } }; diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp index be815587..527de682 100644 --- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp +++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp @@ -174,9 +174,6 @@ void DesktopViewPlugin::updateContents(){ void DesktopViewPlugin::displayProperties(){ QList<QListWidgetItem*> sel = list->selectedItems(); for(int i=0; i<sel.length(); i++){ - //lumina-fileinfo only works on *.desktop files at the moment - if(sel[i]->whatsThis().endsWith(".desktop")){ - LSession::LaunchApplication("lumina-fileinfo \""+sel[i]->whatsThis()); - } + LSession::LaunchApplication("lumina-fileinfo \""+sel[i]->whatsThis()); } } diff --git a/lumina-desktop/fluxboxconf/fluxbox-keys b/lumina-desktop/fluxboxconf/fluxbox-keys index 4d78efcb..f0ec3519 100644 --- a/lumina-desktop/fluxboxconf/fluxbox-keys +++ b/lumina-desktop/fluxboxconf/fluxbox-keys @@ -58,6 +58,10 @@ Mod1 Shift Tab :PrevWindow {groups} (workspace=[current]) (workspace=[current]) Mod4 Tab :NextTab Mod4 Shift Tab :PrevTab +# Arrange/Tile Current windows +Mod4 Left :ArrangeWindowsStackRight (Layer=Normal) +Mod4 Right :ArrangeWindowsStackLeft (Layer=Normal) + # go to a specific tab in the current window Mod4 1 :Tab 1 Mod4 2 :Tab 2 diff --git a/lumina-desktop/main.cpp b/lumina-desktop/main.cpp index adf96181..602ff2ec 100644 --- a/lumina-desktop/main.cpp +++ b/lumina-desktop/main.cpp @@ -80,17 +80,15 @@ int main(int argc, char ** argv) //Startup the Application if(DEBUG){ qDebug() << "Session Init:" << timer->elapsed(); } LSession a(argc, argv); - if(DEBUG){ qDebug() << "Theme Init:" << timer->elapsed(); } - LuminaThemeEngine theme(&a); //Setup Log File qInstallMessageHandler(MessageOutput); - if(DEBUG){ qDebug() << "Session Setup:" << timer->elapsed(); } - a.setupSession(); + if(DEBUG){ qDebug() << "Theme Init:" << timer->elapsed(); } + LuminaThemeEngine theme(&a); if(DEBUG){ qDebug() << "Load Locale:" << timer->elapsed(); } LUtils::LoadTranslation(&a, "lumina-desktop"); - //a.LoadLocale(QLocale().name()); - //Start launching external applications - QTimer::singleShot(3000, &a, SLOT(launchStartupApps()) ); //wait a couple seconds first + if(DEBUG){ qDebug() << "Session Setup:" << timer->elapsed(); } + a.setupSession(); + if(DEBUG){ qDebug() << "Exec Time:" << timer->elapsed(); delete timer;} int retCode = a.exec(); //qDebug() << "Stopping the window manager"; diff --git a/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp b/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp index e60da975..d29d4354 100644 --- a/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp +++ b/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp @@ -1,6 +1,6 @@ //=========================================== // Lumina-DE source code -// Copyright (c) 2012, Ken Moore +// Copyright (c) 2012-2015, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== @@ -14,17 +14,23 @@ LDeskBarPlugin::LDeskBarPlugin(QWidget *parent, QString id, bool horizontal) : L if(QFile::exists(QDir::homePath()+"/Desktop")){ desktopPath = QDir::homePath()+"/Desktop"; } else if(QFile::exists(QDir::homePath()+"/desktop")){ desktopPath = QDir::homePath()+"/desktop"; } else{ desktopPath=""; } + //Make sure the favorites directory exists + if(!QFile::exists(QDir::homePath()+"/.lumina/favorites") ){ + QDir dir; + dir.mkpath(QDir::homePath()+"/.lumina/favorites"); + } //Setup the filter lists for the different types of files - audioFilter <<"*.ogg"<<"*.mp3"<<"*.wav"<<"*.aif"<<"*.iff"<<"*.m3u"<<"*.m4a"<<"*.mid"<<"*.mpa"<<"*.ra"<<"*.wma"; + /*audioFilter <<"*.ogg"<<"*.mp3"<<"*.wav"<<"*.aif"<<"*.iff"<<"*.m3u"<<"*.m4a"<<"*.mid"<<"*.mpa"<<"*.ra"<<"*.wma"; videoFilter <<"*.3g2"<<"*.3gp"<<"*.asf"<<"*.asx"<<"*.avi"<<"*.flv"<<"*.m4v"<<"*.mov"<<"*.mp4"<<"*.mpg"<<"*.rm"<<"*.srt"<<"*.swf"<<"*.vob"<<"*.wmv"; pictureFilter <<"*.bmp"<<"*.dds"<<"*.gif"<<"*.jpg"<<"*.png"<<"*.psd"<<"*.thm"<<"*.tif"<<"*.tiff"<<"*.ai"<<"*.eps"<<"*.ps"<<"*.svg"<<"*.ico"; - docsFilter << "*.txt"<<"*.rtf"<<"*.doc"<<"*.docx"<<"*.odf"<<"*.pdf"; + docsFilter << "*.txt"<<"*.rtf"<<"*.doc"<<"*.docx"<<"*.odf"<<"*.pdf";*/ //initialize the desktop bar items initializeDesktop(); //setup the directory watcher watcher = new QFileSystemWatcher(this); if(!desktopPath.isEmpty()){ - watcher->addPath(desktopPath); + watcher->addPath(desktopPath); + watcher->addPath(QDir::homePath()+"/.lumina/favorites"); } connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(desktopChanged()) ); QTimer::singleShot(1,this, SLOT(desktopChanged()) ); //make sure to load it the first time @@ -107,7 +113,7 @@ QAction* LDeskBarPlugin::newAction(QString filepath, QString name, QIcon icon){ return act; } -void LDeskBarPlugin::updateMenu(QMenu* menu, QFileInfoList files, bool trim){ +/*void LDeskBarPlugin::updateMenu(QMenu* menu, QFileInfoList files, bool trim){ menu->clear(); //re-create the menu (since it is hidden from view) QStringList filevals; @@ -122,7 +128,7 @@ void LDeskBarPlugin::updateMenu(QMenu* menu, QFileInfoList files, bool trim){ for(int i=0; i<filevals.length(); i++){ menu->addAction( newAction( filevals[i].section("::::",1,1), filevals[i].section("::::",0,0), "") ); } -} +}*/ // ======================= // PRIVATE SLOTS @@ -135,59 +141,67 @@ void LDeskBarPlugin::ActionTriggered(QAction* act){ } void LDeskBarPlugin::desktopChanged(){ - if(!desktopPath.isEmpty()){ - QDir dir(desktopPath); - QDir favdir(QDir::homePath()+"/.lumina/favorites"); - totals = dir.entryInfoList( QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - totals << favdir.entryInfoList( QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - //Update all the special menus (trimming the totals list as we go) - updateMenu(dirM, QFileInfoList() << dir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name) << favdir.entryInfoList( QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name)); - updateMenu(audioM, QFileInfoList() << dir.entryInfoList( audioFilter, QDir::Files, QDir::Name) << favdir.entryInfoList( audioFilter, QDir::Files, QDir::Name)); - updateMenu(videoM, QFileInfoList() << dir.entryInfoList( videoFilter, QDir::Files, QDir::Name) << favdir.entryInfoList( videoFilter, QDir::Files, QDir::Name) ); - updateMenu(pictureM, QFileInfoList() << dir.entryInfoList( pictureFilter, QDir::Files, QDir::Name) << favdir.entryInfoList( pictureFilter, QDir::Files, QDir::Name) ); - updateMenu(docM, QFileInfoList() << dir.entryInfoList( docsFilter, QDir::Files, QDir::Name) << favdir.entryInfoList( docsFilter, QDir::Files, QDir::Name) ); - //Now update the launchers - QFileInfoList exe = dir.entryInfoList( QStringList() << "*.desktop", QDir::Files, QDir::Name ); - exe << favdir.entryInfoList( QStringList() << "*.desktop", QDir::Files, QDir::Name ); - // - Get a complete list of apps (in alphabetical order) - QList<XDGDesktop> exeList; - for(int i=0; i<exe.length(); i++){ - totals.removeAll(exe[i]); //Remove this item from the totals - bool ok = false; - XDGDesktop df = LXDG::loadDesktopFile(exe[i].canonicalFilePath(), ok); - if(ok){ - if( LXDG::checkValidity(df) && !df.isHidden ){ exeList << df; } - } - } - exeList = LXDG::sortDesktopNames(exeList); - // - Now re-create the menu with the apps - appM->clear(); - bool listApps = true; //turn this off for the moment (make dynamic later) - if(!listApps){ - //go through the current items and remove them all - while( APPLIST.length() > 0){ - delete this->layout()->takeAt(3); //always after the 3 main menu buttons - } - } - for(int i=0; i<exeList.length(); i++){ - if(listApps){ appM->addAction( newAction(exeList[i].filePath, exeList[i].name, LXDG::findIcon(exeList[i].icon, ":/images/default-application.png")) ); } - else{ - //Create a new LTBWidget for this app - QToolButton *it = new QToolButton(this); - it->setWhatsThis(exeList[i].filePath); - it->setToolTip(exeList[i].name); - it->setIcon( LXDG::findIcon(exeList[i].icon, "") ); - it->setToolButtonStyle(Qt::ToolButtonIconOnly); - it->setAutoRaise(true); - it->setPopupMode(QToolButton::InstantPopup); - if(it->icon().isNull()){ it->setIcon( LXDG::findIcon("application-x-executable","") ); } - connect(it, SIGNAL(triggered(QAction*)), this , SLOT(ActionTriggered(QAction*)) ); - APPLIST << it; - this->layout()->addWidget(it); + QStringList newfavs = LUtils::listFavorites(); + if(lastHomeUpdate.isNull() || (QFileInfo(QDir::homePath()+"/Desktop").lastModified() > lastHomeUpdate) || newfavs!=favs ){ + favs = newfavs; + QDir homedir = QDir( QDir::homePath()+"/Desktop"); + homefiles = homedir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); + lastHomeUpdate = QDateTime::currentDateTime(); + QStringList favitems = favs; + //Remember for format for favorites: <name>::::[app/dir/<mimetype>]::::<full path> + for(int i=0; i<homefiles.length(); i++){ + QString type; + if(homefiles[i].isDir()){ type="dir"; } + else if(homefiles[i].fileName().endsWith(".desktop")){ type="app"; } + else{ type=LXDG::findAppMimeForFile(homefiles[i].fileName()); } + favitems << homefiles[i].fileName()+"::::"+type+"::::"+homefiles[i].absoluteFilePath(); + //qDebug() << "Desktop Item:" << favitems.last(); + } + + favitems.sort(); //sort them alphabetically + //Now add the items to the lists + appM->clear(); + dirM->clear(); + audioM->clear(); + videoM->clear(); + pictureM->clear(); + docM->clear(); + otherM->clear(); + for(int i=0; i<favitems.length(); i++){ + QString type = favitems[i].section("::::",1,1); + QString name = favitems[i].section("::::",0,0); + QString path = favitems[i].section("::::",2,50); + if(type=="app"){ + //Add it to appM + bool ok = false; + XDGDesktop df = LXDG::loadDesktopFile(path, ok); + if(ok){ + if( LXDG::checkValidity(df) && !df.isHidden ){ + appM->addAction( newAction(df.filePath, df.name, LXDG::findIcon(df.icon, ":/images/default-application.png")) ); } } - //Now update the other menu with everything else that is left - updateMenu(otherM, totals, false); + }else if(type=="dir"){ + //Add it to dirM + dirM->addAction( newAction(path, name, LXDG::findIcon("folder","")) ); + }else if(type.startsWith("audio/")){ + //Add it to audioM + audioM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) ); + }else if(type.startsWith("video/")){ + //Add it to videoM + videoM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) ); + }else if(type.startsWith("image/")){ + //Add it to pictureM + pictureM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) ); + }else if(type.startsWith("text/")){ + //Add it to docM + docM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) ); + }else{ + //Add it to otherM + otherM->addAction( newAction(path, name, LXDG::findMimeIcon(type)) ); + } + + } + //Now update the file menu as appropriate fileM->clear(); if(!audioM->isEmpty()){ fileM->addMenu(audioM); } @@ -205,12 +219,11 @@ void LDeskBarPlugin::desktopChanged(){ }else{ fileB->setMenu(fileM); } - } + } //end of check for if updates are needed + //Setup the visibility of the buttons appB->setVisible( !appM->isEmpty() ); dirB->setVisible( !dirM->isEmpty() ); fileB->setVisible( !fileM->isEmpty() ); - //Clear the totals list (since no longer in use) - totals.clear(); } diff --git a/lumina-desktop/panel-plugins/desktopbar/LDeskBar.h b/lumina-desktop/panel-plugins/desktopbar/LDeskBar.h index 1e42bd95..8e624dc2 100644 --- a/lumina-desktop/panel-plugins/desktopbar/LDeskBar.h +++ b/lumina-desktop/panel-plugins/desktopbar/LDeskBar.h @@ -43,17 +43,19 @@ private: //Special toolbuttons and menus QToolButton *appB, *fileB, *dirB; QMenu *appM, *dirM, *audioM, *videoM, *pictureM, *fileM, *otherM, *docM; - QStringList audioFilter, videoFilter, pictureFilter, docsFilter; - QFileInfoList totals; + //QStringList audioFilter, videoFilter, pictureFilter, docsFilter; + QFileInfoList homefiles; + QStringList favs; QList<QToolButton*> APPLIST; - + QDateTime lastHomeUpdate; + void initializeDesktop(); //bool readDesktopFile(QString path, QString &name, QString &iconpath); QAction* newAction(QString filepath, QString name, QString iconpath); QAction* newAction(QString filepath, QString name, QIcon icon); - void updateMenu(QMenu* menu, QFileInfoList files, bool trim = true); + //void updateMenu(QMenu* menu, QFileInfoList files, bool trim = true); private slots: diff --git a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp index a04c6e43..ad1c2fd6 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp @@ -1,15 +1,16 @@ //=========================================== // Lumina-DE source code -// Copyright (c) 2014, Ken Moore +// Copyright (c) 2014-2015, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== #include "UserItemWidget.h" +#include <LuminaUtils.h> -UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, bool isDir, bool goback) : QFrame(parent){ +UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type, bool goback) : QFrame(parent){ createWidget(); //Now fill it appropriately - if(itemPath.endsWith(".desktop")){ + if(itemPath.endsWith(".desktop") || type=="app"){ bool ok = false; XDGDesktop item = LXDG::loadDesktopFile(itemPath, ok); if(ok){ @@ -19,7 +20,7 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, bool isDir, bo icon->setPixmap( LXDG::findIcon("unknown","").pixmap(32,32) ); name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, 180) ); } - }else if(isDir){ + }else if(type=="dir"){ if(itemPath.endsWith("/")){ itemPath.chop(1); } if(goback){ icon->setPixmap( LXDG::findIcon("go-previous","").pixmap(32,32) ); @@ -30,14 +31,17 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, bool isDir, bo } }else{ if(itemPath.endsWith("/")){ itemPath.chop(1); } - icon->setPixmap( LXDG::findMimeIcon(itemPath.section("/",-1)).pixmap(32,32) ); + icon->setPixmap( LXDG::findMimeIcon(type).pixmap(32,32) ); name->setText( this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, 180) ); } - linkPath = QFile::symLinkTarget(itemPath); icon->setWhatsThis(itemPath); - if(isDir && !linkPath.isEmpty()){ isDir = false; } //not a real directory - just a sym link - isDirectory = isDir; //save this for later - isShortcut = itemPath.contains("/home/") && (itemPath.contains("/Desktop/") || itemPath.contains("/.lumina/favorites/") ); + isDirectory = (type=="dir"); //save this for later + if(LUtils::isFavorite(itemPath)){ + linkPath = itemPath; + isShortcut=true; + }else if( itemPath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){ + isShortcut = true; + } //Now setup the button appropriately setupButton(goback); } @@ -45,8 +49,14 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, bool isDir, bo UserItemWidget::UserItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent){ createWidget(); isDirectory = false; - linkPath = QFile::symLinkTarget(item.filePath); - isShortcut = item.filePath.contains("/home/") && (item.filePath.contains("/Desktop/") || item.filePath.contains("/.lumina/favorites/") ); + if(LUtils::isFavorite(item.filePath)){ + linkPath = item.filePath; + isShortcut=true; + }else if( item.filePath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){ + isShortcut = true; + }else{ + isShortcut = false; + } //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) ); @@ -98,8 +108,8 @@ void UserItemWidget::setupButton(bool disable){ button->setToolTip(tr("Delete File")); } connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) ); - }else if( !QFile::exists( QDir::homePath()+"/Desktop/"+icon->whatsThis().section("/",-1) ) && !QFile::exists( QDir::homePath()+"/.lumina/favorites/"+icon->whatsThis().section("/",-1) ) ){ - //This file does not have a desktop shortcut yet -- allow the user to add it + }else if( !QFile::exists( QDir::homePath()+"/Desktop/"+icon->whatsThis().section("/",-1) ) && !LUtils::isFavorite(icon->whatsThis() ) ){ + //This file does not have a shortcut yet -- allow the user to add it button->setWhatsThis("add"); button->setIcon( LXDG::findIcon("bookmark-toolbar","") ); button->setToolTip(tr("Create Shortcut")); @@ -113,10 +123,12 @@ void UserItemWidget::setupButton(bool disable){ void UserItemWidget::buttonClicked(){ button->setVisible(false); if(button->whatsThis()=="add"){ - QFile::link(icon->whatsThis(), QDir::homePath()+"/.lumina/favorites/"+icon->whatsThis().section("/",-1) ); + LUtils::addFavorite(icon->whatsThis()); + //QFile::link(icon->whatsThis(), QDir::homePath()+"/.lumina/favorites/"+icon->whatsThis().section("/",-1) ); emit NewShortcut(); }else if(button->whatsThis()=="remove"){ - QFile::remove(icon->whatsThis()); //never remove the linkPath - since that is the actual file/dir + if(linkPath.isEmpty()){ QFile::remove(icon->whatsThis()); } //This is a desktop file + else{ LUtils::removeFavorite(icon->whatsThis()); } //This is a favorite emit RemovedShortcut(); } } @@ -125,4 +137,4 @@ void UserItemWidget::ItemClicked(){ if(!linkPath.isEmpty()){ emit RunItem(linkPath); } else{ emit RunItem(icon->whatsThis()); } -}
\ No newline at end of file +} diff --git a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h index 1f428ac4..a65d3e83 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h +++ b/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h @@ -1,6 +1,6 @@ //=========================================== // Lumina-DE source code -// Copyright (c) 2014, Ken Moore +// Copyright (c) 2014-2015, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== @@ -25,7 +25,7 @@ class UserItemWidget : public QFrame{ Q_OBJECT public: - UserItemWidget(QWidget *parent=0, QString itemPath="", bool isDir=false, bool goback=false); + UserItemWidget(QWidget *parent=0, QString itemPath="", QString type="unknown", bool goback=false); UserItemWidget(QWidget *parent=0, XDGDesktop item= XDGDesktop()); ~UserItemWidget(); @@ -54,4 +54,4 @@ signals: }; -#endif
\ No newline at end of file +#endif diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp index 52d60714..9c002109 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp @@ -1,6 +1,6 @@ //=========================================== // Lumina-DE source code -// Copyright (c) 2014, Ken Moore +// Copyright (c) 2014-2015, Ken Moore // Available under the 3-clause BSD license // See the LICENSE file for full details //=========================================== @@ -35,6 +35,7 @@ UserWidget::UserWidget(QWidget* parent) : QTabWidget(parent), ui(new Ui::UserWid ui->tool_config_screensettings->setIcon( LXDG::findIcon("preferences-other","") ); ui->tool_home_gohome->setIcon( LXDG::findIcon("go-home","") ); ui->tool_home_browse->setIcon( LXDG::findIcon("document-open","") ); + ui->tool_home_search->setIcon( LXDG::findIcon("system-search","") ); ui->tool_config_about->setIcon( LXDG::findIcon("lumina","") ); //Connect the signals/slots connect(ui->tool_desktopsettings, SIGNAL(clicked()), this, SLOT(openDeskSettings()) ); @@ -46,6 +47,7 @@ UserWidget::UserWidget(QWidget* parent) : QTabWidget(parent), ui(new Ui::UserWid connect(ui->combo_app_cats, SIGNAL(currentIndexChanged(int)), this, SLOT(updateApps()) ); connect(ui->tool_home_gohome, SIGNAL(clicked()), this, SLOT(slotGoHome()) ); connect(ui->tool_home_browse, SIGNAL(clicked()), this, SLOT(slotOpenDir()) ); + connect(ui->tool_home_search, SIGNAL(clicked()), this, SLOT(slotOpenSearch()) ); connect(ui->tool_config_about, SIGNAL(clicked()), this, SLOT(openLuminaInfo()) ); //Setup the special buttons @@ -85,6 +87,7 @@ UserWidget::UserWidget(QWidget* parent) : QTabWidget(parent), ui(new Ui::UserWid ui->tool_qtconfig->setVisible(false); } lastUpdate = QDateTime(); //make sure it refreshes + connect(LSession::handle()->applicationMenu(), SIGNAL(AppMenuUpdated()), this, SLOT(UpdateMenu()) ); QTimer::singleShot(10,this, SLOT(UpdateMenu())); //make sure to load this once after initialization } @@ -147,6 +150,7 @@ void UserWidget::LaunchItem(QString path, bool fix){ void UserWidget::FavChanged(){ //uncheck the current item for a moment + int oldfav = cfav; if(cfav==0){ ui->tool_fav_apps->setChecked(false); } else if(cfav==1){ ui->tool_fav_dirs->setChecked(false); } if(cfav==2){ ui->tool_fav_files->setChecked(false); } @@ -163,31 +167,53 @@ void UserWidget::FavChanged(){ ui->tool_fav_dirs->setChecked(cfav==1); ui->tool_fav_files->setChecked(cfav==2); } - updateFavItems(); + updateFavItems(oldfav!=cfav); } -void UserWidget::updateFavItems(){ - ClearScrollArea(ui->scroll_fav); - QFileInfoList items; - QDir homedir = QDir( QDir::homePath()+"/Desktop"); - QDir favdir = QDir( QDir::homePath()+"/.lumina/favorites"); - if(!favdir.exists()){ favdir.mkpath( QDir::homePath()+"/.lumina/favorites"); } +void UserWidget::updateFavItems(bool newfilter){ + QStringList newfavs = LUtils::listFavorites(); + //qDebug() << "Favorites:" << newfavs; + if(lastHomeUpdate.isNull() || (QFileInfo(QDir::homePath()+"/Desktop").lastModified() > lastHomeUpdate) || newfavs!=favs ){ + favs = newfavs; + + QDir homedir = QDir( QDir::homePath()+"/Desktop"); + homefiles = homedir.entryInfoList(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); + lastHomeUpdate = QDateTime::currentDateTime(); + }else if(!newfilter){ return; } //nothing new to change - stop now + QStringList favitems; + //Remember for format for favorites: <name>::::[app/dir/<mimetype>]::::<full path> if(ui->tool_fav_apps->isChecked()){ - items = homedir.entryInfoList(QStringList()<<"*.desktop", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - items << favdir.entryInfoList(QStringList()<<"*.desktop", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); + favitems = favs.filter("::::app::::"); + for(int i=0; i<homefiles.length(); i++){ + if(homefiles[i].fileName().endsWith(".desktop")){ + favitems << homefiles[i].fileName()+"::::app::::"+homefiles[i].absoluteFilePath(); + } + } }else if(ui->tool_fav_dirs->isChecked()){ - items = homedir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); - items << favdir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + favitems = favs.filter("::::dir::::"); + for(int i=0; i<homefiles.length(); i++){ + if(homefiles[i].isDir()){ + favitems << homefiles[i].fileName()+"::::dir::::"+homefiles[i].absoluteFilePath(); + } + } }else{ //Files - items = homedir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - items << favdir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot, QDir::Name); - for(int i=0; i<items.length(); i++){ - if(items[i].suffix()=="desktop"){ items.removeAt(i); i--; } + for(int i=0; i<favs.length(); i++){ + QString type = favs[i].section("::::",1,1); + if(type != "app" && type !="dir"){ + favitems << favs[i]; + } + } + for(int i=0; i<homefiles.length(); i++){ + if(!homefiles[i].isDir() && !homefiles[i].fileName().endsWith(".desktop") ){ + favitems << homefiles[i].fileName()+"::::"+LXDG::findAppMimeForFile(homefiles[i].fileName())+"::::"+homefiles[i].absoluteFilePath(); + } } } - for(int i=0; i<items.length(); i++){ - UserItemWidget *it = new UserItemWidget(ui->scroll_fav->widget(), items[i].absoluteFilePath(), ui->tool_fav_dirs->isChecked()); + ClearScrollArea(ui->scroll_fav); + favitems.sort(); //sort them alphabetically + 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->tool_fav_dirs->isChecked()); ui->scroll_fav->widget()->layout()->addWidget(it); connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) ); connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) ); @@ -195,15 +221,6 @@ void UserWidget::updateFavItems(){ } static_cast<QBoxLayout*>(ui->scroll_fav->widget()->layout())->addStretch(); - //Clean up any broken sym-links in the favorites directory - /*items = favdir.entryInfoList(QDir::System | QDir::NoDotAndDotDot, QDir::Name); - for(int i=0; i<items.length(); i++){ - if(items[i].isSymLink() && !items[i].exists()){ - //Broken sym-link - remove it - QFile::remove(items[i].absoluteFilePath()); - } - }*/ - } //Apps Tab @@ -268,8 +285,8 @@ void UserWidget::updateHome(){ 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], true, true); } - else{ it = new UserItemWidget(ui->scroll_home->widget(), homedir.absoluteFilePath(items[i]), true, false); } + if(items[i].startsWith("/")){ it = new UserItemWidget(ui->scroll_home->widget(), items[i], "dir", true); } + else{ it = new UserItemWidget(ui->scroll_home->widget(), homedir.absoluteFilePath(items[i]), "dir", false); } ui->scroll_home->widget()->layout()->addWidget(it); connect(it, SIGNAL(RunItem(QString)), this, SLOT(slotGoToDir(QString)) ); connect(it, SIGNAL(NewShortcut()), this, SLOT(updateFavItems()) ); @@ -282,7 +299,7 @@ void UserWidget::slotGoToDir(QString dir){ ui->label_home_dir->setWhatsThis(dir); updateHome(); } - + void UserWidget::slotGoHome(){ slotGoToDir(QDir::homePath()); } @@ -290,7 +307,11 @@ void UserWidget::slotGoHome(){ void UserWidget::slotOpenDir(){ LaunchItem(ui->label_home_dir->whatsThis()); } - + +void UserWidget::slotOpenSearch(){ + LaunchItem("lumina-search -dir \""+ui->label_home_dir->whatsThis()+"\"", false); //use command as-is +} + void UserWidget::mouseMoveEvent( QMouseEvent *event){ QTabBar *wid = tabBar(); if(wid==0){ return; } //invalid widget found @@ -300,4 +321,4 @@ void UserWidget::mouseMoveEvent( QMouseEvent *event){ qDebug() << " - Mouse over tab"; this->setCurrentIndex( wid->tabAt(relpos) ); } -}
\ No newline at end of file +} diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.h b/lumina-desktop/panel-plugins/userbutton/UserWidget.h index c7af2a4d..2dce25b4 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.h +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.h @@ -42,7 +42,9 @@ public slots: private: Ui::UserWidget *ui; QHash<QString, QList<XDGDesktop> > *sysapps; - QDateTime lastUpdate; + QDateTime lastUpdate, lastHomeUpdate; + QStringList favs; + QFileInfoList homefiles; int cfav; //current favorite category void ClearScrollArea(QScrollArea *area); QIcon rotateIcon(QIcon); @@ -52,7 +54,7 @@ private slots: //Favorites Tab void FavChanged(); //for ensuring radio-button-like behaviour - void updateFavItems(); + void updateFavItems(bool newfilter = true); //if false, will only update if filesystem changes //Apps Tab void updateAppCategories(); @@ -63,6 +65,7 @@ private slots: void slotGoToDir(QString dir); void slotGoHome(); void slotOpenDir(); + void slotOpenSearch(); //Slots for the special buttons void openStore(){ diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.ui b/lumina-desktop/panel-plugins/userbutton/UserWidget.ui index f00daf08..bce684fd 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.ui +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.ui @@ -17,7 +17,7 @@ <enum>QTabWidget::West</enum> </property> <property name="currentIndex"> - <number>3</number> + <number>2</number> </property> <widget class="QWidget" name="tab_fav"> <attribute name="title"> @@ -170,8 +170,8 @@ <rect> <x>0</x> <y>0</y> - <width>98</width> - <height>28</height> + <width>260</width> + <height>247</height> </rect> </property> </widget> @@ -276,8 +276,8 @@ <rect> <x>0</x> <y>0</y> - <width>98</width> - <height>28</height> + <width>260</width> + <height>247</height> </rect> </property> </widget> @@ -309,11 +309,61 @@ <number>1</number> </property> <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="spacing"> + <layout class="QGridLayout" name="gridLayout"> + <property name="horizontalSpacing"> + <number>4</number> + </property> + <property name="verticalSpacing"> <number>1</number> </property> - <item> + <item row="0" column="3"> + <widget class="QToolButton" name="tool_home_search"> + <property name="toolTip"> + <string>Search this Directory</string> + </property> + <property name="text"> + <string notr="true"/> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QToolButton" name="tool_home_browse"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>30</width> + <height>30</height> + </size> + </property> + <property name="toolTip"> + <string>Open Directory</string> + </property> + <property name="text"> + <string notr="true">Browse</string> + </property> + <property name="iconSize"> + <size> + <width>20</width> + <height>20</height> + </size> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonIconOnly</enum> + </property> + </widget> + </item> + <item row="0" column="0"> <widget class="QToolButton" name="tool_home_gohome"> <property name="minimumSize"> <size> @@ -338,8 +388,14 @@ </property> </widget> </item> - <item> + <item row="0" column="1"> <widget class="QLabel" name="label_home_dir"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="minimumSize"> <size> <width>0</width> @@ -376,37 +432,6 @@ </property> </widget> </item> - <item> - <widget class="QToolButton" name="tool_home_browse"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>90</width> - <height>30</height> - </size> - </property> - <property name="toolTip"> - <string>Open Directory</string> - </property> - <property name="text"> - <string notr="true">Browse</string> - </property> - <property name="iconSize"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonTextBesideIcon</enum> - </property> - </widget> - </item> </layout> </item> <item> @@ -419,8 +444,8 @@ <rect> <x>0</x> <y>0</y> - <width>98</width> - <height>28</height> + <width>260</width> + <height>247</height> </rect> </property> </widget> diff --git a/lumina-fileinfo/dialog.cpp b/lumina-fileinfo/dialog.cpp index 0444a390..f44ace8f 100644 --- a/lumina-fileinfo/dialog.cpp +++ b/lumina-fileinfo/dialog.cpp @@ -4,363 +4,400 @@ #include <QRegExp> #include <QTemporaryFile> #include <QMessageBox> +#include <QImageReader> #include "LuminaUtils.h" #include <LuminaOS.h> - //this function is just like a regexp. //we just change the required lines and we don't touch to the rest of the file and copy it back. void Dialog::textReplace(QString &origin, QString from, QString to, QString topic) { - if (origin.contains(QRegExp("\n" + topic + "\\s*=\\s*" + from + "\n",Qt::CaseInsensitive))) { - origin.replace(QRegExp("\n" + topic + "\\s*=\\s*" + from + "\n",Qt::CaseInsensitive),"\n" + topic + "=" + to + "\n"); - } else { - origin.append(topic + "=" + to + "\n"); - } + if (origin.contains(QRegExp("\n" + topic + "\\s*=\\s*" + from + "\n",Qt::CaseInsensitive))) { + origin.replace(QRegExp("\n" + topic + "\\s*=\\s*" + from + "\n",Qt::CaseInsensitive),"\n" + topic + "=" + to + "\n"); + } else { + origin.append(topic + "=" + to + "\n"); + } } //get the template from the user home directory or from the qrc files void Dialog::copyTemplate(QString templateType) { - if ((templateType == "-link") or (templateType == "-app")) { - if (QFile::exists(QDir::homePath() + "/.lumina/LuminaDE/fileinfo" + templateType + ".template")) { - //We take the template from homedir - QFile::copy(QDir::homePath() + "/.lumina/LuminaDE/fileinfo" + templateType + ".template", desktopFileName); - } else { - //last possibility is to use the qrc template. - //But based on the initialisation, this should never occurs - QFile::copy(":defaults/fileinfo" + templateType + ".template", desktopFileName); - } - } else { - //error message for developpers - qDebug() << "copyTemplate only accept '-link' or '-app' as parameter"; - } + if ((templateType == "-link") or (templateType == "-app")) { + if (QFile::exists(QDir::homePath() + "/.lumina/LuminaDE/fileinfo" + templateType + ".template")) { + //We take the template from homedir + QFile::copy(QDir::homePath() + "/.lumina/LuminaDE/fileinfo" + templateType + ".template", desktopFileName); + } else { + //last possibility is to use the qrc template. + //But based on the initialisation, this should never occurs + QFile::copy(":defaults/fileinfo" + templateType + ".template", desktopFileName); + } + } else { + //error message for developpers + qDebug() << "copyTemplate only accept '-link' or '-app' as parameter"; + } } Dialog::Dialog(QWidget *parent) : - QDialog(parent), - ui(new Ui::Dialog) + QDialog(parent), + ui(new Ui::Dialog) { - ui->setupUi(this); - desktopType="Application"; //default value - - //Setup all the icons using libLumina - setupIcons(); - - //we copy qrc templates in the home dir of the user. - //this allow the user to adapt those template to is own whishes - QString templateFile = QDir::homePath() + "/.lumina/LuminaDE/fileinfo-link.template"; - if (!QFile::exists(templateFile)) { - QFile::copy(":defaults/fileinfo-link.template", templateFile); - QFile(templateFile).setPermissions(QFileDevice::ReadUser|QFileDevice::WriteUser); - } - templateFile = QDir::homePath() + "/.lumina/LuminaDE/fileinfo-app.template"; - if (!QFile::exists(templateFile)) { - QFile::copy(":defaults/fileinfo-app.template", templateFile); - QFile(templateFile).setPermissions(QFileDevice::ReadUser|QFileDevice::WriteUser); - } + ui->setupUi(this); + desktopType="Application"; //default value + + //Setup all the icons using libLumina + setupIcons(); + + //we copy qrc templates in the home dir of the user. + //this allow the user to adapt those template to is own whishes + QString templateFile = QDir::homePath() + "/.lumina/LuminaDE/fileinfo-link.template"; + if (!QFile::exists(templateFile)) { + QFile::copy(":defaults/fileinfo-link.template", templateFile); + QFile(templateFile).setPermissions(QFileDevice::ReadUser|QFileDevice::WriteUser); + } + templateFile = QDir::homePath() + "/.lumina/LuminaDE/fileinfo-app.template"; + if (!QFile::exists(templateFile)) { + QFile::copy(":defaults/fileinfo-app.template", templateFile); + QFile(templateFile).setPermissions(QFileDevice::ReadUser|QFileDevice::WriteUser); + } } Dialog::~Dialog() { - delete ui; + delete ui; } void Dialog::setupIcons(){ - this->setWindowIcon( LXDG::findIcon("unknown","") ); - ui->pbWorkingDir->setIcon( LXDG::findIcon("folder","") ); - ui->pbCommand->setIcon( LXDG::findIcon("system-search","") ); + this->setWindowIcon( LXDG::findIcon("unknown","") ); + ui->pbWorkingDir->setIcon( LXDG::findIcon("folder","") ); + ui->pbCommand->setIcon( LXDG::findIcon("system-search","") ); } //Inform the user that required input parameters are missing void Dialog::MissingInputs() { - qDebug() << "We cannot continue without a desktop file !!!"; - QMessageBox::critical(this, tr("Error"), tr("Lumina-fileinfo requires inputs:")+"\n"+QString(tr("Example: \"%1\"")).arg("lumina-fileinfo <-application>|<-link> desktopfile") ); - exit(1); + qDebug() << "We cannot continue without a desktop file !!!"; + QMessageBox::critical(this, tr("Error"), tr("Lumina-fileinfo requires inputs:")+"\n"+QString(tr("Example: \"%1\"")).arg("lumina-fileinfo <-application>|<-link> desktopfile") ); + exit(1); } //Initialise the layout of the screen. void Dialog::Initialise(QString param) { - - //in case of "link", several objects are no required - if (param.startsWith("-link")) { - ui->cbRunInTerminal->setVisible(false); - ui->cbStartupNotification->setVisible(false); - ui->lCommand->setVisible(false); - ui->pbCommand->setVisible(false); - ui->lblCommand->setVisible(false); - ui->lblOptions->setVisible(false); - ui->lblWorkingDir->setText(tr("URL")); //we use the WorkingDir boxes for URL - desktopType="link"; - } - if (param.startsWith("-app")) { - ui->cbRunInTerminal->setVisible(true); - ui->cbStartupNotification->setVisible(true); - ui->lCommand->setVisible(true); - ui->pbCommand->setVisible(true); - ui->lblCommand->setVisible(true); - ui->lblOptions->setVisible(true); - ui->lblWorkingDir->setText(tr("Working dir")); - desktopType="app"; - } + //in case of "link", several objects are no required + if (param.startsWith("-link")) { + ui->cbRunInTerminal->setVisible(false); + ui->cbStartupNotification->setVisible(false); + ui->lCommand->setVisible(false); + ui->pbCommand->setVisible(false); + ui->lblCommand->setVisible(false); + ui->lblOptions->setVisible(false); + ui->lblWorkingDir->setText(tr("URL")); //we use the WorkingDir boxes for URL + desktopType="link"; + } + if (param.startsWith("-app")) { + ui->cbRunInTerminal->setVisible(true); + ui->cbStartupNotification->setVisible(true); + ui->lCommand->setVisible(true); + ui->pbCommand->setVisible(true); + ui->lblCommand->setVisible(true); + ui->lblOptions->setVisible(true); + ui->lblWorkingDir->setText(tr("Working dir")); + desktopType="app"; + } } - - - //load the desktop file or the required template void Dialog::LoadDesktopFile(QString input) { - //if we have "-" as 1st char, it means that this is not a desktop file, but a parameter - desktopFileName = input; - if (input.startsWith("-")) { - QMessageBox::critical(this,tr("Error"),tr("The filename cannot start with a \"-\".")); - exit(1); + //if we have "-" as 1st char, it means that this is not a desktop file, but a parameter + desktopFileName = input; + if (input.startsWith("-")) { + QMessageBox::critical(this,tr("Error"),tr("The filename cannot start with a \"-\".")); + exit(1); + } + //if proposed file does not exist, than we will create one based on the templates + if (!QFile::exists(input)) { + if (desktopType=="link") { + copyTemplate("-link"); + } else { + copyTemplate("-app"); } - - //if proposed file does not exist, than we will create one based on the templates - if (!QFile::exists(input)) { - if (desktopType=="link") { - copyTemplate("-link"); - } else { - copyTemplate("-app"); - } + } + this->setWindowTitle(desktopFileName.section("/",-1)); + ui->tabWidget->setCurrentIndex(0); //always start on the file info tab + //Now load the file info and put it into the UI + QFileInfo info(desktopFileName); + QString mime = LXDG::findAppMimeForFile(desktopFileName); + + QList<QByteArray> fmt = QImageReader::supportedImageFormats(); + bool foundimage=false; + for(int i=0; i<fmt.length(); i++){ + if(info.suffix().toLower() == QString(fmt[i]).toLower()){foundimage=true; break; } } - - //use the standard LXDG object and load the desktop file - bool ok = false; - if(desktopFileName.endsWith(".desktop")){ - DF = LXDG::loadDesktopFile(desktopFileName, ok); + if(foundimage){ + ui->label_file_icon->setPixmap( QPixmap(desktopFileName).scaledToHeight(64) ); + }else{ + ui->label_file_icon->setPixmap( LXDG::findMimeIcon(mime).pixmap(QSize(64,64)) ); + } + ui->label_file_mimetype->setText(mime); + QString type; + if(desktopFileName.endsWith(".desktop")){ type = tr("XDG Shortcut"); } + else if(info.isDir()){ type = tr("Directory"); ui->label_file_icon->setPixmap( LXDG::findIcon("folder","").pixmap(QSize(64,64)) ); } + else if(info.isExecutable()){ type = tr("Binary"); } + else{ type = info.suffix().toUpper(); } + if(info.isHidden()){ type = QString(tr("Hidden %1")).arg(type); } + ui->label_file_type->setText(type); + double bytes = info.size(); + QStringList lab; lab << "B" << "KB" << "MB" << "GB" << "TB" << "PB"; + int i=0; + while(i<lab.length() && bytes>1024){ + bytes = bytes/1024; + i++; //next label + } + //convert the size to two decimel places and add the label + QString sz = QString::number( qRound(bytes*100)/100.0 )+lab[i]; + ui->label_file_size->setText( sz ); + ui->label_file_owner->setText(info.owner()); + ui->label_file_group->setText(info.group()); + QString perms; + if(info.isReadable() && info.isWritable()){ perms = tr("Read/Write"); } + else if(info.isReadable()){ perms = tr("Read Only"); } + else if(info.isWritable()){ perms = tr("Write Only"); } + else{ perms = tr("No Access"); } + ui->label_file_perms->setText(perms); + ui->label_file_created->setText( info.created().toString(Qt::SystemLocaleLongDate) ); + ui->label_file_modified->setText( info.lastModified().toString(Qt::SystemLocaleLongDate) ); + + //use the standard LXDG object and load the desktop file + bool ok = false; + if(desktopFileName.endsWith(".desktop")){ + DF = LXDG::loadDesktopFile(desktopFileName, ok); + } + if( ok ) { + if ((DF.type == XDGDesktop::LINK) && (desktopType!="link" )) { + //we open a desktop type "link" but it was not mentionned by parameters + Dialog::Initialise("-link"); } - if( ok ) { - if ((DF.type == XDGDesktop::LINK) && (desktopType!="link" )) { - //we open a desktop type "link" but it was not mentionned by parameters - Dialog::Initialise("-link"); - } - ui->lName->setText(DF.name); - ui->lComment->setText(DF.comment); - ui->lCommand->setText(DF.exec); - //in case of "link" desktop, we populate the correct content in lWorkingDir - if (desktopType=="link") { - ui->lWorkingDir->setText(DF.url); - } else { - ui->lWorkingDir->setText(DF.path); - } - if (DF.startupNotify) ui->cbStartupNotification->setChecked(true); else ui->cbStartupNotification->setChecked(false); - if (DF.useTerminal) ui->cbRunInTerminal->setChecked(true); else ui->cbRunInTerminal->setChecked(false); - iconFileName=""; - ui->pbIcon->setIcon(LXDG::findIcon(DF.icon,"")); - this->setWindowTitle(DF.filePath.section("/",-1)); + ui->lName->setText(DF.name); + ui->lComment->setText(DF.comment); + ui->lCommand->setText(DF.exec); + //in case of "link" desktop, we populate the correct content in lWorkingDir + if (desktopType=="link") { + ui->lWorkingDir->setText(DF.url); } else { - QMessageBox::critical(this, tr("Error"), tr("Invalid File Supplied:") +"\n"+desktopFileName ); - exit(1); + ui->lWorkingDir->setText(DF.path); } - - //we load the file in memory and will adapt it before saving it to disk - QFile file(desktopFileName); - inMemoryFile=""; - if (file.open(QFile::ReadOnly)) { - QTextStream fileData(&file); - inMemoryFile = fileData.readAll(); - file.close(); - //perform some validation checks - //TODO: put those Regex in a config file. - //this will allow checks improvements without compilation of the file - if ((inMemoryFile.contains(QRegExp(".*\\[Desktop Entry\\].*\n"))) && - (inMemoryFile.contains(QRegExp("\n\\s*Type\\s*=.*\n"))) && - (inMemoryFile.contains(QRegExp("\n\\s*Name\\s*=.*\n")))) { - //qDebug() << "sounds a good file"; - } else { - //qDebug() << "wrong file!!!!"; - QMessageBox msgBox; - msgBox.setIcon(QMessageBox::Question); - msgBox.setText(tr("There are some issues with this file !!!!")); - msgBox.setInformativeText(tr("Either you correct this file your self with an editor, or you start from scratch using the link or app template.\nPlease note that this process will update the file called:") + desktopFileName); - QPushButton *linkButton = msgBox.addButton("Link",QMessageBox::AcceptRole); - QPushButton *appButton = msgBox.addButton("App",QMessageBox::ResetRole); - QPushButton *cancelButton = msgBox.addButton("Cancel",QMessageBox::NoRole); - msgBox.exec(); - if (msgBox.clickedButton() == linkButton) { - QFile::remove(desktopFileName); - copyTemplate("-link"); - Initialise("-link"); - LoadDesktopFile(desktopFileName); - } - if (msgBox.clickedButton() == appButton) { - QFile::remove(desktopFileName); - copyTemplate("-app"); - Initialise("-app"); - LoadDesktopFile(desktopFileName); - } - if (msgBox.clickedButton() == cancelButton) { - //we stop here - exit(0); - } - } + if (DF.startupNotify) ui->cbStartupNotification->setChecked(true); else ui->cbStartupNotification->setChecked(false); + if (DF.useTerminal) ui->cbRunInTerminal->setChecked(true); else ui->cbRunInTerminal->setChecked(false); + iconFileName=""; + ui->pbIcon->setIcon(LXDG::findIcon(DF.icon,"")); + if(!info.isWritable()){ ui->tab_deskedit->setEnabled(false); } + } else { + ui->tabWidget->removeTab(1); + return; + } + + //we load the file in memory and will adapt it before saving it to disk + QFile file(desktopFileName); + inMemoryFile=""; + if (file.open(QFile::ReadOnly)) { + QTextStream fileData(&file); + inMemoryFile = fileData.readAll(); + file.close(); + //perform some validation checks + //this will allow checks improvements without compilation of the file + if ((inMemoryFile.contains(QRegExp(".*\\[Desktop Entry\\].*\n"))) && + (inMemoryFile.contains(QRegExp("\n\\s*Type\\s*=.*\n"))) && + (inMemoryFile.contains(QRegExp("\n\\s*Name\\s*=.*\n")))) { + //qDebug() << "sounds a good file"; + } else { + //qDebug() << "wrong file!!!!"; + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Question); + msgBox.setText(tr("There are some issues with this file !!!!")); + msgBox.setInformativeText(tr("Either you correct this file your self with an editor, or you start from scratch using the link or app template.\nPlease note that this process will update the file called:") + desktopFileName); + QPushButton *linkButton = msgBox.addButton("Link",QMessageBox::AcceptRole); + QPushButton *appButton = msgBox.addButton("App",QMessageBox::ResetRole); + QPushButton *cancelButton = msgBox.addButton("Cancel",QMessageBox::NoRole); + msgBox.exec(); + if (msgBox.clickedButton() == linkButton) { + QFile::remove(desktopFileName); + copyTemplate("-link"); + Initialise("-link"); + LoadDesktopFile(desktopFileName); + } + if (msgBox.clickedButton() == appButton) { + QFile::remove(desktopFileName); + copyTemplate("-app"); + Initialise("-app"); + LoadDesktopFile(desktopFileName); + } + if (msgBox.clickedButton() == cancelButton) { + //we stop here + exit(0); + } } + } } void Dialog::on_pbCommand_clicked() { - //the default directory is the user's home directory - QString commandFolder = QDir::homePath(); - if (!ui->lCommand->text().isEmpty()) commandFolder = ui->lCommand->text().section('/', 0, -2); - if (commandFolder.isEmpty()) commandFolder = QDir::homePath(); - - QString fileName = QFileDialog::getOpenFileName(this, + //the default directory is the user's home directory + QString commandFolder = QDir::homePath(); + if (!ui->lCommand->text().isEmpty()) commandFolder = ui->lCommand->text().section('/', 0, -2); + if (commandFolder.isEmpty()) commandFolder = QDir::homePath(); + + QString fileName = QFileDialog::getOpenFileName(this, tr("Open command"), commandFolder, tr("All Files (*)")); - if (!fileName.isEmpty()) { - ui->lCommand->setText(fileName); - ui->lCommand->setModified(true); - } + if (!fileName.isEmpty()) { + ui->lCommand->setText(fileName); + ui->lCommand->setModified(true); + } } void Dialog::on_pbWorkingDir_clicked() { - //the default directory is / - QString workingDir = "/"; - if (ui->lWorkingDir->text().isEmpty()) workingDir = "/"; - else workingDir = ui->lWorkingDir->text(); - QFileDialog::Options options = QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly; - QString directory = QFileDialog::getExistingDirectory(this, + //the default directory is / + QString workingDir = "/"; + if (ui->lWorkingDir->text().isEmpty()) workingDir = "/"; + else workingDir = ui->lWorkingDir->text(); + QFileDialog::Options options = QFileDialog::DontResolveSymlinks | QFileDialog::ShowDirsOnly; + QString directory = QFileDialog::getExistingDirectory(this, tr("Working Directory"), workingDir, options); - if (!directory.isEmpty()) { - ui->lWorkingDir->setText(directory); - ui->lWorkingDir->setModified(true); - } + if (!directory.isEmpty()) { + ui->lWorkingDir->setText(directory); + ui->lWorkingDir->setModified(true); + } } //we save the changes to the destination file void Dialog::on_pbApply_clicked() { - QString from,to; - QString desktopTypeVal="Application"; - if (DF.type == XDGDesktop::APP) { desktopTypeVal="Application"; } - else if (DF.type == XDGDesktop::LINK) { desktopTypeVal="Link"; } - else if (DF.type == XDGDesktop::DIR) { desktopTypeVal="Dir"; } - textReplace(inMemoryFile, desktopTypeVal, desktopType, "Type"); - - if (ui->lName->isModified()) { textReplace(inMemoryFile, DF.name, ui->lName->text(), "Name");} - if (ui->lComment->isModified()) { textReplace(inMemoryFile, DF.comment, ui->lComment->text(), "Comment");} - if (ui->lCommand->isModified()) { textReplace(inMemoryFile, DF.exec, ui->lCommand->text(),"Exec");} - if (desktopType=="link") { - //incase of "link" layout WorkingDir is corresponding to the URL - if (ui->lWorkingDir->isModified()) { textReplace(inMemoryFile, DF.url, ui->lWorkingDir->text(),"URL");} - } else { - if (ui->lWorkingDir->isModified()) { textReplace(inMemoryFile, DF.path, ui->lWorkingDir->text(),"Path");} - } - if (ui->cbStartupNotification->isChecked() != DF.startupNotify) { - if (DF.startupNotify) {from="true"; to="false";} else {from="false"; to="true";} - textReplace(inMemoryFile, from, to,"StartupNotify"); - } - if (ui->cbRunInTerminal->isChecked() != DF.useTerminal) { - if (DF.useTerminal) {from="true"; to="false";} else {from="false"; to="true";} - textReplace(inMemoryFile, from, to,"Terminal"); - } - if (!iconFileName.isEmpty()) { - from=DF.icon; - to=iconFileName; - textReplace(inMemoryFile, from, to,"Icon"); - } - - QFile file(desktopFileName); - if (file.open(QFile::ReadWrite)) { - file.seek(0); - file.write(inMemoryFile.toUtf8()); - - file.resize(file.pos());//remove possible trailing lines - - file.close(); - } else { - //problem to write to the disk - QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to write the adapted desktop file to the disk. Can you re-try the modification after solving the issue with the disk ?")); - } - - //hack required to update the icon on the desktop - QTemporaryFile tempFile ; - tempFile.setAutoRemove(false); - tempFile.setFileTemplate("/tmp/lumina-XXXXXX"); - tempFile.open(); - tempFile.close(); - - QString cmd = "mv"; - cmd = cmd + " " + desktopFileName + " " + tempFile.fileName(); - int ret = LUtils::runCmd(cmd); - if (ret !=0 ) { - qDebug() << "Problem to execute:" << cmd; - QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to execute the following command:") + cmd); - - } - - cmd = "mv"; - cmd = cmd + " " + tempFile.fileName() + " " + desktopFileName; - ret = LUtils::runCmd(cmd); - if (ret !=0 ) { - qDebug() << "Problem to execute:" << cmd; - QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to execute the following command:") + cmd); - } + QString from,to; + QString desktopTypeVal="Application"; + if (DF.type == XDGDesktop::APP) { desktopTypeVal="Application"; } + else if (DF.type == XDGDesktop::LINK) { desktopTypeVal="Link"; } + else if (DF.type == XDGDesktop::DIR) { desktopTypeVal="Dir"; } + textReplace(inMemoryFile, desktopTypeVal, desktopType, "Type"); + + if (ui->lName->isModified()) { textReplace(inMemoryFile, DF.name, ui->lName->text(), "Name");} + if (ui->lComment->isModified()) { textReplace(inMemoryFile, DF.comment, ui->lComment->text(), "Comment");} + if (ui->lCommand->isModified()) { textReplace(inMemoryFile, DF.exec, ui->lCommand->text(),"Exec");} + if (desktopType=="link") { + //incase of "link" layout WorkingDir is corresponding to the URL + if (ui->lWorkingDir->isModified()) { textReplace(inMemoryFile, DF.url, ui->lWorkingDir->text(),"URL");} + } else { + if (ui->lWorkingDir->isModified()) { textReplace(inMemoryFile, DF.path, ui->lWorkingDir->text(),"Path");} + } + if (ui->cbStartupNotification->isChecked() != DF.startupNotify) { + if (DF.startupNotify) {from="true"; to="false";} else {from="false"; to="true";} + textReplace(inMemoryFile, from, to,"StartupNotify"); + } + if (ui->cbRunInTerminal->isChecked() != DF.useTerminal) { + if (DF.useTerminal) {from="true"; to="false";} else {from="false"; to="true";} + textReplace(inMemoryFile, from, to,"Terminal"); + } + if (!iconFileName.isEmpty()) { + from=DF.icon; + to=iconFileName; + textReplace(inMemoryFile, from, to,"Icon"); + } + + QFile file(desktopFileName); + if (file.open(QFile::ReadWrite)) { + file.seek(0); + file.write(inMemoryFile.toUtf8()); + + file.resize(file.pos());//remove possible trailing lines + + file.close(); + } else { + //problem to write to the disk + QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to write the adapted desktop file to the disk. Can you re-try the modification after solving the issue with the disk ?")); + } + + //hack required to update the icon on the desktop + QTemporaryFile tempFile ; + tempFile.setAutoRemove(false); + tempFile.setFileTemplate("/tmp/lumina-XXXXXX"); + tempFile.open(); + tempFile.close(); + + QString cmd = "mv"; + cmd = cmd + " " + desktopFileName + " " + tempFile.fileName(); + int ret = LUtils::runCmd(cmd); + if (ret !=0 ) { + qDebug() << "Problem to execute:" << cmd; + QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to execute the following command:") + cmd); + } + + cmd = "mv"; + cmd = cmd + " " + tempFile.fileName() + " " + desktopFileName; + ret = LUtils::runCmd(cmd); + if (ret !=0 ) { + qDebug() << "Problem to execute:" << cmd; + QMessageBox::critical(this, tr("Problem to write to disk"), tr("We have a problem to execute the following command:") + cmd); + } } void Dialog::on_pbIcon_clicked() { - //the default directory is local/share/icons - QString iconFolder = LOS::AppPrefix()+"/share/icons"; - if (!iconFileName.isEmpty()) iconFolder = iconFileName.section('/', 0, -2); - else if (!DF.icon.isEmpty()) iconFolder = DF.icon.section('/', 0, -2); - if (iconFolder.isEmpty()) iconFolder = LOS::AppPrefix()+"/share/icons"; - - QString fileName = QFileDialog::getOpenFileName(this, + //the default directory is local/share/icons + QString iconFolder = LOS::AppPrefix()+"/share/icons"; + if (!iconFileName.isEmpty()) iconFolder = iconFileName.section('/', 0, -2); + else if (!DF.icon.isEmpty()) iconFolder = DF.icon.section('/', 0, -2); + if (iconFolder.isEmpty()) iconFolder = LOS::AppPrefix()+"/share/icons"; + + QString fileName = QFileDialog::getOpenFileName(this, tr("Open command"), iconFolder, tr("Image Files (*.png *.jpg *.bmp)")); - if (!fileName.isEmpty()) { - ui->pbIcon->setIcon(QPixmap(fileName)); - iconFileName=fileName; - } + if (!fileName.isEmpty()) { + ui->pbIcon->setIcon(QPixmap(fileName)); + iconFileName=fileName; + } } void Dialog::on_lName_textChanged(QString text) { - if (text != DF.name && inMemoryFile.contains(QRegExp("\nName\\[\\S+\\]\\s*=",Qt::CaseInsensitive))) { - QMessageBox msgBox; - msgBox.setText(tr("By modifying this value, you will loose all translated versions")); - msgBox.setInformativeText(tr("The field: Name is translated in several other languages. If you want to continue, you will loose all translated versions")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - int answer = msgBox.exec(); - if (answer==QMessageBox::Ok) { - //remove all translated versions. The lang cannot be null, but the value can be. - inMemoryFile.replace(QRegExp("\nName\\[\\S+\\]\\s*=[^\n]*",Qt::CaseInsensitive), ""); - } else { - ui->lName->setText(DF.name); - } - } + if (text != DF.name && inMemoryFile.contains(QRegExp("\nName\\[\\S+\\]\\s*=",Qt::CaseInsensitive))) { + QMessageBox msgBox; + msgBox.setText(tr("By modifying this value, you will loose all translated versions")); + msgBox.setInformativeText(tr("The field: Name is translated in several other languages. If you want to continue, you will loose all translated versions")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + int answer = msgBox.exec(); + if (answer==QMessageBox::Ok) { + //remove all translated versions. The lang cannot be null, but the value can be. + inMemoryFile.replace(QRegExp("\nName\\[\\S+\\]\\s*=[^\n]*",Qt::CaseInsensitive), ""); + } else { + ui->lName->setText(DF.name); + } + } } void Dialog::on_lComment_textChanged(QString text) { - if (text != DF.name && inMemoryFile.contains(QRegExp("\nComment\\[\\S+\\]\\s*=",Qt::CaseInsensitive))) { - QMessageBox msgBox; - msgBox.setText(tr("By modifying this value, you will loose all translated versions")); - msgBox.setInformativeText(tr("The field: Comment is translated in several other languages. If you want to continue, you will loose all translated versions")); - msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); - int answer = msgBox.exec(); - if (answer==QMessageBox::Ok) { - //remove all translated versions. The lang cannot be null, but the value can be. - inMemoryFile.replace(QRegExp("\nComment\\[\\S+\\]\\s*=[^\n]*",Qt::CaseInsensitive), ""); - } else { - ui->lName->setText(DF.comment); - } - } + if (text != DF.name && inMemoryFile.contains(QRegExp("\nComment\\[\\S+\\]\\s*=",Qt::CaseInsensitive))) { + QMessageBox msgBox; + msgBox.setText(tr("By modifying this value, you will loose all translated versions")); + msgBox.setInformativeText(tr("The field: Comment is translated in several other languages. If you want to continue, you will loose all translated versions")); + msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); + int answer = msgBox.exec(); + if (answer==QMessageBox::Ok) { + //remove all translated versions. The lang cannot be null, but the value can be. + inMemoryFile.replace(QRegExp("\nComment\\[\\S+\\]\\s*=[^\n]*",Qt::CaseInsensitive), ""); + } else { + ui->lName->setText(DF.comment); + } + } } diff --git a/lumina-fileinfo/dialog.h b/lumina-fileinfo/dialog.h index 6f0a4dbf..785cb52e 100644 --- a/lumina-fileinfo/dialog.h +++ b/lumina-fileinfo/dialog.h @@ -10,42 +10,42 @@ class Dialog; class Dialog : public QDialog { - Q_OBJECT - + Q_OBJECT + public: - explicit Dialog(QWidget *parent = 0); + explicit Dialog(QWidget *parent = 0); - XDGDesktop DF ; - QString inMemoryFile; + XDGDesktop DF ; + QString inMemoryFile; - QString desktopFileName ; - QString iconFileName; - QString desktopType; + QString desktopFileName ; + QString iconFileName; + QString desktopType; - void Initialise(QString); - void MissingInputs(); - void LoadDesktopFile(QString); + void Initialise(QString); + void MissingInputs(); + void LoadDesktopFile(QString); - ~Dialog(); + ~Dialog(); public slots: - void setupIcons(); + void setupIcons(); private slots: - void on_pbCommand_clicked(); - void on_pbWorkingDir_clicked(); - void on_pbApply_clicked(); - void on_pbIcon_clicked(); + void on_pbCommand_clicked(); + void on_pbWorkingDir_clicked(); + void on_pbApply_clicked(); + void on_pbIcon_clicked(); - void textReplace(QString &origin, QString from, QString to, QString topic); - void copyTemplate(QString templateType); + void textReplace(QString &origin, QString from, QString to, QString topic); + void copyTemplate(QString templateType); - void on_lName_textChanged(QString text); - void on_lComment_textChanged(QString text); + void on_lName_textChanged(QString text); + void on_lComment_textChanged(QString text); private: - Ui::Dialog *ui; + Ui::Dialog *ui; }; #endif // DIALOG_H diff --git a/lumina-fileinfo/dialog.ui b/lumina-fileinfo/dialog.ui index 311c2ff0..2827127c 100644 --- a/lumina-fileinfo/dialog.ui +++ b/lumina-fileinfo/dialog.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>383</width> - <height>288</height> + <width>349</width> + <height>327</height> </rect> </property> <property name="windowTitle"> @@ -15,162 +15,353 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="3" column="0" alignment="Qt::AlignRight"> - <widget class="QLabel" name="lblWorkingDir"> - <property name="text"> - <string>Working dir:</string> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab_file"> + <attribute name="title"> + <string>File Properties</string> + </attribute> + <layout class="QFormLayout" name="formLayout"> + <property name="labelAlignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QPushButton" name="pbWorkingDir"> - <property name="enabled"> - <bool>true</bool> + <item row="0" column="0"> + <widget class="QLabel" name="label_file_icon"> + <property name="text"> + <string notr="true">icon</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item row="4" column="0" colspan="2"> + <widget class="Line" name="line_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Owner:</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLabel" name="label_file_owner"> + <property name="text"> + <string notr="true"/> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Group:</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QLabel" name="label_file_group"> + <property name="text"> + <string notr="true"/> + </property> + </widget> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="label_11"> + <property name="text"> + <string>Permissions:</string> + </property> + </widget> + </item> + <item row="10" column="0" colspan="2"> + <widget class="Line" name="line_3"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="11" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Created:</string> + </property> + </widget> + </item> + <item row="11" column="1"> + <widget class="QLabel" name="label_file_created"> + <property name="toolTip"> + <string>Note: The time a file was created might be more recent than the time modified if the file permissions were changed recently.</string> + </property> + <property name="text"> + <string notr="true"/> + </property> + </widget> + </item> + <item row="12" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Last Modified:</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Type:</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>MimeType:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="label_file_mimetype"> + <property name="text"> + <string notr="true"/> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="label_file_type"> + <property name="text"> + <string notr="true"/> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="QLabel" name="label_file_perms"> + <property name="text"> + <string notr="true"/> + </property> + </widget> + </item> + <item row="12" column="1"> + <widget class="QLabel" name="label_file_modified"> + <property name="text"> + <string notr="true"/> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>File Size:</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="label_file_size"> + <property name="text"> + <string notr="true"/> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_deskedit"> + <attribute name="title"> + <string>Edit Shortcut</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <property name="spacing"> + <number>2</number> </property> - <property name="text"> - <string/> + <property name="leftMargin"> + <number>4</number> </property> - <property name="icon"> - <iconset> - <normalon>../../../../usr/local/share/icons/gnome/32x32/places/folder.png</normalon> - </iconset> + <property name="topMargin"> + <number>4</number> </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QPushButton" name="pbCommand"> - <property name="text"> - <string/> + <property name="rightMargin"> + <number>4</number> </property> - <property name="icon"> - <iconset> - <normalon>../../../../usr/local/share/icons/gnome/32x32/actions/gnome-run.png</normalon> - </iconset> + <property name="bottomMargin"> + <number>4</number> </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QCheckBox" name="cbStartupNotification"> - <property name="text"> - <string>Use startup notification</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="lWorkingDir"> - <property name="enabled"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="4" column="0" alignment="Qt::AlignRight"> - <widget class="QLabel" name="lblIcon"> - <property name="text"> - <string>Icon:</string> - </property> - </widget> - </item> - <item row="2" column="0" alignment="Qt::AlignRight"> - <widget class="QLabel" name="lblCommand"> - <property name="text"> - <string>Command:</string> - </property> - </widget> - </item> - <item row="1" column="0" alignment="Qt::AlignRight"> - <widget class="QLabel" name="lblComment"> - <property name="text"> - <string>Comment:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="lCommand"/> - </item> - <item row="4" column="1" alignment="Qt::AlignLeft"> - <widget class="QPushButton" name="pbIcon"> - <property name="maximumSize"> - <size> - <width>275</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string/> - </property> - <property name="icon"> - <iconset> - <normalon>../../../../usr/local/share/icons/gnome/32x32/categories/xfce-graphics.png</normalon> - </iconset> - </property> - <property name="iconSize"> - <size> - <width>64</width> - <height>64</height> - </size> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="QCheckBox" name="cbRunInTerminal"> - <property name="text"> - <string>Run in terminal</string> - </property> - </widget> - </item> - <item row="0" column="0" alignment="Qt::AlignRight"> - <widget class="QLabel" name="lblName"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item row="5" column="0" alignment="Qt::AlignRight"> - <widget class="QLabel" name="lblOptions"> - <property name="text"> - <string>Options</string> - </property> - </widget> - </item> - <item row="0" column="1" colspan="2"> - <widget class="QLineEdit" name="lName"/> - </item> - <item row="1" column="1" colspan="2"> - <widget class="QLineEdit" name="lComment"/> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <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="pbCancel"> - <property name="text"> - <string>Cancel</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="pbApply"> - <property name="text"> - <string>Apply</string> - </property> - </widget> - </item> - </layout> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="3" column="0" alignment="Qt::AlignRight"> + <widget class="QLabel" name="lblWorkingDir"> + <property name="text"> + <string>Working dir:</string> + </property> + </widget> + </item> + <item row="3" column="2"> + <widget class="QPushButton" name="pbWorkingDir"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset> + <normalon>../../../../usr/local/share/icons/gnome/32x32/places/folder.png</normalon> + </iconset> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QPushButton" name="pbCommand"> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset> + <normalon>../../../../usr/local/share/icons/gnome/32x32/actions/gnome-run.png</normalon> + </iconset> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QCheckBox" name="cbStartupNotification"> + <property name="text"> + <string>Use startup notification</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QLineEdit" name="lWorkingDir"> + <property name="enabled"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="4" column="0" alignment="Qt::AlignRight"> + <widget class="QLabel" name="lblIcon"> + <property name="text"> + <string>Icon:</string> + </property> + </widget> + </item> + <item row="2" column="0" alignment="Qt::AlignRight"> + <widget class="QLabel" name="lblCommand"> + <property name="text"> + <string>Command:</string> + </property> + </widget> + </item> + <item row="1" column="0" alignment="Qt::AlignRight"> + <widget class="QLabel" name="lblComment"> + <property name="text"> + <string>Comment:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="lCommand"/> + </item> + <item row="4" column="1" alignment="Qt::AlignLeft"> + <widget class="QPushButton" name="pbIcon"> + <property name="maximumSize"> + <size> + <width>275</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset> + <normalon>../../../../usr/local/share/icons/gnome/32x32/categories/xfce-graphics.png</normalon> + </iconset> + </property> + <property name="iconSize"> + <size> + <width>64</width> + <height>64</height> + </size> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QCheckBox" name="cbRunInTerminal"> + <property name="text"> + <string>Run in terminal</string> + </property> + </widget> + </item> + <item row="0" column="0" alignment="Qt::AlignRight"> + <widget class="QLabel" name="lblName"> + <property name="text"> + <string>Name:</string> + </property> + </widget> + </item> + <item row="5" column="0" alignment="Qt::AlignRight"> + <widget class="QLabel" name="lblOptions"> + <property name="text"> + <string>Options</string> + </property> + </widget> + </item> + <item row="0" column="1" colspan="2"> + <widget class="QLineEdit" name="lName"/> + </item> + <item row="1" column="1" colspan="2"> + <widget class="QLineEdit" name="lComment"/> + </item> + </layout> + </item> + <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <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="pbCancel"> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="pbApply"> + <property name="text"> + <string>Apply</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + </widget> </item> </layout> </widget> diff --git a/lumina-fileinfo/lumina-fileinfo.pro b/lumina-fileinfo/lumina-fileinfo.pro index b565818d..c90dd5a4 100644 --- a/lumina-fileinfo/lumina-fileinfo.pro +++ b/lumina-fileinfo/lumina-fileinfo.pro @@ -100,7 +100,7 @@ TRANSLATIONS = i18n/lumina-fileinfo_af.ts \ i18n/lumina-fileinfo_zh_CN.ts \ i18n/lumina-fileinfo_zh_HK.ts \ i18n/lumina-fileinfo_zh_TW.ts \ - i18n/lumina-fileinfo_zu.ts + i18n/lumina-fileinfo_zu.ts dotrans.path=$$PREFIX/share/Lumina-DE/i18n/ dotrans.extra=cd i18n && $${LRELEASE} -nounfinished *.ts && cp *.qm $(INSTALL_ROOT)$$PREFIX/share/Lumina-DE/i18n/ diff --git a/lumina-fileinfo/main.cpp b/lumina-fileinfo/main.cpp index 59e86623..5f6a0d57 100644 --- a/lumina-fileinfo/main.cpp +++ b/lumina-fileinfo/main.cpp @@ -9,22 +9,22 @@ int main(int argc, char ** argv) { - QApplication a(argc, argv); - LUtils::LoadTranslation(&a, "lumina-fileinfo"); - LuminaThemeEngine theme(&a); + QApplication a(argc, argv); + LUtils::LoadTranslation(&a, "lumina-fileinfo"); + LuminaThemeEngine theme(&a); - Dialog w; - QObject::connect(&theme, SIGNAL(updateIcons()), &w, SLOT(setupIcons()) ); - if (argc==2) { - w.LoadDesktopFile(QString(argv[1]).simplified()); - } else if (argc==3) { - w.Initialise(QString(argv[1]).simplified()); - w.LoadDesktopFile(QString(argv[2]).simplified()); - } else { - w.MissingInputs(); - } - w.show(); + Dialog w; + QObject::connect(&theme, SIGNAL(updateIcons()), &w, SLOT(setupIcons()) ); + if (argc==2) { + w.LoadDesktopFile(QString(argv[1]).simplified()); + } else if (argc==3) { + w.Initialise(QString(argv[1]).simplified()); + w.LoadDesktopFile(QString(argv[2]).simplified()); + } else { + w.MissingInputs(); + } + w.show(); - int retCode = a.exec(); - return retCode; + int retCode = a.exec(); + return retCode; }
\ No newline at end of file diff --git a/lumina-fm/MainUI.cpp b/lumina-fm/MainUI.cpp index 5446802c..3cc66d97 100644 --- a/lumina-fm/MainUI.cpp +++ b/lumina-fm/MainUI.cpp @@ -162,6 +162,7 @@ void MainUI::setupIcons(){ ui->actionBackToBrowser->setIcon( LXDG::findIcon("go-previous","") ); ui->actionManage_Bookmarks->setIcon( LXDG::findIcon("bookmarks-organize","") ); ui->actionScan->setIcon( LXDG::findIcon("system-search","") ); + ui->actionSearch->setIcon( LXDG::findIcon("edit-find","") ); //Browser page ui->tool_addNewFile->setIcon( LXDG::findIcon("document-new","")); @@ -679,6 +680,10 @@ void MainUI::on_actionNew_Tab_triggered(){ tabBar->setCurrentIndex(tabBar->count()-1); } +void MainUI::on_actionSearch_triggered(){ + QProcess::startDetached("lumina-search -dir \""+getCurrentDir()+"\""); +} + void MainUI::on_actionClose_triggered(){ if(tabBar->count() > 1){ if(QMessageBox::Yes != QMessageBox::question(this, tr("Verify Quit"), tr("You have multiple tabs open. Are you sure you want to quit?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes ) ){ @@ -969,7 +974,7 @@ void MainUI::OpenContextMenu(const QPoint &pt){ contextMenu->addAction(LXDG::findIcon("edit-delete",""), tr("Delete Selection"), this, SLOT(RemoveItem()) )->setEnabled(info.isWritable()&&hasSelection); if(LUtils::isValidBinary("lumina-fileinfo")){ contextMenu->addSeparator(); - contextMenu->addAction(LXDG::findIcon("system-search",""), tr("File Properties"), this, SLOT(ViewPropertiesItem()) )->setEnabled(hasSelection && info.fileName().endsWith(".desktop")); + contextMenu->addAction(LXDG::findIcon("edit-find-replace",""), tr("File Properties"), this, SLOT(ViewPropertiesItem()) )->setEnabled(hasSelection); } if (info.isDir() || CItem.isEmpty()) { //in case the user click on a directory or click on the background @@ -1008,13 +1013,7 @@ void MainUI::ItemSelectionChanged(){ if(sel.length()==1){ itname = sel[0].fileName(); } bool ok = !itname.isEmpty() && (getCurrentDir()!=QDir::homePath()+"/Desktop"); if(ok){ - if(QFile::exists(favdir+itname)){ - //Make sure this favorite does not already point to the current file - QFileInfo info(favdir+itname); - if(info.isSymLink() && info.exists()){ - ok = false; //still an active favorite - do not allow replacement - } - } + ok = !LUtils::isFavorite(sel[0].canonicalFilePath()); } ui->tool_act_fav->setEnabled(ok); } @@ -1409,13 +1408,14 @@ void MainUI::FavoriteItem(){ if(CItem.isEmpty()){ QFileInfoList sel = getSelectedItems(); if(sel.isEmpty()){ return; } - else{ CItem = sel[0].absoluteFilePath(); } + else{ CItem = sel[0].canonicalFilePath(); } } - QString fname = CItem; - QString fullpath = fname; - fname = fname.section("/",-1); //turn this into just the file name + //QString fname = CItem; + QString fullpath = CItem; + /*fname = fname.section("/",-1); //turn this into just the file name if(QFile::exists(favdir+fname)){ QFile::remove(favdir+fname); } //remove the stale link - QFile::link(fullpath, favdir+fname); + QFile::link(fullpath, favdir+fname);*/ + LUtils::addFavorite(fullpath); CItem.clear(); ItemSelectionChanged(); } @@ -1424,9 +1424,7 @@ void MainUI::ViewPropertiesItem(){ QFileInfoList sel = getSelectedItems(); if(sel.isEmpty()){ return; } for(int i=0; i<sel.length(); i++){ - if(sel[i].absoluteFilePath().endsWith(".desktop")){ - QProcess::startDetached("lumina-fileinfo \""+sel[i].absoluteFilePath()+"\""); - } + QProcess::startDetached("lumina-fileinfo \""+sel[i].absoluteFilePath()+"\""); } } diff --git a/lumina-fm/MainUI.h b/lumina-fm/MainUI.h index 0e3d7eb5..be8bb11f 100644 --- a/lumina-fm/MainUI.h +++ b/lumina-fm/MainUI.h @@ -140,6 +140,7 @@ private slots: //Menu Actions void on_actionNew_Tab_triggered(); + void on_actionSearch_triggered(); void on_actionClose_triggered(); void on_actionView_Hidden_Files_triggered(); void on_actionShow_Action_Buttons_triggered(); diff --git a/lumina-fm/MainUI.ui b/lumina-fm/MainUI.ui index 4b2156c2..9ef367d7 100644 --- a/lumina-fm/MainUI.ui +++ b/lumina-fm/MainUI.ui @@ -1113,6 +1113,7 @@ <string>File</string> </property> <addaction name="actionNew_Tab"/> + <addaction name="actionSearch"/> <addaction name="separator"/> <addaction name="actionClose"/> </widget> @@ -1297,6 +1298,14 @@ <string>Load Thumbnails</string> </property> </action> + <action name="actionSearch"> + <property name="text"> + <string>Search Directory</string> + </property> + <property name="shortcut"> + <string>Ctrl+F</string> + </property> + </action> </widget> <resources/> <connections/> diff --git a/lumina-open/main.cpp b/lumina-open/main.cpp index 70e5b2f7..ecb661e0 100644 --- a/lumina-open/main.cpp +++ b/lumina-open/main.cpp @@ -281,6 +281,7 @@ void getCMD(int argc, char ** argv, QString& binary, QString& args, QString& pat cmd.replace("%F","\""+inFile+"\""); }else if( (cmd.contains("%U") || cmd.contains("%u")) ){ //Apply any special field replacements for the desired format + if(!inFile.contains("://")){ inFile.prepend("file:"); } //local file - add the extra flag inFile.replace(" ", "%20"); //Now replace the field codes cmd.replace("%u","\""+inFile+"\""); diff --git a/lumina-search/ConfigUI.cpp b/lumina-search/ConfigUI.cpp index ada82946..18480984 100644 --- a/lumina-search/ConfigUI.cpp +++ b/lumina-search/ConfigUI.cpp @@ -24,6 +24,7 @@ ConfigUI::ConfigUI(QWidget *parent) : QDialog(parent), ui(new Ui::ConfigUI){ ui->tool_getStartDir->setIcon( LXDG::findIcon("folder","") ); ui->tool_adddirs->setIcon( LXDG::findIcon("list-add","") ); ui->tool_rmdir->setIcon( LXDG::findIcon("list-remove","") ); + newDefaults = false; } ConfigUI::~ConfigUI(){ @@ -74,6 +75,7 @@ void ConfigUI::on_buttonBox_accepted(){ } dirs.removeDuplicates(); newSkipDirs = dirs; + newDefaults = ui->check_setDefaults->isChecked(); this->close(); } diff --git a/lumina-search/ConfigUI.h b/lumina-search/ConfigUI.h index 0ee385c5..173fd6c7 100644 --- a/lumina-search/ConfigUI.h +++ b/lumina-search/ConfigUI.h @@ -21,6 +21,7 @@ public: QString newStartDir; QStringList newSkipDirs; + bool newDefaults; private: Ui::ConfigUI *ui; diff --git a/lumina-search/ConfigUI.ui b/lumina-search/ConfigUI.ui index 95d3a4ad..6a3060e0 100644 --- a/lumina-search/ConfigUI.ui +++ b/lumina-search/ConfigUI.ui @@ -112,11 +112,38 @@ </widget> </item> <item row="3" column="0" colspan="2"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QCheckBox" name="check_setDefaults"> + <property name="text"> + <string>Save as Defaults</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <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="QDialogButtonBox" name="buttonBox"> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Save</set> + </property> + </widget> + </item> + </layout> </item> </layout> </widget> diff --git a/lumina-search/MainUI.cpp b/lumina-search/MainUI.cpp index 6597f589..8f90d536 100644 --- a/lumina-search/MainUI.cpp +++ b/lumina-search/MainUI.cpp @@ -47,7 +47,7 @@ MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){ settings = new QSettings("LuminaDE", "lumina-search",this); searcher->startDir = settings->value("StartSearchDir", QDir::homePath()).toString(); searcher->skipDirs = settings->value("SkipSearchDirs", QStringList()).toStringList(); - + updateDefaultStatusTip(); this->show(); workthread->start(); QTimer::singleShot(0,this, SLOT(setupIcons()) ); @@ -67,6 +67,38 @@ void MainUI::setupIcons(){ ui->tool_configure->setIcon( LXDG::findIcon("configure","") ); } +// =============== +// PUBLIC FUNCTIONS (for input handling primarily) +// =============== +void MainUI::disableExcludes(){ + searcher->skipDirs.clear(); + updateDefaultStatusTip(); +} + +void MainUI::setSearchDirectory(QString path){ + ui->radio_files->setChecked(true); + searcher->startDir = path; + updateDefaultStatusTip(); +} + +void MainUI::setSearchTerm(QString text){ + ui->line_search->setText(text); +} + +//============== +// PRIVATE +//============== +void MainUI::updateDefaultStatusTip(){ + if(ui->radio_files->isChecked()){ + QString txt = tr("Search: %1 -- Smart: %2"); + QString dir = searcher->startDir; + dir.replace(QDir::homePath(), "~"); + QString smart = searcher->skipDirs.isEmpty() ? tr("Off"): tr("On"); + txt = txt.arg(dir,smart); + ui->statusbar->showMessage(txt); + } +} + //============== // PRIVATE SLOTS //============== @@ -90,19 +122,23 @@ void MainUI::searchTypeChanged(){ void MainUI::configureSearch(){ ConfigUI dlg(this); - dlg.loadInitialValues( searcher->startDir, searcher->skipDirs); + dlg.loadInitialValues( settings->value("StartSearchDir",QDir::homePath()).toString(), settings->value("SkipSearchDirs",QStringList()).toStringList()); dlg.exec(); if(dlg.newStartDir.isEmpty()){ return; }//cancelled QString startdir = dlg.newStartDir; QStringList skipdirs = dlg.newSkipDirs; - //Save these values for later - settings->setValue("StartSearchDir", startdir); - settings->setValue("SkipSearchDirs", skipdirs); - + //Save these values for later (if selected) + if(dlg.newDefaults){ + //save these values as the new defaults + settings->setValue("StartSearchDir", startdir); + settings->setValue("SkipSearchDirs", skipdirs); + } + //Set these values in the searcher searcher->startDir = startdir; searcher->skipDirs = skipdirs; + updateDefaultStatusTip(); } void MainUI::searchChanged(){ @@ -114,7 +150,7 @@ void MainUI::searchChanged(){ void MainUI::startSearch(){ ui->listWidget->clear(); stopSearch(); //just in case a search is still running - if(ui->line_search->text().isEmpty()){ return; } //nothing to search for + if(ui->line_search->text().isEmpty()){ updateDefaultStatusTip(); return; } //nothing to search for //emit the proper signal for the worker if(!workthread->isRunning()){ workthread->start(); } //make sure the thread is running @@ -153,6 +189,7 @@ void MainUI::stopSearch(){ searcher->StopSearch(); ui->tool_stop->setVisible(false); ui->tool_configure->setVisible(ui->radio_files->isChecked()); + updateDefaultStatusTip(); } void MainUI::searchMessage(QString msg){ @@ -162,4 +199,5 @@ void MainUI::searchMessage(QString msg){ void MainUI::searchFinished(){ ui->tool_stop->setVisible(false); ui->tool_configure->setVisible(ui->radio_files->isChecked()); + updateDefaultStatusTip(); } diff --git a/lumina-search/MainUI.h b/lumina-search/MainUI.h index cd4a1db7..0a9f4acb 100644 --- a/lumina-search/MainUI.h +++ b/lumina-search/MainUI.h @@ -29,8 +29,13 @@ public: MainUI(); ~MainUI(); + void disableExcludes(); + void setSearchDirectory(QString path); + void setSearchTerm(QString text); + public slots: void setupIcons(); + void startSearch(); //emit the proper signal for the worker private: Ui::MainUI *ui; @@ -39,6 +44,8 @@ private: Worker *searcher; QSettings *settings; + void updateDefaultStatusTip(); + private slots: //Button Slots void closeApplication(){ @@ -52,7 +59,7 @@ private slots: void searchChanged(); //for active searching while typing //Worker Interaction - void startSearch(); //emit the proper signal for the worker + //void startSearch(); //Moved to a public slot void foundSearchItem(QString path); //To get the worker's results void stopSearch(); void searchMessage(QString); diff --git a/lumina-search/main.cpp b/lumina-search/main.cpp index 305c388b..f03bf04a 100644 --- a/lumina-search/main.cpp +++ b/lumina-search/main.cpp @@ -8,6 +8,12 @@ #include <LuminaThemes.h> #include <LuminaUtils.h> +//==== INPUT FORMAT ==== +// lumina-search [-no-excludes] [-dir [directory]] [-search <term>] +// -no-excludes: Don't exclude anything from this search +// -dir [directory]: Setup a file/dir search within the current working dir (or specified dir) +// -search <term>: Start a search with the given term +//=================== int main(int argc, char ** argv) { //qDebug() << "Init App..."; @@ -21,6 +27,44 @@ int main(int argc, char ** argv) MainUI w; QObject::connect(&theme,SIGNAL(updateIcons()), &w, SLOT(setupIcons()) ); w.show(); + if(argc>1){ + bool startsearch = false; + for(int i=1; i<argc; i++){ + QString val = QString(argv[i]).toLower(); + if( val == "-no-excludes"){ w.disableExcludes(); } + else if(val=="-dir"){ + //Check the next input value for a directory path + QString dir; + if( argc>(i+1) ){ dir = QString(argv[i+1]); } + //Check the input for validity + if(dir.startsWith("-")){dir.clear(); } //not a directory, just another input + else if(!dir.startsWith("/")){ //not an absolute path + dir = QDir::currentPath()+"/"+dir; + QFileInfo info(dir); + if( !info.exists() || !info.isDir() ){ dir.clear(); } //invalid relative dir + } + + if(dir.isEmpty()){ dir= QDir::currentPath(); } //use the current directory + else{ i++; } //using the next input value - skip it for the next iteration + w.setSearchDirectory( dir ); + + }else if(val=="-search"){ + //Check the next input value for a text string + QString text; + if( argc>(i+1) ){ text = QString(argv[i+1]); } + //Check the input for validity + if( !text.isEmpty() ){ + i++; //using the next input value - skip it for the next iteration + w.setSearchTerm( text ); + startsearch = true; + } + } + }//end loop over inputs + if(startsearch){ + //A CLI search was requested, go ahead and start it now + QTimer::singleShot(10, &w, SLOT(startSearch())); + } + } //end check for input arguments return a.exec(); } diff --git a/lumina-wm/LScreenSaver.cpp b/lumina-wm-INCOMPLETE/LScreenSaver.cpp index 7af3758f..7af3758f 100644 --- a/lumina-wm/LScreenSaver.cpp +++ b/lumina-wm-INCOMPLETE/LScreenSaver.cpp diff --git a/lumina-wm/LScreenSaver.h b/lumina-wm-INCOMPLETE/LScreenSaver.h index c2965ae6..c2965ae6 100644 --- a/lumina-wm/LScreenSaver.h +++ b/lumina-wm-INCOMPLETE/LScreenSaver.h diff --git a/lumina-wm/WMSession.h b/lumina-wm-INCOMPLETE/WMSession.h index a1212af5..a1212af5 100644 --- a/lumina-wm/WMSession.h +++ b/lumina-wm-INCOMPLETE/WMSession.h diff --git a/lumina-wm/lumina-wm.pro b/lumina-wm-INCOMPLETE/lumina-wm.pro index 34d8a9ac..34d8a9ac 100644 --- a/lumina-wm/lumina-wm.pro +++ b/lumina-wm-INCOMPLETE/lumina-wm.pro diff --git a/lumina-wm/main.cpp b/lumina-wm-INCOMPLETE/main.cpp index b19b00e3..b19b00e3 100644 --- a/lumina-wm/main.cpp +++ b/lumina-wm-INCOMPLETE/main.cpp diff --git a/port-files/Makefile b/port-files/Makefile index 91d0c088..b1a9d27b 100644 --- a/port-files/Makefile +++ b/port-files/Makefile @@ -2,12 +2,9 @@ # $FreeBSD$ PORTNAME= lumina -PORTVERSION= 0.8.4.${GITVERSION} +PORTVERSION= 0.8.4 PORTEPOCH= 1 CATEGORIES= x11 -MASTER_SITES= http://www.pcbsd.org/~kris/software/ \ - ftp://ftp.pcbsd.org/pub/software/ -DISTNAME= ${PORTNAME}-${GITVERSION} MAINTAINER= kmoore@FreeBSD.org COMMENT= Lumina Desktop Environment @@ -37,15 +34,17 @@ RUN_DEPENDS+= gstreamer-plugins-core>=0:${PORTSDIR}/multimedia/gstreamer-plugins MAKE_JOBS_UNSAFE=yes -GITVERSION= CHGVERSION +GITVERSION= 1430233908 USE_XORG= x11 xcomposite xdamage xrender USE_XCB= x11extras wm USE_LDCONFIG= yes USE_QT5= core gui network svg linguist multimedia imageformats \ buildtools x11extras USES= qmake tar:bzip2 - -WRKSRC= ${WRKDIR}/lumina +USE_GITHUB= yes +GH_ACCOUNT= pcbsd +GH_COMMIT= e07dfbb +GH_TAGNAME= v0.8.4-Release QMAKE_ARGS= CONFIG+="configure" diff --git a/port-files/distinfo b/port-files/distinfo index 6facf5bc..aaefc4dd 100644 --- a/port-files/distinfo +++ b/port-files/distinfo @@ -1,2 +1,2 @@ -SHA256 (pcbsd-utils-qt4-0.9.tar.bz2) = 18c3b851bdffe5cb7a64288cad87c6e9669cde53a42b37ec199cce68ff61ec87 -SIZE (pcbsd-utils-qt4-0.9.tar.bz2) = 8089726 +SHA256 (lumina-0.8.4.tar.bz2) = 5fdfbb6b75d86d3cb68dce0453d4675dd7e24312de445e188d5a988512ee9bd3 +SIZE (lumina-0.8.4.tar.bz2) = 23262377 |