diff options
-rw-r--r-- | libLumina/LuminaUtils.cpp | 26 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemstart/LStartButton.cpp | 16 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemstart/LStartButton.h | 1 |
3 files changed, 26 insertions, 17 deletions
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index 699f55fc..9a09ddf9 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -747,36 +747,38 @@ void ResizeMenu::mouseMoveEvent(QMouseEvent *ev){ QRect geom = this->geometry(); //Note: The exact position does not matter as much as the size // since the window will be moved again the next time it is shown + // The "-2" in the sizing below accounts for the menu margins switch(resizeSide){ case TOP: geom.setTop(ev->pos().y()); - if(contents!=0){ contents->setFixedSize(geom.size()); } + this->setGeometry(geom); + if(contents!=0){ contents->setFixedSize(QSize(geom.width()-2, geom.height()-2)); } break; case BOTTOM: geom.setBottom(ev->pos().y()); this->setGeometry(geom); - if(contents!=0){ contents->setFixedSize(geom.size()); } + if(contents!=0){ contents->setFixedSize(QSize(geom.width()-2, geom.height()-2)); } break; case LEFT: geom.setLeft(ev->pos().x()); this->setGeometry(geom); - if(contents!=0){ contents->setFixedSize(geom.size()); } + if(contents!=0){ contents->setFixedSize(QSize(geom.width()-2, geom.height()-2)); } break; case RIGHT: geom.setRight(ev->pos().x()); this->setGeometry(geom); - if(contents!=0){ contents->setFixedSize(geom.size()); } + if(contents!=0){ contents->setFixedSize(QSize(geom.width()-2, geom.height()-2)); } break; default: //NONE qDebug() << " - Mouse At:" << ev->pos(); //Just adjust the mouse cursor which is shown - if(ev->pos().x()==0){ this->setCursor(Qt::SizeHorCursor); } - else if(ev->pos().x() == this->width()){ this->setCursor(Qt::SizeHorCursor); } - else if(ev->pos().y()==0){ this->setCursor(Qt::SizeVerCursor); } - else if(ev->pos().y() == this->height()){ this->setCursor(Qt::SizeVerCursor); } + if(ev->pos().x()<=1 && ev->pos().x() >= -1){ this->setCursor(Qt::SizeHorCursor); } + else if(ev->pos().x() >= this->width()-1 && ev->pos().x() <= this->width()+1){ this->setCursor(Qt::SizeHorCursor); } + else if(ev->pos().y()<=1 && ev->pos().y() >= -1){ this->setCursor(Qt::SizeVerCursor); } + else if(ev->pos().y() >= this->height()-1 && ev->pos().y() <= this->height()+1){ this->setCursor(Qt::SizeVerCursor); } else{ this->setCursor(Qt::ArrowCursor); } } - QWidget::mouseMoveEvent(ev); //do normal processing as well + QMenu::mouseMoveEvent(ev); //do normal processing as well } void ResizeMenu::mousePressEvent(QMouseEvent *ev){ @@ -789,16 +791,16 @@ void ResizeMenu::mousePressEvent(QMouseEvent *ev){ else if(ev->pos().y() >= this->height()-1 && ev->pos().y() <= this->height()+1){ resizeSide = BOTTOM; used = true; } } if(used){ ev->accept(); } - else{ QWidget::mousePressEvent(ev); } //do normal processing + else{ QMenu::mousePressEvent(ev); } //do normal processing } void ResizeMenu::mouseReleaseEvent(QMouseEvent *ev){ if(ev->button() == Qt::LeftButton && resizeSide!=NONE ){ //qDebug() << "Mouse Release Event:" << ev->pos() << resizeSide; resizeSide = NONE; - emit MenuResized(this->size()); + emit MenuResized(contents->size()); ev->accept(); }else{ - QWidget::mouseReleaseEvent(ev); //do normal processing + QMenu::mouseReleaseEvent(ev); //do normal processing } }
\ No newline at end of file diff --git a/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp b/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp index 3e644803..cf37cf88 100644 --- a/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp +++ b/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp @@ -8,7 +8,7 @@ #include "../../LSession.h" #include <LuminaXDG.h> -#include <LuminaUtils.h> +#include <LuminaUtils.h> //This contains the "ResizeMenu" class LStartButtonPlugin::LStartButtonPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ button = new QToolButton(this); @@ -21,14 +21,14 @@ LStartButtonPlugin::LStartButtonPlugin(QWidget *parent, QString id, bool horizon menu = new ResizeMenu(this); menu->setContentsMargins(1,1,1,1); connect(menu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); + connect(menu, SIGNAL(MenuResized(QSize)), this, SLOT(SaveMenuSize(QSize)) ); startmenu = new StartMenu(this); connect(startmenu, SIGNAL(CloseMenu()), this, SLOT(closeMenu()) ); connect(startmenu, SIGNAL(UpdateQuickLaunch(QStringList)), this, SLOT(updateQuickLaunch(QStringList))); menu->setContents(startmenu); - /*mact = new QWidgetAction(this); - mact->setDefaultWidget(startmenu); - menu->addAction(mact);*/ - + QSize saved = LSession::handle()->DesktopPluginSettings()->value("panelPlugs/"+this->type()+"/MenuSize", QSize(0,0)).toSize(); + if(!saved.isNull()){ startmenu->setFixedSize(saved); } //re-load the previously saved value + button->setMenu(menu); connect(menu, SIGNAL(aboutToHide()), this, SLOT(updateButtonVisuals()) ); QTimer::singleShot(0,this, SLOT(OrientationChange())); //Update icons/sizes @@ -100,10 +100,16 @@ void LStartButtonPlugin::RemoveQuick(QString file){ } } +void LStartButtonPlugin::SaveMenuSize(QSize sz){ + //Save this size for the menu + LSession::handle()->DesktopPluginSettings()->setValue("panelPlugs/"+this->type()+"/MenuSize", sz); +} + // ======================== // PRIVATE FUNCTIONS // ======================== void LStartButtonPlugin::openMenu(){ + if(menu->isVisible()){ return; } //don't re-show it - already open startmenu->UpdateMenu(); button->showMenu(); } diff --git a/lumina-desktop/panel-plugins/systemstart/LStartButton.h b/lumina-desktop/panel-plugins/systemstart/LStartButton.h index ac9ad59b..f549b8d2 100644 --- a/lumina-desktop/panel-plugins/systemstart/LStartButton.h +++ b/lumina-desktop/panel-plugins/systemstart/LStartButton.h @@ -80,6 +80,7 @@ private slots: void updateQuickLaunch(QStringList); void LaunchQuick(QString); void RemoveQuick(QString); + void SaveMenuSize(QSize); public slots: void OrientationChange(){ |