remove everything

This commit is contained in:
2026-10-29 20:32:54 +13:00
parent 852a5fe82e
commit 88f4c7312d
118 changed files with 0 additions and 10013 deletions
@@ -1,87 +0,0 @@
#include "DesktopIconProvider.hpp"
#include <QFileInfo>
#include <QIcon>
#include <QPixmap>
#include <QUrl>
namespace {
QIcon resolveDesktopIcon(const QString &name)
{
if (name.isEmpty())
return {};
const QFileInfo direct(name);
if (direct.isAbsolute() && direct.exists())
return QIcon(name);
QIcon themed = QIcon::fromTheme(name);
if (!themed.isNull())
return themed;
QString base = name;
if (base.endsWith(QLatin1String(".png"), Qt::CaseInsensitive)
|| base.endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)
|| base.endsWith(QLatin1String(".xpm"), Qt::CaseInsensitive)) {
base = QFileInfo(base).completeBaseName();
themed = QIcon::fromTheme(base);
if (!themed.isNull())
return themed;
}
const QStringList pixmapDirs = {
QStringLiteral("/usr/share/pixmaps"),
QStringLiteral("/usr/share/icons/hicolor/48x48/apps"),
QStringLiteral("/usr/share/icons/hicolor/scalable/apps"),
};
const QStringList suffixes = {
QString(),
QStringLiteral(".png"),
QStringLiteral(".svg"),
QStringLiteral(".xpm"),
};
for (const QString &dir : pixmapDirs) {
for (const QString &suffix : suffixes) {
const QString candidate = dir + QLatin1Char('/') + (suffix.isEmpty() ? name : base) + suffix;
if (QFileInfo::exists(candidate))
return QIcon(candidate);
}
}
return {};
}
} // namespace
DesktopIconProvider::DesktopIconProvider()
: QQuickImageProvider(QQuickImageProvider::Pixmap)
{
}
QPixmap DesktopIconProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
{
const QString iconName = QUrl::fromPercentEncoding(id.toUtf8());
const QIcon icon = resolveDesktopIcon(iconName);
const QSize target = requestedSize.isValid() && requestedSize.width() > 0 && requestedSize.height() > 0
? requestedSize
: QSize(48, 48);
if (icon.isNull()) {
if (size)
*size = target;
return {};
}
const QPixmap pixmap = icon.pixmap(target);
if (pixmap.isNull()) {
if (size)
*size = target;
return {};
}
if (size)
*size = pixmap.size();
return pixmap;
}
@@ -1,10 +0,0 @@
#pragma once
#include <QQuickImageProvider>
class DesktopIconProvider : public QQuickImageProvider
{
public:
DesktopIconProvider();
QPixmap requestPixmap(const QString &id, QSize *size, const QSize &requestedSize) override;
};
@@ -1,91 +0,0 @@
#include "OutputTracker.hpp"
#include <QCoreApplication>
#include <QGuiApplication>
#include <QJSEngine>
#include <QRect>
OutputTracker::OutputTracker(QObject *parent)
: QObject(parent)
{
if (auto *app = qobject_cast<QGuiApplication *>(QCoreApplication::instance())) {
connect(app, &QGuiApplication::primaryScreenChanged, this, [this](QScreen *screen) {
bindScreen(screen);
});
connect(app, &QGuiApplication::screenAdded, this, [this](QScreen *) {
if (!m_screen)
bindScreen(QGuiApplication::primaryScreen());
});
connect(app, &QGuiApplication::screenRemoved, this, [this](QScreen *screen) {
if (m_screen == screen)
bindScreen(QGuiApplication::primaryScreen());
});
bindScreen(app->primaryScreen());
}
}
OutputTracker *OutputTracker::create(QQmlEngine *engine, QJSEngine *)
{
auto *tracker = new OutputTracker(engine);
QQmlEngine::setObjectOwnership(tracker, QQmlEngine::CppOwnership);
return tracker;
}
void OutputTracker::bindScreen(QScreen *screen)
{
if (m_screen == screen)
return;
if (m_screen) {
disconnect(m_screen, nullptr, this, nullptr);
}
m_screen = screen;
if (m_screen) {
connect(m_screen, &QScreen::geometryChanged, this, [this](const QRect &) {
logGeometry();
emit geometryChanged();
});
connect(m_screen, &QScreen::physicalDotsPerInchChanged, this, &OutputTracker::geometryChanged);
}
logGeometry();
emit geometryChanged();
}
void OutputTracker::logGeometry() const
{
if (!m_screen) {
qWarning("nebula-shell: no Wayland output is available yet");
return;
}
const QRect geo = m_screen->geometry();
qInfo("nebula-shell: output %s %dx%d+%d+%d scale %g",
qPrintable(m_screen->name()),
geo.width(),
geo.height(),
geo.x(),
geo.y(),
m_screen->devicePixelRatio());
}
int OutputTracker::width() const
{
return m_screen ? m_screen->geometry().width() : 0;
}
int OutputTracker::height() const
{
return m_screen ? m_screen->geometry().height() : 0;
}
qreal OutputTracker::devicePixelRatio() const
{
return m_screen ? m_screen->devicePixelRatio() : 1.0;
}
QString OutputTracker::name() const
{
return m_screen ? m_screen->name() : QString();
}
@@ -1,38 +0,0 @@
#pragma once
#include <QObject>
#include <QPointer>
#include <QQmlEngine>
#include <QScreen>
#include <QtQml/qqmlregistration.h>
class QJSEngine;
class OutputTracker : public QObject
{
Q_OBJECT
QML_ELEMENT
QML_SINGLETON
Q_PROPERTY(int width READ width NOTIFY geometryChanged)
Q_PROPERTY(int height READ height NOTIFY geometryChanged)
Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY geometryChanged)
Q_PROPERTY(QString name READ name NOTIFY geometryChanged)
public:
explicit OutputTracker(QObject *parent = nullptr);
static OutputTracker *create(QQmlEngine *engine, QJSEngine *scriptEngine);
int width() const;
int height() const;
qreal devicePixelRatio() const;
QString name() const;
signals:
void geometryChanged();
private:
void bindScreen(QScreen *screen);
void logGeometry() const;
QPointer<QScreen> m_screen;
};
-89
View File
@@ -1,89 +0,0 @@
#include "DesktopIconProvider.hpp"
#include <QCoreApplication>
#include <QDir>
#include <QGuiApplication>
#include <QIcon>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
#include <QUrl>
#include <QtGlobal>
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
#include <LayerShellQt/Shell>
#endif
namespace {
void initializeIconTheme()
{
if (QIcon::themeName().isEmpty()) {
const QStringList candidates = {
QStringLiteral("Adwaita"),
QStringLiteral("Yaru"),
QStringLiteral("ubuntu-mono-dark"),
QStringLiteral("breeze"),
QStringLiteral("hicolor"),
};
const QStringList searchPaths = QIcon::themeSearchPaths();
for (const QString &theme : candidates) {
for (const QString &root : searchPaths) {
if (QDir(root + QLatin1Char('/') + theme).exists()) {
QIcon::setThemeName(theme);
break;
}
}
if (!QIcon::themeName().isEmpty())
break;
}
}
if (QIcon::fallbackThemeName().isEmpty())
QIcon::setFallbackThemeName(QStringLiteral("hicolor"));
}
} // namespace
int main(int argc, char *argv[])
{
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
LayerShellQt::Shell::useLayerShell();
#endif
QGuiApplication app(argc, argv);
app.setApplicationName(QStringLiteral("nebula-shell"));
app.setApplicationDisplayName(QStringLiteral("Nebula Desktop"));
app.setOrganizationName(QStringLiteral("NebulaOS"));
app.setDesktopFileName(QStringLiteral("org.nebulaos.shell"));
initializeIconTheme();
QQuickWindow::setDefaultAlphaBuffer(true);
QQmlApplicationEngine engine;
engine.addImportPath(QStringLiteral("qrc:/qt/qml"));
engine.addImageProvider(QStringLiteral("desktopicon"), new DesktopIconProvider);
QObject::connect(
&engine,
&QQmlApplicationEngine::objectCreationFailed,
&app,
[]() {
qCritical("nebula-shell: failed to load the Nebula QML module.");
QCoreApplication::exit(EXIT_FAILURE);
},
Qt::QueuedConnection);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
engine.loadFromModule(QStringLiteral("Nebula.Shell"), QStringLiteral("Main"));
#else
engine.load(QUrl(QStringLiteral("qrc:/qt/qml/Nebula/Shell/Main.qml")));
#endif
if (engine.rootObjects().isEmpty()) {
qCritical("nebula-shell: failed to load the Nebula QML module.");
return EXIT_FAILURE;
}
return app.exec();
}