aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop/panel-plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core/lumina-desktop/panel-plugins')
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/NewPP.h7
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp12
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp43
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/audioplayer/LPAudioPlayer.cpp30
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/audioplayer/LPAudioPlayer.h49
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.cpp258
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.h59
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.ui182
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/battery/LBattery.cpp15
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/battery/LBattery.h2
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/battery/NOTES2
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp8
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.h2
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/jsonmenu/PPJsonMenu.cpp35
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/jsonmenu/PPJsonMenu.h42
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/panel-plugins.pri15
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/quickcontainer/QuickPPlugin.h2
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp94
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h8
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp20
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.h7
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp119
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h2
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp45
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h4
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp12
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.h2
27 files changed, 900 insertions, 176 deletions
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/NewPP.h b/src-qt5/core/lumina-desktop/panel-plugins/NewPP.h
index 2641ad79..3a5f6a5b 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/NewPP.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/NewPP.h
@@ -26,9 +26,12 @@
#include "appmenu/LAppMenuPlugin.h"
#include "applauncher/AppLaunchButton.h"
#include "systemstart/LStartButton.h"
+#include "audioplayer/LPAudioPlayer.h"
+#include "jsonmenu/PPJsonMenu.h"
//#include "quickcontainer/QuickPPlugin.h"
#include "systemtray/LSysTray.h" //must be last due to X11 compile issues
+
class NewPP{
public:
static LPPlugin* createPlugin(QString plugin, QWidget* parent = 0, bool horizontal = true){
@@ -60,6 +63,10 @@ public:
plug = new LAppMenuPlugin(parent, plugin, horizontal);
}else if(plugin.startsWith("systemstart---")){
plug = new LStartButtonPlugin(parent, plugin, horizontal);
+ }else if(plugin.startsWith("audioplayer---")){
+ plug = new LPAudioPlayer(parent, plugin, horizontal);
+ }else if(plugin.section("::::",0,0)=="jsonmenu" && plugin.split("::::").length()>=3 ){
+ plug = new LPJsonMenu(parent, plugin, horizontal);
}else if(plugin.section("---",0,0).section("::",0,0)=="applauncher"){
plug = new AppLaunchButtonPlugin(parent, plugin, horizontal);
//}else if( plugin.section("---",0,0).startsWith("quick-") && LUtils::validQuickPlugin(plugin.section("---",0,0)) ){
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp b/src-qt5/core/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp
index 321970ed..05b7981f 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/applauncher/AppLaunchButton.cpp
@@ -31,9 +31,8 @@ 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){
+ XDGDesktop desk(appfile);
+ if(desk.isValid()){
icon = LXDG::findIcon(desk.icon, "unknown");
tooltip = QString(tr("Launch %1")).arg(desk.name);
}else{
@@ -56,13 +55,13 @@ void AppLaunchButtonPlugin::updateButtonVisuals(){
void AppLaunchButtonPlugin::AppClicked(){
if(appfile.isEmpty()){
//No App File selected
- QList<XDGDesktop> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All");
+ QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All");
QStringList names;
- for(int i=0; i<apps.length(); i++){ names << apps[i].name; }
+ 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;
+ 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>" ?
@@ -71,4 +70,3 @@ void AppLaunchButtonPlugin::AppClicked(){
LSession::LaunchApplication("lumina-open \""+appfile+"\"");
}
}
-
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp b/src-qt5/core/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp
index 5d20e3ec..e3be55c2 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/appmenu/LAppMenuPlugin.cpp
@@ -62,23 +62,22 @@ void LAppMenuPlugin::LaunchItem(QAction* item){
void LAppMenuPlugin::UpdateMenu(){
mainmenu->clear();
- QHash<QString, QList<XDGDesktop> > *HASH = LSession::handle()->applicationMenu()->currentAppHash();
+ QHash<QString, QList<XDGDesktop*> > *HASH = LSession::handle()->applicationMenu()->currentAppHash();
//Now Re-create the menu (orignally copied from the AppMenu class)
- bool ok; //for checking inputs
//Add link to the file manager
QAction *tmpact = mainmenu->addAction( LXDG::findIcon("user-home", ""), tr("Browse Files") );
tmpact->setWhatsThis("\""+QDir::homePath()+"\"");
//--Look for the app store
- XDGDesktop store = LXDG::loadDesktopFile(LOS::AppStoreShortcut(), ok);
- if(ok){
+ XDGDesktop store(LOS::AppStoreShortcut());
+ if(store.isValid()){
tmpact = mainmenu->addAction( LXDG::findIcon(store.icon, ""), tr("Install Applications") );
tmpact->setWhatsThis("\""+store.filePath+"\"");
}
//--Look for the control panel
- store = LXDG::loadDesktopFile(LOS::ControlPanelShortcut(), ok);
- if(ok){
- tmpact = mainmenu->addAction( LXDG::findIcon(store.icon, ""), tr("Control Panel") );
- tmpact->setWhatsThis("\""+store.filePath+"\"");
+ XDGDesktop controlp(LOS::ControlPanelShortcut());
+ if(controlp.isValid()){
+ tmpact = mainmenu->addAction( LXDG::findIcon(controlp.icon, ""), tr("Control Panel") );
+ tmpact->setWhatsThis("\""+controlp.filePath+"\"");
}
mainmenu->addSeparator();
//--Now create the sub-menus
@@ -104,29 +103,29 @@ void LAppMenuPlugin::UpdateMenu(){
QMenu *menu = new QMenu(name, this);
menu->setIcon(LXDG::findIcon(icon,""));
- QList<XDGDesktop> appL = HASH->value(cats[i]);
+ QList<XDGDesktop*> appL = HASH->value(cats[i]);
for( int a=0; a<appL.length(); a++){
- if(appL[a].actions.isEmpty()){
+ if(appL[a]->actions.isEmpty()){
//Just a single entry point - no extra actions
- QAction *act = new QAction(LXDG::findIcon(appL[a].icon, ""), appL[a].name, menu);
- act->setToolTip(appL[a].comment);
- act->setWhatsThis("\""+appL[a].filePath+"\"");
+ QAction *act = new QAction(LXDG::findIcon(appL[a]->icon, ""), appL[a]->name, menu);
+ act->setToolTip(appL[a]->comment);
+ act->setWhatsThis("\""+appL[a]->filePath+"\"");
menu->addAction(act);
}else{
//This app has additional actions - make this a sub menu
// - first the main menu/action
- QMenu *submenu = new QMenu(appL[a].name, menu);
- submenu->setIcon( LXDG::findIcon(appL[a].icon,"") );
+ QMenu *submenu = new QMenu(appL[a]->name, menu);
+ submenu->setIcon( LXDG::findIcon(appL[a]->icon,"") );
//This is the normal behavior - not a special sub-action (although it needs to be at the top of the new menu)
- QAction *act = new QAction(LXDG::findIcon(appL[a].icon, ""), appL[a].name, submenu);
- act->setToolTip(appL[a].comment);
- act->setWhatsThis(appL[a].filePath);
+ QAction *act = new QAction(LXDG::findIcon(appL[a]->icon, ""), appL[a]->name, submenu);
+ act->setToolTip(appL[a]->comment);
+ act->setWhatsThis(appL[a]->filePath);
submenu->addAction(act);
//Now add entries for every sub-action listed
- for(int sa=0; sa<appL[a].actions.length(); sa++){
- QAction *sact = new QAction(LXDG::findIcon(appL[a].actions[sa].icon, appL[a].icon), appL[a].actions[sa].name, this);
- sact->setToolTip(appL[a].comment);
- sact->setWhatsThis("-action \""+appL[a].actions[sa].ID+"\" \""+appL[a].filePath+"\"");
+ for(int sa=0; sa<appL[a]->actions.length(); sa++){
+ QAction *sact = new QAction(LXDG::findIcon(appL[a]->actions[sa].icon, appL[a]->icon), appL[a]->actions[sa].name, this);
+ sact->setToolTip(appL[a]->comment);
+ sact->setWhatsThis("-action \""+appL[a]->actions[sa].ID+"\" \""+appL[a]->filePath+"\"");
submenu->addAction(sact);
}
menu->addMenu(submenu);
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/LPAudioPlayer.cpp b/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/LPAudioPlayer.cpp
new file mode 100644
index 00000000..5669aaf5
--- /dev/null
+++ b/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/LPAudioPlayer.cpp
@@ -0,0 +1,30 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2014, Susanne Jaeckel
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "LPAudioPlayer.h"
+#include "LSession.h"
+
+LPAudioPlayer::LPAudioPlayer(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){
+ //Setup the button
+ button = new QToolButton(this);
+ button->setAutoRaise(true);
+ button->setToolButtonStyle(Qt::ToolButtonIconOnly);
+ button->setPopupMode(QToolButton::InstantPopup); //make sure it runs the update routine first
+ //connect(button, SIGNAL(clicked()), this, SLOT(openMenu()));
+ this->layout()->setContentsMargins(0,0,0,0);
+ this->layout()->addWidget(button);
+ wact = new QWidgetAction(this);
+ aplayer = new PPlayerWidget(this);
+ button ->setMenu(new QMenu(this) );
+ wact->setDefaultWidget(aplayer);
+ button->menu()->addAction(wact);
+ //Now start up the widgets
+ button->setIcon( LXDG::findIcon("audio-volume-high","") );
+ QTimer::singleShot(0,this,SLOT(OrientationChange()) ); //update the sizing/icon
+}
+
+LPAudioPlayer::~LPAudioPlayer(){
+}
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/LPAudioPlayer.h b/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/LPAudioPlayer.h
new file mode 100644
index 00000000..e5132b1f
--- /dev/null
+++ b/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/LPAudioPlayer.h
@@ -0,0 +1,49 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#ifndef _LUMINA_PANEL_AUDIO_PLAYER_PLUGIN_H
+#define _LUMINA_PANEL_AUDIO_PLAYER_PLUGIN_H
+
+#include "../../Globals.h"
+#include "../LTBWidget.h"
+#include "../LPPlugin.h"
+#include "PPlayerWidget.h"
+
+class LPAudioPlayer : public LPPlugin{
+ Q_OBJECT
+public:
+ LPAudioPlayer(QWidget *parent = 0, QString id = "audioplayer", bool horizontal=true);
+ ~LPAudioPlayer();
+
+private:
+ QToolButton *button;
+ QWidgetAction *wact;
+ PPlayerWidget *aplayer;
+
+ //int iconOld;
+
+private slots:
+ //void updateBattery(bool force = false);
+ //QString getRemainingTime();
+
+public slots:
+ void LocaleChange(){
+ //updateBattery(true);
+ }
+
+ 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();
+ }
+};
+
+#endif
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.cpp b/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.cpp
new file mode 100644
index 00000000..023e20c7
--- /dev/null
+++ b/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.cpp
@@ -0,0 +1,258 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "PPlayerWidget.h"
+#include "ui_PPlayerWidget.h"
+
+#include <QDir>
+#include <QUrl>
+#include <QInputDialog>
+#include <QFileDialog>
+#include <LuminaXDG.h>
+#include <QDebug>
+#include <QDesktopWidget>
+
+PPlayerWidget::PPlayerWidget(QWidget *parent) : QWidget(parent), ui(new Ui::PPlayerWidget()){
+ ui->setupUi(this); //load the designer form
+ PLAYER = new QMediaPlayer(this);
+ PLAYER->setVolume(100);
+ PLAYER->setNotifyInterval(1000); //1 second interval (just needs to be a rough estimate)
+ PLAYLIST = new QMediaPlaylist(this);
+ PLAYLIST->setPlaybackMode(QMediaPlaylist::Sequential);
+ PLAYER->setPlaylist(PLAYLIST);
+
+ configMenu = new QMenu(this);
+ ui->tool_config->setMenu(configMenu);
+ addMenu = new QMenu(this);
+ ui->tool_add->setMenu(addMenu);
+
+ updatinglists = false; //start off as false
+
+ ui->combo_playlist->setContextMenuPolicy(Qt::NoContextMenu);
+
+ LoadIcons();
+ playerStateChanged(); //update button visibility
+ currentSongChanged();
+ //Connect all the signals/slots
+ //connect(infoTimer, SIGNAL(timeout()), this, SLOT(rotateTrackInfo()) );
+ connect(PLAYER, SIGNAL(positionChanged(qint64)),this, SLOT(updateProgress(qint64)) );
+ connect(PLAYER, SIGNAL(durationChanged(qint64)), this, SLOT(updateMaxProgress(qint64)) );
+ connect(PLAYLIST, SIGNAL(mediaChanged(int, int)), this, SLOT(playlistChanged()) );
+ connect(PLAYER, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playerStateChanged()) );
+ connect(PLAYLIST, SIGNAL(currentMediaChanged(const QMediaContent&)), this, SLOT(currentSongChanged()) );
+ connect(ui->combo_playlist, SIGNAL(currentIndexChanged(int)), this, SLOT(userlistSelectionChanged()) );
+ connect(ui->tool_play, SIGNAL(clicked()), this, SLOT(playClicked()) );
+ connect(ui->tool_pause, SIGNAL(clicked()), this, SLOT(pauseClicked()) );
+ connect(ui->tool_stop, SIGNAL(clicked()), this, SLOT(stopClicked()) );
+ connect(ui->tool_next, SIGNAL(clicked()), this, SLOT(nextClicked()) );
+ connect(ui->tool_prev, SIGNAL(clicked()), this, SLOT(prevClicked()) );
+
+}
+
+PPlayerWidget::~PPlayerWidget(){
+ //qDebug() << "Removing PPlayerWidget";
+}
+
+void PPlayerWidget::LoadIcons(){
+ ui->tool_stop->setIcon( LXDG::findIcon("media-playback-stop","") );
+ ui->tool_play->setIcon( LXDG::findIcon("media-playback-start","") );
+ ui->tool_pause->setIcon( LXDG::findIcon("media-playback-pause","") );
+ ui->tool_next->setIcon( LXDG::findIcon("media-skip-forward","") );
+ ui->tool_prev->setIcon( LXDG::findIcon("media-skip-backward","") );
+ ui->tool_add->setIcon( LXDG::findIcon("list-add","") );
+ ui->tool_config->setIcon( LXDG::findIcon("configure","") );
+ //Now re-assemble the menus as well
+ configMenu->clear();
+ configMenu->addAction(LXDG::findIcon("media-eject",""), tr("Clear Playlist"), this, SLOT(ClearPlaylist()));
+ configMenu->addAction(LXDG::findIcon("roll",""), tr("Shuffle Playlist"), this, SLOT(ShufflePlaylist()));
+ addMenu->clear();
+ addMenu->addAction(LXDG::findIcon("document-new",""), tr("Add Files"), this, SLOT(AddFilesToPlaylist()));
+ addMenu->addAction(LXDG::findIcon("folder-new",""), tr("Add Directory"), this, SLOT(AddDirToPlaylist()));
+ addMenu->addAction(LXDG::findIcon("download",""), tr("Add URL"), this, SLOT(AddURLToPlaylist()));
+}
+
+void PPlayerWidget::playClicked(){
+ PLAYER->play();
+}
+
+void PPlayerWidget::pauseClicked(){
+ PLAYER->pause();
+}
+
+void PPlayerWidget::stopClicked(){
+ PLAYER->stop();
+}
+
+void PPlayerWidget::nextClicked(){
+ PLAYLIST->next();
+}
+
+void PPlayerWidget::prevClicked(){
+ PLAYLIST->previous();
+}
+
+void PPlayerWidget::AddFilesToPlaylist(){
+ //Prompt the user to select multimedia files
+ QFileDialog dlg(0, Qt::Dialog | Qt::WindowStaysOnTopHint );
+ dlg.setFileMode(QFileDialog::ExistingFiles);
+ dlg.setAcceptMode(QFileDialog::AcceptOpen);
+ dlg.setNameFilter( tr("Multimedia Files")+" ("+LXDG::findAVFileExtensions().join(" ")+")");
+ dlg.setWindowTitle(tr("Select Multimedia Files"));
+ dlg.setWindowIcon( LXDG::findIcon("file-open","") );
+ dlg.setDirectory(QDir::homePath()); //start in the home directory
+ //ensure it is centered on the current screen
+ QPoint center = QApplication::desktop()->screenGeometry(this).center();
+ dlg.move( center.x()-(dlg.width()/2), center.y()-(dlg.height()/2) );
+ dlg.show();
+ while( dlg.isVisible() ){
+ QApplication::processEvents();
+ }
+ QList<QUrl> files = dlg.selectedUrls();
+ if(files.isEmpty() || dlg.result()!=QDialog::Accepted){ return; } //cancelled
+ //Make this use show/processEvents later
+ //QList<QUrl> files = QFileDialog::getOpenFileUrls(0, tr("Select Multimedia Files"), QDir::homePath(), "Multimedia Files ("+LXDG::findAVFileExtensions().join(" ")+")");
+ QList<QMediaContent> urls;
+ for(int i=0; i<files.length(); i++){
+ urls << QMediaContent(files[i]);
+ }
+ PLAYLIST->addMedia(urls);
+ playlistChanged();
+}
+
+void PPlayerWidget::AddDirToPlaylist(){
+ QFileDialog dlg(0, Qt::Dialog | Qt::WindowStaysOnTopHint );
+ dlg.setFileMode(QFileDialog::Directory);
+ dlg.setOption(QFileDialog::ShowDirsOnly, true);
+ dlg.setAcceptMode(QFileDialog::AcceptOpen);
+ dlg.setWindowTitle(tr("Select Multimedia Directory"));
+ dlg.setWindowIcon( LXDG::findIcon("folder-open","") );
+ dlg.setDirectory(QDir::homePath()); //start in the home directory
+ //ensure it is centered on the current screen
+ QPoint center = QApplication::desktop()->screenGeometry(this).center();
+ dlg.move( center.x()-(dlg.width()/2), center.y()-(dlg.height()/2) );
+ dlg.show();
+ while( dlg.isVisible() ){
+ QApplication::processEvents();
+ }
+ if(dlg.result() != QDialog::Accepted){ return; } //cancelled
+ QStringList sel = dlg.selectedFiles();
+ if(sel.isEmpty()){ return; } //cancelled
+ QString dirpath = sel.first(); //QFileDialog::getExistingDirectory(0, tr("Select a Multimedia Directory"), QDir::homePath() );
+ if(dirpath.isEmpty()){ return; } //cancelled
+ QDir dir(dirpath);
+ QFileInfoList files = dir.entryInfoList(LXDG::findAVFileExtensions(), QDir::Files | QDir::NoDotAndDotDot, QDir::Name);
+ if(files.isEmpty()){ return; } //nothing in this directory
+ QList<QMediaContent> urls;
+ for(int i=0; i<files.length(); i++){
+ urls << QMediaContent(QUrl::fromLocalFile(files[i].absoluteFilePath()) );
+ }
+ PLAYLIST->addMedia(urls);
+ playlistChanged();
+}
+
+void PPlayerWidget::AddURLToPlaylist(){
+ QInputDialog dlg(0, Qt::Dialog | Qt::WindowStaysOnTopHint );
+ dlg.setInputMode(QInputDialog::TextInput);
+ dlg.setLabelText(tr("Enter a valid URL for a multimedia file or stream:"));
+ dlg.setTextEchoMode(QLineEdit::Normal);
+ dlg.setWindowTitle(tr("Multimedia URL"));
+ dlg.setWindowIcon( LXDG::findIcon("download","") );
+ //ensure it is centered on the current screen
+ QPoint center = QApplication::desktop()->screenGeometry(this).center();
+ dlg.move( center.x()-(dlg.width()/2), center.y()-(dlg.height()/2) );
+ dlg.show();
+ while( dlg.isVisible() ){
+ QApplication::processEvents();
+ }
+ QString url = dlg.textValue();
+ if(url.isEmpty() || dlg.result()!=QDialog::Accepted){ return; } //cancelled
+
+ //QString url = QInputDialog::getText(0, tr("Multimedia URL"), tr("Enter a valid URL for a multimedia file or stream"), QLineEdit::Normal);
+ //if(url.isEmpty()){ return; }
+ QUrl newurl(url);
+ if(!newurl.isValid()){ return; } //invalid URL
+ PLAYLIST->addMedia(newurl);
+ playlistChanged();
+}
+
+void PPlayerWidget::ClearPlaylist(){
+ PLAYER->stop();
+ PLAYLIST->clear();
+ playlistChanged();
+}
+
+void PPlayerWidget::ShufflePlaylist(){
+ PLAYLIST->shuffle();
+}
+
+
+void PPlayerWidget::userlistSelectionChanged(){ //front-end combobox was changed by the user
+ if(updatinglists){ return; }
+ PLAYLIST->setCurrentIndex( ui->combo_playlist->currentIndex() );
+}
+
+void PPlayerWidget::playerStateChanged(){
+ switch( PLAYER->state() ){
+ case QMediaPlayer::StoppedState:
+ ui->tool_stop->setVisible(false);
+ ui->tool_play->setVisible(true);
+ ui->tool_pause->setVisible(false);
+ ui->progressBar->setVisible(false);
+ break;
+ case QMediaPlayer::PausedState:
+ ui->tool_stop->setVisible(true);
+ ui->tool_play->setVisible(true);
+ ui->tool_pause->setVisible(false);
+ ui->progressBar->setVisible(true);
+ break;
+ case QMediaPlayer::PlayingState:
+ ui->tool_stop->setVisible(true);
+ ui->tool_play->setVisible(false);
+ ui->tool_pause->setVisible(true);
+ ui->progressBar->setVisible(true);
+ break;
+ }
+
+}
+
+void PPlayerWidget::playlistChanged(){
+ updatinglists = true;
+ ui->combo_playlist->clear();
+ for(int i=0; i<PLAYLIST->mediaCount(); i++){
+ QUrl url = PLAYLIST->media(i).canonicalUrl();
+ if(url.isLocalFile()){
+ ui->combo_playlist->addItem(LXDG::findMimeIcon(url.fileName().section(".",-1)), url.fileName() );
+ }else{
+ ui->combo_playlist->addItem(LXDG::findIcon("download",""), url.toString() );
+ }
+ }
+ if(PLAYLIST->currentIndex()<0 && PLAYLIST->mediaCount()>0){ PLAYLIST->setCurrentIndex(0); }
+ ui->combo_playlist->setCurrentIndex(PLAYLIST->currentIndex());
+
+ updatinglists = false;
+}
+
+void PPlayerWidget::currentSongChanged(){
+ if(PLAYLIST->currentIndex() != ui->combo_playlist->currentIndex()){
+ updatinglists = true;
+ ui->combo_playlist->setCurrentIndex(PLAYLIST->currentIndex());
+ updatinglists = false;
+ }
+ ui->tool_next->setEnabled( PLAYLIST->nextIndex() >= 0 );
+ ui->tool_prev->setEnabled( PLAYLIST->previousIndex() >= 0);
+ ui->label_num->setText( QString::number( PLAYLIST->currentIndex()+1)+"/"+QString::number(PLAYLIST->mediaCount()) );
+ ui->progressBar->setRange(0, PLAYER->duration() );
+ ui->progressBar->setValue(0);
+}
+
+void PPlayerWidget::updateProgress(qint64 val){
+ //qDebug() << "Update Progress Bar:" << val;
+ ui->progressBar->setValue(val);
+}
+
+void PPlayerWidget::updateMaxProgress(qint64 val){
+ ui->progressBar->setRange(0,val);
+}
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.h b/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.h
new file mode 100644
index 00000000..a551d74f
--- /dev/null
+++ b/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.h
@@ -0,0 +1,59 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2015, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This plugin is a simple audio player on the desktop
+//===========================================
+#ifndef _LUMINA_PANEL_PLUGIN_AUDIO_PLAYER_WIDGET_H
+#define _LUMINA_PANEL_PLUGIN_AUDIO_PLAYER_WIDGET_H
+
+#include <QMediaPlaylist>
+#include <QMediaPlayer>
+#include <QTimer>
+#include <QWidget>
+#include <QMenu>
+
+
+namespace Ui{
+ class PPlayerWidget;
+};
+
+class PPlayerWidget : public QWidget{
+ Q_OBJECT
+public:
+ PPlayerWidget(QWidget *parent = 0);
+ ~PPlayerWidget();
+
+public slots:
+ void LoadIcons();
+
+private:
+ Ui::PPlayerWidget *ui;
+ QMediaPlaylist *PLAYLIST;
+ QMediaPlayer *PLAYER;
+ QMenu *configMenu, *addMenu;
+ bool updatinglists;
+
+private slots:
+ void playClicked();
+ void pauseClicked();
+ void stopClicked();
+ void nextClicked();
+ void prevClicked();
+
+ void AddFilesToPlaylist();
+ void AddDirToPlaylist();
+ void AddURLToPlaylist();
+ void ClearPlaylist();
+ void ShufflePlaylist();
+ void userlistSelectionChanged(); //front-end combobox was changed by the user
+ void playerStateChanged();
+ void playlistChanged(); //list of items changed
+ void currentSongChanged();
+ void updateProgress(qint64 val);
+ void updateMaxProgress(qint64 val);
+};
+
+#endif
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.ui b/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.ui
new file mode 100644
index 00000000..2d2450be
--- /dev/null
+++ b/src-qt5/core/lumina-desktop/panel-plugins/audioplayer/PPlayerWidget.ui
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>PPlayerWidget</class>
+ <widget class="QWidget" name="PPlayerWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>346</width>
+ <height>90</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">QToolButton::menu-indicator{ image: none; }</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>4</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QToolButton" name="tool_config">
+ <property name="text">
+ <string notr="true">Config</string>
+ </property>
+ <property name="popupMode">
+ <enum>QToolButton::InstantPopup</enum>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="tool_add">
+ <property name="text">
+ <string notr="true">Add</string>
+ </property>
+ <property name="popupMode">
+ <enum>QToolButton::InstantPopup</enum>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="tool_prev">
+ <property name="text">
+ <string notr="true">prev</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_num">
+ <property name="text">
+ <string notr="true">1/10</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="tool_next">
+ <property name="text">
+ <string notr="true">next</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QComboBox" name="combo_playlist"/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QToolButton" name="tool_play">
+ <property name="text">
+ <string notr="true">Play</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="tool_pause">
+ <property name="text">
+ <string notr="true">Pause</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="tool_stop">
+ <property name="text">
+ <string notr="true">Stop</string>
+ </property>
+ <property name="autoRaise">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="value">
+ <number>24</number>
+ </property>
+ <property name="textVisible">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/battery/LBattery.cpp b/src-qt5/core/lumina-desktop/panel-plugins/battery/LBattery.cpp
index dda32ecd..ee379613 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/battery/LBattery.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/battery/LBattery.cpp
@@ -1,10 +1,11 @@
//===========================================
// Lumina-DE source code
-// Copyright (c) 2014, Susanne Jaeckel
+// Copyright (c) 2014, Susanne Jaeckel, 2015-2016 Ken Moore
// Available under the 3-clause BSD license
// See the LICENSE file for full details
//===========================================
#include "LBattery.h"
+#include "LSession.h"
LBattery::LBattery(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){
iconOld = -1;
@@ -34,8 +35,8 @@ void LBattery::updateBattery(bool force){
int icon = -1;
if (charge > 90) { icon = 4; }
else if (charge > 70) { icon = 3; }
- else if (charge > 50) { icon = 2; }
- else if (charge > 30) { icon = 1; }
+ else if (charge > 20) { icon = 2; }
+ else if (charge > 5) { icon = 1; }
else if (charge > 0 ) { icon = 0; }
if(LOS::batteryIsCharging()){ icon = icon+10; }
//icon = icon + result.at(0).toInt() * 10;
@@ -75,7 +76,15 @@ void LBattery::updateBattery(bool force){
label->setPixmap( LXDG::findIcon("battery-missing", "").pixmap(label->size()) );
break;
}
+ if(icon<iconOld && icon==0){
+ //Play some audio warning chime when
+ LSession::handle()->playAudioFile(LOS::LuminaShare()+"low-battery.ogg");
+ }
+ if(icon==0){ label->setStyleSheet("QLabel{ background: red;}"); }
+ else if(icon==14 && charge>98){ label->setStyleSheet("QLabel{ background: green;}"); }
+ else{ label->setStyleSheet("QLabel{ background: transparent;}"); }
iconOld = icon;
+
}
//Now update the display
QString tt;
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/battery/LBattery.h b/src-qt5/core/lumina-desktop/panel-plugins/battery/LBattery.h
index 3d31faad..29562d5d 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/battery/LBattery.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/battery/LBattery.h
@@ -12,7 +12,7 @@
#include <QString>
#include <QLabel>
-#include <LuminaUtils.h>
+#include <LUtils.h>
#include <LuminaXDG.h>
#include <LuminaOS.h>
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/battery/NOTES b/src-qt5/core/lumina-desktop/panel-plugins/battery/NOTES
index 3ea07778..3d93267e 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/battery/NOTES
+++ b/src-qt5/core/lumina-desktop/panel-plugins/battery/NOTES
@@ -22,7 +22,7 @@ apm -l
apm -t
Zeigt die verbleibende Zeit in Sekunden
-Aufruf Systemfunktionen: LuminaUtils.h
+Aufruf Systemfunktionen: LUtils.h
mit der Methode:
QStringList LUtils::getCmdOutput(QString cmd, QStringList args)
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp b/src-qt5/core/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp
index 48bbface..90d942de 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/desktopbar/LDeskBar.cpp
@@ -102,7 +102,7 @@ void LDeskBarPlugin::filechanged(QString file){
}
void LDeskBarPlugin::updateFiles(){
QFileInfoList homefiles = LSession::handle()->DesktopFiles();
- QStringList favitems = LUtils::listFavorites();
+ QStringList favitems = LDesktopUtils::listFavorites();
//Remember for format for favorites: <name>::::[app/dir/<mimetype>]::::<full path>
for(int i=0; i<homefiles.length(); i++){
if( !favitems.filter(homefiles[i].canonicalFilePath()).isEmpty() ){ continue; } //duplicate entry
@@ -130,11 +130,9 @@ void LDeskBarPlugin::updateFiles(){
if(type=="app"){
//Add it to appM
bool ok = false;
- XDGDesktop df = LXDG::loadDesktopFile(path, ok);
- if(ok){
- if( LXDG::checkValidity(df) && !df.isHidden ){
+ XDGDesktop df(path);
+ if(df.isValid() && !df.isHidden){
appM->addAction( newAction(df.filePath, df.name, LXDG::findIcon(df.icon, ":/images/default-application.png")) );
- }
}
}else if(type=="dir"){
//Add it to dirM
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.h b/src-qt5/core/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.h
index 851d9e35..af9250b7 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/desktopswitcher/LDesktopSwitcher.h
@@ -14,7 +14,7 @@
#include <QMenu>
#include <QToolButton>
-#include <LuminaUtils.h>
+#include <LUtils.h>
#include <LuminaXDG.h>
#include <LuminaX11.h>
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/jsonmenu/PPJsonMenu.cpp b/src-qt5/core/lumina-desktop/panel-plugins/jsonmenu/PPJsonMenu.cpp
new file mode 100644
index 00000000..14880f9b
--- /dev/null
+++ b/src-qt5/core/lumina-desktop/panel-plugins/jsonmenu/PPJsonMenu.cpp
@@ -0,0 +1,35 @@
+//===========================================
+// Lumina Desktop source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#include "PPJsonMenu.h"
+#include "../../JsonMenu.h"
+
+LPJsonMenu::LPJsonMenu(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){
+ //Setup the button
+ button = new QToolButton(this);
+ button->setAutoRaise(true);
+ button->setToolButtonStyle(Qt::ToolButtonIconOnly);
+ button->setPopupMode(QToolButton::InstantPopup); //make sure it runs the update routine first
+ //connect(button, SIGNAL(clicked()), this, SLOT(openMenu()));
+ this->layout()->setContentsMargins(0,0,0,0);
+ this->layout()->addWidget(button);
+ //Parse the id and get the extra information needed for the plugin
+ QStringList info = id.section("---",0,0).split("::::"); //FORMAT:[ "jsonmenu---<number>",exec,name, icon(optional)]
+ if(info.length()>=3){
+ qDebug() << "Custom JSON Menu Loaded:" << info;
+ JsonMenu *menu = new JsonMenu(info[1], button);
+ button->setText(info[2]);
+ //connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(SystemApplication(QAction*)) );
+ if(info.length()>=4){ button->setIcon( LXDG::findIcon(info[3],"run-build") ); }
+ else{ button->setIcon( LXDG::findIcon("run-build","") ); }
+ button->setMenu(menu);
+ }
+ //Now start up the widgets
+ QTimer::singleShot(0,this,SLOT(OrientationChange()) ); //update the sizing/icon
+}
+
+LPJsonMenu::~LPJsonMenu(){
+}
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/jsonmenu/PPJsonMenu.h b/src-qt5/core/lumina-desktop/panel-plugins/jsonmenu/PPJsonMenu.h
new file mode 100644
index 00000000..d0827fd2
--- /dev/null
+++ b/src-qt5/core/lumina-desktop/panel-plugins/jsonmenu/PPJsonMenu.h
@@ -0,0 +1,42 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#ifndef _LUMINA_PANEL_JSON_PLUGIN_H
+#define _LUMINA_PANEL_JSON_PLUGIN_H
+
+#include "../../Globals.h"
+#include "../LPPlugin.h"
+
+
+class LPJsonMenu : public LPPlugin{
+ Q_OBJECT
+public:
+ LPJsonMenu(QWidget *parent = 0, QString id = "jsonmenu", bool horizontal=true);
+ ~LPJsonMenu();
+
+private:
+ QToolButton *button;
+
+private slots:
+ //void SystemApplication(QAction*);
+
+public slots:
+ void LocaleChange(){
+ }
+
+ 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();
+ }
+};
+
+#endif
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/panel-plugins.pri b/src-qt5/core/lumina-desktop/panel-plugins/panel-plugins.pri
index afa7dbe2..9db23968 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/panel-plugins.pri
+++ b/src-qt5/core/lumina-desktop/panel-plugins/panel-plugins.pri
@@ -18,7 +18,10 @@ SOURCES += $$PWD/userbutton/LUserButton.cpp \
$$PWD/applauncher/AppLaunchButton.cpp \
$$PWD/systemstart/LStartButton.cpp \
$$PWD/systemstart/StartMenu.cpp \
- $$PWD/systemstart/ItemWidget.cpp
+ $$PWD/systemstart/ItemWidget.cpp \
+ $$PWD/audioplayer/LPAudioPlayer.cpp \
+ $$PWD/audioplayer/PPlayerWidget.cpp \
+ $$PWD/jsonmenu/PPJsonMenu.cpp
HEADERS += $$PWD/userbutton/LUserButton.h \
$$PWD/userbutton/UserWidget.h \
@@ -40,10 +43,14 @@ HEADERS += $$PWD/userbutton/LUserButton.h \
$$PWD/applauncher/AppLaunchButton.h \
$$PWD/systemstart/LStartButton.h \
$$PWD/systemstart/StartMenu.h \
- $$PWD/systemstart/ItemWidget.h
+ $$PWD/systemstart/ItemWidget.h \
+ $$PWD/audioplayer/LPAudioPlayer.h \
+ $$PWD/audioplayer/PPlayerWidget.h \
+ $$PWD/jsonmenu/PPJsonMenu.h
# $$PWD/quickcontainer/QuickPPlugin.h
FORMS += $$PWD/userbutton/UserWidget.ui \
$$PWD/systemdashboard/SysMenuQuick.ui \
- $$PWD/systemstart/StartMenu.ui
- \ No newline at end of file
+ $$PWD/systemstart/StartMenu.ui \
+ $$PWD/audioplayer/PPlayerWidget.ui
+
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/quickcontainer/QuickPPlugin.h b/src-qt5/core/lumina-desktop/panel-plugins/quickcontainer/QuickPPlugin.h
index e160c2b3..6f61c4d5 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/quickcontainer/QuickPPlugin.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/quickcontainer/QuickPPlugin.h
@@ -13,7 +13,7 @@
#include <QVBoxLayout>
#include "../LPPlugin.h"
-#include <LuminaUtils.h>
+#include <LUtils.h>
#include <QDebug>
class QuickPPlugin : public LPPlugin{
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp
index 3a0493a3..ea074a59 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp
@@ -5,7 +5,7 @@
// See the LICENSE file for full details
//===========================================
#include "ItemWidget.h"
-#include <LuminaUtils.h>
+#include <LUtils.h>
#include <QMenu>
#include "../../LSession.h"
@@ -16,8 +16,8 @@ ItemWidget::ItemWidget(QWidget *parent, QString itemPath, QString type, bool gob
bool inHome = type.endsWith("-home"); //internal code
if(inHome){ type = type.remove("-home"); }
if(itemPath.endsWith(".desktop") || type=="app"){
- XDGDesktop item = LXDG::loadDesktopFile(itemPath, gooditem);
- if(gooditem){ gooditem = LXDG::checkValidity(item); }
+ XDGDesktop item(itemPath, this);
+ gooditem = item.isValid();
//qDebug() << "Good Item:" << gooditem << itemPath;
if(gooditem){
icon->setPixmap( LXDG::findIcon(item.icon, "preferences-system-windows-actions").pixmap(32,32) );
@@ -26,7 +26,7 @@ ItemWidget::ItemWidget(QWidget *parent, QString itemPath, QString type, bool gob
if(!item.genericName.isEmpty() && item.name!=item.genericName){ text.append("<br><i> -- "+item.genericName+"</i>"); }
name->setText(text);
name->setToolTip(item.comment);
- setupActions(item);
+ setupActions(&item);
}else{
return;
}
@@ -73,7 +73,7 @@ ItemWidget::ItemWidget(QWidget *parent, QString itemPath, QString type, bool gob
icon->setWhatsThis(itemPath);
if(!goback){ this->setWhatsThis(name->text()); }
isDirectory = (type=="dir"); //save this for later
- if(LUtils::isFavorite(itemPath)){
+ if(LDesktopUtils::isFavorite(itemPath)){
linkPath = itemPath;
isShortcut=true;
}else if( inHome ){//|| itemPath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
@@ -89,13 +89,14 @@ ItemWidget::ItemWidget(QWidget *parent, QString itemPath, QString type, bool gob
}
// - Application constructor
-ItemWidget::ItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent){
+ItemWidget::ItemWidget(QWidget *parent, XDGDesktop *item) : QFrame(parent){
createWidget();
+ if(item==0){ gooditem = false; return; }
isDirectory = false;
- if(LUtils::isFavorite(item.filePath)){
- linkPath = item.filePath;
+ if(LDesktopUtils::isFavorite(item->filePath)){
+ linkPath = item->filePath;
isShortcut=true;
- }else if( item.filePath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
+ }else if( item->filePath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
isShortcut = true;
}else{
isShortcut = false;
@@ -104,20 +105,35 @@ ItemWidget::ItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent){
name->setToolTip(icon->whatsThis()); //also allow the user to see the full shortcut path
}
//Now fill it appropriately
- icon->setPixmap( LXDG::findIcon(item.icon,"preferences-system-windows-actions").pixmap(64,64) );
- text = item.name;
- if(!item.genericName.isEmpty() && item.name!=item.genericName){ text.append("<br><i> -- "+item.genericName+"</i>"); }
+ icon->setPixmap( LXDG::findIcon(item->icon,"preferences-system-windows-actions").pixmap(64,64) );
+ text = item->name;
+ if(!item->genericName.isEmpty() && item->name!=item->genericName){ text.append("<br><i> -- "+item->genericName+"</i>"); }
name->setText(text);
- name->setToolTip(item.comment);
- this->setWhatsThis(item.name);
- icon->setWhatsThis(item.filePath);
- iconPath = item.icon;
+ name->setToolTip(item->comment);
+ this->setWhatsThis(item->name);
+ icon->setWhatsThis(item->filePath);
+ iconPath = item->icon;
//Now setup the buttons appropriately
setupContextMenu();
setupActions(item);
}
-ItemWidget::~ItemWidget(){
+ItemWidget::~ItemWidget(){
+ icon->setPixmap(QPixmap()); //make sure the pixmap is cleared from memory too
+ actButton->deleteLater();
+ contextMenu->clear();
+ contextMenu->deleteLater();
+ if(actButton->menu()!=0){
+ for(int i=0; i<actButton->menu()->actions().length(); i++){
+ actButton->menu()->actions().at(i)->deleteLater();
+ }
+ actButton->menu()->deleteLater();
+ }
+ actButton->deleteLater();
+ icon->deleteLater();
+ name->deleteLater();
+ menureset->deleteLater();
+ linkPath.clear(); iconPath.clear(); text.clear();
}
void ItemWidget::triggerItem(){
@@ -132,7 +148,7 @@ void ItemWidget::createWidget(){
menureset->setSingleShot(true);
menureset->setInterval(1000); //1 second
this->setContentsMargins(0,0,0,0);
- contextMenu = new QMenu();
+ contextMenu = new QMenu(this);
connect(contextMenu, SIGNAL(aboutToShow()), this, SLOT(actionMenuOpen()) );
connect(contextMenu, SIGNAL(aboutToHide()), this, SLOT(actionMenuClosed()) );
actButton = new QToolButton(this);
@@ -144,7 +160,7 @@ void ItemWidget::createWidget(){
name->setTextFormat(Qt::RichText);
name->setTextInteractionFlags(Qt::NoTextInteraction);
//Add them to the layout
- this->setLayout(new QHBoxLayout());
+ this->setLayout(new QHBoxLayout(this));
this->layout()->setContentsMargins(1,1,1,1);
this->layout()->addWidget(icon);
this->layout()->addWidget(actButton);
@@ -161,7 +177,7 @@ void ItemWidget::setupContextMenu(){
contextMenu->addAction( LXDG::findIcon("preferences-desktop-icons",""), tr("Pin to Desktop"), this, SLOT(PinToDesktop()) );
}
//Favorite Item
- if( LUtils::isFavorite(icon->whatsThis()) ){ //Favorite Item - can always remove this
+ if( LDesktopUtils::isFavorite(icon->whatsThis()) ){ //Favorite Item - can always remove this
contextMenu->addAction( LXDG::findIcon("edit-delete",""), tr("Remove from Favorites"), this, SLOT(RemoveFavorite()) );
}else{
//This file does not have a shortcut yet -- allow the user to add it
@@ -176,14 +192,14 @@ void ItemWidget::setupContextMenu(){
}
}
-void ItemWidget::setupActions(XDGDesktop app){
- if(app.actions.isEmpty()){ actButton->setVisible(false); return; }
+void ItemWidget::setupActions(XDGDesktop *app){
+ if(app==0 || app->actions.isEmpty()){ actButton->setVisible(false); return; }
//Actions Available - go ahead and list them all
actButton->setMenu( new QMenu(this) );
- for(int i=0; i<app.actions.length(); i++){
- QAction *act = new QAction(LXDG::findIcon(app.actions[i].icon, app.icon), app.actions[i].name, this);
- act->setToolTip(app.actions[i].ID);
- act->setWhatsThis(app.actions[i].ID);
+ for(int i=0; i<app->actions.length(); i++){
+ QAction *act = new QAction(LXDG::findIcon(app->actions[i].icon, app->icon), app->actions[i].name, this);
+ act->setToolTip(app->actions[i].ID);
+ act->setWhatsThis(app->actions[i].ID);
actButton->menu()->addAction(act);
}
connect(actButton->menu(), SIGNAL(triggered(QAction*)), this, SLOT(actionClicked(QAction*)) );
@@ -201,19 +217,21 @@ void ItemWidget::updateItems(){
for(int i=0; i<newname.length(); i++){ newname[i] = name->fontMetrics().elidedText(newname[i], Qt::ElideRight, name->width()); }
name->setText( newname.join("<br>") );
//Now reload the icon if necessary
- if(icon->pixmap()->size().height() < (H-4) ){
- if(iconPath.isEmpty()){
- //Use item path (thumbnail or mimetype)
- if(LUtils::imageExtensions().contains(icon->whatsThis().section("/",-1).section(".",-1).toLower()) ){
- icon->setPixmap( QIcon(icon->whatsThis()).pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) );
+ if(icon->pixmap()!=0){
+ if(icon->pixmap()->size().height() < (H-4) ){
+ if(iconPath.isEmpty()){
+ //Use item path (thumbnail or mimetype)
+ if(LUtils::imageExtensions().contains(icon->whatsThis().section("/",-1).section(".",-1).toLower()) ){
+ icon->setPixmap( QIcon(icon->whatsThis()).pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) );
+ }else{
+ icon->setPixmap( LXDG::findMimeIcon(icon->whatsThis().section("/",-1)).pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) );
+ }
}else{
- icon->setPixmap( LXDG::findMimeIcon(icon->whatsThis().section("/",-1)).pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) );
+ icon->setPixmap( LXDG::findIcon(iconPath,"preferences-system-windows-actions").pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) );
}
- }else{
- icon->setPixmap( LXDG::findIcon(iconPath,"preferences-system-windows-actions").pixmap(H-4,H-4).scaledToHeight(H-4,Qt::SmoothTransformation) );
+ }else if(icon->pixmap()->size().height() > (H-4) ){
+ icon->setPixmap( icon->pixmap()->scaled(H-4, H-4, Qt::IgnoreAspectRatio, Qt::SmoothTransformation) );
}
- }else if(icon->pixmap()->size().height() > (H-4) ){
- icon->setPixmap( icon->pixmap()->scaled(H-4, H-4, Qt::IgnoreAspectRatio, Qt::SmoothTransformation) );
}
}
@@ -224,13 +242,13 @@ void ItemWidget::PinToDesktop(){
}
void ItemWidget::RemoveFavorite(){
- LUtils::removeFavorite(icon->whatsThis());
+ LDesktopUtils::removeFavorite(icon->whatsThis());
linkPath.clear();
emit RemovedShortcut();
}
void ItemWidget::AddFavorite(){
- if( LUtils::addFavorite(icon->whatsThis()) ){
+ if( LDesktopUtils::addFavorite(icon->whatsThis()) ){
linkPath = icon->whatsThis();
emit NewShortcut();
}
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h
index 8190de43..11394dd6 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h
@@ -32,9 +32,7 @@ public:
// - Favorites (path/type)
ItemWidget(QWidget *parent=0, QString itemPath="", QString type="unknown", bool goback=false);
// - Generic Apps
- ItemWidget(QWidget *parent=0, XDGDesktop item= XDGDesktop());
- // - Categories
- //ItemWidget(QWidget *parent=0, QString cat="");
+ ItemWidget(QWidget *parent=0, XDGDesktop *item= 0);
~ItemWidget();
@@ -51,9 +49,9 @@ private:
QTimer *menureset;
void createWidget();
- //void setupButton(bool disable = false);
+
void setupContextMenu();
- void setupActions(XDGDesktop);
+ void setupActions(XDGDesktop*);
void updateItems(); //update the text/icon to match sizes
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp
index f817e0c0..f44add77 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp
@@ -8,7 +8,7 @@
#include "../../LSession.h"
#include <LuminaXDG.h>
-#include <LuminaUtils.h> //This contains the "ResizeMenu" class
+#include <LUtils.h> //This contains the "ResizeMenu" class
LStartButtonPlugin::LStartButtonPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){
button = new QToolButton(this);
@@ -51,7 +51,7 @@ void LStartButtonPlugin::updateButtonVisuals(){
void LStartButtonPlugin::updateQuickLaunch(QStringList apps){
//First clear any obsolete apps
QStringList old;
- qDebug() << "Update QuickLaunch Buttons";
+ //qDebug() << "Update QuickLaunch Buttons";
for(int i=0; i<QUICKL.length(); i++){
if( !apps.contains(QUICKL[i]->whatsThis()) ){
//App was removed
@@ -82,13 +82,13 @@ void LStartButtonPlugin::updateQuickLaunch(QStringList apps){
connect(tmp, SIGNAL(Remove(QString)), this, SLOT(RemoveQuick(QString)) );
}
}
- qDebug() << " - Done updateing QuickLaunch Buttons";
+ //qDebug() << " - Done updateing QuickLaunch Buttons";
QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes
}
void LStartButtonPlugin::LaunchQuick(QString file){
//Need to get which button was clicked
- qDebug() << "Quick Launch triggered:" << file;
+ //qDebug() << "Quick Launch triggered:" << file;
if(!file.isEmpty()){
LSession::LaunchApplication("lumina-open \""+file+"\"");
emit MenuClosed();
@@ -96,7 +96,7 @@ void LStartButtonPlugin::LaunchQuick(QString file){
}
void LStartButtonPlugin::RemoveQuick(QString file){
- qDebug() << "Remove Quicklaunch Button:" << file;
+ //qDebug() << "Remove Quicklaunch Button:" << file;
if(!file.isEmpty()){
startmenu->UpdateQuickLaunch(file, false); //always a removal
emit MenuClosed();
@@ -113,6 +113,14 @@ void LStartButtonPlugin::SaveMenuSize(QSize sz){
// ========================
void LStartButtonPlugin::openMenu(){
if(menu->isVisible()){ return; } //don't re-show it - already open
+ //TESTING CODE TO SEE IF THIS MAKES IT RECOVER MEMORY
+ /*StartMenu *old = startmenu;
+ startmenu = new StartMenu(this);
+ connect(startmenu, SIGNAL(CloseMenu()), this, SLOT(closeMenu()) );
+ connect(startmenu, SIGNAL(UpdateQuickLaunch(QStringList)), this, SLOT(updateQuickLaunch(QStringList)));
+ menu->setContents(startmenu);
+ if(old!=0){ old->deleteLater(); }*/
+//--------
startmenu->UpdateMenu();
button->showMenu();
}
@@ -124,6 +132,6 @@ void LStartButtonPlugin::closeMenu(){
void LStartButtonPlugin::shortcutActivated(){
if(LSession::handle()->registerStartButton(this->type())){
if(menu->isVisible()){ closeMenu(); }
- else{ openMenu(); }
+ else{ this->activateWindow(); openMenu(); }
}
}
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.h b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.h
index a7d98353..d46bb1be 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/LStartButton.h
@@ -24,7 +24,8 @@
// libLumina includes
#include <LuminaXDG.h>
-#include <LuminaUtils.h>
+#include <LUtils.h>
+#include <ResizeMenu.h>
#include "StartMenu.h"
@@ -100,12 +101,12 @@ public slots:
void LocaleChange(){
updateButtonVisuals();
- startmenu->UpdateAll();
+ if(startmenu!=0){ startmenu->UpdateAll(); }
}
void ThemeChange(){
updateButtonVisuals();
- startmenu->UpdateAll();
+ if(startmenu!=0){ startmenu->UpdateAll(); }
}
};
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
index 60a313e8..d05ba22f 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
@@ -23,8 +23,8 @@ StartMenu::StartMenu(QWidget *parent) : QWidget(parent), ui(new Ui::StartMenu){
searchTimer->setInterval(300); //~1/3 second
searchTimer->setSingleShot(true);
connect(searchTimer, SIGNAL(timeout()), this, SLOT(startSearch()) );
- sysapps = LSession::handle()->applicationMenu()->currentAppHash();
connect(LSession::handle()->applicationMenu(), SIGNAL(AppMenuUpdated()), this, SLOT(UpdateApps()) );
+ connect(LSession::handle(), SIGNAL(FavoritesChanged()), this, SLOT(UpdateFavs()) );
//Need to load the last used setting of the application list
QString state = LSession::handle()->DesktopPluginSettings()->value("panelPlugs/systemstart/showcategories", "partial").toString();
if(state=="partial"){ui->check_apps_showcats->setCheckState(Qt::PartiallyChecked); }
@@ -72,9 +72,8 @@ void StartMenu::UpdateAll(){
if(QFile::exists(tmp)){
ui->tool_launch_controlpanel->setWhatsThis(tmp);
//Now read the file to see which icon to use
- bool ok = false;
- XDGDesktop desk = LXDG::loadDesktopFile(tmp, ok);
- if(ok && LXDG::checkValidity(desk)){
+ XDGDesktop desk(tmp);
+ if(desk.isValid()){
ui->tool_launch_controlpanel->setIcon(LXDG::findIcon(desk.icon,"preferences-other"));
}else{ ui->tool_launch_controlpanel->setVisible(false); }
}else{ ui->tool_launch_controlpanel->setVisible(false); }
@@ -83,9 +82,8 @@ void StartMenu::UpdateAll(){
if(QFile::exists(tmp)){
ui->tool_launch_store->setWhatsThis(tmp);
//Now read the file to see which icon to use
- bool ok = false;
- XDGDesktop desk = LXDG::loadDesktopFile(tmp, ok);
- if(ok && LXDG::checkValidity(desk)){
+ XDGDesktop desk(tmp);
+ if(desk.isValid()){
ui->tool_launch_store->setIcon(LXDG::findIcon(desk.icon,"utilities-file-archiver"));
}else{ ui->tool_launch_store->setVisible(false); }
}else{ ui->tool_launch_store->setVisible(false); }
@@ -131,7 +129,7 @@ void StartMenu::UpdateMenu(bool forceall){
if(forceall){ UpdateAll(); }
//Quick update routine before the menu is made visible
//qDebug() << "update favs";
- UpdateFavs();
+ //UpdateFavs();
//qDebug() << "check page";
if(ui->stackedWidget->currentWidget() != ui->page_main){
ui->stackedWidget->setCurrentWidget(ui->page_main); //just show the main page
@@ -158,16 +156,45 @@ void StartMenu::UpdateQuickLaunch(QString path, bool keep){
// ==========================
// PRIVATE FUNCTIONS
// ==========================
+/*void StartMenu::deleteChildren(QWidget *obj){
+ if(obj->layout()==0){
+ for(int i=0; i<obj->children().count(); i++){
+ obj->children().at(i)->deleteLater();
+ }
+ }else{
+
+ }
+}*/
+
void StartMenu::ClearScrollArea(QScrollArea *area){
- area->takeWidget()->deleteLater();
- area->setWidget( new QWidget() ); //create a new widget in the scroll area
- area->widget()->setContentsMargins(0,0,0,0);
- QVBoxLayout *layout = new QVBoxLayout;
+ //QWidget *old = area->takeWidget();
+ //qDebug() << "Clear Scroll Area:";
+ //if(old->layout()!=0){ qDebug() << " - Number of items in layout:" << old->layout()->count(); }
+ //qDebug() << " - Number of Children:" << old->children().count();
+ //deleteChildren(old); //make sure we *fully* delete these items to save memory
+ //old->deleteLater();
+ if(area == ui->scroll_favs){
+ area->takeWidget()->deleteLater();
+ }
+ if(area->widget()==0){
+ area->setWidget( new QWidget(area) ); //create a new widget in the scroll area
+ }
+ if(area->widget()->layout()==0){
+ QVBoxLayout *layout = new QVBoxLayout(area->widget());
layout->setSpacing(2);
layout->setContentsMargins(3,1,3,1);
layout->setDirection(QBoxLayout::TopToBottom);
layout->setAlignment(Qt::AlignTop);
+ area->widget()->setContentsMargins(0,0,0,0);
area->widget()->setLayout(layout);
+ }
+ //Now clear the items in the layout
+ while( area->widget()->layout()->count() >0 ){
+ QLayoutItem *it = area->widget()->layout()->takeAt(0);
+ //Need to delete both the widget and the layout item
+ if(it->widget()!=0){ it->widget()->deleteLater(); }
+ delete it;
+ }
}
void StartMenu::SortScrollArea(QScrollArea *area){
@@ -216,18 +243,18 @@ void StartMenu::do_search(QString search, bool force){
QStringList found; //syntax: [<sorter>::::<mimetype>::::<filepath>]
QString tmp = search;
if(LUtils::isValidBinary(tmp)){ found << "0::::application/x-executable::::"+tmp; }
- QList<XDGDesktop> apps = sysapps->value("All");
+ QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All");
for(int i=0; i<apps.length(); i++){
int priority = -1;
- if(apps[i].name.toLower()==search.toLower()){ priority = 10; }
- else if(apps[i].name.startsWith(search, Qt::CaseInsensitive)){ priority = 15; }
- else if(apps[i].name.contains(search, Qt::CaseInsensitive)){ priority = 19; }
- else if(apps[i].genericName.contains(search, Qt::CaseInsensitive)){ priority = 20; }
- else if(apps[i].comment.contains(search, Qt::CaseInsensitive)){ priority = 30; }
+ if(apps[i]->name.toLower()==search.toLower()){ priority = 10; }
+ else if(apps[i]->name.startsWith(search, Qt::CaseInsensitive)){ priority = 15; }
+ else if(apps[i]->name.contains(search, Qt::CaseInsensitive)){ priority = 19; }
+ else if(apps[i]->genericName.contains(search, Qt::CaseInsensitive)){ priority = 20; }
+ else if(apps[i]->comment.contains(search, Qt::CaseInsensitive)){ priority = 30; }
//Can add other filters here later
if(priority>0){
- found << QString::number(priority)+"::::app::::"+apps[i].filePath;
+ found << QString::number(priority)+"::::app::::"+apps[i]->filePath;
}
}
found.sort(Qt::CaseInsensitive); //sort by priority/type (lower numbers are higher on list)
@@ -238,10 +265,8 @@ void StartMenu::do_search(QString search, bool force){
if(topsearch.isEmpty()){ topsearch = found[i].section("::::",2,-1); }
ItemWidget *it = 0;
if( found[i].section("::::",2,-1).endsWith(".desktop")){
- bool ok = false;
- XDGDesktop item = LXDG::loadDesktopFile(found[i].section("::::",2,-1), ok);
- if(ok){ ok = LXDG::checkValidity(item); }
- if(ok){ it = new ItemWidget(ui->scroll_favs->widget(), item); }
+ XDGDesktop item(found[i].section("::::",2,-1));
+ if(item.isValid()){ it = new ItemWidget(ui->scroll_favs->widget(), &item); }
}else{
it = new ItemWidget(ui->scroll_favs->widget(), found[i].section("::::",2,-1), found[i].section("::::",1,1) );
}
@@ -302,17 +327,17 @@ void StartMenu::ChangeCategory(QString cat){
//Listing Update routines
void StartMenu::UpdateApps(){
ClearScrollArea(ui->scroll_apps);
- //Now assemble the apps list (note: this normally happens in the background - not when it is visible/open)
- //qDebug() << "Update Apps:" << CCat << ui->check_apps_showcats->checkState();
+ //Now assemble the apps list
+ //qDebug() << "Update Apps:";// << CCat << ui->check_apps_showcats->checkState();
if(ui->check_apps_showcats->checkState() == Qt::PartiallyChecked){
//qDebug() << " - Partially Checked";
//Show a single page of apps, but still divided up by categories
CCat.clear();
- QStringList cats = sysapps->keys();
+ QStringList cats = LSession::handle()->applicationMenu()->currentAppHash()->keys();
cats.sort();
cats.removeAll("All");
for(int c=0; c<cats.length(); c++){
- QList<XDGDesktop> apps = sysapps->value(cats[c]);
+ QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value(cats[c]);
if(apps.isEmpty()){ continue; }
//Add the category label to the scroll
QLabel *catlabel = new QLabel("<b>"+cats[c]+"</b>",ui->scroll_apps->widget());
@@ -321,7 +346,7 @@ void StartMenu::UpdateApps(){
//Now add all the apps for this category
for(int i=0; i<apps.length(); i++){
ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), apps[i] );
- if(!it->gooditem){ continue; } //invalid for some reason
+ if(!it->gooditem){ qDebug() << "Invalid Item:"; it->deleteLater(); continue; } //invalid for some reason
ui->scroll_apps->widget()->layout()->addWidget(it);
connect(it, SIGNAL(NewShortcut()), this, SLOT(UpdateFavs()) );
connect(it, SIGNAL(RemovedShortcut()), this, SLOT(UpdateFavs()) );
@@ -335,12 +360,12 @@ void StartMenu::UpdateApps(){
//Only show categories to start with - and have the user click-into a cat to see apps
if(CCat.isEmpty()){
//No cat selected yet - show cats only
- QStringList cats = sysapps->keys();
+ QStringList cats = LSession::handle()->applicationMenu()->currentAppHash()->keys();
cats.sort();
cats.removeAll("All"); //This is not a "real" category
for(int c=0; c<cats.length(); c++){
ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), cats[c], "chcat::::"+cats[c] );
- if(!it->gooditem){ continue; } //invalid for some reason
+ if(!it->gooditem){ qDebug() << "Invalid Item:";it->deleteLater(); continue; } //invalid for some reason
ui->scroll_apps->widget()->layout()->addWidget(it);
connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) );
}
@@ -352,11 +377,11 @@ void StartMenu::UpdateApps(){
ui->scroll_apps->widget()->layout()->addWidget(it);
connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) );
//Show apps for this cat
- QList<XDGDesktop> apps = sysapps->value(CCat);
+ QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value(CCat);
for(int i=0; i<apps.length(); i++){
//qDebug() << " - App:" << apps[i].name;
ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), apps[i] );
- if(!it->gooditem){ continue; } //invalid for some reason
+ if(!it->gooditem){ qDebug() << "Invalid Item:"; it->deleteLater(); continue; } //invalid for some reason
ui->scroll_apps->widget()->layout()->addWidget(it);
connect(it, SIGNAL(NewShortcut()), this, SLOT(UpdateFavs()) );
connect(it, SIGNAL(RemovedShortcut()), this, SLOT(UpdateFavs()) );
@@ -368,12 +393,12 @@ void StartMenu::UpdateApps(){
}else{
//qDebug() << " - Not Checked";
//No categories at all - just alphabetize all the apps
- QList<XDGDesktop> apps = sysapps->value("All");
+ QList<XDGDesktop*> apps = LSession::handle()->applicationMenu()->currentAppHash()->value("All");
CCat.clear();
//Now add all the apps for this category
- for(int i=0; i<apps.length(); i++){
+ for(int i=0; i<apps.length(); i++){
ItemWidget *it = new ItemWidget(ui->scroll_apps->widget(), apps[i] );
- if(!it->gooditem){ continue; } //invalid for some reason
+ if(!it->gooditem){ it->deleteLater(); continue; } //invalid for some reason
ui->scroll_apps->widget()->layout()->addWidget(it);
connect(it, SIGNAL(NewShortcut()), this, SLOT(UpdateFavs()) );
connect(it, SIGNAL(RemovedShortcut()), this, SLOT(UpdateFavs()) );
@@ -387,7 +412,7 @@ void StartMenu::UpdateApps(){
void StartMenu::UpdateFavs(){
//SYNTAX NOTE: (per-line) "<name>::::[dir/app/<mimetype>]::::<path>"
- QStringList newfavs = LUtils::listFavorites();
+ QStringList newfavs = LDesktopUtils::listFavorites();
if(favs == newfavs){ return; } //nothing to do - same as before
favs = newfavs;
ClearScrollArea(ui->scroll_favs);
@@ -400,10 +425,11 @@ void StartMenu::UpdateFavs(){
else if(type==1){ tmp = favs.filter("::::dir::::"); } //dirs next
else{ tmp = rest; } //everything left over
if(type==1){
+ SortScrollArea(ui->scroll_favs);
//Need to run a special routine for sorting the apps (already in the widget)
//qDebug() << "Sort App Widgets...";
// Since each app actually might have a different name listed within the file
- QLayout *lay = ui->scroll_favs->widget()->layout();
+ /*QLayout *lay = ui->scroll_favs->widget()->layout();
QStringList items;
for(int i=0; i<lay->count(); i++){
items << lay->itemAt(i)->widget()->whatsThis().toLower();
@@ -423,7 +449,8 @@ void StartMenu::UpdateFavs(){
break;
}
}
- }
+ }*/
+
}//end of special app sorting routine
tmp.sort(); //Sort alphabetically by name (dirs/files)
for(int i=0; i<tmp.length(); i++){
@@ -431,10 +458,8 @@ void StartMenu::UpdateFavs(){
if( !QFile::exists(tmp[i].section("::::",2,-1)) ){ continue; } //invalid favorite - skip it
ItemWidget *it = 0;
if( tmp[i].section("::::",2,-1).endsWith(".desktop")){
- bool ok = false;
- XDGDesktop item = LXDG::loadDesktopFile(tmp[i].section("::::",2,-1), ok);
- if(ok){ ok = LXDG::checkValidity(item); }
- if(ok){ it = new ItemWidget(ui->scroll_favs->widget(), item); }
+ XDGDesktop item(tmp[i].section("::::",2,-1));
+ if(item.isValid()){ it = new ItemWidget(ui->scroll_favs->widget(), &item); }
}else{
it = new ItemWidget(ui->scroll_favs->widget(), tmp[i].section("::::",2,-1), tmp[i].section("::::",1,1) );
}
@@ -448,6 +473,7 @@ void StartMenu::UpdateFavs(){
}
//QApplication::processEvents();
} //end loop over types
+ ui->scroll_favs->update();
//qDebug() << "End updateFavs";
}
@@ -463,11 +489,10 @@ void StartMenu::on_stackedWidget_currentChanged(int val){
//Battery available - update the status button
int charge = LOS::batteryCharge();
QString TT, ICON;
- if(charge < 10){ ICON="-low"; }
- else if(charge<20){ ICON="-caution"; }
- else if(charge<40){ ICON="-040"; }
- else if(charge<60){ ICON="-060"; }
- else if(charge<80){ ICON="-080"; }
+ if(charge<=5){ ICON="-caution"; }
+ else if(charge<=20){ ICON="-040"; }
+ else if(charge<=70){ ICON="-060"; }
+ else if(charge<=90){ ICON="-080"; }
else{ ICON="-100"; }
if(LOS::batteryIsCharging()){
if(charge>=80){ ICON.clear(); } //for charging, there is no suffix to the icon name over 80%
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h
index 9a629cc2..8ab04d94 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h
@@ -32,12 +32,12 @@ public slots:
private:
Ui::StartMenu *ui;
- QHash<QString, QList<XDGDesktop> > *sysapps;
QStringList favs;
QString CCat, CSearch, topsearch; //current category/search
QTimer *searchTimer;
//Simple utility functions
+ //void deleteChildren(QWidget *obj); //recursive function
void ClearScrollArea(QScrollArea *area);
void SortScrollArea(QScrollArea *area);
void do_search(QString search, bool force);
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp
index 1d32440a..8d7dab7a 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.cpp
@@ -5,7 +5,8 @@
// See the LICENSE file for full details
//===========================================
#include "UserItemWidget.h"
-#include <LuminaUtils.h>
+#include <LUtils.h>
+#include <LDesktopUtils.h>
#include <QMenu>
#define TEXTCUTOFF 165
@@ -15,12 +16,11 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type,
bool inHome = type.endsWith("-home"); //internal code
if(inHome){ type = type.remove("-home"); }
if(itemPath.endsWith(".desktop") || type=="app"){
- bool ok = false;
- XDGDesktop item = LXDG::loadDesktopFile(itemPath, ok);
- if(ok && LXDG::checkValidity(item) ){
+ XDGDesktop item(itemPath);
+ if( item.isValid() ){
icon->setPixmap( LXDG::findIcon(item.icon, "preferences-system-windows-actions").pixmap(32,32) );
name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, TEXTCUTOFF) );
- setupActions(item);
+ setupActions(&item);
}else{
gooditem = false;
return;
@@ -51,7 +51,7 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type,
icon->setWhatsThis(itemPath);
if(!goback){ this->setWhatsThis(name->text()); }
isDirectory = (type=="dir"); //save this for later
- if(LUtils::isFavorite(itemPath)){
+ if(LDesktopUtils::isFavorite(itemPath)){
linkPath = itemPath;
isShortcut=true;
}else if( inHome ){//|| itemPath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
@@ -63,22 +63,23 @@ UserItemWidget::UserItemWidget(QWidget *parent, QString itemPath, QString type,
setupButton(goback);
}
-UserItemWidget::UserItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent){
+UserItemWidget::UserItemWidget(QWidget *parent, XDGDesktop *item) : QFrame(parent){
+ if(item==0){ return; }
createWidget();
isDirectory = false;
- if(LUtils::isFavorite(item.filePath)){
- linkPath = item.filePath;
+ if(LDesktopUtils::isFavorite(item->filePath)){
+ linkPath = item->filePath;
isShortcut=true;
- }else if( item.filePath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
+ }else if( item->filePath.section("/",0,-2)==QDir::homePath()+"/Desktop" ){
isShortcut = true;
}else{
isShortcut = false;
}
//Now fill it appropriately
- icon->setPixmap( LXDG::findIcon(item.icon,"preferences-system-windows-actions").pixmap(32,32) );
- name->setText( this->fontMetrics().elidedText(item.name, Qt::ElideRight, TEXTCUTOFF) );
+ icon->setPixmap( LXDG::findIcon(item->icon,"preferences-system-windows-actions").pixmap(32,32) );
+ name->setText( this->fontMetrics().elidedText(item->name, Qt::ElideRight, TEXTCUTOFF) );
this->setWhatsThis(name->text());
- icon->setWhatsThis(item.filePath);
+ icon->setWhatsThis(item->filePath);
//Now setup the buttons appropriately
setupButton();
setupActions(item);
@@ -152,14 +153,14 @@ void UserItemWidget::setupButton(bool disable){
}
}
-void UserItemWidget::setupActions(XDGDesktop app){
- if(app.actions.isEmpty()){ actButton->setVisible(false); return; }
+void UserItemWidget::setupActions(XDGDesktop *app){
+ if(app==0 || app->actions.isEmpty()){ actButton->setVisible(false); return; }
//Actions Available - go ahead and list them all
actButton->setMenu( new QMenu(this) );
- for(int i=0; i<app.actions.length(); i++){
- QAction *act = new QAction(LXDG::findIcon(app.actions[i].icon, app.icon), app.actions[i].name, this);
- act->setToolTip(app.actions[i].ID);
- act->setWhatsThis(app.actions[i].ID);
+ for(int i=0; i<app->actions.length(); i++){
+ QAction *act = new QAction(LXDG::findIcon(app->actions[i].icon, app->icon), app->actions[i].name, this);
+ act->setToolTip(app->actions[i].ID);
+ act->setWhatsThis(app->actions[i].ID);
actButton->menu()->addAction(act);
}
connect(actButton->menu(), SIGNAL(triggered(QAction*)), this, SLOT(actionClicked(QAction*)) );
@@ -171,7 +172,7 @@ void UserItemWidget::setupActions(XDGDesktop app){
void UserItemWidget::buttonClicked(){
button->setVisible(false);
if(button->whatsThis()=="add"){
- LUtils::addFavorite(icon->whatsThis());
+ LDesktopUtils::addFavorite(icon->whatsThis());
//QFile::link(icon->whatsThis(), QDir::homePath()+"/.lumina/favorites/"+icon->whatsThis().section("/",-1) );
emit NewShortcut();
}else if(button->whatsThis()=="remove"){
@@ -184,7 +185,7 @@ void UserItemWidget::buttonClicked(){
}
//Don't emit the RemovedShortcut signal here - the automatic ~/Desktop watcher will see the change when finished
}else{
- LUtils::removeFavorite(icon->whatsThis()); //This is a favorite
+ LDesktopUtils::removeFavorite(icon->whatsThis()); //This is a favorite
emit RemovedShortcut();
}
}
@@ -201,4 +202,4 @@ void UserItemWidget::actionClicked(QAction *act){
if(!linkPath.isEmpty()){ cmd = cmd.arg(linkPath); }
else{ cmd = cmd.arg(icon->whatsThis()); }
emit RunItem(cmd);
-} \ No newline at end of file
+}
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h
index 2251344c..0b212f10 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserItemWidget.h
@@ -28,7 +28,7 @@ class UserItemWidget : public QFrame{
Q_OBJECT
public:
UserItemWidget(QWidget *parent=0, QString itemPath="", QString type="unknown", bool goback=false);
- UserItemWidget(QWidget *parent=0, XDGDesktop item= XDGDesktop());
+ UserItemWidget(QWidget *parent=0, XDGDesktop *item= 0);
~UserItemWidget();
bool gooditem;
@@ -41,7 +41,7 @@ private:
void createWidget();
void setupButton(bool disable = false);
- void setupActions(XDGDesktop);
+ void setupActions(XDGDesktop*);
private slots:
void buttonClicked();
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
index c7d8109c..a0ba8996 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp
@@ -130,8 +130,8 @@ void UserWidget::UpdateAll(){
QString APPSTORE = LOS::AppStoreShortcut();
if(QFile::exists(APPSTORE) && !APPSTORE.isEmpty()){
//Now load the info
- bool ok = false;
- XDGDesktop store = LXDG::loadDesktopFile(APPSTORE, ok);
+ XDGDesktop store(APPSTORE);
+ bool ok = store.isValid();
if(ok){
ui->tool_app_store->setIcon( LXDG::findIcon(store.icon, "") );
ui->tool_app_store->setText( store.name );
@@ -143,8 +143,8 @@ void UserWidget::UpdateAll(){
QString CONTROLPANEL = LOS::ControlPanelShortcut();
if(QFile::exists(CONTROLPANEL) && !CONTROLPANEL.isEmpty()){
//Now load the info
- bool ok = false;
- XDGDesktop cpan = LXDG::loadDesktopFile(CONTROLPANEL, ok);
+ XDGDesktop cpan(CONTROLPANEL);
+ bool ok = cpan.isValid();
if(ok){
ui->tool_controlpanel->setIcon( LXDG::findIcon(cpan.icon, "") );
}
@@ -221,7 +221,7 @@ void UserWidget::updateFavItems(bool newfilter){
if(updatingfavs){ return; }
updatingfavs = true;
//qDebug() << "Updating User Favorite Items";
- QStringList newfavs = LUtils::listFavorites();
+ QStringList newfavs = LDesktopUtils::listFavorites();
//qDebug() << "Favorites:" << newfavs;
if(lastHomeUpdate.isNull() || (QFileInfo(QDir::homePath()+"/Desktop").lastModified() > lastHomeUpdate) || newfavs!=favs ){
favs = newfavs;
@@ -307,7 +307,7 @@ void UserWidget::updateAppCategories(){
void UserWidget::updateApps(){
if(ui->combo_app_cats->currentIndex() < 0){ return; } //no cat
QString cat = ui->combo_app_cats->itemData( ui->combo_app_cats->currentIndex() ).toString();
- QList<XDGDesktop> items = sysapps->value(cat);
+ QList<XDGDesktop*> items = sysapps->value(cat);
ClearScrollArea(ui->scroll_apps);
for(int i=0; i<items.length(); i++){
UserItemWidget *it = new UserItemWidget(ui->scroll_apps->widget(), items[i]);
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.h b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.h
index af9408dd..8b03c489 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/userbutton/UserWidget.h
@@ -42,7 +42,7 @@ public slots:
private:
Ui::UserWidget *ui;
- QHash<QString, QList<XDGDesktop> > *sysapps;
+ QHash<QString, QList<XDGDesktop*> > *sysapps;
QDateTime lastUpdate, lastHomeUpdate;
QStringList favs;
QFileInfoList homefiles;
bgstack15