diff options
Diffstat (limited to 'lumina-desktop')
-rw-r--r-- | lumina-desktop/LSession.cpp | 5 | ||||
-rw-r--r-- | lumina-desktop/LWinInfo.cpp | 8 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp | 42 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h | 8 | ||||
-rw-r--r-- | lumina-desktop/lumina-desktop.pro | 2 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/NewPP.h | 3 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp | 73 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/applauncher/AppLaunchButton.h | 63 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/taskmanager/LTaskButton.cpp | 7 |
9 files changed, 196 insertions, 15 deletions
diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 8eef0b95..6437524b 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -257,6 +257,11 @@ void LSession::checkUserFiles(){ }*/ LUtils::LoadSystemDefaults(); } + if(oldversion <= 83){ + //Convert the old->new favorites framework + + } + //Check for the default applications file for lumina-open dset = QDir::homePath()+"/.lumina/LuminaDE/lumina-open.conf"; if(!QFile::exists(dset)){ diff --git a/lumina-desktop/LWinInfo.cpp b/lumina-desktop/LWinInfo.cpp index 4ea91c1f..b1476c4e 100644 --- a/lumina-desktop/LWinInfo.cpp +++ b/lumina-desktop/LWinInfo.cpp @@ -15,9 +15,11 @@ QString LWinInfo::text(){ if(window==0){ return ""; } QString nm = LSession::handle()->XCB->WindowVisibleIconName(window); - if(nm.isEmpty()){ nm = LSession::handle()->XCB->WindowIconName(window); } - if(nm.isEmpty()){ nm = LSession::handle()->XCB->WindowVisibleName(window); } - if(nm.isEmpty()){ nm = LSession::handle()->XCB->WindowName(window); } + if(nm.simplified().isEmpty()){ nm = LSession::handle()->XCB->WindowIconName(window); } + if(nm.simplified().isEmpty()){ nm = LSession::handle()->XCB->WindowVisibleName(window); } + if(nm.simplified().isEmpty()){ nm = LSession::handle()->XCB->WindowName(window); } + if(nm.simplified().isEmpty()){ nm = LSession::handle()->XCB->OldWindowIconName(window); } + if(nm.simplified().isEmpty()){ nm = LSession::handle()->XCB->OldWindowName(window); } return nm; } diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp index dc0c7596..b3c6afcf 100644 --- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -7,18 +7,19 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par lay->setContentsMargins(0,0,0,0); button = new QToolButton(this); button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); - button->setIconSize(QSize(64,64)); button->setAutoRaise(true); button->setText("..."); //Need to set something here so that initial sizing works properly + lay->addWidget(button, 0, Qt::AlignCenter); connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) ); - this->setInitialSize(64,66+this->fontMetrics().height()); - /*if(this->settings->allKeys().isEmpty()){ - //Brand new plugin: set initial size - this->settings->setValue("location/width",64); - this->settings->setValue("location/height",66+this->fontMetrics().height()); - this->settings->sync(); - }*/ + menu = new QMenu(this); + menu->addAction(LXDG::findIcon("zoom-in",""), tr("Increase Size"), this, SLOT(increaseIconSize())); + menu->addAction(LXDG::findIcon("zoom-out",""), tr("Decrease Size"), this, SLOT(decreaseIconSize())); + int icosize = settings->value("iconsize",64).toInt(); + button->setIconSize(QSize(icosize,icosize)); + this->setInitialSize(icosize,icosize+10+this->fontMetrics().height()); + this->setContextMenuPolicy(Qt::CustomContextMenu); + connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(openContextMenu()) ); watcher = new QFileSystemWatcher(this); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT( loadButton()) ); QTimer::singleShot(1,this, SLOT(loadButton()) ); @@ -62,4 +63,27 @@ void AppLauncherPlugin::buttonClicked(){ LSession::LaunchApplication("lumina-open \""+path+"\""); } -}
\ No newline at end of file +} + +void AppLauncherPlugin::openContextMenu(){ + if(button->underMouse()){ + menu->popup(QCursor::pos()); + }else{ + emit OpenDesktopMenu(); + } +} + +void AppLauncherPlugin::increaseIconSize(){ + int icosize = settings->value("iconsize",64).toInt(); + icosize += 16; + button->setIconSize(QSize(icosize,icosize)); + settings->setValue("iconsize",icosize); +} + +void AppLauncherPlugin::decreaseIconSize(){ + int icosize = settings->value("iconsize",64).toInt(); + if(icosize < 20){ return; } //cannot get smaller + icosize -= 16; + button->setIconSize(QSize(icosize,icosize)); + settings->setValue("iconsize",icosize); +} diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h index bb21b636..2c861e4d 100644 --- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h +++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h @@ -16,6 +16,8 @@ #include <QFile> #include <QFileSystemWatcher> #include <QTimer> +#include <QMenu> +#include <QCursor> #include "../LDPlugin.h" @@ -30,9 +32,15 @@ public: private: QToolButton *button; QFileSystemWatcher *watcher; + QMenu *menu; private slots: void loadButton(); void buttonClicked(); + void openContextMenu(); + + void increaseIconSize(); + void decreaseIconSize(); + }; #endif diff --git a/lumina-desktop/lumina-desktop.pro b/lumina-desktop/lumina-desktop.pro index dc3db9bd..6c3ee0cc 100644 --- a/lumina-desktop/lumina-desktop.pro +++ b/lumina-desktop/lumina-desktop.pro @@ -50,6 +50,7 @@ SOURCES += main.cpp \ panel-plugins/systemdashboard/SysMenuQuick.cpp \ panel-plugins/showdesktop/LHomeButton.cpp \ panel-plugins/appmenu/LAppMenuPlugin.cpp \ + panel-plugins/applauncher/AppLaunchButton.cpp \ desktop-plugins/applauncher/AppLauncherPlugin.cpp \ desktop-plugins/desktopview/DesktopViewPlugin.cpp \ desktop-plugins/notepad/NotepadPlugin.cpp \ @@ -89,6 +90,7 @@ HEADERS += Globals.h \ panel-plugins/systemdashboard/SysMenuQuick.h \ panel-plugins/showdesktop/LHomeButton.h \ panel-plugins/appmenu/LAppMenuPlugin.h \ + panel-plugins/applauncher/AppLaunchButton.h \ desktop-plugins/SamplePlugin.h \ desktop-plugins/calendar/CalendarPlugin.h \ desktop-plugins/applauncher/AppLauncherPlugin.h \ diff --git a/lumina-desktop/panel-plugins/NewPP.h b/lumina-desktop/panel-plugins/NewPP.h index 6c5c369c..3a593629 100644 --- a/lumina-desktop/panel-plugins/NewPP.h +++ b/lumina-desktop/panel-plugins/NewPP.h @@ -23,6 +23,7 @@ #include "systemdashboard/LSysDashboard.h" #include "showdesktop/LHomeButton.h" #include "appmenu/LAppMenuPlugin.h" +#include "applauncher/AppLaunchButton.h" #include "systemtray/LSysTray.h" //must be last due to X11 compile issues class NewPP{ @@ -52,6 +53,8 @@ public: plug = new LSysDashboard(parent, plugin, horizontal); }else if(plugin.startsWith("appmenu---")){ plug = new LAppMenuPlugin(parent, plugin, horizontal); + }else if(plugin.section("---",0,0).section("::",0,0)=="applauncher"){ + plug = new AppLaunchButtonPlugin(parent, plugin, horizontal); }else{ qWarning() << "Invalid Panel Plugin:"<<plugin << " -- Ignored"; } diff --git a/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp b/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp new file mode 100644 index 00000000..5bd7fa96 --- /dev/null +++ b/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp @@ -0,0 +1,73 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "AppLaunchButton.h" +#include "../../LSession.h" + +#include <LuminaXDG.h> + +AppLaunchButtonPlugin::AppLaunchButtonPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ + button = new QToolButton(this); + button->setAutoRaise(true); + button->setToolButtonStyle(Qt::ToolButtonIconOnly); + appfile = id.section("---",0,0).section("::",1,1); + if(!QFile::exists(appfile)){ appfile.clear(); } + connect(button, SIGNAL(clicked()), this, SLOT(AppClicked())); + this->layout()->setContentsMargins(0,0,0,0); + this->layout()->addWidget(button); + + QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes +} + +AppLaunchButtonPlugin::~AppLaunchButtonPlugin(){ + +} + +void AppLaunchButtonPlugin::updateButtonVisuals(){ + QIcon icon; + QString tooltip = tr("Click to assign an application"); + if(appfile.endsWith(".desktop")){ + bool ok = false; + XDGDesktop desk = LXDG::loadDesktopFile(appfile,ok); + if(ok){ + icon = LXDG::findIcon(desk.icon, "unknown"); + tooltip = QString(tr("Launch %1")).arg(desk.name); + }else{ + icon = LXDG::findIcon("task-attention",""); + appfile.clear(); + } + }else if(QFile::exists(appfile)){ + icon = LXDG::findMimeIcon(appfile.section("/",-1)); + tooltip = QString(tr("Open %1")).arg(appfile.section("/",-1)); + }else{ + icon = LXDG::findIcon("task-attention", ""); + } + button->setIcon( icon ); + button->setToolTip(tooltip); +} + +// ======================== +// PRIVATE FUNCTIONS +// ======================== +void AppLaunchButtonPlugin::AppClicked(){ + if(appfile.isEmpty()){ + //No App File selected + QList<XDGDesktop> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All"); + QStringList names; + for(int i=0; i<apps.length(); i++){ names << apps[i].name; } + bool ok = false; + QString app = QInputDialog::getItem(this, tr("Select Application"), tr("Name:"), names, 0, false, &ok); + if(!ok || names.indexOf(app)<0){ return; } //cancelled + appfile = apps[ names.indexOf(app) ].filePath; + //Still need to find a way to set this value persistently + // --- perhaps replace the plugin in the desktop settings file with the new path? + // --- "applauncher::broken---<something>" -> "applauncher::fixed---<something>" ? + QTimer::singleShot(0,this, SLOT(updateButtonVisuals())); + }else{ + LSession::LaunchApplication("lumina-open \""+appfile+"\""); + } +} + diff --git a/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.h b/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.h new file mode 100644 index 00000000..3aa3c7ad --- /dev/null +++ b/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.h @@ -0,0 +1,63 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +// This panel plugin is a simple button to launch a single application +//=========================================== +#ifndef _LUMINA_DESKTOP_LAUNCH_APP_PANEL_PLUGIN_H +#define _LUMINA_DESKTOP_LAUNCH_APP_PANEL_PLUGIN_H + +// Qt includes +#include <QToolButton> +#include <QString> +#include <QWidget> + + +// Lumina-desktop includes +#include "../LPPlugin.h" //main plugin widget + +// libLumina includes +#include "LuminaXDG.h" + +// PANEL PLUGIN BUTTON +class AppLaunchButtonPlugin : public LPPlugin{ + Q_OBJECT + +public: + AppLaunchButtonPlugin(QWidget *parent = 0, QString id = "applauncher", bool horizontal=true); + ~AppLaunchButtonPlugin(); + +private: + QToolButton *button; + QString appfile; + + void updateButtonVisuals(); + +private slots: + void AppClicked(); + +public slots: + void OrientationChange(){ + if(this->layout()->direction()==QBoxLayout::LeftToRight){ + this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); + button->setIconSize( QSize(this->height(), this->height()) ); + }else{ + this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred); + button->setIconSize( QSize(this->width(), this->width()) ); + } + this->layout()->update(); + updateButtonVisuals(); + } + + void LocaleChange(){ + updateButtonVisuals(); + } + + void ThemeChange(){ + updateButtonVisuals(); + } +}; + +#endif
\ No newline at end of file diff --git a/lumina-desktop/panel-plugins/taskmanager/LTaskButton.cpp b/lumina-desktop/panel-plugins/taskmanager/LTaskButton.cpp index 7c24dc3d..20607c60 100644 --- a/lumina-desktop/panel-plugins/taskmanager/LTaskButton.cpp +++ b/lumina-desktop/panel-plugins/taskmanager/LTaskButton.cpp @@ -121,13 +121,14 @@ void LTaskButton::UpdateButton(){ //single window this->setPopupMode(QToolButton::DelayedPopup); this->setMenu(actMenu); - if(showText){ this->setText( this->fontMetrics().elidedText(WINLIST[0].text(), Qt::ElideRight,80) ); } - else if(noicon){ this->setText( this->fontMetrics().elidedText(cname, Qt::ElideRight ,80) ); } - else{ this->setText(""); } + if(showText){ this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); this->setText( this->fontMetrics().elidedText(WINLIST[0].text(), Qt::ElideRight,80) ); } + else if(noicon){ this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); this->setText( this->fontMetrics().elidedText(cname, Qt::ElideRight ,80) ); } + else{ this->setToolButtonStyle(Qt::ToolButtonIconOnly); this->setText(""); } }else if(WINLIST.length() > 1){ //multiple windows this->setPopupMode(QToolButton::InstantPopup); this->setMenu(winMenu); + this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); if(noicon || showText){ this->setText( this->fontMetrics().elidedText(cname, Qt::ElideRight ,80) +" ("+QString::number(WINLIST.length())+")" ); } else{ this->setText("("+QString::number(WINLIST.length())+")"); } } |