aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop/panel-plugins/clock/LClock.cpp
diff options
context:
space:
mode:
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.cpp24
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);
}
bgstack15