diff options
author | Ken Moore <ken@ixsystems.com> | 2016-12-23 11:47:30 -0500 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2016-12-23 11:47:30 -0500 |
commit | c880254cf13ba16697a948e4ac0478ebfd602ac5 (patch) | |
tree | 8386ffca6de834f7d5287793a9b4d6d8bb85d2e6 /src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp | |
parent | Merge branch 'master' of github.com:trueos/lumina (diff) | |
download | lumina-c880254cf13ba16697a948e4ac0478ebfd602ac5.tar.gz lumina-c880254cf13ba16697a948e4ac0478ebfd602ac5.tar.bz2 lumina-c880254cf13ba16697a948e4ac0478ebfd602ac5.zip |
Clean up some vertical-panel issues with the clock plugin and the system tray.
Diffstat (limited to 'src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp')
-rw-r--r-- | src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp | 24 |
1 files changed, 19 insertions, 5 deletions
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 <LuminaXDG.h> 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; i<label.count("\n")+1; i++){ + if(this->size().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); } |