diff options
34 files changed, 764 insertions, 85 deletions
@@ -8,6 +8,9 @@ Makefile.Release moc_*.cpp ui_*.h qrc_*.cpp +.build + +# Compiled binaries src-qt5/core/lumina-desktop/lumina-desktop src-qt5/core/lumina-session/start-lumina-desktop src-qt5/core/lumina-wm*/lumina-wm @@ -22,25 +25,26 @@ src-qt5/core-utils/lumina-xconfig/lumina-xconfig src-qt5/desktop-utils/lumina-fm/lumina-fm src-qt5/desktop-utils/lumina-fileinfo/lumina-fileinfo src-qt5/desktop-utils/lumina-screenshot/lumina-screenshot -src-qt5/desktop-utils/lumina-terminal/lumina-terminal +src-qt5/*/lumina-terminal/lumina-terminal src-qt5/desktop-utils/lumina-textedit/lumina-textedit src-qt5/desktop-utils/lumina-archiver/lumina-archiver src-qt5/desktop-utils/lumina-calculator/lumina-calculator src-qt5/desktop-utils/lumina-pdf/lumina-pdf -src-qt5/desktop-utils/lumina-pdf/.build/ src-qt5/desktop-utils/lumina-notify/lumina-notify src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/ -src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/.build/ src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/Makefile src-qt5/core/lumina-theme-engine/src/lthemeengine-qtplugin/liblthemeengine.so src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/Makefile src-qt5/core/lumina-theme-engine/src/lthemeengine-sstest/lthemeengine-sstest -src-qt5/core/lumina-theme-engine/src/lthemeengine-style/.build/ src-qt5/core/lumina-theme-engine/src/lthemeengine-style/Makefile src-qt5/core/lumina-theme-engine/src/lthemeengine-style/liblthemeengine-style.so src-qt5/core/lumina-theme-engine/src/lthemeengine/Makefile src-qt5/core/lumina-theme-engine/src/lthemeengine/lthemeengine src-qt5/desktop-utils/lumina-mediaplayer/lumina-mediaplayer +src-qt5/src-cpp/tests/test + + +# QMake-generated Makefiles src-qt5/Makefile src-qt5/*/Makefile src-qt5/*/*/Makefile diff --git a/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp b/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp index 9804fbae..11c0d468 100644 --- a/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp +++ b/src-qt5/core/libLumina/LuminaOS-FreeBSD.cpp @@ -289,8 +289,13 @@ void LOS::systemSuspend(){ //Battery Availability bool LOS::hasBattery(){ - int val = LUtils::getCmdOutput("apm -l").join("").toInt(); - return (val >= 0 && val <= 100); + static int hasbat = -1; + if(hasbat < 0 ){ + int val = batteryCharge(); + if(val >= 0 && val <= 100){ hasbat = 1; } + else{ hasbat = 0; } + } + return (hasbat==1); } //Battery Charge Level diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp index 5e931e5f..a17ed060 100644 --- a/src-qt5/core/lumina-desktop-unified/LSession.cpp +++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp @@ -10,7 +10,7 @@ #include "BootSplash.h" #ifndef DEBUG -#define DEBUG 1 +#define DEBUG 0 #endif //Initialize all the global objects to null pointers @@ -33,12 +33,14 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu mediaObj = 0; //private object used for playing login/logout chimes if(this->isPrimaryProcess()){ //Setup the global registrations + if(DEBUG){ qDebug() << "Starting session init..."; } qsrand(QDateTime::currentMSecsSinceEpoch()); this->setApplicationName("Lumina Desktop Environment"); this->setApplicationVersion( LDesktopUtils::LuminaDesktopVersion() ); this->setOrganizationName("LuminaDesktopEnvironment"); this->setQuitOnLastWindowClosed(false); //since the LDesktop's are not necessarily "window"s //Enable a few of the simple effects by default + if(DEBUG){ qDebug() << " - Setting attributes and effects"; } this->setEffectEnabled( Qt::UI_AnimateMenu, true); this->setEffectEnabled( Qt::UI_AnimateCombo, true); this->setEffectEnabled( Qt::UI_AnimateTooltip, true); @@ -46,19 +48,24 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu this->setAttribute(Qt::AA_UseHighDpiPixmaps); //allow pixmaps to be scaled up as well as down //Now initialize the global objects (but do not start them yet) + if(DEBUG){ qDebug() << " - Create native event objects"; } Lumina::NEF = new NativeEventFilter(); Lumina::NWS = new NativeWindowSystem(); Lumina::SS = new LScreenSaver(); Lumina::DESKMAN = new DesktopManager(); //Now put the Native Window System into it's own thread to keep things snappy + if(DEBUG){ qDebug() << " - Create extra threads"; } Lumina::EVThread = new QThread(); Lumina::DESKMAN->moveToThread(Lumina::EVThread); Lumina::EVThread->start(); Lumina::APPLIST = XDGDesktopList::instance(); + if(DEBUG){ qDebug() << " - Create root window"; } Lumina::ROOTWIN = new RootWindow(); Lumina::SHORTCUTS = new LShortcutEvents(); //this can be moved to it's own thread eventually as well + if(DEBUG){ qDebug() << " - Setup Connections"; } setupGlobalConnections(); } //end check for primary process + if(DEBUG){ qDebug() << " [finished] Session init"; } } LSession::~LSession(){ @@ -81,7 +88,7 @@ LSession::~LSession(){ void LSession::setupSession(){ BootSplash splash; splash.showScreen("init"); - qDebug() << "Initializing Session:" << QDateTime::currentDateTime().toString( Qt::SystemLocaleShortDate);; + qDebug() << "Setting up session:" << QDateTime::currentDateTime().toString( Qt::SystemLocaleShortDate);; if(QFile::exists("/tmp/.luminastopping")){ QFile::remove("/tmp/.luminastopping"); } QTime* timer = 0; if(DEBUG){ timer = new QTime(); timer->start(); qDebug() << " - Init srand:" << timer->elapsed();} diff --git a/src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf b/src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf index f0cdc5a4..0a7c9fb2 100644 --- a/src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf +++ b/src-qt5/core/lumina-desktop-unified/defaults/desktop/panels.conf @@ -4,7 +4,7 @@ windows/anchor="bottom" windows/align="center" windows/length_percent=100 -windows/width_percent=3 +windows/width_font_percent=3 windows/plugins="" windows/background="#1A000000" @@ -17,6 +17,6 @@ active_ids="initial" anchor="bottom" align="center" length_percent=100 -width_percent=2.1 +width_font_percent=2.1 plugins="" background="#33000000" diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow-Widgets.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow-Widgets.cpp index 6a4c4cb0..44007b08 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow-Widgets.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/RootWindow-Widgets.cpp @@ -13,8 +13,10 @@ RootDesktop *root_view; RootWindow::RootWindow() : QObject(){ root_win = QWindow::fromWinId( QX11Info::appRootWindow() ); - root_view = new RootDesktop(root_win); //make it a child of the root window + //qDebug() << "Creating RootDesktop Object"; root_obj = RootDesktopObject::instance(); + //qDebug() << "Creating RootDesktop View"; + root_view = new RootDesktop(root_win); //make it a child of the root window syncRootSize(); connect(root_win, SIGNAL(widthChanged(int)), this, SLOT(syncRootSize()) ); connect(root_win, SIGNAL(heightChanged(int)),this, SLOT(syncRootSize()) ); diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp index 94079bf7..2233273e 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp @@ -10,6 +10,10 @@ #include <QQmlEngine> #include <QDebug> +#ifdef USE_WIDGETS +#include <Plugin.h> +#endif + PanelObject::PanelObject(QString id, QObject *parent) : QObject(parent){ panel_id = id; } @@ -56,8 +60,12 @@ void PanelObject::setGeometry( QRect newgeom ){ void PanelObject::setPlugins( QStringList plist){ //Iterate through the list and find the URL's for the files QStringList dirs; dirs << ":/qml/plugins/"; //add local directories here + static QStringList built_in; +#ifdef USE_WIDGETS + if(built_in.isEmpty()){ built_in = Plugin::built_in_plugins(); } +#endif for(int i=0; i<plist.length(); i++){ - bool found = false; + bool found = built_in.contains(plist[i].toLower()); for(int j=0; j<dirs.length() && !found; j++){ if(QFile::exists(dirs[j]+plist[i]+".qml")){ plist[i] = QUrl::fromLocalFile(dirs[j]+plist[i]+".qml").url(); @@ -86,6 +94,7 @@ void PanelObject::syncWithSettings(QRect parent_geom){ double length = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/length_percent", 100).toDouble()/100.0; double width = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/width_font_percent", 2.1).toDouble(); width = qRound(width * QApplication::fontMetrics().height() ); + //qDebug() << " Got Panel Width From Settings:" << width; this->setBackground( DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/background", "rgba(0,0,0,120)").toString() ); // qDebug() << "Update Panel:" << panel_id << id << anchor+"/"+align << length << width; //Now calculate the geometry of the panel diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp index 79737ddc..06c41354 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.cpp @@ -14,7 +14,7 @@ // === PUBLIC === RootDesktopObject::RootDesktopObject(QObject *parent) : QObject(parent){ last_window_up = 0; - updateScreens(); //make sure the internal list is updated right away + //updateScreens(); //make sure the internal list is updated right away connect(this, SIGNAL(changePanels(QStringList)), this, SLOT(setPanels(QStringList)) ); currentTimeTimer = new QTimer(this); connect(currentTimeTimer, SIGNAL(timeout()), this, SLOT(updateCurrentTime()) ); @@ -46,6 +46,7 @@ RootDesktopObject* RootDesktopObject::instance(){ //QML Read Functions QStringList RootDesktopObject::screens(){ + if(s_objects.length()<1){ updateScreens(); } //qDebug() << "Request Screens:" << s_objects.length(); QStringList names; for(int i=0; i<s_objects.length(); i++){ names << s_objects[i]->name(); } @@ -53,6 +54,7 @@ QStringList RootDesktopObject::screens(){ } ScreenObject* RootDesktopObject::screen(QString id){ + if(s_objects.length()<1){ updateScreens(); } //qDebug() << "Got Screen Request:" << id; for(int i=0; i<s_objects.length(); i++){ if(s_objects[i]->name()==id){ return s_objects[i]; } @@ -175,13 +177,13 @@ void RootDesktopObject::setPanels(QStringList ids){ } } //end loop over screens+session //Now calculate the available session geometry - QRegion sess(geom); + QRegion sess(total); for(int i=0; i<panel_objects.length(); i++){ - sess = sess.subtracted( QRegion(panel_objects[i].geometry()) ); + sess = sess.subtracted( QRegion(panel_objects[i]->geometry()) ); } if(sess != session_avail_geom){ session_avail_geom = sess; - emit sessionGeomAvailableChanged(); } + emit sessionGeomAvailableChanged(); } if(change){ emit panelsChanged(); } @@ -254,12 +256,20 @@ void RootDesktopObject::launchApp(QString appOrPath){ //C++ Access Functions (simplifications for the QML ones) QList<NativeWindowObject*> RootDesktopObject::windowObjects(){ return window_objects; + +} +QList<NativeWindowObject*> RootDesktopObject::trayWindowObjects(){ + return tray_window_objects; } QList<ScreenObject*> RootDesktopObject::screenObjects(){ return s_objects; } +QRegion* RootDesktopObject::availableGeometry(){ + return &session_avail_geom; +} + // === PUBLIC SLOTS === void RootDesktopObject::updateScreens(){ QList<QScreen*> scrns = QApplication::screens(); @@ -311,6 +321,7 @@ void RootDesktopObject::updateCurrentTime(){ currentDateTimeStruct = DT; currentTimeString = tmp; emit currentTimeChanged(); + //qDebug() << "Current Time Changed:" << currentTimeString; } } diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h index 4a722ec0..760228b8 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/RootDesktopObject.h @@ -46,6 +46,7 @@ public: Q_INVOKABLE QString currentTime(); Q_INVOKABLE QDateTime currentDateTime(); + //QML Globals Access Q_INVOKABLE OSInterface* os_interface(); @@ -57,7 +58,9 @@ public: //C++ Access Functions (simplifications for the QML ones) QList<NativeWindowObject*> windowObjects(); + QList<NativeWindowObject*> trayWindowObjects(); QList<ScreenObject*> screenObjects(); + QRegion* availableGeometry(); private: QList<ScreenObject*> s_objects; diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp index d6e0abb6..f36db2be 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/ScreenObject.cpp @@ -7,11 +7,12 @@ #include "ScreenObject.h" #include <QQmlEngine> #include <QDebug> +#include "RootDesktopObject.h" ScreenObject::ScreenObject(QScreen *scrn, QObject *parent) : QObject(parent){ bg_screen = scrn; connect(this, SIGNAL(changePanels(QStringList)), this, SLOT(setPanels(QStringList)) ); - connect(RootWindowObject::instance(), SIGNAL(sessionGeomAvailableChanged()), this, SLOT(updateAvailableGeometry()) ); + connect(RootDesktopObject::instance(), SIGNAL(sessionGeomAvailableChanged()), this, SLOT(updateAvailableGeometry()) ); } void ScreenObject::RegisterType(){ @@ -52,7 +53,7 @@ void ScreenObject::setPanels(QStringList ids){ QRegion *sess = RootDesktopObject::instance()->availableGeometry(); QRect avail = sess->intersected(bg_screen->geometry()).boundingRect(); - if(session_available_geometry.isNull()){ avail = bg_screen->geometry(); } + if(avail.isNull()){ avail = bg_screen->geometry(); } //First update/remove any current panel objects bool change = false; for(int i=0; i<panel_objects.length(); i++){ diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/Panel.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/Panel.cpp index 3f75e8c8..07456419 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/Panel.cpp +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/Panel.cpp @@ -11,6 +11,7 @@ Panel::Panel(PanelObject *pobj) : QWidget(0, Qt::Window | Qt::FramelessWindowHin this->setObjectName("LuminaPanelBackgroundWidget"); obj = pobj; layout = new QBoxLayout(QBoxLayout::LeftToRight, this); + layout->setContentsMargins(0,0,0,0); this->setBackgroundRole(QPalette::AlternateBase); connect(obj, SIGNAL(backgroundChanged()), this, SLOT(updateBackground()) ); connect(obj, SIGNAL(geomChanged()), this, SLOT(updateGeom()) ); @@ -35,8 +36,8 @@ Plugin* Panel::findPlugin(QString id){ } Plugin* Panel::createPlugin(QString id){ - - return 0; + Plugin* tmp = Plugin::createPlugin(this, id, true, obj->isVertical()); + return tmp; } // PRIVATE SLOTS @@ -76,6 +77,7 @@ void Panel::updatePlugins(){ layout->removeWidget(plug); //remove from the layout for a moment } layout->insertWidget(i, plug); + plug->setupSizing(); } //Now remove any plugins which were deleted from config for(int i=0; i<lastplugins.length(); i++){ diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/Plugin.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/Plugin.cpp new file mode 100644 index 00000000..3080c377 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/Plugin.cpp @@ -0,0 +1,35 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "Plugin.h" + +//Add includes for individual plugin files here +#include <ClockPlugin.h> +#include <SpacerPlugin.h> +#include <StatusTrayPlugin.h> + +QStringList Plugin::built_in_plugins(){ + QStringList list; + list << "clock" << "spacer" << "statustray"; + return list; +} + +Plugin* Plugin::createPlugin(QWidget *parent, QString id, bool panelplug, bool vertical){ + Plugin *plug = 0; + QString id_extra, id_primary; + if(id.contains("--")){ id_extra = id.section("--",1,-1); id_primary = id.section("--",0,0); } + else{ id_primary = id; } //no extra info on this one + id_primary = id_primary.toLower(); + if(id_primary=="clock"){ + plug = new ClockPlugin(parent, id, panelplug, vertical); + }else if(id_primary=="spacer"){ + plug = new SpacerPlugin(parent, id, panelplug, vertical); + }else if(id_primary=="statustray"){ + plug = new StatusTrayPlugin(parent, id, panelplug, vertical); + } + + return plug; +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/Plugin.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/Plugin.h index 0934374f..4620407f 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/Plugin.h +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/Plugin.h @@ -15,44 +15,69 @@ class Plugin : public QWidget{ Q_OBJECT private: - bool isPanelPlugin; - bool isVertical; //only used for panel plugins QString _id; signals: void orientationChanged(); public: - Plugin(QWidget *parent, QString id, bool panelplug = false) : QWidget(parent){ + QBoxLayout *boxLayout; + bool isPanelPlugin; + bool isVertical; //only used for panel plugins + + //These static functions are defined in "Plugin.cpp" + static QStringList built_in_plugins(); + static Plugin* createPlugin(QWidget *parent, QString id, bool panelplug = false, bool vertical = false); + + Plugin(QWidget *parent, QString id, bool panelplug = false, bool vertical = false) : QWidget(parent){ isPanelPlugin = panelplug; - isVertical = false; + isVertical = vertical; _id = id; + boxLayout = new QBoxLayout(QBoxLayout::LeftToRight); + this->setLayout( boxLayout ); + boxLayout->setContentsMargins(0,0,0,0); + this->setContentsMargins(0,0,0,0); + updateLayoutOrientation(); + connect(this, SIGNAL(orientationChanged()), this, SLOT(updateLayoutOrientation()) ); } void setVertical(bool set){ if(set!=isVertical){ isVertical = set; emit orientationChanged(); } + setupSizing(); } QString id(){ return _id; } -private slots: + virtual void setupSizing(){ + if(isPanelPlugin){ + if(!isVertical){ this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); } + else{ this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); } + }else{ + this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + } + } +private slots: + void updateLayoutOrientation(){ + boxLayout->setDirection( this->isVertical ? QBoxLayout::TopToBottom : QBoxLayout::LeftToRight ); + } }; //Special subclass for a button-based plugin class PluginButton : public Plugin{ Q_OBJECT -private: - QToolButton *button; public: - PluginButton(QWidget *parent, QString id, bool panelplug=false) : Plugin(parent, id, panelplug) { + QToolButton *button; + PluginButton(QWidget *parent, QString id, bool panelplug=false, bool vertical = false) : Plugin(parent, id, panelplug, vertical) { button = new QToolButton(this); - this->setLayout( new QBoxLayout(QBoxLayout::LeftToRight) ); - this->layout()->setContentsMargins(0,0,0,0); + button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + button->setAutoRaise(true); + button->setPopupMode(QToolButton::InstantPopup); this->layout()->addWidget(button); } ~PluginButton(){} }; + #endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/BatteryButton.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/BatteryButton.cpp new file mode 100644 index 00000000..656c19c1 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/BatteryButton.cpp @@ -0,0 +1,28 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "BatteryButton.h" + +BatteryButton::BatteryButton(QWidget *parent) : QToolButton(parent){ + this->setAutoRaise(true); + this->setPopupMode(QToolButton::InstantPopup); + this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + //Setup the menu + + //Now start the initial update routine in a moment + connect(OSInterface::instance(), SIGNAL(batteryChanged()), this, SLOT(updateButton()) ); + QTimer::singleShot(10, this, SLOT(updateButton()) ); +} + +BatteryButton::~BatteryButton(){ + +} + +void BatteryButton::updateButton(){ + this->setIcon( QIcon::fromTheme( OSInterface::instance()->batteryIcon() ) ); + //Now get all the info about the battery for the tooltip + this->setToolTip( OSInterface::instance()->batteryStatus() ); +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/BatteryButton.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/BatteryButton.h new file mode 100644 index 00000000..4ee6e9d8 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/BatteryButton.h @@ -0,0 +1,22 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_DESKTOP_PLUGIN_BUTTON_BATTERY_H +#define _LUMINA_DESKTOP_PLUGIN_BUTTON_BATTERY_H + +#include <global-includes.h> + +class BatteryButton : public QToolButton{ + Q_OBJECT +private slots: + void updateButton(); + +public: + BatteryButton(QWidget *parent = 0); + ~BatteryButton(); + +}; +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/CalendarMenu.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/CalendarMenu.h new file mode 100644 index 00000000..38521c97 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/CalendarMenu.h @@ -0,0 +1,40 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// Simple menu popup with a calendar in it +//=========================================== +#ifndef _LUMINA_DESKTOP_WIDGET_MENU_CALENDAR_H +#define _LUMINA_DESKTOP_WIDGET_MENU_CALENDAR_H + +#include <QMenu> +#include <QWidgetAction> +#include <QCalendarWidget> +#include <QDate> + +class CalendarMenu : public QMenu { + Q_OBJECT +private: + QCalendarWidget *cal; + QWidgetAction *WA; +public: + CalendarMenu() : QMenu(){ + cal = new QCalendarWidget(); + WA = new QWidgetAction(this); + WA->setDefaultWidget(cal); + this->addAction(WA); + connect(this, SIGNAL(aboutToShow()), this, SLOT(resetDate()) ); + } + ~CalendarMenu(){ + cal->deleteLater(); + } + +private slots: + void resetDate(){ + cal->setSelectedDate(QDate::currentDate()); + } + +}; +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h new file mode 100644 index 00000000..d028de8f --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h @@ -0,0 +1,96 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_DESKTOP_PLUGIN_CLOCK_H +#define _LUMINA_DESKTOP_PLUGIN_CLOCK_H + +#include <Plugin.h> +#include <RootDesktopObject.h> +#include <CalendarMenu.h> + +class ClockPlugin : public PluginButton{ + Q_OBJECT + +private: + int textRows; + +private slots: + void updateTime(){ + //qDebug() << "Clock: Update Time"; + QString text = RootDesktopObject::instance()->currentTime(); + //Adjust the text to fix the widget as needed + //qDebug() << "Clock: Update Time:" << textRows << text << text.split(" "); + if(textRows>1){ + QStringList textL = text.split(" "); //natural breaks + int max = button->width() + (isVertical ? -1 : 200); //button->height() for vertical panels once text rotation is worked out + while(textL.length()!=textRows){ + if(textL.length() > textRows){ + //Need to get a bit more complicated - join the shorter sections together + //Find the smallest section and merge it into the previous one + //Note: This is horribly inefficient, but due to the inherently short length of textL it is acceptable + int min = -1; int index = -1; + for(int i=1; i<textL.length(); i++){ + int combined = button->fontMetrics().width(textL[i-1]+" "+textL[i]); + int tmp = button->fontMetrics().width(textL[i]); + if( max>combined && (min<0 || tmp<min)){ min = tmp; index = i; } + } + if(index>0){ textL[index-1] = textL[index-1]+" "+textL[index]; textL.removeAt(index); } + else{ break; } + }else{ + //Need to get a lot more complicated - need to break up sections mid-word based on widget width + // NOT WORKING - can cause infinite loop somehow (perhaps max is 0 on init?) + /*for(int i=0; i<textL.length(); i++){ + int tmp = button->fontMetrics().width(textL[i]); + if(tmp>max){ + //qDebug() << "CLOCK:" << i << tmp << max << textL[i]; + QString tmps = button->fontMetrics().elidedText(textL[i], Qt::ElideRight, max).section("...",0,-2); //remove the three dots at end + QString rem = textL[i].remove(tmps); + textL[i] = tmps; textL.insert(i+1, rem); + } + }*/ + //Now go ahead and break the main loop - text all fits width-wise now + break; + } + } //end of loop + text = textL.join("\n"); + } + //qDebug() << "Got Text:" << text; + this->button->setText(text); + } + +public: + ClockPlugin(QWidget *parent, QString id, bool panelplug, bool vertical) : PluginButton(parent, id, panelplug, vertical){ + connect(RootDesktopObject::instance(), SIGNAL(currentTimeChanged()), this, SLOT(updateTime()) ); + QFont tmp = button->font(); + tmp.setBold(true); + button->setFont( tmp ); + textRows = 1; + //Setup the popup menu + static QMenu *calMenu = 0; + if(calMenu == 0){ + calMenu = new CalendarMenu(); + } + button->setMenu(calMenu); + QTimer::singleShot(0, this, SLOT(updateTime()) ); + } + ~ClockPlugin(){ } + +protected: + void resizeEvent(QResizeEvent *ev){ + Plugin::resizeEvent(ev); + //Re-calculate the text sizing for display + int tmp = button->height() / button->fontMetrics().height(); + if(isVertical && isPanelPlugin){ tmp+=5; } //non-rotated text - need more columns + //qDebug() << "Got height/font ratio:" << tmp; + if(tmp!=textRows){ + textRows = tmp; + if(textRows<1){ textRows = 1; } + if(button->isVisible() && !button->text().isEmpty()){ QTimer::singleShot(0, this, SLOT(updateTime()) ); } + } + } +}; + +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/NetworkButton.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/NetworkButton.cpp new file mode 100644 index 00000000..1108878d --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/NetworkButton.cpp @@ -0,0 +1,36 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "NetworkButton.h" +#include <global-objects.h> + +NetworkButton::NetworkButton(QWidget *parent) : QToolButton(parent){ + this->setAutoRaise(true); + this->setPopupMode(QToolButton::InstantPopup); + this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + //Setup the menu + + //Now start the initial update routine in a moment + connect(OSInterface::instance(), SIGNAL(networkStatusChanged()), this, SLOT(updateButton()) ); + QTimer::singleShot(10, this, SLOT(updateButton()) ); +} + +NetworkButton::~NetworkButton(){ + +} + +void NetworkButton::updateButton(){ + this->setIcon( QIcon::fromTheme( OSInterface::instance()->networkIcon() ) ); + //Now get all the info about the battery for the tooltip + this->setToolTip( OSInterface::instance()->networkStatus() ); + //qDebug() << "Network Button Sync:" << OSInterface::instance()->networkIcon(); +} + +void NetworkButton::buttonClicked(){ + if(OSInterface::instance()->hasNetworkManager()){ + LSession::instance()->LaunchStandardApplication( OSInterface::instance()->networkManagerUtility() ); + } +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/NetworkButton.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/NetworkButton.h new file mode 100644 index 00000000..deb6f939 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/NetworkButton.h @@ -0,0 +1,23 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_DESKTOP_PLUGIN_BUTTON_NETWORK_H +#define _LUMINA_DESKTOP_PLUGIN_BUTTON_NETWORK_H + +#include <global-includes.h> + +class NetworkButton : public QToolButton{ + Q_OBJECT +private slots: + void updateButton(); + void buttonClicked(); + +public: + NetworkButton(QWidget *parent = 0); + ~NetworkButton(); + +}; +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/SpacerPlugin.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/SpacerPlugin.h new file mode 100644 index 00000000..b3f25450 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/SpacerPlugin.h @@ -0,0 +1,24 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_DESKTOP_PLUGIN_SPACER_H +#define _LUMINA_DESKTOP_PLUGIN_SPACER_H +#include <Plugin.h> + +class SpacerPlugin : public Plugin{ + Q_OBJECT + +public: + SpacerPlugin(QWidget *parent, QString id, bool panelplug, bool vertical) : Plugin(parent, id, panelplug, vertical){} + ~SpacerPlugin(){ } + + //Replace the virtual sizing function + void setupSizing(){ + this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + } +}; + +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/StatusTrayPlugin.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/StatusTrayPlugin.h new file mode 100644 index 00000000..7752a7a7 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/StatusTrayPlugin.h @@ -0,0 +1,52 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_DESKTOP_PLUGIN_STATUSTRAY_H +#define _LUMINA_DESKTOP_PLUGIN_STATUSTRAY_H + +#include <Plugin.h> +#include <SystemTrayMenu.h> +#include <VolumeButton.h> +#include <BatteryButton.h> +#include <NetworkButton.h> +#include <UpdatesButton.h> + +#include <global-includes.h> + +class StatusTrayPlugin : public PluginButton{ + Q_OBJECT + +private: + +private slots: + void updateIcons(){ + QStringList icons; icons << "open-menu" << "show-menu" << "view-grid" << "up" << "arrow-up"; + for(int i=0; i<icons.length(); i++){ + if(QIcon::hasThemeIcon(icons[i])){ button->setIcon( QIcon::fromTheme(icons[i])); break; } + } + } + +public: + StatusTrayPlugin(QWidget *parent, QString id, bool panelplug, bool vertical) : PluginButton(parent, id, panelplug, vertical){ + //Setup the popup menu for the system tray + static QMenu *systrayMenu = 0; + if(systrayMenu == 0){ + systrayMenu = new SystemTrayMenu(); + } + button->setMenu(systrayMenu); + connect(systrayMenu, SIGNAL(hasTrayIcons(bool)), button, SLOT(setVisible(bool)) ); + updateIcons(); + //Now create/add all the other buttons + if(OSInterface::instance()->OS_volumeSupported()){ boxLayout->addWidget( new VolumeButton(this) ); } + boxLayout->addWidget( new NetworkButton(this) ); + if(OSInterface::instance()->batteryAvailable()){ boxLayout->addWidget( new BatteryButton(this) ); } + if(OSInterface::instance()->updatesSupported()){ boxLayout->addWidget( new UpdatesButton(this) ); } + } + ~StatusTrayPlugin(){ } + +}; + +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/SystemTrayMenu.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/SystemTrayMenu.cpp new file mode 100644 index 00000000..f746b460 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/SystemTrayMenu.cpp @@ -0,0 +1,65 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "SystemTrayMenu.h" + +#include <global-objects.h> + +SystemTrayMenu::SystemTrayMenu() : QMenu() { + this->setWindowFlags(Qt::Popup | Qt::WindowTransparentForInput); + widget = new QWidget(); + layout = new QGridLayout(widget); + WA = new QWidgetAction(this); + WA->setDefaultWidget(widget); + this->addAction(WA); + connect(RootDesktopObject::instance(), SIGNAL(trayWindowsChanged()), this, SLOT(trayWindowsChanged()) ); + QTimer::singleShot(50, this, SLOT(trayWindowsChanged()) ); //first-time load of tray windows +} + +SystemTrayMenu::~SystemTrayMenu(){ + widget->deleteLater(); +} + +int SystemTrayMenu::numTrayIcons(){ + return TIcons.count(); +} + +void SystemTrayMenu::trayWindowsChanged(){ + //Clear all the tray icons + for(int i=0; i<TIcons.length(); i++){ layout->removeWidget(TIcons[i]); TIcons[i]->deleteLater(); } + TIcons.clear(); + //Now generate all the tray icons + QList<NativeWindowObject*> wins = RootDesktopObject::instance()->trayWindowObjects(); + for(int i=0; i<wins.length(); i++){ + TrayIcon *tmp = new TrayIcon(this, wins[i]); + connect(this, SIGNAL(aboutToShow()), tmp, SLOT(aboutToShow()) ); + TIcons << tmp; + layout->addWidget(tmp, i/3, i%3); //3 columns of icons + } + emit hasTrayIcons( numTrayIcons()>0 ); +} + +// ================ +// TrayIcon +// ================ +TrayIcon::TrayIcon(QWidget *parent, NativeWindowObject *win) : QLabel(parent){ + WIN = win; + connect(win, SIGNAL(iconChanged()), this, SLOT(updateIcon()) ); +} + +TrayIcon::~TrayIcon(){ + +} + +void TrayIcon::updateIcon(){ + //Just set a hard 48x48 pixel size for now + // It is small enough that most apps support it, but large enough to be visible on high-DPI screens + this->setPixmap( WIN->property(NativeWindowObject::Icon).value<QIcon>().pixmap(QSize(48,48)) ); +} + +void TrayIcon::aboutToShow(){ + WIN->setGeometryNow( QRect(this->mapToGlobal(this->geometry().topLeft()), QSize(48,48)) ); +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/SystemTrayMenu.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/SystemTrayMenu.h new file mode 100644 index 00000000..a546331a --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/SystemTrayMenu.h @@ -0,0 +1,49 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// Simple menu which shows icons for all the system tray apps +//=========================================== +#ifndef _LUMINA_DESKTOP_WIDGET_MENU_SYSTEMTRAY_H +#define _LUMINA_DESKTOP_WIDGET_MENU_SYSTEMTRAY_H + +#include <global-includes.h> +class TrayIcon : public QLabel { + Q_OBJECT +private: + NativeWindowObject *WIN; + +public: + TrayIcon(QWidget *parent, NativeWindowObject *win); + ~TrayIcon(); + +private slots: + void updateIcon(); + void aboutToShow(); + +}; + +class SystemTrayMenu : public QMenu { + Q_OBJECT +private: + QWidget *widget; + QWidgetAction *WA; + QGridLayout *layout; + QList<TrayIcon*> TIcons; + +public: + SystemTrayMenu(); + ~SystemTrayMenu(); + + int numTrayIcons(); + +private slots: + void trayWindowsChanged(); + +signals: + void hasTrayIcons(bool); + +}; +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/UpdatesButton.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/UpdatesButton.cpp new file mode 100644 index 00000000..4f5c8ee2 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/UpdatesButton.cpp @@ -0,0 +1,30 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "UpdatesButton.h" + +UpdatesButton::UpdatesButton(QWidget *parent) : QToolButton(parent){ + this->setAutoRaise(true); + this->setPopupMode(QToolButton::InstantPopup); + this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + //Setup the menu + + //Now start the initial update routine in a moment + connect(OSInterface::instance(), SIGNAL(updateStatusChanged()), this, SLOT(updateButton()) ); + QTimer::singleShot(10, this, SLOT(updateButton()) ); +} + +UpdatesButton::~UpdatesButton(){ + +} + +void UpdatesButton::updateButton(){ + this->setIcon( QIcon::fromTheme( OSInterface::instance()->updateIcon() ) ); + //Now get all the info about the battery for the tooltip + this->setToolTip( OSInterface::instance()->updateStatusInfo() ); + //qDebug() << "Update Button sync:" << OSInterface::instance()->updateIcon() << OSInterface::instance()->updateStatus() << OSInterface::instance()->updateStatusInfo(); + this->setVisible( !OSInterface::instance()->updateStatus().isEmpty() ); +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/UpdatesButton.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/UpdatesButton.h new file mode 100644 index 00000000..30185852 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/UpdatesButton.h @@ -0,0 +1,22 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_DESKTOP_PLUGIN_BUTTON_UPDATES_H +#define _LUMINA_DESKTOP_PLUGIN_BUTTON_UPDATES_H + +#include <global-includes.h> + +class UpdatesButton : public QToolButton{ + Q_OBJECT +private slots: + void updateButton(); + +public: + UpdatesButton(QWidget *parent = 0); + ~UpdatesButton(); + +}; +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/VolumeButton.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/VolumeButton.cpp new file mode 100644 index 00000000..bc0d2d89 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/VolumeButton.cpp @@ -0,0 +1,28 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "VolumeButton.h" + +VolumeButton::VolumeButton(QWidget *parent) : QToolButton(parent){ + this->setAutoRaise(true); + this->setPopupMode(QToolButton::InstantPopup); + this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + //Setup the menu + + //Now start the initial update routine in a moment + connect(OSInterface::instance(), SIGNAL(volumeChanged()), this, SLOT(updateButton()) ); + QTimer::singleShot(10, this, SLOT(updateButton()) ); +} + +VolumeButton::~VolumeButton(){ + +} + +void VolumeButton::updateButton(){ + this->setIcon( QIcon::fromTheme( OSInterface::instance()->volumeIcon() ) ); + int vol = OSInterface::instance()->volume(); + this->setToolTip( QString("%1%").arg(QString::number(vol)) ); +} diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/VolumeButton.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/VolumeButton.h new file mode 100644 index 00000000..44adc7ad --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/VolumeButton.h @@ -0,0 +1,22 @@ +//=========================================== +// Lumina-desktop source code +// Copyright (c) 2018, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#ifndef _LUMINA_DESKTOP_PLUGIN_BUTTON_VOLUME_H +#define _LUMINA_DESKTOP_PLUGIN_BUTTON_VOLUME_H + +#include <global-includes.h> + +class VolumeButton : public QToolButton{ + Q_OBJECT +private slots: + void updateButton(); + +public: + VolumeButton(QWidget *parent = 0); + ~VolumeButton(); + +}; +#endif diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/plugins.pri b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/plugins.pri new file mode 100644 index 00000000..f45e8c09 --- /dev/null +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/plugins.pri @@ -0,0 +1,18 @@ +#update the includepath so we can just #include as needed without paths +INCLUDEPATH *= $${PWD} + +SOURCES *= $${PWD}/SystemTrayMenu.cpp \ + $${PWD}/VolumeButton.cpp \ + $${PWD}/BatteryButton.cpp \ + $${PWD}/NetworkButton.cpp \ + $${PWD}/UpdatesButton.cpp + +HEADERS *= $${PWD}/ClockPlugin.h \ + $${PWD}/CalendarMenu.h \ + $${PWD}/SpacerPlugin.h \ + $${PWD}/StatusTrayPlugin.h \ + $${PWD}/SystemTrayMenu.h \ + $${PWD}/VolumeButton.h \ + $${PWD}/BatteryButton.h \ + $${PWD}/NetworkButton.h \ + $${PWD}/UpdatesButton.h diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/src-widgets.pri b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/src-widgets.pri index 5ed94f1b..8465b5f9 100644 --- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/src-widgets.pri +++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/src-widgets.pri @@ -4,7 +4,8 @@ INCLUDEPATH *= $${PWD} SOURCES *= $${PWD}/RootDesktop.cpp \ $${PWD}/ContextMenu.cpp \ $${PWD}/NativeWindow.cpp \ - $${PWD}/Panel.cpp + $${PWD}/Panel.cpp \ + $${PWD}/Plugin.cpp HEADERS *= $${PWD}/RootDesktop.h \ $${PWD}/ContextMenu.h \ @@ -12,3 +13,5 @@ HEADERS *= $${PWD}/RootDesktop.h \ $${PWD}/NativeEmbedWidget.h \ $${PWD}/Panel.h \ $${PWD}/Plugin.h + +include("plugins/plugins.pri") diff --git a/src-qt5/core/lumina-session/session.cpp b/src-qt5/core/lumina-session/session.cpp index 0f0a99eb..665b6a40 100644 --- a/src-qt5/core/lumina-session/session.cpp +++ b/src-qt5/core/lumina-session/session.cpp @@ -127,7 +127,7 @@ void LSession::setupCompositor(){ } QString disp = getenv("DISPLAY"); if(startcompton && QFile::exists(set)){ startProcess("compositing","compton -d "+disp+" --config \""+set+"\"", QStringList() << set); } - else if(startcompton){ startProcess("compositing","compton -d "+disp); } + else if(startcompton){ startProcess("compositing","compton --backend xr_glx_hybrid -d "+disp); } }else if(LUtils::isValidBinary("xcompmgr") && !settings.value("compositingWithGpuAccelOnly",true).toBool() ){ startProcess("compositing","xcompmgr"); } } } @@ -187,7 +187,7 @@ void LSession::start(bool unified){ if(LUtils::isValidBinary("xscreensaver")){ startProcess("screensaver","xscreensaver -no-splash"); } }else{ //unified process - setupCompositor(); + setupCompositor(); //required for Lumina 2 startProcess("runtime","lumina-desktop-unified"); } } diff --git a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp index 714cfe45..150f8375 100644 --- a/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp +++ b/src-qt5/desktop-utils/lumina-archiver/TarBackend.cpp @@ -12,10 +12,16 @@ #include <QCoreApplication> #include <QTimer> +#ifdef Q_OS_LINUX +#define TAR_CMD "bsdtar" +#else +#define TAR_CMD "tar" +#endif + Backend::Backend(QObject *parent) : QObject(parent){ //Setup the backend process PROC.setProcessChannelMode(QProcess::MergedChannels); - PROC.setProgram("tar"); + PROC.setProgram(TAR_CMD); connect(&PROC, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(procFinished(int, QProcess::ExitStatus)) ); connect(&PROC, SIGNAL(readyReadStandardOutput()), this, SLOT(processData()) ); connect(&PROC, SIGNAL(started()), this, SIGNAL(ProcessStarting()) ); @@ -124,7 +130,7 @@ void Backend::startAdd(QStringList paths, bool absolutePaths){ args<< "@"+filepath; } STARTING=true; - PROC.start("tar", args); + PROC.start(TAR_CMD, args); } void Backend::startRemove(QStringList paths){ @@ -140,7 +146,7 @@ void Backend::startRemove(QStringList paths){ } args<< "@"+filepath; STARTING=true; - PROC.start("tar", args); + PROC.start(TAR_CMD, args); } void Backend::startExtract(QString path, bool overwrite, QString file){ @@ -162,7 +168,7 @@ void Backend::startExtract(QString path, bool overwrite, QStringList files){ args << "-C" << path; STARTING=true; //qDebug() << "Starting command:" << "tar" << args; - PROC.start("tar", args); + PROC.start(TAR_CMD, args); } void Backend::startViewFile(QString path){ @@ -180,7 +186,7 @@ void Backend::startViewFile(QString path){ while(!tmpProc.waitForFinished(500)){ QCoreApplication::processEvents(); } emit ProcessFinished(tmpProc.exitCode()==0, ""); QProcess::startDetached("xdg-open", QStringList() << newfilename); - //PROC.start("tar", args); + //PROC.start(TAR_CMD, args); } //=============== @@ -226,7 +232,7 @@ void Backend::startList(){ args << "-tv"; LIST = STARTING=true; //qDebug() << "Starting List:" << "tar "+args.join(" ")+" "+flags.join(" "); - PROC.start("tar", QStringList() << args << flags); + PROC.start(TAR_CMD, QStringList() << args << flags); } //=============== diff --git a/src-qt5/desktop-utils/lumina-mediaplayer/extra/pandora.png b/src-qt5/desktop-utils/lumina-mediaplayer/extra/pandora.png Binary files differnew file mode 100644 index 00000000..daff651b --- /dev/null +++ b/src-qt5/desktop-utils/lumina-mediaplayer/extra/pandora.png diff --git a/src-qt5/desktop-utils/lumina-mediaplayer/extra/resources.qrc b/src-qt5/desktop-utils/lumina-mediaplayer/extra/resources.qrc index 3e09863d..fc53d7e5 100644 --- a/src-qt5/desktop-utils/lumina-mediaplayer/extra/resources.qrc +++ b/src-qt5/desktop-utils/lumina-mediaplayer/extra/resources.qrc @@ -1,5 +1,5 @@ <RCC> <qresource> - <file alias="pandora">Pandora.svg</file> + <file alias="pandora">pandora.png</file> </qresource> </RCC> diff --git a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.cpp b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.cpp index 358a8dbd..227b9014 100644 --- a/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.cpp +++ b/src-qt5/desktop-utils/lumina-mediaplayer/mainUI.cpp @@ -196,8 +196,9 @@ void MainUI::setupConnections(){ } void MainUI::setupIcons(){ + ui->radio_local->setIcon( LXDG::findIcon("multimedia-audio-player","media-audio") ); - ui->radio_pandora->setIcon( LXDG::findIcon("pandora",":pandora") ); + ui->radio_pandora->setIcon( QIcon::fromTheme("pandora",QIcon(":pandora")) ); ui->actionClose->setIcon( LXDG::findIcon("application-close","dialog-close") ); ui->actionPlay->setIcon( LXDG::findIcon("media-playback-start","") ); @@ -270,7 +271,7 @@ void MainUI::PlayerTypeChanged(bool active){ if(ui->radio_pandora->isChecked()){ ui->stackedWidget->setCurrentWidget(ui->page_pandora); PandoraStateChanged(PANDORA->currentState()); - QIcon ico = LXDG::findIcon("pandora",":pandora"); + QIcon ico = QIcon::fromTheme("pandora",QIcon(":pandora")); SYSTRAY->setIcon( ico ); this->setWindowIcon( ico ); this->setWindowTitle( tr("Pandora Radio") ); @@ -279,7 +280,7 @@ void MainUI::PlayerTypeChanged(bool active){ }else{ ui->stackedWidget->setCurrentWidget(ui->page_local); LocalStateChanged(QMediaPlayer::StoppedState); - QIcon ico = LXDG::findIcon("media-playlist-audio","audio-x-generic"); + QIcon ico = LXDG::findIcon("multimedia-audio-player","media-audio"); SYSTRAY->setIcon( ico ); this->setWindowIcon( ico ); this->setWindowTitle( tr("Media Player") ); diff --git a/src-qt5/src-cpp/framework-OSInterface_private.cpp b/src-qt5/src-cpp/framework-OSInterface_private.cpp index 15ee6f8e..b0a22b1d 100644 --- a/src-qt5/src-cpp/framework-OSInterface_private.cpp +++ b/src-qt5/src-cpp/framework-OSInterface_private.cpp @@ -8,7 +8,7 @@ //=========================================== #include <framework-OSInterface.h> #include <QtConcurrent> - +#include <QIcon> #include <QQmlEngine> OSInterface::OSInterface(QObject *parent) : QObject(parent){ @@ -341,31 +341,34 @@ void OSInterface::syncNetworkInfo(OSInterface *os, QHash<QString, QVariant> *has hash->insert("netaccess/address", address.join(", ")); //Figure out the icon used for this type/strnegth - QString icon; + QStringList icons; if(type.startsWith("cell")){ - if(address.isEmpty()){ icon = "network-cell-off"; } - else if(strength>80){ icon = "network-cell-connected-100"; } - else if(strength>60){ icon = "network-cell-connected-75"; } - else if(strength>40){ icon = "network-cell-connected-50"; } - else if(strength>10){ icon = "network-cell-connected-25"; } - else if(strength >=0){ icon = "network-cell-connected-00"; } - else{ icon = "network-cell"; } //unknown strength - just use generic icon so we at least get off/on visibility + if(address.isEmpty()){ icons <<"network-cell-off"; } + else if(strength>80){ icons <<"network-cell-connected-100"; } + else if(strength>60){ icons <<"network-cell-connected-75"; } + else if(strength>40){ icons << "network-cell-connected-50"; } + else if(strength>10){ icons << "network-cell-connected-25"; } + else if(strength >=0){ icons << "network-cell-connected-00"; } + icons << "network-cell"; //fallback - just use generic icon so we at least get off/on visibility + }else if(type=="wifi"){ - if(address.isEmpty()){ icon = "network-wireless-off"; } - else if(strength>80){ icon = "network-wireless-100"; } - else if(strength>60){ icon = "network-wireless-75"; } - else if(strength>40){ icon = "network-wireless-50"; } - else if(strength>10){ icon = "network-wireless-25"; } - else if(strength >=0){ icon = "network-wireless-00"; } - else{ icon = "network-wireless"; } //unknown strength - just use generic icon so we at least get off/on visibility + if(address.isEmpty()){ icons << "network-wireless-disconnected" << "network-wireless-00" << "network-wireless-off"; } + else if(strength>80){ icons << "network-wireless-100"; } + else if(strength>60){ icons << "network-wireless-75"; } + else if(strength>40){ icons << "network-wireless-50"; } + else if(strength>10){ icons << "network-wireless-25"; } + else if(strength >=0){ icons << "network-wireless-00"; } + icons << "network-wireless"; //fallback - just use generic icon so we at least get off/on visibility + }else if(type=="wired"){ - if(strength==100 && !address.isEmpty()){ icon = "network-wired-connected"; } - else if(strength==100){ icon = "network-wired-pending"; } - else{ icon = "network-wired-disconnected"; } - }else{ - icon = "network-workgroup"; //failover to a generic "network" icon + if(strength==100 && !address.isEmpty()){ icons << "network-wired-connected" << "network-wired"; } + else if(strength==100){ icons << "network-wired-pending" << "network-wired-aquiring"; } + else{ icons << "network-wired-unavailable" << "network-wired-disconnected" ; } + } + icons << "network-workgroup" << "network-unknown"; + for(int i=0; i<icons.length(); i++){ + if(QIcon::hasThemeIcon(icons[i])){ hash->insert("netaccess/icon",icons[i]); break; } } - hash->insert("netaccess/icon",icon); //qDebug() << "[DEBUG] Emit NetworkStatusChanged"; os->emit networkStatusChanged(); QTimer::singleShot(0, timer, SLOT(start())); @@ -490,24 +493,26 @@ void OSInterface::syncBatteryInfo(OSInterface *os, QHash<QString, QVariant> *has } hash->insert("battery/time", time); //Determine the icon which should be used for this status - QString icon; + QStringList icons; if(charging){ - if(charge>=99){ icon="battery-charging"; } - else if(charge>80){ icon="battery-charging-80"; } - else if(charge >60){ icon="battery-charging-60"; } - else if(charge >30){ icon="battery-charging-40"; } - else if(charge >0){ icon="battery-charging-20"; } - else{ icon="battery-unknown"; } + if(charge>=99){ icons << "battery-100-charging" << "battery-charging-100" << "battery-full-charging" << "battery-charging-full" << "battery-charging"; } + else if(charge >80){ icons << "battery-charging-80"<< "battery-80-charging"<< "battery-charging-080" << "battery-080-charging" << "battery-good-charging" << "battery-charging-good"; } + else if(charge >60){ icons << "battery-charging-60"<< "battery-60-charging"<< "battery-charging-060" << "battery-060-charging" << "battery-good-charging" << "battery-charging-good"; } + else if(charge >40){ icons << "battery-charging-40"<< "battery-40-charging"<< "battery-charging-040" << "battery-040-charging" << "battery-good-charging" << "battery-charging-good"; } + else if(charge >20){ icons << "battery-charging-20"<< "battery-20-charging"<< "battery-charging-020" << "battery-020-charging" << "battery-low-charging" << "battery-charging-low"; } + else if(charge > 0){ icons << "battery-charging-00"<< "battery-00-charging"<< "battery-charging-000" << "battery-000-charging" << "battery-caution-charging" << "battery-charging-caution"; } }else{ - if(charge>90){ icon="battery"; } - else if(charge>80){ icon="battery-80"; } - else if(charge >60){ icon="battery-60"; } - else if(charge >30){ icon="battery-40"; } - else if(charge >10){ icon="battery-20"; } - else if(charge >0){ icon="battery-alert"; } - else{ icon="battery-unknown"; } + if(charge>=99){ icons << "battery-100" << "battery-full-charged" << "battery-full" << "battery"; } + else if(charge >80){ icons << "battery-80"<< "battery-080" << "battery-good"; } + else if(charge >60){ icons << "battery-60"<< "battery-060" << "battery-good"; } + else if(charge >40){ icons << "battery-40"<< "battery-040" << "battery-good"; } + else if(charge >20){ icons << "battery-20"<< "battery-020" << "battery-low"; } + else if(charge > 0){ icons << "battery-00" << "battery-000" << "battery-caution"; } + } + icons << "battery-unknown" << "battery"; + for(int i=0; i<icons.length(); i++){ + if(QIcon::hasThemeIcon(icons[i])){ hash->insert("battery/icon",icons[i]); break; } } - hash->insert("battery/icon",icon); //Now emit the change signal and restart the timer os->emit batteryChanged(); QTimer::singleShot(0, timer, SLOT(start())); @@ -515,18 +520,23 @@ void OSInterface::syncBatteryInfo(OSInterface *os, QHash<QString, QVariant> *has void OSInterface::syncUpdateInfo(OSInterface *os, QHash<QString, QVariant> *hash, QTimer *timer){ //Get the current status - QString status, icon; + QString status; + QStringList icons; if(OS_updatesRunning()){ - status="running"; icon="sync"; + status="running"; icons << "state-download" << "update-medium" << "sync"; }else if(OS_updatesFinished()){ - status="finished"; icon="security-high"; + status="finished"; icons << "state-ok" << "update-high" << "security-high"; }else if(OS_updatesAvailable()){ - status="available"; icon="security-medium"; + status="available"; icons << "state-warning" << "update-medium" << "security-medium"; } + icons << "state-offline" << "update-none"; + //qDebug() << "Update Sync:" << status << icons; //Save the current info into the hash (if different) if(status != updateStatus()){ hash->insert("updates/status", status); - hash->insert("updates/icon", icon); + for(int i=0; i<icons.length(); i++){ + if(QIcon::hasThemeIcon(icons[i])){ hash->insert("updates/icon", icons[i]); break;} + } os->emit updateStatusChanged(); } QTimer::singleShot(0, timer, SLOT(start())); |