From c880254cf13ba16697a948e4ac0478ebfd602ac5 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 23 Dec 2016 11:47:30 -0500 Subject: Clean up some vertical-panel issues with the clock plugin and the system tray. --- .../lumina-desktop/panel-plugins/clock/LClock.cpp | 24 +++++++++++++++++----- .../lumina-desktop/panel-plugins/clock/LClock.h | 4 +++- .../lumina-desktop/panel-plugins/panel-plugins.pri | 3 ++- .../panel-plugins/systemtray/LSysTray.cpp | 9 +++++--- .../panel-plugins/systemtray/LSysTray.h | 1 + 5 files changed, 31 insertions(+), 10 deletions(-) (limited to 'src-qt5/core/lumina-desktop/panel-plugins') diff --git a/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp b/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp index 1b23607a..b370c536 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp @@ -10,7 +10,7 @@ #include LClock::LClock(QWidget *parent, QString id, bool horizontal) : LPPlugin(parent, id, horizontal){ - button = new QToolButton(this); + button = new QToolButton(this); //RotateToolButton(this); button->setAutoRaise(true); button->setToolButtonStyle(Qt::ToolButtonTextOnly); button->setStyleSheet("font-weight: bold;"); @@ -77,7 +77,13 @@ void LClock::updateTime(bool adjustformat){ } if( this->layout()->direction() == QBoxLayout::TopToBottom ){ //different routine for vertical text (need newlines instead of spaces) - label.replace(" ","\n"); + for(int i=0; isize().width() < (this->fontMetrics().width(label.section("\n",i,i))+10 )&& label.section("\n",i,i).contains(" ")){ + label.replace(label.section("\n",i,i), label.section("\n",i,i).replace(" ", "\n")); + i--; + } + } + //label.replace(" ","\n"); }else if( this->size().height() < 2*this->fontMetrics().height() ){ label.replace("\n",", "); } @@ -94,7 +100,13 @@ void LClock::updateTime(bool adjustformat){ }else{ button->setStyleSheet("font-weight: bold;"); }*/ - this->setFixedWidth( this->sizeHint().width() +6); + if(this->layout()->direction()==QBoxLayout::LeftToRight){ + //horizontal layout + this->setFixedWidth( this->sizeHint().width() +6); + }else{ + //vertical layout + this->setMaximumWidth(100000); + } } button->setText(label); } @@ -204,10 +216,12 @@ void LClock::ThemeChange(){ } void LClock::OrientationChange(){ - if(this->layout()->direction()==QBoxLayout::LeftToRight){ + if(this->layout()->direction()==QBoxLayout::LeftToRight){ //horizontal panel + //button->setRotation(0); //no rotation of text this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); - }else{ + }else{ //vertical panel + //button->setRotation(90); //90 degree rotation this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); } diff --git a/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.h b/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.h index 8131375d..eddf782c 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.h +++ b/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.h @@ -22,6 +22,8 @@ #include "../LPPlugin.h" +//#include "../RotateToolButton.h" + class LClock : public LPPlugin{ Q_OBJECT public: @@ -30,7 +32,7 @@ public: private: QTimer *timer; - QToolButton *button; + QToolButton *button; //RotateToolButton QString timefmt, datefmt, datetimeorder; bool deftime, defdate; QMenu *TZMenu; diff --git a/src-qt5/core/lumina-desktop/panel-plugins/panel-plugins.pri b/src-qt5/core/lumina-desktop/panel-plugins/panel-plugins.pri index 9db23968..c40c4725 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/panel-plugins.pri +++ b/src-qt5/core/lumina-desktop/panel-plugins/panel-plugins.pri @@ -23,7 +23,8 @@ SOURCES += $$PWD/userbutton/LUserButton.cpp \ $$PWD/audioplayer/PPlayerWidget.cpp \ $$PWD/jsonmenu/PPJsonMenu.cpp -HEADERS += $$PWD/userbutton/LUserButton.h \ +HEADERS += $$PWD/RotateToolButton.h \ + $$PWD/userbutton/LUserButton.h \ $$PWD/userbutton/UserWidget.h \ $$PWD/userbutton/UserItemWidget.h \ $$PWD/desktopbar/LDeskBar.h \ diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp index b6af4451..a71fd57e 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.cpp @@ -117,10 +117,14 @@ void LSysTray::checkAll(){ LI->addWidget(cont); //qDebug() << " - Update tray layout"; if(this->layout()->direction()==QBoxLayout::LeftToRight){ - cont->setSizeSquare(this->height()-2-2*frame->frameWidth()); //horizontal tray + int sz = this->height()-2-2*frame->frameWidth(); + if(sz>64){ sz = 64; } + cont->setSizeSquare(sz); //horizontal tray this->setMaximumSize( trayIcons.length()*this->height(), 10000); }else{ - cont->setSizeSquare(this->width()-2-2*frame->frameWidth()); //vertical tray + int sz = this->width()-2-2*frame->frameWidth(); + if(sz>64){ sz = 64; } + cont->setSizeSquare(sz); //vertical tray this->setMaximumSize(10000, trayIcons.length()*this->width()); } //LSession::processEvents(); @@ -161,4 +165,3 @@ void LSysTray::UpdateTrayWindow(WId win){ QTimer::singleShot(0,this, SLOT(checkAll()) ); } - diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.h b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.h index 84cde5c9..7db307c6 100644 --- a/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.h +++ b/src-qt5/core/lumina-desktop/panel-plugins/systemtray/LSysTray.h @@ -62,6 +62,7 @@ public slots: this->setMaximumSize(10000, trayIcons.length()*this->width()); sz = this->width()-2*frame->frameWidth(); } + if(sz>64){ sz = 64; } //many tray icons can't go larger than this anyway for(int i=0; isetSizeSquare(sz); trayIcons[i]->repaint(); -- cgit