mirror of
https://github.com/vicr123/theshell.git
synced 2025-01-23 12:12:06 -05:00
Timer now sent to lock screen
This commit is contained in:
parent
34ea1f34f8
commit
f665589cc1
9 changed files with 126 additions and 29 deletions
|
@ -368,6 +368,7 @@ void InfoPaneDropdown::timerTick() {
|
|||
stopwatchTime = stopwatchTime.addMSecs(this->stopwatchTime.elapsed());
|
||||
}
|
||||
ui->stopwatchLabel->setText(stopwatchTime.toString("hh:mm:ss.zzz"));
|
||||
updateTimers();
|
||||
}
|
||||
|
||||
void InfoPaneDropdown::show(dropdownType showWith) {
|
||||
|
@ -998,12 +999,14 @@ void InfoPaneDropdown::startTimer(QTime time) {
|
|||
connect(timer, &QTimer::timeout, [=]() {
|
||||
timeUntilTimeout = timeUntilTimeout.addSecs(-1);
|
||||
if (timeUntilTimeout == QTime(0, 0, 0)) {
|
||||
if (timerNotificationId != 0 ) {
|
||||
if (timerNotificationId != 0) {
|
||||
notificationEngine->CloseNotification(timerNotificationId);
|
||||
}
|
||||
QVariantMap hints;
|
||||
hints.insert("x-thesuite-timercomplete", true);
|
||||
timerNotificationId = notificationEngine->Notify("theShell", 0, "", "Timer Elapsed",
|
||||
"Your timer has completed.",
|
||||
QStringList(), QVariantMap(), 0);
|
||||
QStringList(), hints, 0);
|
||||
ui->timeEdit->setVisible(true);
|
||||
ui->label_7->setVisible(false);
|
||||
ui->pushButton_2->setText("Start");
|
||||
|
@ -1029,13 +1032,35 @@ void InfoPaneDropdown::startTimer(QTime time) {
|
|||
playlist->setPlaybackMode(QMediaPlaylist::Loop);
|
||||
ringtone->setPlaylist(playlist);
|
||||
ringtone->play();
|
||||
updateTimers();
|
||||
} else {
|
||||
ui->label_7->setText(timeUntilTimeout.toString("HH:mm:ss"));
|
||||
emit timerChanged(timeUntilTimeout.toString("HH:mm:ss"));
|
||||
updateTimers();
|
||||
}
|
||||
});
|
||||
timer->start();
|
||||
emit timerChanged(timeUntilTimeout.toString("HH:mm:ss"));
|
||||
updateTimers();
|
||||
}
|
||||
|
||||
void InfoPaneDropdown::updateTimers() {
|
||||
QStringList parts;
|
||||
if (timer != NULL) {
|
||||
parts.append(timeUntilTimeout.toString("HH:mm:ss"));
|
||||
}
|
||||
|
||||
if (stopwatchRunning) {
|
||||
QTime stopwatchTime = QTime::fromMSecsSinceStartOfDay(0);
|
||||
stopwatchTime = stopwatchTime.addMSecs(stopwatchTimeAdd);
|
||||
stopwatchTime = stopwatchTime.addMSecs(this->stopwatchTime.elapsed());
|
||||
parts.append(stopwatchTime.toString("hh:mm:ss"));
|
||||
}
|
||||
|
||||
if (parts.count() != 0) {
|
||||
emit timerVisibleChanged(true);
|
||||
emit timerChanged(parts.join(" · "));
|
||||
} else {
|
||||
emit timerVisibleChanged(false);
|
||||
}
|
||||
}
|
||||
|
||||
void InfoPaneDropdown::notificationClosed(uint id, uint reason) {
|
||||
|
@ -1055,13 +1080,11 @@ void InfoPaneDropdown::on_pushButton_2_clicked()
|
|||
ui->pushButton_3->setVisible(true);
|
||||
ui->label_7->setEnabled(false);
|
||||
ui->pushButton_2->setText("Resume");
|
||||
emit timerEnabledChanged(false);
|
||||
} else {
|
||||
timer->start();
|
||||
ui->pushButton_3->setVisible(false);
|
||||
ui->label_7->setEnabled(true);
|
||||
ui->pushButton_2->setText("Pause");
|
||||
emit timerEnabledChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1481,8 +1504,9 @@ void InfoPaneDropdown::updateKdeconnect() {
|
|||
QListWidgetItem* item = new QListWidgetItem;
|
||||
item->setText(deviceInterface.property("name").toString());
|
||||
item->setIcon(QIcon::fromTheme(deviceInterface.property("iconName").toString()));
|
||||
item->setData(Qt::UserRole, device);
|
||||
if (!isReachable) {
|
||||
item->setTextColor(ui->kdeconnectDevices->palette().color(QPalette::Disabled, QPalette::Text));
|
||||
item->setForeground(ui->kdeconnectDevices->palette().brush(QPalette::Disabled, QPalette::Text));
|
||||
}
|
||||
ui->kdeconnectDevices->addItem(item);
|
||||
}
|
||||
|
@ -1618,3 +1642,23 @@ void InfoPaneDropdown::on_systemFont_currentFontChanged(const QFont &f)
|
|||
themeSettings->setValue("fonts/smallFamily", f.family());
|
||||
//ui->systemFont->setFont(QFont(themeSettings->value("font/defaultFamily", defaultFont).toString(), themeSettings->value("font/defaultSize", 10).toInt()));
|
||||
}
|
||||
|
||||
void InfoPaneDropdown::on_locateDeviceButton_clicked()
|
||||
{
|
||||
if (ui->kdeconnectDevices->selectedItems().count() != 0) {
|
||||
if (QMessageBox::question(this, "Locate Device", "Your device will ring at full volume. Tap the button on the screen of the device to silence it.", QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok) == QMessageBox::Ok) {
|
||||
QString device = ui->kdeconnectDevices->selectedItems().first()->data(Qt::UserRole).toString();
|
||||
QDBusInterface findPhone("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device + "/findmyphone", "org.kde.kdeconnect.device.findmyphone");
|
||||
findPhone.call("ring");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void InfoPaneDropdown::on_pingDeviceButton_clicked()
|
||||
{
|
||||
if (ui->kdeconnectDevices->selectedItems().count() != 0) {
|
||||
QString device = ui->kdeconnectDevices->selectedItems().first()->data(Qt::UserRole).toString();
|
||||
QDBusInterface findPhone("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device + "/ping", "org.kde.kdeconnect.device.ping");
|
||||
findPhone.call("sendPing");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,6 +208,12 @@ private slots:
|
|||
|
||||
void on_systemFont_currentFontChanged(const QFont &f);
|
||||
|
||||
void on_locateDeviceButton_clicked();
|
||||
|
||||
void on_pingDeviceButton_clicked();
|
||||
|
||||
void updateTimers();
|
||||
|
||||
public slots:
|
||||
void getNetworks();
|
||||
|
||||
|
|
|
@ -321,7 +321,7 @@
|
|||
<item>
|
||||
<widget class="AnimatedStackedWidget" name="pageStack">
|
||||
<property name="currentIndex">
|
||||
<number>6</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="clockFrame">
|
||||
<property name="autoFillBackground">
|
||||
|
@ -546,14 +546,14 @@
|
|||
<second>0</second>
|
||||
<year>1969</year>
|
||||
<month>11</month>
|
||||
<day>11</day>
|
||||
<day>10</day>
|
||||
</datetime>
|
||||
</property>
|
||||
<property name="date">
|
||||
<date>
|
||||
<year>1969</year>
|
||||
<month>11</month>
|
||||
<day>11</day>
|
||||
<day>10</day>
|
||||
</date>
|
||||
</property>
|
||||
<property name="displayFormat">
|
||||
|
@ -1184,8 +1184,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>165</width>
|
||||
<height>59</height>
|
||||
<width>928</width>
|
||||
<height>620</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||
|
@ -1366,10 +1366,47 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="kdeconnectArea">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_24">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_20">
|
||||
<item>
|
||||
<widget class="QListWidget" name="kdeconnectDevices"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_24">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_22">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pingDeviceButton">
|
||||
<property name="text">
|
||||
<string>Ping</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="network-connect"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="locateDeviceButton">
|
||||
<property name="text">
|
||||
<string>Locate</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="audio-volume-high"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -95,6 +95,7 @@ uint NotificationDBus::Notify(QString app_name, uint replaces_id,
|
|||
NotificationArgs.append(replaces_id);
|
||||
NotificationArgs.append(QStringList());
|
||||
}
|
||||
NotificationArgs.append(hints);
|
||||
|
||||
NotificationEmit.setArguments(NotificationArgs);
|
||||
QDBusConnection::sessionBus().call(NotificationEmit, QDBus::NoBlock);
|
||||
|
|
|
@ -34,7 +34,7 @@ NotificationsAdaptor::~NotificationsAdaptor()
|
|||
// destructor
|
||||
}
|
||||
|
||||
void NotificationsAdaptor::CloseNotification(int id)
|
||||
void NotificationsAdaptor::CloseNotification(uint id)
|
||||
{
|
||||
// handle method call org.freedesktop.Notifications.CloseNotification
|
||||
parent()->CloseNotification(id);
|
||||
|
|
|
@ -36,8 +36,8 @@ class NotificationsAdaptor: public QDBusAbstractAdaptor
|
|||
Q_CLASSINFO("D-Bus Introspection", ""
|
||||
" <interface name=\"org.freedesktop.Notifications\">\n"
|
||||
" <signal name=\"NotificationClosed\">\n"
|
||||
" <arg direction=\"out\" type=\"i\" name=\"id\"/>\n"
|
||||
" <arg direction=\"out\" type=\"i\" name=\"reason\"/>\n"
|
||||
" <arg direction=\"out\" type=\"u\" name=\"id\"/>\n"
|
||||
" <arg direction=\"out\" type=\"u\" name=\"reason\"/>\n"
|
||||
" </signal>\n"
|
||||
" <signal name=\"ActionInvoked\">\n"
|
||||
" <arg direction=\"out\" type=\"u\" name=\"id\"/>\n"
|
||||
|
@ -59,7 +59,7 @@ class NotificationsAdaptor: public QDBusAbstractAdaptor
|
|||
" <arg direction=\"in\" type=\"i\" name=\"expire_timeout\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"CloseNotification\">\n"
|
||||
" <arg direction=\"in\" type=\"i\" name=\"id\"/>\n"
|
||||
" <arg direction=\"in\" type=\"u\" name=\"id\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"GetServerInformation\">\n"
|
||||
" <arg direction=\"out\" type=\"s\"/>\n"
|
||||
|
@ -78,13 +78,13 @@ public:
|
|||
|
||||
public: // PROPERTIES
|
||||
public Q_SLOTS: // METHODS
|
||||
void CloseNotification(int id);
|
||||
void CloseNotification(uint id);
|
||||
QStringList GetCapabilities();
|
||||
QString GetServerInformation(QString &vendor, QString &version, QString &spec_version);
|
||||
uint Notify(const QString &app_name, uint replaces_id, const QString &app_icon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int expire_timeout);
|
||||
Q_SIGNALS: // SIGNALS
|
||||
void ActionInvoked(uint id, const QString &action_key);
|
||||
void NotificationClosed(int id, int reason);
|
||||
void NotificationClosed(uint id, uint reason);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
|
||||
#define ChangelogOnbording "New in theShell 5.3:\n"\
|
||||
"- Default system font can be set in theme settings."\
|
||||
"- Battery indicator now shows battery for devices connected over KDE Connect\n"\
|
||||
"- Added some KDE Connect actions in the status center\n"\
|
||||
"- The stopwatch is now shown on the bar when being used."\
|
||||
"\n"\
|
||||
"New in theShell 5.2: \n"\
|
||||
"- New Onboarding experience. Every time theShell updates, you'll get a changelog.\n" \
|
||||
|
|
|
@ -19,6 +19,10 @@ QDBUSXML2CPP_ADAPTOR_SOURCE_FLAGS = -l NotificationDBus -i notificationdbus.h
|
|||
#appMenuRegistrar.files = com.canonical.AppMenu.Registrar.xml
|
||||
#appMenuRegistrar.header_flags = -l DBusMenuRegistrar -i dbusmenuregistrar.h
|
||||
|
||||
#notifications.files = org.freedesktop.Notifications.xml
|
||||
#notifications.header_flags = -l NotificationDBus -i notificationdbus.h
|
||||
#DBUS_ADAPTORS += notifications
|
||||
|
||||
#DBUS_ADAPTORS += com.canonical.AppMenu.Registrar.xml
|
||||
|
||||
SOURCES += main.cpp\
|
||||
|
|
|
@ -256,20 +256,22 @@ void UPowerDBus::DeviceChanged() {
|
|||
QDBusInterface interface("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device");
|
||||
QString name = interface.property("name").toString();
|
||||
QDBusInterface batteryInterface("org.kde.kdeconnect", "/modules/kdeconnect/devices/" + device, "org.kde.kdeconnect.device.battery");
|
||||
QDBusReply<int> currentCharge = batteryInterface.call("charge");
|
||||
QDBusReply<bool> charging = batteryInterface.call("isCharging");
|
||||
if (batteryInterface.isValid()) {
|
||||
QDBusReply<int> currentCharge = batteryInterface.call("charge");
|
||||
QDBusReply<bool> charging = batteryInterface.call("isCharging");
|
||||
|
||||
QString batteryText;
|
||||
if (charging) {
|
||||
if (currentCharge == 100) {
|
||||
batteryText = QString::number(currentCharge) + "% battery on " + name + " (Full)";
|
||||
QString batteryText;
|
||||
if (charging) {
|
||||
if (currentCharge == 100) {
|
||||
batteryText = QString::number(currentCharge) + "% battery on " + name + " (Full)";
|
||||
} else {
|
||||
batteryText = QString::number(currentCharge) + "% battery on " + name + " (Charging)";
|
||||
}
|
||||
} else {
|
||||
batteryText = QString::number(currentCharge) + "% battery on " + name + " (Charging)";
|
||||
batteryText = QString::number(currentCharge) + "% battery on " + name + " (Discharging)";
|
||||
}
|
||||
} else {
|
||||
batteryText = QString::number(currentCharge) + "% battery on " + name + " (Discharging)";
|
||||
displayOutput.append(batteryText);
|
||||
}
|
||||
displayOutput.append(batteryText);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue