-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: use qt libraries and follow qml module conventions
Uses a qml module instead of a context property. Replaces usages of std and hyprutils with qtbase where applicable. Removes dependencies: hyprutils, wl-copy, whoami, uname. Rolls c++ version back to 20, as 23 isn't currently required for anything.
- Loading branch information
Showing
17 changed files
with
420 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
qt_add_executable(hyprsysteminfo | ||
main.cpp | ||
util/Utils.cpp | ||
SystemInfo.cpp | ||
SystemIconProvider.cpp | ||
) | ||
|
||
qt_add_qml_module(hyprsysteminfo | ||
URI org.hyprland.systeminfo | ||
VERSION 1.0 | ||
QML_FILES main.qml | ||
) | ||
|
||
target_link_libraries(hyprsysteminfo PRIVATE Qt6::Widgets Qt6::QuickControls2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "SystemIconProvider.hpp" | ||
#include <qicon.h> | ||
#include <qlogging.h> | ||
#include <qpixmap.h> | ||
|
||
QPixmap CSystemIconProvider::requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) { | ||
auto icon = QIcon::fromTheme(id); | ||
|
||
if (!requestedSize.isValid()) { | ||
qCritical() << "Icon requests without an explicit size are not allowed."; | ||
return QPixmap(); | ||
} | ||
|
||
auto pixmap = icon.pixmap(requestedSize.width(), requestedSize.height()); | ||
|
||
if (pixmap.isNull()) { | ||
qWarning() << "Could not load icon" << id; | ||
return QPixmap(); | ||
} | ||
|
||
if (size != nullptr) | ||
*size = pixmap.size(); | ||
|
||
return pixmap; | ||
} |
10 changes: 2 additions & 8 deletions
10
qmlSources/SystemIconProvider.hpp → src/SystemIconProvider.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,14 @@ | ||
#ifndef SYSTEMICONPROVIDER_H | ||
#define SYSTEMICONPROVIDER_H | ||
#pragma once | ||
|
||
#include <QIcon> | ||
#include <QObject> | ||
#include <QPixmap> | ||
#include <QQmlApplicationEngine> | ||
#include <QQuickImageProvider> | ||
#include <iostream> | ||
|
||
class CSystemIconProvider : public QQuickImageProvider { | ||
public: | ||
CSystemIconProvider() : QQuickImageProvider(QQuickImageProvider::Pixmap) {} | ||
|
||
QPixmap requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) override { | ||
return QIcon::fromTheme(id).pixmap({512, 512}); | ||
} | ||
QPixmap requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) override; | ||
}; | ||
|
||
#endif // SYSTEMICONPROVIDER_H |
Oops, something went wrong.