aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2017-08-29 13:08:26 -0400
committerKen Moore <ken@ixsystems.com>2017-08-29 13:08:26 -0400
commitfca13b7dd02f5445e0523cb7736abcd91c7b2864 (patch)
tree207b22e46ee950eea41a3d8c1072aecc163a538a /src-qt5/core/lumina-desktop-unified
parentCleanup the DesktopSettings class and add some more settings files to it. (diff)
downloadlumina-fca13b7dd02f5445e0523cb7736abcd91c7b2864.tar.gz
lumina-fca13b7dd02f5445e0523cb7736abcd91c7b2864.tar.bz2
lumina-fca13b7dd02f5445e0523cb7736abcd91c7b2864.zip
Start getting the Root context menu all moved over from Lumina 1 to 2.
Not quite finished yet.
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified')
-rw-r--r--src-qt5/core/lumina-desktop-unified/LSession.cpp2
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp53
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h7
3 files changed, 45 insertions, 17 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/LSession.cpp b/src-qt5/core/lumina-desktop-unified/LSession.cpp
index ef1e2828..b7ea2fe1 100644
--- a/src-qt5/core/lumina-desktop-unified/LSession.cpp
+++ b/src-qt5/core/lumina-desktop-unified/LSession.cpp
@@ -54,7 +54,7 @@ LSession::LSession(int &argc, char ** argv) : LSingleApplication(argc, argv, "lu
Lumina::NWS->moveToThread(Lumina::EVThread);
Lumina::EVThread->start();
Lumina::ROOTWIN = new RootWindow();
- Lumina::APPLIST = new XDGDesktopList(0, true); //keep this list up to date
+ Lumina::APPLIST = XDGDesktopList::instance();
Lumina::SHORTCUTS = new LShortcutEvents(); //this can be moved to it's own thread eventually as well
setupGlobalConnections();
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp
index c3e9a1db..ec470d48 100644
--- a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.cpp
@@ -8,36 +8,39 @@
#include <global-objects.h>
void DesktopContextMenu::SettingsChanged(DesktopSettings::File file){
- if(file == DesktopSettings::ContextMenu){ UpdateMenu(); }
+ if(file == DesktopSettings::ContextMenu){ UpdateMenu(false); }
}
-void DesktopContextMenu::UpdateMenu(){
+void DesktopContextMenu::UpdateMenu(bool fast){
//Put a label at the top
unsigned int num = Lumina::NWS->currentWorkspace();
workspaceLabel->setText( "<b>"+QString(tr("Workspace %1")).arg(QString::number(num+1))+"</b>");
+ if(fast && usewinmenu){ updateWinMenu(); }
+ if(fast){ return; } //already done
this->clear(); //clear it for refresh
this->addAction(wkspaceact);
this->addSeparator();
//Now load the user's menu setup and fill the menu
- QStringList items = DesktopSettings::instance()->value(DesktopSettings::ContextMenu, "itemlist", QStringList()<< "terminal" << "filemanager" << "line" << "settings" <<"lockdesktop").toStringList();
- //usewinmenu=false;
+ QStringList items = DesktopSettings::instance()->value(DesktopSettings::ContextMenu, "itemlist", QStringList()<< "terminal" << "filemanager" << "line" << "applications" << "windowlist" << "settings" << "lockdesktop").toStringList();
+ usewinmenu=false;
for(int i=0; i<items.length(); i++){
if(items[i]=="terminal"){ this->addAction(LXDG::findIcon("utilities-terminal",""), tr("Terminal"))->setWhatsThis("lumina-open -terminal"); }
else if(items[i]=="lockdesktop"){ this->addAction(LXDG::findIcon("system-lock-screen",""), tr("Lock Session"), this, SIGNAL(LockSession()) ); }
else if(items[i]=="filemanager"){ this->addAction( LXDG::findIcon("user-home",""), tr("Browse Files"))->setWhatsThis("lumina-open \""+QDir::homePath()+"\""); }
- //else if(items[i]=="applications"){ this->addMenu( LSession::handle()->applicationMenu() ); }
+ else if(items[i]=="applications"){ this->addMenu( appMenu ); }
else if(items[i]=="line"){ this->addSeparator(); }
//else if(items[i]=="settings"){ this->addMenu( LSession::handle()->settingsMenu() ); }
- //else if(items[i]=="windowlist"){ this->addMenu( winMenu); usewinmenu=true;}
+ else if(items[i]=="windowlist"){ updateWinMenu(); this->addMenu( winMenu); usewinmenu=true; }
else if(items[i].startsWith("app::::") && items[i].endsWith(".desktop")){
//Custom *.desktop application
QString file = items[i].section("::::",1,1).simplified();
- XDGDesktop xdgf(file);// = LXDG::loadDesktopFile(file, ok);
- if(xdgf.type!=XDGDesktop::BAD){
- this->addAction( LXDG::findIcon(xdgf.icon,""), xdgf.name)->setWhatsThis("lumina-open \""+file+"\"");
- }else{
- qDebug() << "Could not load application file:" << file;
- }
+ //Try to use the pre-loaded app entry for this
+ XDGDesktop *xdg = XDGDesktopList::instance()->findAppFile(file);
+ if(xdg!=0){ xdg->addToMenu(this); }
+ else{
+ XDGDesktop xdgf(file);// = LXDG::loadDesktopFile(file, ok);
+ if(xdgf.type!=XDGDesktop::BAD){ xdgf.addToMenu(this); }
+ }
}/*else if(items[i].startsWith("jsonmenu::::")){
//Custom JSON menu system (populated on demand via external scripts/tools
QStringList info = items[i].split("::::"); //FORMAT:[ "jsonmenu",exec,name, icon(optional)]
@@ -62,11 +65,15 @@ DesktopContextMenu::DesktopContextMenu(QWidget *parent) : QMenu(parent){
parent->setContextMenuPolicy(Qt::CustomContextMenu);
connect(parent, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showMenu(const QPoint&)) );
}
+ appMenu = 0;
+ winMenu = 0;
workspaceLabel = new QLabel(0);
wkspaceact = new QWidgetAction(0);
wkspaceact->setDefaultWidget(workspaceLabel);
connect(this, SIGNAL(triggered(QAction*)), this, SLOT(LaunchAction(QAction*)) );
-
+ //Connect to a couple global objects
+ connect(XDGDesktopList::instance(), SIGNAL(appsUpdated()), this, SLOT(updateAppMenu()) );
+ connect(this, SIGNAL(aboutToShow()), this, SLOT(UpdateMenu()) ); //this will do a "fast" update
}
DesktopContextMenu::~DesktopContextMenu(){
@@ -78,9 +85,8 @@ DesktopContextMenu::~DesktopContextMenu(){
void DesktopContextMenu::start(){
connect(DesktopSettings::instance(), SIGNAL(FileModified(DesktopSettings::File)), this, SLOT(SettingsChanged(DesktopSettings::File)) );
connect(this, SIGNAL(LockSession()), Lumina::SS, SLOT(LockScreenNow()) );
-
+ UpdateMenu(false);
//Still need to connect to some "workspaceChanged(int)" signal
- QTimer::singleShot(0, this, SLOT(UpdateMenu()) ); //initial update
}
// === PRIVATE SLOTS ===
@@ -95,3 +101,20 @@ void DesktopContextMenu::LaunchAction(QAction *act){
void DesktopContextMenu::showMenu(const QPoint &pt){
this->popup(pt);
}
+
+void DesktopContextMenu::updateAppMenu(){
+ if(appMenu==0){
+ appMenu = new QMenu(this);
+ appMenu->setTitle( tr("Applications"));
+ appMenu->setIcon( LXDG::findIcon("system-run","") );
+ }
+ XDGDesktopList::instance()->populateMenu(appMenu);
+}
+
+void DesktopContextMenu::updateWinMenu(){
+ if(winMenu==0){
+ winMenu = new QMenu(this);
+ winMenu->setTitle( tr("Task Manager") );
+ }
+}
+
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h
index 7fd21967..31daa0a8 100644
--- a/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/ContextMenu.h
@@ -13,11 +13,13 @@ class DesktopContextMenu : public QMenu{
Q_OBJECT
public slots:
void SettingsChanged(DesktopSettings::File);
- void UpdateMenu(); //re-create the menu
+ void UpdateMenu(bool fast = true); //re-create the menu
private:
QLabel *workspaceLabel;
QWidgetAction *wkspaceact;
+ QMenu *appMenu, *winMenu;
+ bool usewinmenu;
public:
DesktopContextMenu(QWidget *parent = 0);
@@ -29,6 +31,9 @@ private slots:
void LaunchAction(QAction *act);
void showMenu(const QPoint&);
+ void updateAppMenu();
+ void updateWinMenu();
+
signals:
void LockSession();
void showLeaveDialog();
bgstack15