diff options
Diffstat (limited to 'lumina-desktop/desktop-plugins')
11 files changed, 170 insertions, 121 deletions
diff --git a/lumina-desktop/desktop-plugins/LDPlugin.cpp b/lumina-desktop/desktop-plugins/LDPlugin.cpp new file mode 100644 index 00000000..f7be148d --- /dev/null +++ b/lumina-desktop/desktop-plugins/LDPlugin.cpp @@ -0,0 +1,29 @@ +//=========================================== +// Lumina-DE source code +// Copyright (c) 2014-2015, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "LDPlugin.h" + +#include "../LSession.h" + +LDPlugin::LDPlugin(QWidget *parent, QString id) : QFrame(parent){ + PLUGID=id; + prefix = id.replace("/","_")+"/"; + qDebug() << "ID:" << PLUGID << prefix; + settings = LSession::handle()->DesktopPluginSettings(); + //Use plugin-specific values for stylesheet control (applauncher, desktopview, etc...) + this->setObjectName(id.section("---",0,0).section("::",0,0)); +} + +void LDPlugin::setInitialSize(int width, int height){ + //Note: Only run this in the plugin initization routine: + // if the plugin is completely new (first time used), it will be this size + if(settings->allKeys().filter(prefix).isEmpty()){ + //Brand new plugin: set initial size + settings->setValue(prefix+"location/width",width); + settings->setValue(prefix+"location/height",height); + settings->sync(); + } +} diff --git a/lumina-desktop/desktop-plugins/LDPlugin.h b/lumina-desktop/desktop-plugins/LDPlugin.h index fc6ab604..a69ca9c2 100644 --- a/lumina-desktop/desktop-plugins/LDPlugin.h +++ b/lumina-desktop/desktop-plugins/LDPlugin.h @@ -28,42 +28,35 @@ class LDPlugin : public QFrame{ Q_OBJECT private: - QString PLUGID; - -public: + QString PLUGID, prefix; QSettings *settings; - LDPlugin(QWidget *parent = 0, QString id="unknown", bool opaque = false) : QFrame(parent){ - PLUGID=id; - settings = new QSettings("desktop-plugins",PLUGID); - //Use two values for stylesheet access, Visible or normal plugin base - if(opaque){ this->setObjectName("LuminaDesktopPluginVisible"); } - else{ this->setObjectName("LuminaDesktopPlugin"); } - //Use plugin-specific values for stylesheet control (applauncher, desktopview, etc...) - //qDebug() << "set Objectname:" << id.section("---",0,0).section("::",0,0); - this->setObjectName(id.section("---",0,0).section("::",0,0)); - } +public: + LDPlugin(QWidget *parent = 0, QString id="unknown"); - ~LDPlugin(){ - - } + ~LDPlugin(){} QString ID(){ return PLUGID; } - void setInitialSize(int width, int height){ - //Note: Only run this in the plugin initization routine: - // if the plugin is completely new (first time used), it will be this size - if(settings->allKeys().isEmpty()){ - //Brand new plugin: set initial size - settings->setValue("location/width",width); - settings->setValue("location/height",height); - settings->sync(); - } + void setInitialSize(int width, int height); + + void saveSetting(QString var, QVariant val){ + settings->setValue(prefix+var, val); + settings->sync(); } - - virtual void scalePlugin(double xscale, double yscale){ + + QVariant readSetting(QString var, QVariant defaultval){ + return settings->value(prefix+var, defaultval); + } + + void removeSettings(){ //such as when a plugin is deleted + QStringList list = settings->allKeys().filter(prefix); + for(int i=0; i<list.length(); i++){ settings->remove(list[i]); } + } + + /*virtual void scalePlugin(double xscale, double yscale){ //This can be re-implemented in the subclassed plugin as necessary // Example: If there are icons in the plugin which should also be re-scaled @@ -82,7 +75,7 @@ public: val = settings->value("location/y",0).toInt(); if(val>0){ val = qRound(val*yscale); } settings->setValue("location/y",val); - } + }*/ public slots: virtual void LocaleChange(){ diff --git a/lumina-desktop/desktop-plugins/LDPluginContainer.h b/lumina-desktop/desktop-plugins/LDPluginContainer.h index 04ae8262..0e570e26 100644 --- a/lumina-desktop/desktop-plugins/LDPluginContainer.h +++ b/lumina-desktop/desktop-plugins/LDPluginContainer.h @@ -27,43 +27,31 @@ class LDPluginContainer : public QMdiSubWindow{ Q_OBJECT private: - QSettings *settings; QTimer *syncTimer; bool locked, setup; - + LDPlugin *PLUG; + private slots: void saveGeometry(){ - if(settings==0){ return; } - settings->setValue("location/x", this->pos().x()); - settings->setValue("location/y", this->pos().y()); - settings->setValue("location/width", this->size().width()); - settings->setValue("location/height", this->size().height()); - settings->sync(); + if(PLUG==0){ return; } + PLUG->saveSetting("location/x", this->pos().x()); + PLUG->saveSetting("location/y", this->pos().y()); + PLUG->saveSetting("location/width", this->size().width()); + PLUG->saveSetting("location/height", this->size().height()); } public: LDPluginContainer(LDPlugin *plugin = 0, bool islocked = true) : QMdiSubWindow(){ locked = islocked; setup=true; + PLUG = plugin; syncTimer = new QTimer(this); syncTimer->setInterval(500); //save settings 1 second after it is moved syncTimer->setSingleShot(true); //no repeats connect(syncTimer, SIGNAL(timeout()), this, SLOT(saveGeometry()) ); this->setWhatsThis(plugin->ID()); if(locked){ this->setWindowFlags(Qt::FramelessWindowHint); } - else{ this->setWindowFlags(Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); } - settings = plugin->settings; //save this pointer for access later - if(settings!=0){ - if(settings->allKeys().isEmpty()){ - //Brand new plugin - no location/size info saved yet - //save the initial size of the plugin - the initial location will be set automatically - QSize sz = plugin->sizeHint(); - if(!sz.isValid()){ sz = QSize(64,64); } - settings->setValue("location/width", sz.width()); - settings->setValue("location/height", sz.height()); - settings->sync(); - } - } + else{ this->setWindowFlags(Qt::CustomizeWindowHint); }//Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); } this->setContentsMargins(0,0,0,0); if(!locked){ this->setWindowTitle( plugin->ID().replace("---"," - ") ); @@ -80,7 +68,7 @@ public: } void loadInitialPosition(){ - QRect set(settings->value("location/x",-12345).toInt(), settings->value("location/y",-12345).toInt(), settings->value("location/width",this->widget()->sizeHint().width()).toInt(), settings->value("location/height",this->widget()->sizeHint().height()).toInt()); + QRect set(PLUG->readSetting("location/x",-12345).toInt(), PLUG->readSetting("location/y",-12345).toInt(), PLUG->readSetting("location/width",this->widget()->sizeHint().width()).toInt(), PLUG->readSetting("location/height",this->widget()->sizeHint().height()).toInt()); //qDebug() << "Initial Plugin Location:" << set.x() << set.y() << set.width() << set.height(); if(set.height() < 10){ set.setHeight(10); } //to prevent foot-shooting if(set.width() < 10){ set.setWidth(10); } //to prevent foot-shooting @@ -122,11 +110,10 @@ protected: if( !this->whatsThis().isEmpty() && !locked){ //Plugin removed by the user - delete the settings file locked = true; //ensure that the save settings routines don't do anything during the close - //QFile::remove( settings->fileName() ); emit PluginRemoved( this->whatsThis() ); } if(syncTimer->isActive()){ syncTimer->stop(); } //prevent save routine from running in a moment - settings = 0; //ensure we don't touch the settings file after a close event + //settings = 0; //ensure we don't touch the settings file after a close event QMdiSubWindow::closeEvent(event); //continue closing this window } diff --git a/lumina-desktop/desktop-plugins/NewDP.h b/lumina-desktop/desktop-plugins/NewDP.h index 78f10981..b5881c4e 100644 --- a/lumina-desktop/desktop-plugins/NewDP.h +++ b/lumina-desktop/desktop-plugins/NewDP.h @@ -26,6 +26,7 @@ class NewDP{ public: static LDPlugin* createPlugin(QString plugin, QWidget* parent=0){ + //qDebug() << "Create Plugin:" << plugin; LDPlugin *plug = 0; if(plugin.section("---",0,0)=="sample"){ plug = new SamplePlugin(parent, plugin); @@ -49,9 +50,10 @@ public: }else{ qWarning() << "Invalid Desktop Plugin:"<<plugin << " -- Ignored"; } + //qDebug() << " -- done"; return plug; } }; -#endif
\ No newline at end of file +#endif diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp index b3c6afcf..4dee95ca 100644 --- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -13,11 +13,8 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par lay->addWidget(button, 0, Qt::AlignCenter); connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) ); 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(); + int icosize = this->readSetting("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); @@ -27,23 +24,75 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par void AppLauncherPlugin::loadButton(){ QString def = this->ID().section("::",1,50).section("---",0,0).simplified(); - QString path = this->settings->value("applicationpath",def).toString(); //use the default if necessary + QString path = this->readSetting("applicationpath",def).toString(); //use the default if necessary //qDebug() << "Default Application Launcher:" << def << path; - bool ok = false; - XDGDesktop file = LXDG::loadDesktopFile(path, ok); - if(path.isEmpty() || !QFile::exists(path) || !ok){ - button->setWhatsThis(""); - button->setIcon( LXDG::findIcon("quickopen-file","") ); - button->setText( tr("Click to Set") ); + bool ok = QFile::exists(path); + QString txt; + if(path.endsWith(".desktop") && ok){ + XDGDesktop file = LXDG::loadDesktopFile(path, ok); + if(path.isEmpty() || !QFile::exists(path) || !ok){ + button->setWhatsThis(""); + button->setIcon( LXDG::findIcon("quickopen-file","") ); + txt = tr("Click to Set"); + if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); } + }else{ + button->setWhatsThis(file.filePath); + button->setIcon( LXDG::findIcon(file.icon,"quickopen") ); + txt = file.name; + if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); } + watcher->addPath(file.filePath); //make sure to update this shortcut if the file changes + } + }else if(ok){ + QFileInfo info(path); + button->setWhatsThis(info.absoluteFilePath()); + if(info.isDir()){ + button->setIcon( LXDG::findIcon("folder","") ); + }else if(LUtils::imageExtensions().contains(info.suffix().toLower()) ){ + button->setIcon( QIcon(QPixmap(path).scaled(256,256)) ); //max size for thumbnails in memory + }else{ + button->setIcon( LXDG::findMimeIcon(path) ); + } + txt = info.fileName(); if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); } + watcher->addPath(path); //make sure to update this shortcut if the file changes }else{ - button->setWhatsThis(file.filePath); - button->setIcon( LXDG::findIcon(file.icon,"quickopen") ); - button->setText( this->fontMetrics().elidedText(file.name, Qt::ElideRight, 64) ); + //InValid File + button->setWhatsThis(""); + button->setIcon( LXDG::findIcon("quickopen","") ); + button->setText( tr("Click to Set") ); if(!watcher->files().isEmpty()){ watcher->removePaths(watcher->files()); } - watcher->addPath(file.filePath); //make sure to update this shortcut if the file changes } - this->adjustSize(); //make sure to adjust the button on first show. + //Now adjust the visible text as necessary based on font/grid sizing + button->setToolTip(txt); + int icosize = this->readSetting("iconsize",64).toInt(); + //qDebug() << "Initial Button Text:" << txt << icosize; + if(button->fontMetrics().width(txt) > (icosize-2) ){ + //int dash = this->fontMetrics().width("-"); + //Text too long, try to show it on two lines + txt = txt.section(" ",0,2).replace(" ","\n"); //First take care of any natural breaks + if(txt.contains("\n")){ + //need to check each line + QStringList txtL = txt.split("\n"); + for(int i=0; i<txtL.length(); i++){ txtL[i] = button->fontMetrics().elidedText(txtL[i], Qt::ElideRight, icosize); } + txt = txtL.join("\n"); + }else{ + txt = this->fontMetrics().elidedText(txt,Qt::ElideRight, 2*icosize); + //Now split the line in half for the two lines + txt.insert( (txt.count()/2), "\n"); + } + } + //qDebug() << " - Setting Button Text:" << txt; + button->setText(txt); + //Now setup the menu again + menu->clear(); + menu->addAction(LXDG::findIcon("zoom-in",""), tr("Increase Size"), this, SLOT(increaseIconSize())); + menu->addAction(LXDG::findIcon("zoom-out",""), tr("Decrease Size"), this, SLOT(decreaseIconSize())); + if( !button->whatsThis().isEmpty() && button->whatsThis().startsWith(QDir::homePath()+"/Desktop") ){ + menu->addAction(LXDG::findIcon("list-remove",""), tr("Delete File"), this, SLOT(deleteFile()) ); + } + + button->setFixedSize(icosize+4, icosize+8+(2*button->fontMetrics().height()) ); //make sure to adjust the button on first show. + this->setInitialSize(button->width()+4, button->height()+4); QTimer::singleShot(100, this, SLOT(update()) ); //Make sure to re-draw the image in a moment } @@ -57,7 +106,7 @@ void AppLauncherPlugin::buttonClicked(){ 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 - this->settings->setValue("applicationpath", apps[ names.indexOf(app) ].filePath); + this->saveSetting("applicationpath", apps[ names.indexOf(app) ].filePath); QTimer::singleShot(0,this, SLOT(loadButton())); }else{ LSession::LaunchApplication("lumina-open \""+path+"\""); @@ -74,16 +123,25 @@ void AppLauncherPlugin::openContextMenu(){ } void AppLauncherPlugin::increaseIconSize(){ - int icosize = settings->value("iconsize",64).toInt(); + int icosize = this->readSetting("iconsize",64).toInt(); icosize += 16; button->setIconSize(QSize(icosize,icosize)); - settings->setValue("iconsize",icosize); + this->saveSetting("iconsize",icosize); + } void AppLauncherPlugin::decreaseIconSize(){ - int icosize = settings->value("iconsize",64).toInt(); + int icosize = this->readSetting("iconsize",64).toInt(); if(icosize < 20){ return; } //cannot get smaller icosize -= 16; button->setIconSize(QSize(icosize,icosize)); - settings->setValue("iconsize",icosize); + this->saveSetting("iconsize",icosize); } + +void AppLauncherPlugin::deleteFile(){ + if(QFileInfo(button->whatsThis()).isDir()){ + QProcess::startDetached("rm -r \""+button->whatsThis()+"\""); + }else{ + QFile::remove(button->whatsThis()); + } +}
\ No newline at end of file diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h index 2c861e4d..fdb4e8f4 100644 --- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h +++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.h @@ -41,6 +41,7 @@ private slots: void increaseIconSize(); void decreaseIconSize(); + void deleteFile(); }; #endif diff --git a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp index b2ed3d03..cc1136f1 100644 --- a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp +++ b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp @@ -256,7 +256,7 @@ void PlayerWidget::updateMaxProgress(qint64 val){ } -AudioPlayerPlugin::AudioPlayerPlugin(QWidget *parent, QString ID) : LDPlugin(parent, ID, true){ +AudioPlayerPlugin::AudioPlayerPlugin(QWidget *parent, QString ID) : LDPlugin(parent, ID){ player = new PlayerWidget(this); this->setLayout( new QVBoxLayout() ); this->layout()->setContentsMargins(0,0,0,0); diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp index 991abf2e..81f1281b 100644 --- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp +++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.cpp @@ -21,7 +21,7 @@ DesktopViewPlugin::DesktopViewPlugin(QWidget* parent, QString ID) : LDPlugin(par list->setSpacing(2); list->setSelectionBehavior(QAbstractItemView::SelectItems); list->setSelectionMode(QAbstractItemView::ExtendedSelection); - //int icosize = settings->value("IconSize",64).toInt(); + //int icosize = this->readSetting("IconSize",64).toInt(); //list->setIconSize(QSize(icosize,icosize)); //list->setUniformItemSizes(true); list->setContextMenuPolicy(Qt::CustomContextMenu); @@ -42,10 +42,8 @@ DesktopViewPlugin::DesktopViewPlugin(QWidget* parent, QString ID) : LDPlugin(par } this->layout()->addWidget(list); this->setInitialSize(600,600); - watcher = new QFileSystemWatcher(this); - watcher->addPath(QDir::homePath()+"/Desktop"); - connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(updateContents()) ); - + + connect(QApplication::instance(), SIGNAL(DesktopFilesChanged()), this, SLOT(updateContents()) ); connect(list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(runItems()) ); connect(list, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showMenu(const QPoint&)) ); QTimer::singleShot(0,this, SLOT(updateContents()) ); @@ -116,21 +114,19 @@ void DesktopViewPlugin::showMenu(const QPoint &pos){ } void DesktopViewPlugin::increaseIconSize(){ - int icosize = settings->value("IconSize",64).toInt(); + int icosize = this->readSetting("IconSize",64).toInt(); icosize+=16; //go in orders of 16 pixels //list->setIconSize(QSize(icosize,icosize)); - settings->setValue("IconSize",icosize); - settings->sync(); + this->saveSetting("IconSize",icosize); updateContents(); } void DesktopViewPlugin::decreaseIconSize(){ - int icosize = settings->value("IconSize",64).toInt(); + int icosize = this->readSetting("IconSize",64).toInt(); if(icosize < 20){ return; } //too small to decrease more icosize-=16; //go in orders of 16 pixels //list->setIconSize(QSize(icosize,icosize)); - settings->setValue("IconSize",icosize); - settings->sync(); + this->saveSetting("IconSize",icosize); updateContents(); } @@ -140,7 +136,7 @@ void DesktopViewPlugin::updateContents(){ QList<QByteArray> fmt = QImageReader::supportedImageFormats(); for(int i=0; i<fmt.length(); i++){ imgExtensions << QString::fromLocal8Bit(fmt[i]); } }*/ - int icosize = settings->value("IconSize",64).toInt(); + int icosize = this->readSetting("IconSize",64).toInt(); QSize gridSZ = QSize(icosize+8,icosize+4+(2*this->fontMetrics().height()) ); //qDebug() << "Icon Size:" << icosize <<"Grid Size:" << gridSZ.width() << gridSZ.height(); list->setGridSize(gridSZ); diff --git a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h index d8f217f0..7a2d327b 100644 --- a/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h +++ b/lumina-desktop/desktop-plugins/desktopview/DesktopViewPlugin.h @@ -25,7 +25,7 @@ public: private: QListWidget *list; - QFileSystemWatcher *watcher; + //QFileSystemWatcher *watcher; QMenu *menu; //QStringList imgExtensions; diff --git a/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp b/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp index dacaca60..7d9076c7 100644 --- a/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp +++ b/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp @@ -7,7 +7,8 @@ #include <QFileDialog> #include <QInputDialog> -NotePadPlugin::NotePadPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID, true){ +NotePadPlugin::NotePadPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID){ + //qDebug() << "Creating Notepad Plugin:"; QVBoxLayout *vlay = new QVBoxLayout(); this->setLayout( new QVBoxLayout() ); this->layout()->setContentsMargins(0,0,0,0); @@ -54,34 +55,16 @@ NotePadPlugin::NotePadPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID, edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); vlay->addWidget(edit); - //Special detection of the old notes format and conversion to the new files format - if( this->settings->value("availableNotes",-1).toInt() > 0){ - qDebug() << "Converting all old desktop notes into the new file-based format (located at ~/Notes/<name>.note)"; - int notes = this->settings->value("availableNotes",1).toInt(); - int current = settings->value("currentNote",1).toInt(); - for(int i=0; i<(notes+1); i++){ - QString note = settings->value("Note-"+QString::number(i),"").toString(); - settings->remove("Note-"+QString::number(i)); - if(!note.isEmpty()){ - //Save this note in the new file format - LUtils::writeFile(QDir::homePath()+"/Notes/Note-"+QString::number(i)+".note", note.split("\n"), true); - } - if(i==current){ - //Convert the current note value to the new format - settings->setValue("currentFile", QDir::homePath()+"/Notes/Note-"+QString::number(i)+".note"); - } - } - //Clear the old settings-based values - settings->remove("availableNotes"); - settings->remove("currentNote"); - } //Now load the new file-based system for saving notes - settings->setValue("customFile",""); //always clear this when the plugin is initialized (only maintained per-session) + //qDebug() << "Saving a new setting"; + this->saveSetting("customFile",""); //always clear this when the plugin is initialized (only maintained per-session) + //qDebug() << "Loading Notes Dir"; notesDirChanged(); + //qDebug() << "Set Sizing"; //Now setup the initial values for the plugin this->setInitialSize(200,300); - + //qDebug() << "Connect Signals/slots"; //Setup the button connections connect(open, SIGNAL(clicked()), this, SLOT(openNote()) ); connect(add, SIGNAL(clicked()), this, SLOT(newNote()) ); @@ -92,7 +75,7 @@ NotePadPlugin::NotePadPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID, connect(watcher, SIGNAL(directoryChanged(QString)), this, SLOT(notesDirChanged()) ); //re-load the available notes connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT(noteChanged()) ); //re-load the current file QTimer::singleShot(0,this, SLOT(loadIcons()) ); - + //qDebug() << " - Done with init"; } NotePadPlugin::~NotePadPlugin(){ @@ -133,7 +116,7 @@ void NotePadPlugin::openNote(){ }else{ //New note - add it to the end of the list and then load it cnote->addItem(name, fullpath); - settings->setValue("customFile", fullpath); //save this as a custom file + this->saveSetting("customFile", fullpath); //save this as a custom file cnote->setCurrentIndex( cnote->count()-1 ); QTimer::singleShot(1000, this, SLOT(notesDirChanged())); //Make sure to refresh the list (only one custom file at a time) } @@ -179,7 +162,7 @@ void NotePadPlugin::remNote(){ QString note = cnote->currentData().toString(); if(note.isEmpty()){ return; } watcher->removePath(note); //remove this file from the watcher - settings->setValue("currentFile",""); //reset the internal value + this->saveSetting("currentFile",""); //reset the internal value QFile::remove(note); //remove the file //if(!note.startsWith(QDir::homePath()+"/Notes/") ){ //If the file was not in the notes directory, need to manually prompt for a re-load @@ -206,14 +189,14 @@ void NotePadPlugin::updateContents(){ void NotePadPlugin::notesDirChanged(){ if(updating){ return; } - QString cfile = settings->value("currentFile","").toString(); + QString cfile = this->readSetting("currentFile","").toString(); QStringList notes; QDir dir(QDir::homePath()+"/Notes"); QStringList files = dir.entryList(QStringList() << "*.note", QDir::Files | QDir::NoDotAndDotDot, QDir::Name); for(int i=0; i<files.length(); i++){ notes << dir.absoluteFilePath(files[i]); } - QString custom = settings->value("customFile","").toString(); + QString custom = this->readSetting("customFile","").toString(); if(!custom.isEmpty() && QFile::exists(custom) ){ notes << custom; } //qDebug() << "Available Notes:" << notes << cfile; //Now update the UI list @@ -249,16 +232,16 @@ void NotePadPlugin::noteChanged(){ cnote->setCurrentIndex(0); return; } - QString oldnote = settings->value("currentFile","").toString(); + QString oldnote = this->readSetting("currentFile","").toString(); //qDebug() << "Note Changed:" << note << oldnote; if( oldnote!=note ){ //Clear the old note file/setting if(!oldnote.isEmpty()){ watcher->removePath(oldnote); - settings->setValue("currentFile",""); + this->saveSetting("currentFile",""); } if(!note.isEmpty()){ - settings->setValue("currentFile",note); + this->saveSetting("currentFile",note); watcher->addPath(note); } } diff --git a/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp index 0d568a45..981e411d 100644 --- a/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp +++ b/lumina-desktop/desktop-plugins/systemmonitor/MonitorWidget.cpp @@ -49,7 +49,7 @@ void MonitorWidget::UpdateStats(){ // -- TO DO -- } -SysMonitorPlugin::SysMonitorPlugin(QWidget *parent, QString ID) : LDPlugin(parent, ID, true){ +SysMonitorPlugin::SysMonitorPlugin(QWidget *parent, QString ID) : LDPlugin(parent, ID){ monitor = new MonitorWidget(this); this->setLayout( new QVBoxLayout() ); this->layout()->setContentsMargins(0,0,0,0); |