system source, some code improvements

This commit is contained in:
2019-12-14 23:54:15 +03:00
parent c05a87a540
commit 276248a748
133 changed files with 748 additions and 526 deletions

View File

@ -15,7 +15,6 @@ Icon=utilities-system-monitor
X-KDE-ServiceTypes=Plasma/Applet
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml
X-Plasma-RemoteLocation=
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com

View File

@ -15,7 +15,6 @@ Icon=utilities-system-monitor
X-KDE-ServiceTypes=Plasma/Applet
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml
X-Plasma-RemoteLocation=
X-KDE-PluginInfo-Author=Evgeniy Alekseev aka arcanis
X-KDE-PluginInfo-Email=esalexeev@gmail.com

View File

@ -28,7 +28,7 @@ class DPPlugin : public QQmlExtensionPlugin
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
public:
void registerTypes(const char *uri);
void registerTypes(const char *uri) override;
};

View File

@ -56,19 +56,19 @@ DPAdds::~DPAdds()
// HACK: since QML could not use QLoggingCategory I need this hack
bool DPAdds::isDebugEnabled() const
bool DPAdds::isDebugEnabled()
{
return LOG_DP().isDebugEnabled();
}
int DPAdds::currentDesktop() const
int DPAdds::currentDesktop()
{
return KWindowSystem::currentDesktop();
}
QStringList DPAdds::dictKeys(const bool _sorted, const QString &_regexp) const
QStringList DPAdds::dictKeys(const bool _sorted, const QString &_regexp)
{
qCDebug(LOG_DP) << "Should be sorted" << _sorted << "and filter applied" << _regexp;
@ -85,7 +85,7 @@ QStringList DPAdds::dictKeys(const bool _sorted, const QString &_regexp) const
}
int DPAdds::numberOfDesktops() const
int DPAdds::numberOfDesktops()
{
return KWindowSystem::numberOfDesktops();
}
@ -104,13 +104,13 @@ QString DPAdds::toolTipImage(const int _desktop) const
if (m_tooltipType == "names") {
QStringList windowList;
std::for_each(info.windowsData.cbegin(), info.windowsData.cend(),
[&windowList](WindowData data) { windowList.append(data.name); });
[&windowList](const WindowData &data) { windowList.append(data.name); });
return QString("<ul><li>%1</li></ul>").arg(windowList.join("</li><li>"));
}
// init
QGraphicsScene *toolTipScene = new QGraphicsScene();
QGraphicsView *toolTipView = new QGraphicsView(toolTipScene);
auto *toolTipScene = new QGraphicsScene();
auto *toolTipView = new QGraphicsView(toolTipScene);
toolTipView->setStyleSheet("background: transparent");
toolTipView->setContentsMargins(0, 0, 0, 0);
toolTipView->setFrameShape(QFrame::NoFrame);
@ -119,8 +119,8 @@ QString DPAdds::toolTipImage(const int _desktop) const
// update
float margin = 5.0f * info.desktop.width() / 400.0f;
toolTipView->resize(info.desktop.width() + 2.0f * margin,
info.desktop.height() + 2.0f * margin);
toolTipView->resize(static_cast<int>(info.desktop.width() + 2.0f * margin),
static_cast<int>(info.desktop.height() + 2.0f * margin));
toolTipScene->clear();
toolTipScene->setBackgroundBrush(QBrush(Qt::NoBrush));
// borders
@ -215,7 +215,7 @@ void DPAdds::setToolTipData(const QVariantMap &_tooltipData)
}
QString DPAdds::infoByKey(const QString &_key) const
QString DPAdds::infoByKey(const QString &_key)
{
qCDebug(LOG_AW) << "Requested info for key" << _key;
@ -246,7 +246,7 @@ QString DPAdds::valueByKey(const QString &_key, int _desktop) const
// HACK: this method uses variables from version.h
QString DPAdds::getAboutText(const QString &_type) const
QString DPAdds::getAboutText(const QString &_type)
{
qCDebug(LOG_DP) << "Type" << _type;
@ -254,7 +254,7 @@ QString DPAdds::getAboutText(const QString &_type) const
}
QVariantMap DPAdds::getFont(const QVariantMap &_defaultFont) const
QVariantMap DPAdds::getFont(const QVariantMap &_defaultFont)
{
qCDebug(LOG_DP) << "Default font is" << _defaultFont;
@ -285,7 +285,7 @@ void DPAdds::sendNotification(const QString &_eventId, const QString &_message)
// slot for mouse click
void DPAdds::setCurrentDesktop(const int _desktop) const
void DPAdds::setCurrentDesktop(const int _desktop)
{
qCDebug(LOG_DP) << "Desktop" << _desktop;
@ -293,7 +293,7 @@ void DPAdds::setCurrentDesktop(const int _desktop) const
}
DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int _desktop) const
DPAdds::DesktopWindowsInfo DPAdds::getInfoByDesktop(const int _desktop)
{
qCDebug(LOG_DP) << "Desktop" << _desktop;

View File

@ -42,21 +42,21 @@ class DPAdds : public QObject
public:
explicit DPAdds(QObject *_parent = nullptr);
virtual ~DPAdds();
Q_INVOKABLE bool isDebugEnabled() const;
Q_INVOKABLE int currentDesktop() const;
Q_INVOKABLE QStringList dictKeys(const bool _sorted = true, const QString &_regexp = "") const;
Q_INVOKABLE int numberOfDesktops() const;
~DPAdds() override;
Q_INVOKABLE static bool isDebugEnabled();
Q_INVOKABLE static int currentDesktop();
Q_INVOKABLE static QStringList dictKeys(const bool _sorted = true, const QString &_regexp = "");
Q_INVOKABLE static int numberOfDesktops();
Q_INVOKABLE QString toolTipImage(const int _desktop) const;
Q_INVOKABLE QString parsePattern(const QString &_pattern, const int _desktop) const;
// values
Q_INVOKABLE void setMark(const QString &_newMark);
Q_INVOKABLE void setToolTipData(const QVariantMap &_tooltipData);
Q_INVOKABLE QString infoByKey(const QString &_key) const;
Q_INVOKABLE static QString infoByKey(const QString &_key);
Q_INVOKABLE QString valueByKey(const QString &_key, int _desktop = -1) const;
// configuration slots
Q_INVOKABLE QString getAboutText(const QString &_type) const;
Q_INVOKABLE QVariantMap getFont(const QVariantMap &_defaultFont) const;
Q_INVOKABLE static QString getAboutText(const QString &_type);
Q_INVOKABLE static QVariantMap getFont(const QVariantMap &_defaultFont);
signals:
void desktopChanged() const;
@ -64,10 +64,10 @@ signals:
public slots:
Q_INVOKABLE static void sendNotification(const QString &_eventId, const QString &_message);
Q_INVOKABLE void setCurrentDesktop(const int _desktop) const;
Q_INVOKABLE static void setCurrentDesktop(const int _desktop);
private:
DesktopWindowsInfo getInfoByDesktop(const int _desktop) const;
static DesktopWindowsInfo getInfoByDesktop(const int _desktop);
// variables
int m_tooltipWidth = 200;
QString m_mark = "*";