aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets
diff options
context:
space:
mode:
authorKen Moore <ken@ixsystems.com>2018-05-15 08:55:31 -0400
committerKen Moore <ken@ixsystems.com>2018-05-15 08:55:31 -0400
commit1d06950a02d5d8312d0f179e11dee8d7a37adb6d (patch)
treeeade1c90e7fc0c9c20445ca0d05c7b2c24205efb /src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets
parentGet the plugin system working with the panels. (diff)
downloadlumina-1d06950a02d5d8312d0f179e11dee8d7a37adb6d.tar.gz
lumina-1d06950a02d5d8312d0f179e11dee8d7a37adb6d.tar.bz2
lumina-1d06950a02d5d8312d0f179e11dee8d7a37adb6d.zip
Get the Clock plugin cleaned up a bit so it better supports multi-line panels.
Diffstat (limited to 'src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets')
-rw-r--r--src-qt5/core/lumina-desktop-unified/src-desktop/src-widgets/plugins/ClockPlugin.h48
1 files changed, 45 insertions, 3 deletions
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