diff options
-rw-r--r-- | libLumina/LuminaUtils.cpp | 84 | ||||
-rw-r--r-- | libLumina/LuminaUtils.h | 36 | ||||
-rw-r--r-- | libLumina/LuminaXDG.cpp | 1 | ||||
-rw-r--r-- | lumina-desktop/LDesktop.cpp | 6 | ||||
-rw-r--r-- | lumina-desktop/LPanel.cpp | 2 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/clock/LClock.cpp | 3 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemstart/LStartButton.cpp | 8 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemstart/LStartButton.h | 7 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemstart/StartMenu.cpp | 1 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemstart/StartMenu.h | 1 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemstart/StartMenu.ui | 16 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemtray/LSysTray.cpp | 6 | ||||
-rw-r--r-- | lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp | 10 |
13 files changed, 155 insertions, 26 deletions
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp index 5f2de8b3..699f55fc 100644 --- a/libLumina/LuminaUtils.cpp +++ b/libLumina/LuminaUtils.cpp @@ -718,3 +718,87 @@ void LUtils::LoadSystemDefaults(bool skipOS){ LUtils::writeFile(setdir+"/desktopsettings.conf", deskset, true); LUtils::writeFile(setdir+"/lumina-open.conf", lopenset, true); } + +// ======================= +// RESIZEMENU CLASS +// ======================= +ResizeMenu::ResizeMenu(QWidget *parent) : QMenu(parent){ + this->setContentsMargins(1,1,1,1); + resizeSide = NONE; + cAct = new QWidgetAction(this); + contents = 0; + connect(this, SIGNAL(aboutToShow()), this, SLOT(clearFlags()) ); + connect(this, SIGNAL(aboutToHide()), this, SLOT(clearFlags()) ); +} + +ResizeMenu::~ResizeMenu(){ + +} + +void ResizeMenu::setContents(QWidget *con){ + this->clear(); + cAct->setDefaultWidget(con); + this->addAction(cAct); + contents = con; //save for later + contents->setCursor(Qt::ArrowCursor); +} + +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 + switch(resizeSide){ + case TOP: + geom.setTop(ev->pos().y()); + if(contents!=0){ contents->setFixedSize(geom.size()); } + break; + case BOTTOM: + geom.setBottom(ev->pos().y()); + this->setGeometry(geom); + if(contents!=0){ contents->setFixedSize(geom.size()); } + break; + case LEFT: + geom.setLeft(ev->pos().x()); + this->setGeometry(geom); + if(contents!=0){ contents->setFixedSize(geom.size()); } + break; + case RIGHT: + geom.setRight(ev->pos().x()); + this->setGeometry(geom); + if(contents!=0){ contents->setFixedSize(geom.size()); } + 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); } + else{ this->setCursor(Qt::ArrowCursor); } + } + QWidget::mouseMoveEvent(ev); //do normal processing as well +} + +void ResizeMenu::mousePressEvent(QMouseEvent *ev){ + bool used = false; + if(ev->buttons().testFlag(Qt::LeftButton) && resizeSide==NONE){ + //qDebug() << "Mouse Press Event:" << ev->pos() << resizeSide; + if(ev->pos().x()<=1 && ev->pos().x() >= -1){resizeSide = LEFT; used = true;} + else if(ev->pos().x() >= this->width()-1 && ev->pos().x() <= this->width()+1){ resizeSide = RIGHT; used = true;} + else if(ev->pos().y()<=1 && ev->pos().y() >= -1){ resizeSide = TOP; used = true; } + 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 +} + +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()); + ev->accept(); + }else{ + QWidget::mouseReleaseEvent(ev); //do normal processing + } +}
\ No newline at end of file diff --git a/libLumina/LuminaUtils.h b/libLumina/LuminaUtils.h index 3ab741a0..bbb40c38 100644 --- a/libLumina/LuminaUtils.h +++ b/libLumina/LuminaUtils.h @@ -19,6 +19,10 @@ #include <QObject> #include <QTranslator> #include <QApplication> +#include <QMenu> +#include <QMouseEvent> +#include <QSize> +#include <QWidgetAction> class LUtils{ public: @@ -87,4 +91,36 @@ public: }; +//Special subclass for a menu which the user can grab the edges and resize as necessary +// Note: Make sure that you don't set 0pixel contents margins on this menu +// - it needs at least 1 pixel margins for the user to be able to grab it +class ResizeMenu : public QMenu{ + Q_OBJECT +public: + ResizeMenu(QWidget *parent = 0); + virtual ~ResizeMenu(); + + void setContents(QWidget *con); + +private: + enum SideFlag{NONE, TOP, BOTTOM, LEFT, RIGHT}; + SideFlag resizeSide; + QWidget *contents; + QWidgetAction *cAct; + +private slots: + void clearFlags(){ + resizeSide=NONE; + } + +protected: + virtual void mouseMoveEvent(QMouseEvent *ev); + virtual void mousePressEvent(QMouseEvent *ev); + virtual void mouseReleaseEvent(QMouseEvent *ev); + +signals: + void MenuResized(QSize); //Emitted when the menu is manually resized by the user + +}; + #endif diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp index 15cd47fe..3fe533a5 100644 --- a/libLumina/LuminaXDG.cpp +++ b/libLumina/LuminaXDG.cpp @@ -421,6 +421,7 @@ QStringList LXDG::systemApplicationDirs(){ //for(int s=0; s<subs.length(); s++){ out << dir.absoluteFilePath(subs[s]); } } } + //qDebug() << "System Application Dirs:" << out; return out; } diff --git a/lumina-desktop/LDesktop.cpp b/lumina-desktop/LDesktop.cpp index 8204de29..0b207e0a 100644 --- a/lumina-desktop/LDesktop.cpp +++ b/lumina-desktop/LDesktop.cpp @@ -359,9 +359,11 @@ void LDesktop::RemoveDeskPlugin(QString ID){ //This was a temporary plugin (desktop file?) check for existance/dir and remove it as necessary QString path = ID.section("---",0,0).section("::",1,50); //full file path QFileInfo info(path); - if(info.exists() && info.canonicalPath()==QDir::homePath()+"/Desktop"){ + qDebug() << "Removing applauncher:" << path << ID; + if(info.exists() && info.absolutePath()==QDir::homePath()+"/Desktop"){ //Need to remove this file/dir as well - if(!info.isSymLink() && info.isDir()){ QProcess::startDetached("rm -r \""+info.absoluteFilePath()+"\""); } + qDebug() << "Removing File:" << path; + if(!info.isSymLink() && info.isDir()){ QProcess::startDetached("rm -r \""+path+"\""); } else{ QFile::remove(path); } //just remove the file/symlink directly } } diff --git a/lumina-desktop/LPanel.cpp b/lumina-desktop/LPanel.cpp index 57eff210..2eabc96e 100644 --- a/lumina-desktop/LPanel.cpp +++ b/lumina-desktop/LPanel.cpp @@ -313,7 +313,7 @@ void LPanel::checkPanelFocus(){ //=========== void LPanel::paintEvent(QPaintEvent *event){ QPainter *painter = new QPainter(this); - qDebug() << "Paint Tray:"; + //qDebug() << "Paint Tray:"; //Make sure the base background of the event rectangle is the associated rectangle from the BGWindow QRect rec = this->geometry(); //start with the global geometry of the panel //Need to translate that rectangle to the background image coordinates diff --git a/lumina-desktop/panel-plugins/clock/LClock.cpp b/lumina-desktop/panel-plugins/clock/LClock.cpp index b9f15c49..7af36e5a 100644 --- a/lumina-desktop/panel-plugins/clock/LClock.cpp +++ b/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -125,7 +125,8 @@ void LClock::updateFormats(){ void LClock::updateMenu(){ QDateTime cdt = QDateTime::currentDateTime(); TZMenu->setTitle(QString(tr("Time Zone (%1)")).arg(cdt.timeZoneAbbreviation()) ); - calendar->showToday(); + calendar->showToday(); //make sure the current month is visible + calendar->setSelectedDate(QDate::currentDate()); //select the actual date for today } void LClock::openMenu(){ diff --git a/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp b/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp index 146fec3d..3e644803 100644 --- a/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp +++ b/lumina-desktop/panel-plugins/systemstart/LStartButton.cpp @@ -8,6 +8,7 @@ #include "../../LSession.h" #include <LuminaXDG.h> +#include <LuminaUtils.h> LStartButtonPlugin::LStartButtonPlugin(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ button = new QToolButton(this); @@ -17,15 +18,16 @@ LStartButtonPlugin::LStartButtonPlugin(QWidget *parent, QString id, bool horizon connect(button, SIGNAL(clicked()), this, SLOT(openMenu())); this->layout()->setContentsMargins(0,0,0,0); this->layout()->addWidget(button); - menu = new QMenu(this); + menu = new ResizeMenu(this); menu->setContentsMargins(1,1,1,1); connect(menu, SIGNAL(aboutToHide()), this, SIGNAL(MenuClosed())); startmenu = new StartMenu(this); connect(startmenu, SIGNAL(CloseMenu()), this, SLOT(closeMenu()) ); connect(startmenu, SIGNAL(UpdateQuickLaunch(QStringList)), this, SLOT(updateQuickLaunch(QStringList))); - mact = new QWidgetAction(this); + menu->setContents(startmenu); + /*mact = new QWidgetAction(this); mact->setDefaultWidget(startmenu); - menu->addAction(mact); + menu->addAction(mact);*/ button->setMenu(menu); connect(menu, SIGNAL(aboutToHide()), this, SLOT(updateButtonVisuals()) ); diff --git a/lumina-desktop/panel-plugins/systemstart/LStartButton.h b/lumina-desktop/panel-plugins/systemstart/LStartButton.h index 33c48bbf..ac9ad59b 100644 --- a/lumina-desktop/panel-plugins/systemstart/LStartButton.h +++ b/lumina-desktop/panel-plugins/systemstart/LStartButton.h @@ -23,7 +23,8 @@ #include "../LPPlugin.h" //main plugin widget // libLumina includes -#include "LuminaXDG.h" +#include <LuminaXDG.h> +#include <LuminaUtils.h> #include "StartMenu.h" @@ -64,8 +65,8 @@ public: ~LStartButtonPlugin(); private: - QMenu *menu; - QWidgetAction *mact; + ResizeMenu *menu; + //QWidgetAction *mact; StartMenu *startmenu; QToolButton *button; QList<LQuickLaunchButton*> QUICKL; diff --git a/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp b/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp index 4c64f554..009e2351 100644 --- a/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp +++ b/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp @@ -15,6 +15,7 @@ StartMenu::StartMenu(QWidget *parent) : QWidget(parent), ui(new Ui::StartMenu){ ui->setupUi(this); //load the designer file + this->setMouseTracking(true); sysapps = LSession::handle()->applicationMenu()->currentAppHash(); connect(LSession::handle()->applicationMenu(), SIGNAL(AppMenuUpdated()), this, SLOT(UpdateApps()) ); UpdateAll(); diff --git a/lumina-desktop/panel-plugins/systemstart/StartMenu.h b/lumina-desktop/panel-plugins/systemstart/StartMenu.h index bf673a86..8e2b2a3c 100644 --- a/lumina-desktop/panel-plugins/systemstart/StartMenu.h +++ b/lumina-desktop/panel-plugins/systemstart/StartMenu.h @@ -9,6 +9,7 @@ #include <QWidget> #include <QScrollArea> +#include <QMouseEvent> #include <LuminaXDG.h> diff --git a/lumina-desktop/panel-plugins/systemstart/StartMenu.ui b/lumina-desktop/panel-plugins/systemstart/StartMenu.ui index 716a5e97..332baa1e 100644 --- a/lumina-desktop/panel-plugins/systemstart/StartMenu.ui +++ b/lumina-desktop/panel-plugins/systemstart/StartMenu.ui @@ -21,16 +21,16 @@ <number>2</number> </property> <property name="leftMargin"> - <number>0</number> + <number>1</number> </property> <property name="topMargin"> - <number>0</number> + <number>1</number> </property> <property name="rightMargin"> - <number>0</number> + <number>1</number> </property> <property name="bottomMargin"> - <number>0</number> + <number>1</number> </property> <item> <widget class="QLineEdit" name="line_search"> @@ -142,8 +142,8 @@ <rect> <x>0</x> <y>0</y> - <width>180</width> - <height>195</height> + <width>178</width> + <height>193</height> </rect> </property> </widget> @@ -394,8 +394,8 @@ <rect> <x>0</x> <y>0</y> - <width>87</width> - <height>16</height> + <width>98</width> + <height>28</height> </rect> </property> </widget> diff --git a/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp b/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp index 2befba0d..3be31f43 100644 --- a/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp +++ b/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp @@ -115,10 +115,10 @@ void LSysTray::checkAll(){ LI->addWidget(cont); //qDebug() << " - Update tray layout"; if(this->layout()->direction()==QBoxLayout::LeftToRight){ - cont->setSizeSquare(this->height()-2*frame->frameWidth()); //horizontal tray + cont->setSizeSquare(this->height()-2-2*frame->frameWidth()); //horizontal tray this->setMaximumSize( trayIcons.length()*this->height(), 10000); }else{ - cont->setSizeSquare(this->width()-2*frame->frameWidth()); //vertical tray + cont->setSizeSquare(this->width()-2-2*frame->frameWidth()); //vertical tray this->setMaximumSize(10000, trayIcons.length()*this->width()); } LSession::processEvents(); @@ -126,7 +126,7 @@ void LSysTray::checkAll(){ cont->attachApp(wins[i]); if(cont->appID()==0){ //could not attach window - remove the widget - qDebug() << "Invalid Tray Container:"; + //qDebug() << "Invalid Tray Container:"; trayIcons.takeAt(trayIcons.length()-1); //Always at the end LI->removeWidget(cont); delete cont; diff --git a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp index 78d90524..1b843e3e 100644 --- a/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp +++ b/lumina-desktop/panel-plugins/systemtray/TrayIcon.cpp @@ -36,10 +36,10 @@ void TrayIcon::attachApp(WId id){ dmgID = LSession::handle()->XCB->EmbedWindow(AID, IID); if( dmgID != 0 ){ LSession::handle()->XCB->RestoreWindow(AID); //make it visible - qDebug() << "New System Tray App:" << AID; + //qDebug() << "New System Tray App:" << AID; QTimer::singleShot(1000, this, SLOT(updateIcon()) ); }else{ - qWarning() << "Could not Embed Tray Application:" << AID; + //qWarning() << "Could not Embed Tray Application:" << AID; IID = 0; AID = 0; } @@ -55,15 +55,15 @@ void TrayIcon::setSizeSquare(int side){ // ============== void TrayIcon::detachApp(){ if(AID==0){ return; } //already detached - qDebug() << "Detach App:" << AID; + //qDebug() << "Detach App:" << AID; //Temporarily move the AID, so that internal slots do not auto-run WId tmp = AID; AID = 0; //Now detach the application window and clean up - qDebug() << " - Unembed"; + //qDebug() << " - Unembed"; //WIN->setParent(0); //Reset parentage back to the main stack LSession::handle()->XCB->UnembedWindow(tmp); - qDebug() << " - finished app:" << tmp; + //qDebug() << " - finished app:" << tmp; IID = 0; } |