aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-desktop
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp1
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h48
2 files changed, 46 insertions, 3 deletions
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp
index 035dd29c..2233273e 100644
--- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-cpp/PanelObject.cpp
@@ -94,6 +94,7 @@ void PanelObject::syncWithSettings(QRect parent_geom){
double length = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/length_percent", 100).toDouble()/100.0;
double width = DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/width_font_percent", 2.1).toDouble();
width = qRound(width * QApplication::fontMetrics().height() );
+ //qDebug() << " Got Panel Width From Settings:" << width;
this->setBackground( DesktopSettings::instance()->value(DesktopSettings::Panels, id+"/background", "rgba(0,0,0,120)").toString() );
// qDebug() << "Update Panel:" << panel_id << id << anchor+"/"+align << length << width;
//Now calculate the geometry of the panel
diff --git a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h
index be5d017b..7e7b06c7 100644
--- a/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h
+++ b/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h
@@ -12,22 +12,64 @@
class ClockPlugin : public PluginButton{
Q_OBJECT
+
+private:
+ int textRows;
+
private slots:
void updateTime(){
//qDebug() << "Clock: Update Time";
- this->button->setText(RootDesktopObject::instance()->currentTime() );
+ QString text = RootDesktopObject::instance()->currentTime();
+ //Adjust the text to fix the widget as needed
+ //qDebug() << "Clock: Update Time:" << textRows << text << text.split(" ");
+ if(textRows>1){
+ QStringList textL = text.split(" "); //natural breaks
+ while(textL.length()!=textRows){
+ if(textL.length() > textRows){
+ //Need to get a bit more complicated - join the shorter sections together
+ //Look for an am/pm section and combine that with the previous one
+ int index = textL.lastIndexOf(QRegExp("(AM|am|PM|pm)"));
+ //qDebug() << "Got AM/PM index:" << index;
+ if(index>0){ textL[index-1] = textL[index-1]+" "+textL[index]; textL.removeAt(index); }
+ else{
+ //TO-DO
+ break;
+ }
+ }else{
+ //Need to get a lot more complicated - need to break up sections based on widget width
+ // TO-DO
+ break;
+ }
+ } //end of loop
+ text = textL.join("\n");
+ }
+ //qDebug() << "Got Text:" << text;
+ this->button->setText(text);
}
public:
ClockPlugin(QWidget *parent, QString id, bool panelplug) : PluginButton(parent, id, panelplug){
connect(RootDesktopObject::instance(), SIGNAL(currentTimeChanged()), this, SLOT(updateTime()) );
- QFont tmp = button->font();
+ /*QFont tmp = button->font();
tmp.setBold(true);
- button->setFont( tmp );
+ button->setFont( tmp );*/
+ textRows = 1;
QTimer::singleShot(0, this, SLOT(updateTime()) );
}
~ClockPlugin(){ }
+protected:
+ void resizeEvent(QResizeEvent *ev){
+ Plugin::resizeEvent(ev);
+ //Re-calculate the text sizing for display
+ int tmp = button->height() / button->fontMetrics().height();
+ //qDebug() << "Got height/font ratio:" << tmp;
+ if(tmp!=textRows){
+ textRows = tmp;
+ if(textRows<1){ textRows = 1; }
+ QTimer::singleShot(0, this, SLOT(updateTime()) );
+ }
+ }
};
#endif
bgstack15