diff options
Diffstat (limited to 'lumina-desktop/desktop-plugins')
-rw-r--r-- | lumina-desktop/desktop-plugins/LDPlugin.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/LDPluginContainer.h | 13 | ||||
-rw-r--r-- | lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp | 20 |
3 files changed, 24 insertions, 11 deletions
diff --git a/lumina-desktop/desktop-plugins/LDPlugin.cpp b/lumina-desktop/desktop-plugins/LDPlugin.cpp index f7be148d..9e9cfeba 100644 --- a/lumina-desktop/desktop-plugins/LDPlugin.cpp +++ b/lumina-desktop/desktop-plugins/LDPlugin.cpp @@ -20,7 +20,7 @@ LDPlugin::LDPlugin(QWidget *parent, QString id) : QFrame(parent){ 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()){ + if(settings->allKeys().filter(prefix+"location").isEmpty()){ //Brand new plugin: set initial size settings->setValue(prefix+"location/width",width); settings->setValue(prefix+"location/height",height); diff --git a/lumina-desktop/desktop-plugins/LDPluginContainer.h b/lumina-desktop/desktop-plugins/LDPluginContainer.h index 0e570e26..c4d4c9fc 100644 --- a/lumina-desktop/desktop-plugins/LDPluginContainer.h +++ b/lumina-desktop/desktop-plugins/LDPluginContainer.h @@ -50,32 +50,35 @@ public: 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::CustomizeWindowHint); }//Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); } this->setContentsMargins(0,0,0,0); if(!locked){ + this->setStyleSheet("LDPluginContainer{ border-size: 1px;}"); this->setWindowTitle( plugin->ID().replace("---"," - ") ); - this->setWidget( new QWidget() ); + //this->setWidget( new QWidget() ); this->setWidget( plugin ); - this->setWindowIcon(QIcon()); //remove the Qt icon + //this->setWindowIcon(QIcon()); //remove the Qt icon }else{ this->setStyleSheet("LDPluginContainer{ background: transparent; border: none;}"); this->setWidget(plugin); } + //qDebug() << "New Container:" << PLUG->size() << PLUG->sizeHint(); } ~LDPluginContainer(){ } void loadInitialPosition(){ - 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()); + QRect set(PLUG->readSetting("location/x",-12345).toInt(), PLUG->readSetting("location/y",-12345).toInt(), PLUG->readSetting("location/width",this->widget()->size().width()).toInt(), PLUG->readSetting("location/height",this->widget()->size().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 if(set.x()!=-12345 && set.y()!=-12345){ //custom location specified + //qDebug() << " - Found Geom:" << set; this->setGeometry(set); + //this->move(set.x(), set.y()); }else{ + //qDebug() << " - Found Size:" << set; this->resize(set.width(), set.height()); } setup=false; //done with setup diff --git a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp index 4dee95ca..447f959b 100644 --- a/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp +++ b/lumina-desktop/desktop-plugins/applauncher/AppLauncherPlugin.cpp @@ -13,12 +13,19 @@ 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); - int icosize = this->readSetting("iconsize",64).toInt(); - button->setIconSize(QSize(icosize,icosize)); + 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()) ); watcher = new QFileSystemWatcher(this); connect(watcher, SIGNAL(fileChanged(QString)), this, SLOT( loadButton()) ); + //Calculate the initial size of the button + this->setInitialSize(icosize+8, icosize+8+qRound(2.2*button->fontMetrics().height())); + QTimer::singleShot(1,this, SLOT(loadButton()) ); } @@ -73,7 +80,10 @@ void AppLauncherPlugin::loadButton(){ 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); } + 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, icosize); } + } txt = txtL.join("\n"); }else{ txt = this->fontMetrics().elidedText(txt,Qt::ElideRight, 2*icosize); @@ -91,8 +101,8 @@ void AppLauncherPlugin::loadButton(){ 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); + button->setFixedSize(icosize+4, icosize+8+qRound(2.1*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 } |