aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lumina-desktop/panel-plugins/systemstart/LStartButton.cpp40
-rw-r--r--lumina-desktop/panel-plugins/systemstart/LStartButton.h35
-rw-r--r--lumina-desktop/panel-plugins/systemstart/StartMenu.cpp19
-rw-r--r--lumina-desktop/panel-plugins/systemstart/StartMenu.h2
4 files changed, 67 insertions, 29 deletions
diff --git a/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp b/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp
index d578e3b5..146fec3d 100644
--- a/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp
+++ b/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp
@@ -46,6 +46,7 @@ void LStartButtonPlugin::updateButtonVisuals(){
void LStartButtonPlugin::updateQuickLaunch(QStringList apps){
//First clear any obsolete apps
QStringList old;
+ qDebug() << "Update QuickLaunch Buttons";
for(int i=0; i<QUICKL.length(); i++){
if( !apps.contains(QUICKL[i]->whatsThis()) ){
//App was removed
@@ -53,39 +54,46 @@ void LStartButtonPlugin::updateQuickLaunch(QStringList apps){
i--;
}else{
//App still listed - update the button
- old << QUICKL[i]->defaultAction()->whatsThis(); //add the list of current buttons
+ old << QUICKL[i]->whatsThis(); //add the list of current buttons
LFileInfo info(QUICKL[i]->whatsThis());
- QUICKL[i]->defaultAction()->setIcon( LXDG::findIcon(info.iconfile(),"unknown") );
- if(info.isDesktopFile()){ QUICKL[i]->defaultAction()->setToolTip( info.XDG()->name ); }
- else{ QUICKL[i]->defaultAction()->setToolTip( info.fileName() ); }
+ QUICKL[i]->setIcon( LXDG::findIcon(info.iconfile(),"unknown") );
+ if(info.isDesktopFile()){ QUICKL[i]->setToolTip( info.XDG()->name ); }
+ else{ QUICKL[i]->setToolTip( info.fileName() ); }
}
}
//Now go through and create any new buttons
for(int i=0; i<apps.length(); i++){
if( !old.contains(apps[i]) ){
//New App
- QToolButton *tmp = new QToolButton(this);
- QAction *act = new QAction(tmp);
- tmp->setDefaultAction(act);
- act->setWhatsThis(apps[i]);
+ LQuickLaunchButton *tmp = new LQuickLaunchButton(apps[i], this);
QUICKL << tmp;
LFileInfo info(apps[i]);
- act->setIcon( LXDG::findIcon( info.iconfile() ) );
- if(info.isDesktopFile()){ act->setToolTip( info.XDG()->name ); }
- else{ act->setToolTip( info.fileName() ); }
+ tmp->setIcon( LXDG::findIcon( info.iconfile() ) );
+ if(info.isDesktopFile()){ tmp->setToolTip( info.XDG()->name ); }
+ else{ tmp->setToolTip( info.fileName() ); }
//Now add the button to the layout and connect the signal/slots
this->layout()->insertWidget(i+1,tmp); //"button" is always in slot 0
- connect(tmp, SIGNAL(triggered(QAction*)), this, SLOT(LaunchQuick(QAction*)) );
+ connect(tmp, SIGNAL(Launch(QString)), this, SLOT(LaunchQuick(QString)) );
+ connect(tmp, SIGNAL(Remove(QString)), this, SLOT(RemoveQuick(QString)) );
}
}
+ qDebug() << " - Done updateing QuickLaunch Buttons";
QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes
}
-void LStartButtonPlugin::LaunchQuick(QAction* act){
+void LStartButtonPlugin::LaunchQuick(QString file){
//Need to get which button was clicked
- qDebug() << "Quick Launch triggered:" << act->whatsThis();
- if(!act->whatsThis().isEmpty()){
- LSession::LaunchApplication("lumina-open \""+act->whatsThis()+"\"");
+ qDebug() << "Quick Launch triggered:" << file;
+ if(!file.isEmpty()){
+ LSession::LaunchApplication("lumina-open \""+file+"\"");
+ emit MenuClosed();
+ }
+}
+
+void LStartButtonPlugin::RemoveQuick(QString file){
+ qDebug() << "Remove Quicklaunch Button:" << file;
+ if(!file.isEmpty()){
+ startmenu->UpdateQuickLaunch(file, false); //always a removal
emit MenuClosed();
}
}
diff --git a/lumina-desktop/panel-plugins/systemstart/LStartButton.h b/lumina-desktop/panel-plugins/systemstart/LStartButton.h
index 6a9cdaba..33c48bbf 100644
--- a/lumina-desktop/panel-plugins/systemstart/LStartButton.h
+++ b/lumina-desktop/panel-plugins/systemstart/LStartButton.h
@@ -16,7 +16,7 @@
#include <QToolButton>
#include <QString>
#include <QWidget>
-
+#include <QMenu>
// Lumina-desktop includes
//#include "../../Globals.h"
@@ -27,6 +27,34 @@
#include "StartMenu.h"
+//Simple Tool Button For QuickLaunch Items
+class LQuickLaunchButton : public QToolButton{
+ Q_OBJECT
+signals:
+ void Launch(QString);
+ void Remove(QString);
+
+private slots:
+ void rmentry(){
+ emit Remove(this->whatsThis());
+ }
+ void launchentry(){
+ emit Launch(this->whatsThis());
+ }
+
+public:
+ LQuickLaunchButton(QString path, QWidget* parent = 0) : QToolButton(parent){
+ this->setWhatsThis(path);
+ this->setMenu(new QMenu(this));
+ this->setContextMenuPolicy(Qt::CustomContextMenu);
+ this->menu()->addAction( LXDG::findIcon("edit-delete",""), tr("Remove from Quicklaunch"), this, SLOT(rmentry()) );
+ connect(this, SIGNAL(clicked()), this, SLOT(launchentry()) );
+ connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showMenu()) );
+ }
+ ~LQuickLaunchButton(){}
+
+};
+
// PANEL PLUGIN BUTTON
class LStartButtonPlugin : public LPPlugin{
Q_OBJECT
@@ -40,7 +68,7 @@ private:
QWidgetAction *mact;
StartMenu *startmenu;
QToolButton *button;
- QList<QToolButton*> QUICKL;
+ QList<LQuickLaunchButton*> QUICKL;
private slots:
void openMenu();
@@ -49,7 +77,8 @@ private slots:
void updateButtonVisuals();
void updateQuickLaunch(QStringList);
- void LaunchQuick(QAction*);
+ void LaunchQuick(QString);
+ void RemoveQuick(QString);
public slots:
void OrientationChange(){
diff --git a/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp b/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
index 5bab9377..4c64f554 100644
--- a/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
+++ b/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
@@ -123,6 +123,16 @@ void StartMenu::ReLoadQuickLaunch(){
emit UpdateQuickLaunch( LSession::handle()->sessionSettings()->value("QuicklaunchApps",QStringList()).toStringList() );
}
+void StartMenu::UpdateQuickLaunch(QString path, bool keep){
+ QStringList QL = LSession::handle()->sessionSettings()->value("QuicklaunchApps",QStringList()).toStringList();
+ if(keep){QL << path; }
+ else{ QL.removeAll(path); }
+ QL.removeDuplicates();
+ LSession::handle()->sessionSettings()->setValue("QuicklaunchApps",QL);
+ LSession::handle()->sessionSettings()->sync();
+ emit UpdateQuickLaunch(QL);
+}
+
// ==========================
// PRIVATE FUNCTIONS
// ==========================
@@ -178,15 +188,6 @@ void StartMenu::LaunchItem(QString path, bool fix){
}
}
-void StartMenu::UpdateQuickLaunch(QString path, bool keep){
- QStringList QL = LSession::handle()->sessionSettings()->value("QuicklaunchApps",QStringList()).toStringList();
- if(keep){QL << path; }
- else{ QL.removeAll(path); }
- QL.removeDuplicates();
- LSession::handle()->sessionSettings()->setValue("QuicklaunchApps",QL);
- emit UpdateQuickLaunch(QL);
-}
-
//Listing Update routines
void StartMenu::UpdateApps(){
ClearScrollArea(ui->scroll_apps);
diff --git a/lumina-desktop/panel-plugins/systemstart/StartMenu.h b/lumina-desktop/panel-plugins/systemstart/StartMenu.h
index ebf2ad9c..bf673a86 100644
--- a/lumina-desktop/panel-plugins/systemstart/StartMenu.h
+++ b/lumina-desktop/panel-plugins/systemstart/StartMenu.h
@@ -27,6 +27,7 @@ public slots:
void UpdateMenu(bool forceall = false); //for item changes
void ReLoadQuickLaunch();
+ void UpdateQuickLaunch(QString, bool);
private:
Ui::StartMenu *ui;
@@ -39,7 +40,6 @@ private:
private slots:
void LaunchItem(QString path, bool fix = true);
- void UpdateQuickLaunch(QString, bool);
//Application/Favorite Listings
void UpdateApps();
bgstack15