mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-28 09:27:18 +00:00
parent
960640f5bc
commit
332d78eb25
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -24,7 +24,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: create build environment
|
- name: create build environment
|
||||||
run: pacman -Sy --noconfirm base-devel cmake extra-cmake-modules python util-linux-libs xorg-server-xvfb
|
run: pacman -Syu --noconfirm base-devel cmake extra-cmake-modules python util-linux-libs xorg-server-xvfb
|
||||||
|
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
run: pacman -S --noconfirm plasma-workspace
|
run: pacman -S --noconfirm plasma-workspace
|
||||||
|
@ -9,6 +9,9 @@ endif ()
|
|||||||
if (POLICY CMP0071)
|
if (POLICY CMP0071)
|
||||||
cmake_policy(SET CMP0071 NEW)
|
cmake_policy(SET CMP0071 NEW)
|
||||||
endif ()
|
endif ()
|
||||||
|
if (POLICY CMP0160)
|
||||||
|
cmake_policy(SET CMP0160 OLD)
|
||||||
|
endif ()
|
||||||
|
|
||||||
project(awesomewidgets)
|
project(awesomewidgets)
|
||||||
set(PROJECT_AUTHOR "Evgeniy Alekseev")
|
set(PROJECT_AUTHOR "Evgeniy Alekseev")
|
||||||
|
@ -51,6 +51,12 @@ ConfigModel {
|
|||||||
source: "dataengine.qml"
|
source: "dataengine.qml"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigCategory {
|
||||||
|
name: i18n("Report bug")
|
||||||
|
icon: "tools-report-bug"
|
||||||
|
source: "bug.qml"
|
||||||
|
}
|
||||||
|
|
||||||
ConfigCategory {
|
ConfigCategory {
|
||||||
name: i18n("About")
|
name: i18n("About")
|
||||||
icon: "help-about"
|
icon: "help-about"
|
||||||
|
@ -27,8 +27,8 @@ KCM.SimpleKCM {
|
|||||||
id: advancedPage
|
id: advancedPage
|
||||||
|
|
||||||
// backend
|
// backend
|
||||||
AWActions {
|
AWConfigHelper {
|
||||||
id: awActions
|
id: awConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
property alias cfg_background: background.checked
|
property alias cfg_background: background.checked
|
||||||
@ -52,7 +52,6 @@ KCM.SimpleKCM {
|
|||||||
property alias cfg_telemetryId: telemetryId.value
|
property alias cfg_telemetryId: telemetryId.value
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: pageColumn
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
CheckBoxSelector {
|
CheckBoxSelector {
|
||||||
@ -198,7 +197,7 @@ KCM.SimpleKCM {
|
|||||||
|
|
||||||
ButtonSelector {
|
ButtonSelector {
|
||||||
value: i18n("Drop key cache")
|
value: i18n("Drop key cache")
|
||||||
onButtonActivated: awActions.dropCache()
|
onButtonActivated: awConfig.dropCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonSelector {
|
ButtonSelector {
|
||||||
|
@ -42,7 +42,6 @@ KCM.SimpleKCM {
|
|||||||
property string cfg_textStyle: textStyle.value
|
property string cfg_textStyle: textStyle.value
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: pageColumn
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
FontSelector {
|
FontSelector {
|
||||||
|
@ -19,12 +19,15 @@ import QtQuick 2.15
|
|||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import QtQuick.Dialogs
|
import QtQuick.Dialogs
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
|
import org.kde.kcmutils as KCM
|
||||||
|
|
||||||
import org.kde.plasma.private.awesomewidget 1.0
|
import org.kde.plasma.awesomewidgets
|
||||||
|
import org.kde.plasma.private.awesomewidget
|
||||||
|
|
||||||
|
|
||||||
Dialog {
|
KCM.SimpleKCM {
|
||||||
id: reportDialog
|
id: bugPage
|
||||||
|
|
||||||
AWActions {
|
AWActions {
|
||||||
id: awActions
|
id: awActions
|
||||||
}
|
}
|
||||||
@ -32,12 +35,6 @@ Dialog {
|
|||||||
id: awBugReporter
|
id: awBugReporter
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 640
|
|
||||||
height: 480
|
|
||||||
|
|
||||||
title: i18n("Report a bug")
|
|
||||||
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Cancel | DialogButtonBox.Reset
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
@ -52,7 +49,6 @@ Dialog {
|
|||||||
|
|
||||||
GroupBox {
|
GroupBox {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: parent.height / 5
|
|
||||||
title: i18n("Description")
|
title: i18n("Description")
|
||||||
|
|
||||||
TextArea {
|
TextArea {
|
||||||
@ -64,7 +60,6 @@ Dialog {
|
|||||||
|
|
||||||
GroupBox {
|
GroupBox {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: parent.height / 5
|
|
||||||
title: i18n("Steps to reproduce")
|
title: i18n("Steps to reproduce")
|
||||||
|
|
||||||
TextArea {
|
TextArea {
|
||||||
@ -76,7 +71,6 @@ Dialog {
|
|||||||
|
|
||||||
GroupBox {
|
GroupBox {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
height: parent.height / 5
|
|
||||||
title: i18n("Expected result")
|
title: i18n("Expected result")
|
||||||
|
|
||||||
TextArea {
|
TextArea {
|
||||||
@ -130,27 +124,36 @@ Dialog {
|
|||||||
FileDialog {
|
FileDialog {
|
||||||
id: logPath
|
id: logPath
|
||||||
title: i18n("Open log file")
|
title: i18n("Open log file")
|
||||||
onAccepted:
|
onAccepted: logBody.text = awActions.getFileContent(logPath.selectedFile.toString().replace("file://", ""))
|
||||||
logBody.text = awActions.getFileContent(logPath.fileUrl.toString().replace("file://", ""))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DialogButtonBox {
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
standardButtons: DialogButtonBox.Ok | DialogButtonBox.Reset
|
||||||
|
alignment: Qt.AlignRight
|
||||||
|
onAccepted: sendBugReport()
|
||||||
|
onReset: resetDialog()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onAccepted: {
|
function sendBugReport() {
|
||||||
const text = awBugReporter.generateText(description.text, reproduce.text, expected.text, logBody.text)
|
const text = awBugReporter.generateText(description.text, reproduce.text, expected.text, logBody.text)
|
||||||
awBugReporter.sendBugReport(title.text, text)
|
awBugReporter.sendBugReport(title.text, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
onReset: {
|
function resetDialog() {
|
||||||
title.text = ""
|
title.text = ""
|
||||||
description.text = ""
|
description.text = ""
|
||||||
reproduce.text = ""
|
reproduce.text = ""
|
||||||
expected.text = ""
|
expected.text = ""
|
||||||
|
logBody.text = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
resetDialog()
|
||||||
awBugReporter.doConnect()
|
awBugReporter.doConnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -37,7 +37,6 @@ KCM.SimpleKCM {
|
|||||||
property variant cfg_dataengine: awConfig.readDataEngineConfiguration()
|
property variant cfg_dataengine: awConfig.readDataEngineConfiguration()
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: pageColumn
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
GroupBox {
|
GroupBox {
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Controls
|
|
||||||
import QtQuick.Dialogs
|
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import org.kde.plasma.core as PlasmaCore
|
import org.kde.plasma.core as PlasmaCore
|
||||||
import org.kde.plasma.plasmoid 2.0
|
import org.kde.plasma.plasmoid 2.0
|
||||||
@ -39,9 +37,6 @@ PlasmoidItem {
|
|||||||
AWTelemetryHandler {
|
AWTelemetryHandler {
|
||||||
id: awTelemetryHandler
|
id: awTelemetryHandler
|
||||||
}
|
}
|
||||||
BugReport {
|
|
||||||
id: bugReport
|
|
||||||
}
|
|
||||||
|
|
||||||
property variant tooltipSettings: {
|
property variant tooltipSettings: {
|
||||||
"tooltipNumber": plasmoid.configuration.tooltipNumber,
|
"tooltipNumber": plasmoid.configuration.tooltipNumber,
|
||||||
@ -92,7 +87,7 @@ PlasmoidItem {
|
|||||||
|
|
||||||
color: plasmoid.configuration.fontColor
|
color: plasmoid.configuration.fontColor
|
||||||
font.family: plasmoid.configuration.fontFamily
|
font.family: plasmoid.configuration.fontFamily
|
||||||
font.italic: plasmoid.configuration.fontStyle === "italic" ? true : false
|
font.italic: plasmoid.configuration.fontStyle === "italic"
|
||||||
font.pointSize: plasmoid.configuration.fontSize
|
font.pointSize: plasmoid.configuration.fontSize
|
||||||
font.weight: General.fontWeight[plasmoid.configuration.fontWeight]
|
font.weight: General.fontWeight[plasmoid.configuration.fontWeight]
|
||||||
|
|
||||||
@ -111,35 +106,11 @@ PlasmoidItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialog {
|
|
||||||
id: tagSelector
|
|
||||||
title: i18n("Select tag")
|
|
||||||
|
|
||||||
ComboBox {
|
|
||||||
id: tagSelectorBox
|
|
||||||
width: parent.width
|
|
||||||
editable: true
|
|
||||||
}
|
|
||||||
|
|
||||||
onAccepted: {
|
|
||||||
const tag = tagSelectorBox.editText
|
|
||||||
let message = i18n("Tag: %1", tag)
|
|
||||||
message += "<br>"
|
|
||||||
message += i18n("Value: %1", awKeys.valueByKey(tag))
|
|
||||||
message += "<br>"
|
|
||||||
message += i18n("Info: %1", awKeys.infoByKey(tag))
|
|
||||||
awActions.sendNotification("tag", message)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Plasmoid.contextualActions: [
|
Plasmoid.contextualActions: [
|
||||||
PlasmaCore.Action {
|
PlasmaCore.Action {
|
||||||
text: i18n("Request key")
|
text: i18n("Run monitor")
|
||||||
icon.name: "utilities-system-monitor"
|
icon.name: "utilities-system-monitor"
|
||||||
onTriggered: {
|
onTriggered: awActions.runCmd("plasma-systemmonitor", [])
|
||||||
tagSelectorBox.model = awKeys.dictKeys(true)
|
|
||||||
tagSelector.open()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
PlasmaCore.Action {
|
PlasmaCore.Action {
|
||||||
text: i18n("Show README")
|
text: i18n("Show README")
|
||||||
@ -150,14 +121,6 @@ PlasmoidItem {
|
|||||||
text: i18n("Check updates")
|
text: i18n("Check updates")
|
||||||
icon.name: "system-software-update"
|
icon.name: "system-software-update"
|
||||||
onTriggered: awActions.checkUpdates(true)
|
onTriggered: awActions.checkUpdates(true)
|
||||||
},
|
|
||||||
PlasmaCore.Action {
|
|
||||||
text: i18n("Report bug")
|
|
||||||
icon.name: "tools-report-bug"
|
|
||||||
onTriggered: {
|
|
||||||
bugReport.reset()
|
|
||||||
bugReport.open()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ KCM.SimpleKCM {
|
|||||||
property alias cfg_batInTooltipColor: batInTooltipColor.value
|
property alias cfg_batInTooltipColor: batInTooltipColor.value
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: pageColumn
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
@ -40,7 +40,6 @@ KCM.SimpleKCM {
|
|||||||
signal needTextUpdate(string newText)
|
signal needTextUpdate(string newText)
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: pageColumn
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
AWInfoLabel {}
|
AWInfoLabel {}
|
||||||
|
@ -75,7 +75,7 @@ bool AWActions::runCmd(const QString &_cmd, const QStringList &_args)
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Cmd" << _cmd << "args" << _args;
|
qCDebug(LOG_AW) << "Cmd" << _cmd << "args" << _args;
|
||||||
|
|
||||||
sendNotification(QString("Info"), i18n("Run %1", _cmd));
|
sendNotification("system", i18n("Run %1", _cmd));
|
||||||
|
|
||||||
return QProcess::startDetached(_cmd, _args);
|
return QProcess::startDetached(_cmd, _args);
|
||||||
}
|
}
|
||||||
@ -88,20 +88,6 @@ void AWActions::showReadme()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWActions::showLegacyInfo()
|
|
||||||
{
|
|
||||||
auto msgBox = new QMessageBox(nullptr);
|
|
||||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
msgBox->setModal(false);
|
|
||||||
msgBox->setWindowTitle(i18n("Not supported"));
|
|
||||||
msgBox->setText(i18n("You are using mammoth's Qt version, try to update it first"));
|
|
||||||
msgBox->setStandardButtons(QMessageBox::Ok);
|
|
||||||
msgBox->setIcon(QMessageBox::Information);
|
|
||||||
|
|
||||||
msgBox->open();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// HACK: this method uses variables from version.h
|
// HACK: this method uses variables from version.h
|
||||||
QString AWActions::getAboutText(const QString &_type)
|
QString AWActions::getAboutText(const QString &_type)
|
||||||
{
|
{
|
||||||
@ -135,7 +121,6 @@ void AWActions::sendNotification(const QString &_eventId, const QString &_messag
|
|||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Event" << _eventId << "with message" << _message;
|
qCDebug(LOG_AW) << "Event" << _eventId << "with message" << _message;
|
||||||
|
|
||||||
KNotification *notification
|
auto *event = KNotification::event(_eventId, QString("Awesome Widget ::: %1").arg(_eventId), _message);
|
||||||
= KNotification::event(_eventId, QString("Awesome Widget ::: %1").arg(_eventId), _message);
|
event->setComponentName("plasma-applet-org.kde.plasma.awesome-widget");
|
||||||
notification->setComponentName("plasma-applet-org.kde.plasma.awesome-widget");
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ public:
|
|||||||
Q_INVOKABLE void checkUpdates(bool _showAnyway = false);
|
Q_INVOKABLE void checkUpdates(bool _showAnyway = false);
|
||||||
Q_INVOKABLE static QString getFileContent(const QString &_path);
|
Q_INVOKABLE static QString getFileContent(const QString &_path);
|
||||||
Q_INVOKABLE static bool runCmd(const QString &_cmd, const QStringList &_args);
|
Q_INVOKABLE static bool runCmd(const QString &_cmd, const QStringList &_args);
|
||||||
Q_INVOKABLE static void showLegacyInfo();
|
|
||||||
Q_INVOKABLE static void showReadme();
|
Q_INVOKABLE static void showReadme();
|
||||||
// configuration slots
|
// configuration slots
|
||||||
Q_INVOKABLE static QString getAboutText(const QString &_type);
|
Q_INVOKABLE static QString getAboutText(const QString &_type);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "awbugreporter.h"
|
#include "awbugreporter.h"
|
||||||
|
|
||||||
#include <KI18n/KLocalizedString>
|
#include <KI18n/KLocalizedString>
|
||||||
|
#include <KNotifications/KNotification>
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -114,6 +115,12 @@ void AWBugReporter::issueReplyReceived(QNetworkReply *_reply)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWBugReporter::openBugReport()
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl(m_lastBugUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWBugReporter::showInformation(const int _number, const QString &_url)
|
void AWBugReporter::showInformation(const int _number, const QString &_url)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Created issue with number" << _number << "and url" << _url;
|
qCDebug(LOG_AW) << "Created issue with number" << _number << "and url" << _url;
|
||||||
@ -121,29 +128,9 @@ void AWBugReporter::showInformation(const int _number, const QString &_url)
|
|||||||
// cache url first
|
// cache url first
|
||||||
m_lastBugUrl = _url;
|
m_lastBugUrl = _url;
|
||||||
|
|
||||||
auto msgBox = new QMessageBox(nullptr);
|
auto event = KNotification::event("system", i18n("Issue created"), i18n("Issue %1 has been created", _number));
|
||||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
event->setComponentName("plasma-applet-org.kde.plasma.awesome-widget");
|
||||||
msgBox->setModal(false);
|
|
||||||
msgBox->setWindowTitle(i18n("Issue created"));
|
|
||||||
msgBox->setText(i18n("Issue %1 has been created", _number));
|
|
||||||
msgBox->setStandardButtons(QMessageBox::Open | QMessageBox::Close);
|
|
||||||
msgBox->setIcon(QMessageBox::Information);
|
|
||||||
|
|
||||||
msgBox->open(this, SLOT(userReplyOnBugReport(QAbstractButton *)));
|
auto action = event->addAction(i18n("Details"));
|
||||||
}
|
connect(action, &KNotificationAction::activated, this, &AWBugReporter::openBugReport);
|
||||||
|
|
||||||
|
|
||||||
void AWBugReporter::userReplyOnBugReport(QAbstractButton *_button)
|
|
||||||
{
|
|
||||||
auto ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
|
|
||||||
qCInfo(LOG_AW) << "User select" << ret;
|
|
||||||
|
|
||||||
switch (ret) {
|
|
||||||
case QMessageBox::AcceptRole:
|
|
||||||
QDesktopServices::openUrl(m_lastBugUrl);
|
|
||||||
break;
|
|
||||||
case QMessageBox::RejectRole:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -40,8 +40,8 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void issueReplyReceived(QNetworkReply *_reply);
|
void issueReplyReceived(QNetworkReply *_reply);
|
||||||
|
void openBugReport();
|
||||||
void showInformation(int _number, const QString &_url);
|
void showInformation(int _number, const QString &_url);
|
||||||
void userReplyOnBugReport(QAbstractButton *_button);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_lastBugUrl;
|
QString m_lastBugUrl;
|
||||||
|
@ -85,7 +85,7 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString &
|
|||||||
// extensions
|
// extensions
|
||||||
for (auto &item : m_dirs) {
|
for (auto &item : m_dirs) {
|
||||||
QStringList items
|
QStringList items
|
||||||
= QDir(QString("%1/%2").arg(m_baseDir).arg(item)).entryList(QStringList() << "*.desktop", QDir::Files);
|
= QDir(QString("%1/%2").arg(m_baseDir, item)).entryList({"*.desktop"}, QDir::Files);
|
||||||
settings.beginGroup(item);
|
settings.beginGroup(item);
|
||||||
for (auto &it : items)
|
for (auto &it : items)
|
||||||
copyExtensions(it, item, settings, false);
|
copyExtensions(it, item, settings, false);
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
|
|
||||||
#include "awkeys.h"
|
#include "awkeys.h"
|
||||||
|
|
||||||
#include <QtConcurrent>
|
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
#include <QDBusError>
|
#include <QDBusError>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QtConcurrent>
|
||||||
|
|
||||||
#include "awdataaggregator.h"
|
#include "awdataaggregator.h"
|
||||||
#include "awdataengineaggregator.h"
|
#include "awdataengineaggregator.h"
|
||||||
@ -189,7 +189,8 @@ void AWKeys::dataUpdated(const QHash<QString, KSysGuard::SensorInfo> &_sensors,
|
|||||||
if (!_sensors.contains(data.sensorProperty))
|
if (!_sensors.contains(data.sensorProperty))
|
||||||
continue;
|
continue;
|
||||||
auto sensor = _sensors[data.sensorProperty];
|
auto sensor = _sensors[data.sensorProperty];
|
||||||
std::ignore = QtConcurrent::run(m_threadPool, &AWKeys::setDataBySource, this, data.sensorProperty, sensor, data.payload);
|
std::ignore = QtConcurrent::run(m_threadPool, &AWKeys::setDataBySource, this, data.sensorProperty, sensor,
|
||||||
|
data.payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "awupdatehelper.h"
|
#include "awupdatehelper.h"
|
||||||
|
|
||||||
#include <KI18n/KLocalizedString>
|
#include <KI18n/KLocalizedString>
|
||||||
|
#include <KNotifications/KNotification>
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -70,8 +71,7 @@ bool AWUpdateHelper::checkVersion()
|
|||||||
qCInfo(LOG_AW) << "Found version" << version << "actual one is" << m_foundVersion;
|
qCInfo(LOG_AW) << "Found version" << version << "actual one is" << m_foundVersion;
|
||||||
|
|
||||||
if ((version != m_foundVersion) && (!QString(CHANGELOG).isEmpty())) {
|
if ((version != m_foundVersion) && (!QString(CHANGELOG).isEmpty())) {
|
||||||
genMessageBox(i18nc("Changelog of %1", VERSION), QString(CHANGELOG).replace('@', '\n'), QMessageBox::Ok)
|
sendNotification(i18nc("Changelog of %1", VERSION), QString(CHANGELOG).replace('@', '\n'));
|
||||||
->open();
|
|
||||||
return true;
|
return true;
|
||||||
} else if (version != m_foundVersion) {
|
} else if (version != m_foundVersion) {
|
||||||
qCWarning(LOG_AW) << "No changelog information provided";
|
qCWarning(LOG_AW) << "No changelog information provided";
|
||||||
@ -84,6 +84,12 @@ bool AWUpdateHelper::checkVersion()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWUpdateHelper::openReleasesPage()
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl(QString(RELEASES) + m_foundVersion.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void AWUpdateHelper::showInfo(const QVersionNumber &_version)
|
void AWUpdateHelper::showInfo(const QVersionNumber &_version)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Version" << _version;
|
qCDebug(LOG_AW) << "Version" << _version;
|
||||||
@ -91,7 +97,7 @@ void AWUpdateHelper::showInfo(const QVersionNumber &_version)
|
|||||||
auto text = i18n("You are using the actual version %1", _version.toString());
|
auto text = i18n("You are using the actual version %1", _version.toString());
|
||||||
if (!QString(COMMIT_SHA).isEmpty())
|
if (!QString(COMMIT_SHA).isEmpty())
|
||||||
text += QString(" (%1)").arg(QString(COMMIT_SHA));
|
text += QString(" (%1)").arg(QString(COMMIT_SHA));
|
||||||
return genMessageBox(i18n("No new version found"), text, QMessageBox::Ok)->open();
|
sendNotification(i18n("No new version found"), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -105,24 +111,9 @@ void AWUpdateHelper::showUpdates(const QVersionNumber &_version)
|
|||||||
text += i18n("New version : %1", _version.toString()) + "\n\n";
|
text += i18n("New version : %1", _version.toString()) + "\n\n";
|
||||||
text += i18n("Click \"Ok\" to download");
|
text += i18n("Click \"Ok\" to download");
|
||||||
|
|
||||||
genMessageBox(i18n("There are updates"), text, QMessageBox::Ok | QMessageBox::Cancel)
|
auto event = sendNotification(i18n("There are updates"), text);
|
||||||
->open(this, SLOT(userReplyOnUpdates(QAbstractButton *)));
|
auto action = event->addAction(i18n("Details"));
|
||||||
}
|
connect(action, &KNotificationAction::activated, this, &AWUpdateHelper::openReleasesPage);
|
||||||
|
|
||||||
|
|
||||||
void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *_button)
|
|
||||||
{
|
|
||||||
auto ret = dynamic_cast<QMessageBox *>(sender())->buttonRole(_button);
|
|
||||||
qCInfo(LOG_AW) << "User select" << ret;
|
|
||||||
|
|
||||||
switch (ret) {
|
|
||||||
case QMessageBox::AcceptRole:
|
|
||||||
QDesktopServices::openUrl(QString(RELEASES) + m_foundVersion.toString());
|
|
||||||
break;
|
|
||||||
case QMessageBox::RejectRole:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -158,18 +149,12 @@ void AWUpdateHelper::versionReplyReceived(QNetworkReply *_reply, const bool _sho
|
|||||||
|
|
||||||
|
|
||||||
// additional method which is used to show message box which does not block UI
|
// additional method which is used to show message box which does not block UI
|
||||||
QMessageBox *AWUpdateHelper::genMessageBox(const QString &_title, const QString &_body,
|
KNotification *AWUpdateHelper::sendNotification(const QString &_title, const QString &_body)
|
||||||
const QMessageBox::StandardButtons _buttons)
|
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << "Construct message box with title" << _title << "and body" << _body;
|
qCDebug(LOG_AW) << "Construct message box with title" << _title << "and body" << _body;
|
||||||
|
|
||||||
auto msgBox = new QMessageBox(nullptr);
|
auto event = KNotification::event("system", _title, _body);
|
||||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
event->setComponentName("plasma-applet-org.kde.plasma.awesome-widget");
|
||||||
msgBox->setModal(false);
|
|
||||||
msgBox->setWindowTitle(_title);
|
|
||||||
msgBox->setText(_body);
|
|
||||||
msgBox->setStandardButtons(_buttons);
|
|
||||||
msgBox->setIcon(QMessageBox::Information);
|
|
||||||
|
|
||||||
return msgBox;
|
return event;
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QVersionNumber>
|
#include <QVersionNumber>
|
||||||
|
|
||||||
|
|
||||||
|
class KNotification;
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
|
||||||
class AWUpdateHelper : public QObject
|
class AWUpdateHelper : public QObject
|
||||||
@ -35,14 +35,13 @@ public:
|
|||||||
bool checkVersion();
|
bool checkVersion();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void openReleasesPage();
|
||||||
static void showInfo(const QVersionNumber &_version);
|
static void showInfo(const QVersionNumber &_version);
|
||||||
void showUpdates(const QVersionNumber &_version);
|
void showUpdates(const QVersionNumber &_version);
|
||||||
void userReplyOnUpdates(QAbstractButton *_button);
|
|
||||||
void versionReplyReceived(QNetworkReply *_reply, bool _showAnyway);
|
void versionReplyReceived(QNetworkReply *_reply, bool _showAnyway);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static QMessageBox *genMessageBox(const QString &_title, const QString &_body,
|
static KNotification *sendNotification(const QString &_title, const QString &_body);
|
||||||
QMessageBox::StandardButtons _buttons);
|
|
||||||
QVersionNumber m_foundVersion;
|
QVersionNumber m_foundVersion;
|
||||||
QString m_genericConfig;
|
QString m_genericConfig;
|
||||||
};
|
};
|
||||||
|
@ -41,7 +41,7 @@ Item {
|
|||||||
onAccepted: {
|
onAccepted: {
|
||||||
const status = awConfig.exportConfiguration(
|
const status = awConfig.exportConfiguration(
|
||||||
configuration,
|
configuration,
|
||||||
fileDialog.fileUrl.toString().replace("file://", ""))
|
fileDialog.selectedFile.toString().replace("file://", ""))
|
||||||
if (status) {
|
if (status) {
|
||||||
messageDialog.title = i18n("Success")
|
messageDialog.title = i18n("Success")
|
||||||
messageDialog.text = i18n("Please note that binary files were not copied")
|
messageDialog.text = i18n("Please note that binary files were not copied")
|
||||||
|
@ -58,7 +58,7 @@ Item {
|
|||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
const importConfig = awConfig.importConfiguration(
|
const importConfig = awConfig.importConfiguration(
|
||||||
fileDialog.fileUrl.toString().replace("file://", ""),
|
fileDialog.selectedFile.toString().replace("file://", ""),
|
||||||
importPlasmoid.checked, importExtensions.checked,
|
importPlasmoid.checked, importExtensions.checked,
|
||||||
importAdds.checked)
|
importAdds.checked)
|
||||||
configurationReceived(importConfig)
|
configurationReceived(importConfig)
|
||||||
|
Loading…
Reference in New Issue
Block a user