diff options
author | Ken Moore <ken@pcbsd.org> | 2015-06-20 10:35:33 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-06-20 10:35:33 -0400 |
commit | a439cc018cb2d22885521aa9ce56c83797f6600c (patch) | |
tree | 602106a1c9a48c0868113b0e412b6eebd2dc609f /lumina-desktop | |
parent | Merge branch 'master' of github.com:pcbsd/lumina (diff) | |
download | lumina-a439cc018cb2d22885521aa9ce56c83797f6600c.tar.gz lumina-a439cc018cb2d22885521aa9ce56c83797f6600c.tar.bz2 lumina-a439cc018cb2d22885521aa9ce56c83797f6600c.zip |
Clean up the desktop plugin/container interactions quite a bit to ensure consistency and proper size calculations (especially for new plugins).
Diffstat (limited to 'lumina-desktop')
-rw-r--r-- | lumina-desktop/LDesktop.cpp | 14 | ||||
-rw-r--r-- | lumina-desktop/LSession.cpp | 1 | ||||
-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 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserWidget.cpp | 6 |
6 files changed, 40 insertions, 16 deletions
diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp index 5e359df7..76130b00 100644 --- a/lumina-desktop/LDesktop.cpp +++ b/lumina-desktop/LDesktop.cpp @@ -186,12 +186,15 @@ void LDesktop::CreateDesktopPluginContainer(LDPlugin *plug){ } //Create a new plugin container LDPluginContainer *win = new LDPluginContainer(plug, desktoplocked); - if(desktoplocked){ bgDesktop->addSubWindow(win, Qt::FramelessWindowHint); } - else{ bgDesktop->addSubWindow(win, Qt::CustomizeWindowHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); } - win->adjustSize(); + if(desktoplocked){ + bgDesktop->addSubWindow(win, Qt::FramelessWindowHint); + }else{ bgDesktop->addSubWindow(win, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); } + //win->adjustSize(); win->loadInitialPosition(); win->show(); win->update(); + bgDesktop->update(); + QApplication::processEvents(); connect(win, SIGNAL(PluginRemoved(QString)), this, SLOT(DesktopPluginRemoved(QString)) ); } @@ -296,6 +299,8 @@ void LDesktop::UpdateMenu(bool fast){ if(!desktoplocked){ deskMenu->addAction(LXDG::findIcon("document-encrypt",""),tr("Lock Desktop"), this, SLOT(ToggleDesktopLock()) ); deskMenu->addAction(LXDG::findIcon("snap-orthogonal",""),tr("Snap Plugins to Grid"), this, SLOT(AlignDesktopPlugins()) ); + deskMenu->addAction(LXDG::findIcon("shapes",""), tr("Tile Plugins"), bgDesktop, SLOT(tileSubWindows()) ); + deskMenu->addAction(LXDG::findIcon("window-duplicate",""), tr("Cascade Plugins"), bgDesktop, SLOT(cascadeSubWindows()) ); }else{ deskMenu->addAction(LXDG::findIcon("document-decrypt",""),tr("Unlock Desktop"), this, SLOT(ToggleDesktopLock()) ); } deskMenu->addSeparator(); deskMenu->addAction(LXDG::findIcon("system-log-out",""), tr("Log Out"), this, SLOT(SystemLogout()) ); @@ -321,7 +326,6 @@ void LDesktop::winClicked(QAction* act){ void LDesktop::UpdateDesktop(){ if(DEBUG){ qDebug() << " - Update Desktop Plugins for screen:" << desktopnumber; } QStringList plugins = settings->value(DPREFIX+"pluginlist", QStringList()).toStringList(); - if(defaultdesktop && plugins.isEmpty()){ //plugins << "sample" << "sample" << "sample"; } @@ -379,10 +383,12 @@ void LDesktop::UpdateDesktop(){ connect(plug, SIGNAL(OpenDesktopMenu()), this, SLOT(ShowMenu()) ); if(DEBUG){ qDebug() << " -- Show Plugin"; } PLUGINS << plug; + QApplication::processEvents(); //need a moment between plugin/container creation CreateDesktopPluginContainer(plug); if(DEBUG){ qDebug() << " -- Done Creating Plugin Container"; } } } + QApplication::processEvents(); //need to process events between loading of plugins } } diff --git a/lumina-desktop/LSession.cpp b/lumina-desktop/LSession.cpp index 90be178b..29e1d237 100644 --- a/lumina-desktop/LSession.cpp +++ b/lumina-desktop/LSession.cpp @@ -331,6 +331,7 @@ void LSession::watcherChange(QString changed){ else if(changed.endsWith("desktopsettings.conf") ){ emit DesktopConfigChanged(); } else if(changed == QDir::homePath()+"/Desktop"){ desktopFiles = QDir(QDir::homePath()+"/Desktop").entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs ,QDir::Name | QDir::IgnoreCase | QDir::DirsFirst); + if(DEBUG){ qDebug() << "New Desktop Files:" << desktopFiles.length(); } emit DesktopFilesChanged(); } //Now double-check all the watches files to ensure that none of them got removed 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 } diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp index bae14b5a..2c85caab 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp @@ -172,6 +172,7 @@ void UserWidget::FavChanged(){ } void UserWidget::updateFavItems(bool newfilter){ + //qDebug() << "Updating User Favorite Items"; QStringList newfavs = LUtils::listFavorites(); //qDebug() << "Favorites:" << newfavs; if(lastHomeUpdate.isNull() || (QFileInfo(QDir::homePath()+"/Desktop").lastModified() > lastHomeUpdate) || newfavs!=favs ){ @@ -180,6 +181,7 @@ void UserWidget::updateFavItems(bool newfilter){ homefiles = LSession::handle()->DesktopFiles(); lastHomeUpdate = QDateTime::currentDateTime(); }else if(!newfilter){ return; } //nothing new to change - stop now + //qDebug() << " - Passed Smoke Test..."; QStringList favitems; //Remember for format for favorites: <name>::::[app/dir/<mimetype>]::::<full path> if(ui->tool_fav_apps->isChecked()){ @@ -211,7 +213,9 @@ void UserWidget::updateFavItems(bool newfilter){ } } ClearScrollArea(ui->scroll_fav); + //qDebug() << " - Sorting Items"; favitems.sort(); //sort them alphabetically + //qDebug() << " - Creating Items:" << favitems; for(int i=0; i<favitems.length(); i++){ UserItemWidget *it = new UserItemWidget(ui->scroll_fav->widget(), favitems[i].section("::::",2,50), favitems[i].section("::::",1,1) ); ui->scroll_fav->widget()->layout()->addWidget(it); @@ -220,7 +224,7 @@ void UserWidget::updateFavItems(bool newfilter){ connect(it, SIGNAL(RemovedShortcut()), this, SLOT(updateFavItems()) ); } static_cast<QBoxLayout*>(ui->scroll_fav->widget()->layout())->addStretch(); - + //qDebug() << " - Done"; } //Apps Tab |