aboutsummaryrefslogtreecommitdiff
path: root/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
diff options
context:
space:
mode:
authorKen Moore <moorekou@gmail.com>2015-10-07 11:11:59 -0400
committerKen Moore <moorekou@gmail.com>2015-10-07 11:11:59 -0400
commit8c693c2ef0f7a33f9f9970c342e23e9a5823468a (patch)
tree47cb61f2d7e897f14134a33d039cb260d78a602f /lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
parentClean up the quicklaunch buttons a bit more - also add a context menu for rem... (diff)
downloadlumina-8c693c2ef0f7a33f9f9970c342e23e9a5823468a.tar.gz
lumina-8c693c2ef0f7a33f9f9970c342e23e9a5823468a.tar.bz2
lumina-8c693c2ef0f7a33f9f9970c342e23e9a5823468a.zip
Commit the 3rd iteration of the desktop plugin container system.
- Now the desktop plugins are drag-and-drop based, resulting in the user being able to simply drag the plugins around as necessry. - All the plugins now have a special context menu (right-click, or click and hold the left mouse button for 1/2 second), which provides options to start moving/resizing the plugin as well as the removal option. Known Issues: - The cross-application drop event for files is currently flagged as valid - but does not actually run anything yet (to be finished up soon) - Hidden panels are not being updated when plugins are moved around yet - resulting in some screen artifacting on the panel. (to be fixed soon)
Diffstat (limited to 'lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp')
-rw-r--r--lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp58
1 files changed, 31 insertions, 27 deletions
diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
index ae454511..3acb83fb 100644
--- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
+++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp
@@ -9,42 +9,46 @@ AppLauncherPlugin::AppLauncherPlugin(QWidget* parent, QString ID) : LDPlugin(par
button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
button->setAutoRaise(true);
button->setText("...\n..."); //Need to set something here so that initial sizing works properly
-
+ button->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
lay->addWidget(button, 0, Qt::AlignCenter);
connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()) );
- menu = new QMenu(this);
- int icosize = this->readSetting("iconsize",-1).toInt();
+ //menu = new QMenu(this);
+ /*int icosize = this->readSetting("iconsize",-1).toInt();
if(icosize <1){
icosize = LSession::handle()->sessionSettings()->value("DefaultIconSize",64).toInt();
this->saveSetting("iconsize",icosize);
- }
- button->setIconSize(QSize(icosize,icosize));
- this->setContextMenuPolicy(Qt::CustomContextMenu);
- connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(openContextMenu()) );
+ }*/
+ //int icosize
+ //button->setIconSize(QSize(icosize,icosize));
+ button->setContextMenuPolicy(Qt::NoContextMenu);
+ //connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(openContextMenu()) );
watcher = new QFileSystemWatcher(this);
connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT( loadButton()) );
//Calculate the initial size of the button
//qDebug() << "Button Size:" << button->size();
//qDebug() << "Calculated:" << icosize+4 << icosize+8+qRound(2.15*button->fontMetrics().height());
//qDebug() << "Preferred Size:" << button->sizeHint();
- QSize sz(qRound(1.1*icosize), icosize+qRound(2.7*button->fontMetrics().height()) );
- button->setFixedSize(sz); //make sure to adjust the button on first show.
- this->setInitialSize(this->sizeHint().width()+2, this->sizeHint().height()+2); //give the container a bit of a buffer
+ //QSize sz(qRound(1.1*icosize), icosize+qRound(2.7*button->fontMetrics().height()) );
+ //button->setFixedSize(sz); //make sure to adjust the button on first show.
+ this->setInitialSize(120, 100); //give the container a bit of a buffer
QTimer::singleShot(100,this, SLOT(loadButton()) );
}
void AppLauncherPlugin::Cleanup(){
//This is run only when the plugin was forcibly closed/removed
- if(QFile::exists(button->whatsThis()) && button->whatsThis().startsWith(QDir::homePath()+"/Desktop") ){
+ /*if(QFile::exists(button->whatsThis()) && button->whatsThis().startsWith(QDir::homePath()+"/Desktop") ){
deleteFile();
- }
+ }*/
}
-void AppLauncherPlugin::loadButton(bool onchange){
+void AppLauncherPlugin::loadButton(){
QString def = this->ID().section("::",1,50).section("---",0,0).simplified();
QString path = this->readSetting("applicationpath",def).toString(); //use the default if necessary
//qDebug() << "Default Application Launcher:" << def << path;
bool ok = QFile::exists(path);
+ int icosize = this->width()/1.8; //This is the same calculation as in the LDesktopPluginSpace
+ button->setFixedSize( this->width()-4, this->height()-4);
+ button->setIconSize( QSize(icosize,icosize) );
QString txt;
if(path.endsWith(".desktop") && ok){
XDGDesktop file = LXDG::loadDesktopFile(path, ok);
@@ -82,12 +86,12 @@ void AppLauncherPlugin::loadButton(bool onchange){
}
//Now adjust the visible text as necessary based on font/grid sizing
button->setToolTip(txt);
- int icosize = this->readSetting("iconsize",64).toInt();
- int bwid = qRound(1.1*icosize);
- this->setFixedSize(bwid, icosize+qRound(2.5*button->fontMetrics().height()) ); //make sure to adjust the button on first show.
- if(onchange){ this->adjustSize( bwid+4, icosize+8+qRound(2.5*button->fontMetrics().height())); }
+ //int icosize = this->readSetting("iconsize",64).toInt();
+ //int bwid = qRound(1.1*icosize);
+ //this->setFixedSize(bwid, icosize+qRound(2.5*button->fontMetrics().height()) ); //make sure to adjust the button on first show.
+ //if(onchange){ this->adjustSize( bwid+4, icosize+8+qRound(2.5*button->fontMetrics().height())); }
//qDebug() << "Initial Button Text:" << txt << icosize;
- if(button->fontMetrics().width(txt) > (bwid-2) ){
+ if(button->fontMetrics().width(txt) > (button->width()-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
@@ -96,11 +100,11 @@ void AppLauncherPlugin::loadButton(bool onchange){
QStringList txtL = txt.split("\n");
for(int i=0; i<txtL.length(); i++){
if(i>1){ txtL.removeAt(i); i--; } //Only take the first two lines
- else{ txtL[i] = button->fontMetrics().elidedText(txtL[i], Qt::ElideRight, bwid-2); }
+ else{ txtL[i] = button->fontMetrics().elidedText(txtL[i], Qt::ElideRight, (button->width()-2) ); }
}
txt = txtL.join("\n");
}else{
- txt = this->fontMetrics().elidedText(txt,Qt::ElideRight, 2*bwid -4);
+ txt = this->fontMetrics().elidedText(txt,Qt::ElideRight, 2*button->width() -4);
//Now split the line in half for the two lines
txt.insert( (txt.count()/2), "\n");
}
@@ -109,12 +113,12 @@ void AppLauncherPlugin::loadButton(bool onchange){
//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->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()) );
- }
+ }*/
QTimer::singleShot(100, this, SLOT(update()) ); //Make sure to re-draw the image in a moment
}
@@ -137,15 +141,15 @@ void AppLauncherPlugin::buttonClicked(){
}
-void AppLauncherPlugin::openContextMenu(){
+/*void AppLauncherPlugin::openContextMenu(){
if(button->underMouse()){
menu->popup(QCursor::pos());
}else{
emit OpenDesktopMenu();
}
-}
+}*/
-void AppLauncherPlugin::increaseIconSize(){
+/*void AppLauncherPlugin::increaseIconSize(){
int icosize = this->readSetting("iconsize",64).toInt();
icosize += 16;
button->setIconSize(QSize(icosize,icosize));
@@ -169,4 +173,4 @@ void AppLauncherPlugin::deleteFile(){
}else{
QFile::remove(button->whatsThis());
}
-} \ No newline at end of file
+}*/ \ No newline at end of file
bgstack15