Support setting time format

pull/18/head
reionwong 4 years ago
parent 10a2fbbda3
commit 9fd06f84ca

@ -37,6 +37,8 @@ Item {
property bool darkMode: FishUI.Theme.darkMode
property color textColor: rootItem.darkMode ? "#FFFFFF" : "#000000";
property var timeFormat: StatusBar.twentyFourTime ? "HH:mm" : "h:mm ap"
Rectangle {
id: background
anchors.fill: parent
@ -453,7 +455,7 @@ Item {
running: true
triggeredOnStart: true
onTriggered: {
timeLabel.text = new Date().toLocaleTimeString(Qt.locale(), Locale.ShortFormat)
timeLabel.text = new Date().toLocaleTimeString(Qt.locale(), rootItem.timeFormat)
}
}
}

@ -4,5 +4,8 @@
<method name="setBatteryPercentage">
<arg name="batteryPercentage" type="b" direction="in"/>
</method>
<method name="setTwentyFourTime">
<arg name="t" type="b" direction="in"/>
</method>
</interface>
</node>

@ -28,6 +28,7 @@
#include <QDBusConnection>
#include <QApplication>
#include <QSettings>
#include <QScreen>
#include <NETWM>
@ -38,6 +39,9 @@ StatusBar::StatusBar(QQuickView *parent)
: QQuickView(parent)
, m_acticity(new Activity)
{
QSettings settings("cutefish", "locale");
m_twentyFourTime = settings.value("twentyFour", false).toBool();
setFlags(Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
setColor(Qt::transparent);
@ -73,11 +77,24 @@ QRect StatusBar::screenRect()
return m_screenRect;
}
bool StatusBar::twentyFourTime()
{
return m_twentyFourTime;
}
void StatusBar::setBatteryPercentage(bool enabled)
{
Battery::self()->setShowPercentage(enabled);
}
void StatusBar::setTwentyFourTime(bool t)
{
if (m_twentyFourTime != t) {
m_twentyFourTime = t;
emit twentyFourTimeChanged();
}
}
void StatusBar::updateGeometry()
{
const QRect rect = screen()->geometry();

@ -27,13 +27,16 @@ class StatusBar : public QQuickView
{
Q_OBJECT
Q_PROPERTY(QRect screenRect READ screenRect NOTIFY screenRectChanged)
Q_PROPERTY(bool twentyFourTime READ twentyFourTime NOTIFY twentyFourTimeChanged)
public:
explicit StatusBar(QQuickView *parent = nullptr);
QRect screenRect();
bool twentyFourTime();
void setBatteryPercentage(bool enabled);
void setTwentyFourTime(bool t);
void updateGeometry();
void updateViewStruts();
@ -41,6 +44,7 @@ public:
signals:
void screenRectChanged();
void launchPadChanged();
void twentyFourTimeChanged();
private slots:
void initState();
@ -49,6 +53,7 @@ private slots:
private:
QRect m_screenRect;
Activity *m_acticity;
bool m_twentyFourTime;
};
#endif // STATUSBAR_H

Loading…
Cancel
Save