diff options
author | wi <william.os4y@gmail.com> | 2015-04-12 22:21:19 +0200 |
---|---|---|
committer | wi <william.os4y@gmail.com> | 2015-04-12 22:21:19 +0200 |
commit | b26a12931cc2488359cc2bd26e508a01efded9d5 (patch) | |
tree | b27468f3aa3d79b878a7881934bbbc50ca158474 /lumina-desktop | |
parent | refactring of lumina-fileinfo: (diff) | |
parent | Fix location of ogg / vorbis gstreamer plugins (diff) | |
download | lumina-b26a12931cc2488359cc2bd26e508a01efded9d5.tar.gz lumina-b26a12931cc2488359cc2bd26e508a01efded9d5.tar.bz2 lumina-b26a12931cc2488359cc2bd26e508a01efded9d5.zip |
Merge remote-tracking branch 'upstream/master' into deskEditor
Diffstat (limited to 'lumina-desktop')
-rw-r--r-- | lumina-desktop/AppMenu.cpp | 3 | ||||
-rw-r--r-- | lumina-desktop/LSession.cpp | 43 | ||||
-rw-r--r-- | lumina-desktop/LSession.h | 2 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp | 8 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h | 14 | ||||
-rw-r--r-- | lumina-desktop/main.cpp | 6 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp | 45 |
7 files changed, 57 insertions, 64 deletions
diff --git a/lumina-desktop/AppMenu.cpp b/lumina-desktop/AppMenu.cpp index 8736b61e..6c24d632 100644 --- a/lumina-desktop/AppMenu.cpp +++ b/lumina-desktop/AppMenu.cpp @@ -14,7 +14,8 @@ AppMenu::AppMenu(QWidget* parent) : QMenu(parent){ APPS.clear(); watcher = new QFileSystemWatcher(this); connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(watcherUpdate()) ); - QTimer::singleShot(200, this, SLOT(start()) ); //Now start filling the menu + //QTimer::singleShot(200, this, SLOT(start()) ); //Now start filling the menu + start(); //do the initial run during session init so things are responsive immediately. } AppMenu::~AppMenu(){ diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 6437524b..bce1d607 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -171,6 +171,20 @@ void LSession::CleanupSession(){ for(int i=0; i<20; i++){ LSession::processEvents(); usleep(25); } //1/2 second pause } +int LSession::VersionStringToNumber(QString version){ + version = version.section("-",0,0); //trim any extra labels off the end + int maj, mid, min; //major/middle/minor version numbers (<Major>.<Middle>.<Minor>) + maj = mid = min = 0; + bool ok = true; + maj = version.section(".",0,0).toInt(&ok); + if(ok){ mid = version.section(".",1,1).toInt(&ok); }else{ maj = 0; } + if(ok){ min = version.section(".",2,2).toInt(&ok); }else{ mid = 0; } + if(!ok){ min = 0; } + //Now assemble the number + //NOTE: This format allows numbers to be anywhere from 0->999 without conflict + return (maj*1000000 + mid*1000 + min); +} + void LSession::launchStartupApps(){ //First start any system-defined startups, then do user defined qDebug() << "Launching startup applications"; @@ -213,6 +227,18 @@ void LSession::launchStartupApps(){ if(sessionsettings->value("EnableNumlock",true).toBool()){ QProcess::startDetached("numlockx on"); } + //Now get any XDG startup applications and launch them + QList<XDGDesktop> xdgapps = LXDG::findAutoStartFiles(); + for(int i=0; i<xdgapps.length(); i++){ + qDebug() << " - Auto-Starting File:" << xdgapps[i].filePath; + if(xdgapps[i].startupNotify){ + LSession::LaunchApplication("lumina-open \""+xdgapps[i].filePath+"\""); + }else{ + //Don't update the mouse cursor + QProcess::startDetached("lumina-open \""+xdgapps[i].filePath+"\""); + } + } + } void LSession::StartLogout(){ @@ -240,15 +266,16 @@ void LSession::watcherChange(QString changed){ } void LSession::checkUserFiles(){ - //version conversion examples: [1.0.0 -> 100], [1.2.0 -> 120], [0.6.0 -> 60] - int oldversion = sessionsettings->value("DesktopVersion","0").toString().section("-",0,0).remove(".").toInt(); - bool newversion = ( oldversion < this->applicationVersion().remove(".").toInt() ); + //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()) ); //Check for the desktop settings file QString dset = QDir::homePath()+"/.lumina/LuminaDE/desktopsettings.conf"; bool firstrun = false; - if(!QFile::exists(dset) || oldversion < 50){ - if( oldversion < 50 ){ QFile::remove(dset); qDebug() << "Current desktop settings obsolete: Re-implementing defaults"; } + if(!QFile::exists(dset) || oldversion < 5000){ + if( oldversion < 5000 ){ QFile::remove(dset); qDebug() << "Current desktop settings obsolete: Re-implementing defaults"; } else{ firstrun = true; } /*if(QFile::exists(LOS::LuminaShare()+"desktopsettings.conf")){ if( QFile::copy(LOS::LuminaShare()+"desktopsettings.conf", dset) ){ @@ -257,10 +284,10 @@ void LSession::checkUserFiles(){ }*/ LUtils::LoadSystemDefaults(); } - if(oldversion <= 83){ - //Convert the old->new favorites framework + /*if(oldversion <= 8003){ + //Convert the old->new favorites framework (Not implemented yet) - } + }*/ //Check for the default applications file for lumina-open dset = QDir::homePath()+"/.lumina/LuminaDE/lumina-open.conf"; diff --git a/lumina-desktop/LSession.h b/lumina-desktop/LSession.h index fdd47eb6..4c9ea15e 100644 --- a/lumina-desktop/LSession.h +++ b/lumina-desktop/LSession.h @@ -112,6 +112,8 @@ private: void CleanupSession(); + int VersionStringToNumber(QString version); + public slots: void launchStartupApps(); void StartLogout(); diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp index 5526f267..f8e85cea 100644 --- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp +++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp @@ -4,6 +4,7 @@ #include <QDir> #include <QClipboard> #include <QMimeData> +#include <QImageReader> #include <LuminaXDG.h> #include "LSession.h" @@ -128,6 +129,10 @@ void DesktopViewPlugin::decreaseIconSize(){ void DesktopViewPlugin::updateContents(){ list->clear(); + if(imgExtensions.isEmpty()){ + QList<QByteArray> fmt = QImageReader::supportedImageFormats(); + for(int i=0; i<fmt.length(); i++){ imgExtensions << QString::fromLocal8Bit(fmt[i]); } + } int icosize = settings->value("IconSize",64).toInt(); list->setGridSize(QSize(icosize+8,icosize+4+this->fontMetrics().height())); QDir dir(QDir::homePath()+"/Desktop"); @@ -153,6 +158,9 @@ void DesktopViewPlugin::updateContents(){ it->setIcon( LXDG::findMimeIcon(files[i].fileName()) ); it->setText( files[i].fileName() ); } + }else if(imgExtensions.contains(files[i].suffix().toLower()) ){ + it->setIcon( QIcon( QPixmap(files[i].absoluteFilePath()).scaled(icosize,icosize,Qt::IgnoreAspectRatio, Qt::SmoothTransformation) ) ); + it->setText( files[i].fileName() ); }else{ it->setIcon( LXDG::findMimeIcon( files[i].fileName() ) ); it->setText( files[i].fileName() ); diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h index 86240dc8..90bc20eb 100644 --- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h +++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h @@ -27,6 +27,7 @@ private: QListWidget *list; QFileSystemWatcher *watcher; QMenu *menu; + QStringList imgExtensions; private slots: void runItems(); @@ -47,19 +48,6 @@ public slots: void ThemeChange(){ QTimer::singleShot(0,this, SLOT(updateContents())); } - -/*protected: - void mousePressEvent(QMouseEvent *ev){ - if(ev->button()==Qt::RightButton){ - qDebug() << " - got mouse event"; - //Only show the context menu if an item is under the mouse (don't block the desktop menu) - if(list->itemAt( ev->globalPos()) !=0){ - ev->accept(); - showMenu(ev->globalPos()); - } - } - } - */ }; #endif diff --git a/lumina-desktop/main.cpp b/lumina-desktop/main.cpp index bd26e8f4..357fd14c 100644 --- a/lumina-desktop/main.cpp +++ b/lumina-desktop/main.cpp @@ -51,6 +51,12 @@ void MessageOutput(QtMsgType type, const QMessageLogContext &context, const QStr int main(int argc, char ** argv) { + if (argc > 1) { + if (QString(argv[1]) == QString("--version")){ + qDebug() << LUtils::LuminaDesktopVersion(); + return 0; + } + } if(!QFile::exists(LOS::LuminaShare())){ qDebug() << "Lumina does not appear to be installed correctly. Cannot find: " << LOS::LuminaShare(); return 1; diff --git a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp index e966f389..e5cc17df 100644 --- a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp +++ b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp @@ -39,7 +39,7 @@ void TrayIcon::attachApp(WId id){ AID = id; IID = this->winId(); //embed directly into this widget //IID = LX11::CreateWindow( this->winId(), this->rect() ); //Create an intermediate window to be the parent - if( LX11::EmbedWindow(AID, IID) ){ + if( LSession::handle()->XCB->EmbedWindow(AID, IID) ){ LX11::RestoreWindow(AID); //make it visible //XSelectInput(QX11Info::display(), AID, StructureNotifyMask); //xcb_damage_create(QX11Info::connection(), dmgID, AID, XCB_DAMAGE_REPORT_LEVEL_RAW_RECTANGLES); @@ -69,7 +69,7 @@ void TrayIcon::detachApp(){ AID = 0; //Now detach the application window and clean up qDebug() << " - Unembed"; - LX11::UnembedWindow(tmp); + LSession::handle()->XCB->UnembedWindow(tmp); //if(dmgID!=0){ //XDamageDestroy(QX11Info::display(), dmgID); //} @@ -81,24 +81,6 @@ void TrayIcon::detachApp(){ // ============== // PRIVATE SLOTS // ============== -/*void TrayIcon::slotAttach(){ - IID = this->winId(); //embed directly into this widget - //IID = LX11::CreateWindow( this->winId(), this->rect() ); //Create an intermediate window to be the parent - if( LX11::EmbedWindow(AID, IID) ){ - LX11::RestoreWindow(AID); //make it visible - //XSelectInput(QX11Info::display(), AID, StructureNotifyMask); - dmgID = XDamageCreate( QX11Info::display(), AID, XDamageReportRawRectangles ); - updateIcon(); - qDebug() << "New System Tray App:" << AID; - QTimer::singleShot(500, this, SLOT(updateIcon()) ); - }else{ - qWarning() << "Could not Embed Tray Application:" << AID; - //LX11::DestroyWindow(IID); - IID = 0; - AID = 0; - } -}*/ - void TrayIcon::updateIcon(){ if(AID==0){ return; } //Make sure the icon is square @@ -119,16 +101,13 @@ void TrayIcon::paintEvent(QPaintEvent *event){ //qDebug() << " - Draw tray:" << AID << IID << this->winId(); //qDebug() << " - - " << event->rect().x() << event->rect().y() << event->rect().width() << event->rect().height(); //qDebug() << " - Get image:" << AID; - QPixmap pix = LSession::handle()->XCB->WindowImage(AID); - if(pix.isNull()){ + QPixmap pix; //Try to grab the window directly with Qt - qDebug() << " - - Grab window directly"; QList<QScreen*> scrnlist = QApplication::screens(); for(int i=0; i<scrnlist.length(); i++){ pix = scrnlist[i]->grabWindow(AID); break; //stop here } - } //qDebug() << " - Pix size:" << pix.size().width() << pix.size().height(); //qDebug() << " - Geom:" << this->geometry().x() << this->geometry().y() << this->geometry().width() << this->geometry().height(); if(!pix.isNull()){ @@ -141,13 +120,6 @@ void TrayIcon::paintEvent(QPaintEvent *event){ } } -/*void TrayIcon::moveEvent(QMoveEvent *event){ - //Make sure the main Tray window is right underneath the widget - //qDebug() << "Move Event:" << event->pos().x() << event->pos().y(); - LX11::MoveResizeWindow(AID, QRect( this->mapToGlobal(event->pos()), this->size()) ); - QWidget::moveEvent(event); -}*/ - void TrayIcon::resizeEvent(QResizeEvent *event){ //qDebug() << "Resize Event:" << event->size().width() << event->size().height(); if(AID!=0){ @@ -155,14 +127,3 @@ void TrayIcon::resizeEvent(QResizeEvent *event){ QTimer::singleShot(500, this, SLOT(update()) ); //make sure to re-draw the window in a moment } } - -/*bool TrayIcon::x11Event(XEvent *event){ - qDebug() << "XEvent"; - if( event->xany.window==AID || event->type==( (int)dmgID+XDamageNotify) ){ - qDebug() << "Tray X Event:" << AID; - this->update(); //trigger a repaint - return true; - }else{ - return false; //no special handling - } -}*/ |