File indexing completed on 2024-11-24 05:00:55

0001 /*  This file is part of the KDE libraries
0002     SPDX-FileCopyrightText: 2013 Kevin Ottens <ervin+bluesystems@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #ifndef KDEPLATFORMTHEME_H
0008 #define KDEPLATFORMTHEME_H
0009 
0010 #include <qpa/qplatformtheme.h>
0011 
0012 #include <QHash>
0013 #include <QKeySequence>
0014 
0015 class KHintsSettings;
0016 class KFontSettingsData;
0017 class KWaylandIntegration;
0018 class X11Integration;
0019 class QIconEngine;
0020 class QWindow;
0021 
0022 class KdePlatformTheme : public QPlatformTheme
0023 {
0024 public:
0025     KdePlatformTheme();
0026     ~KdePlatformTheme() override;
0027 
0028     QVariant themeHint(ThemeHint hint) const override;
0029     QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const override;
0030 
0031     const QPalette *palette(Palette type = SystemPalette) const override;
0032     const QFont *font(Font type) const override;
0033     QIconEngine *createIconEngine(const QString &iconName) const override;
0034     QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const override;
0035 
0036     QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const override;
0037     bool usePlatformNativeDialog(DialogType type) const override;
0038 
0039     QString standardButtonText(int button) const override;
0040 
0041     QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const override;
0042 
0043     QPlatformMenuBar *createPlatformMenuBar() const override;
0044 
0045     void globalMenuBarExistsNow();
0046     void globalMenuBarNoLongerExists();
0047     void windowCreated(QWindow *window);
0048 
0049 private:
0050     void setMenuBarForWindow(QWindow *window, const QString &serviceName, const QString &objectPath) const;
0051     void loadSettings();
0052     void setQtQuickControlsTheme();
0053 
0054     static void setWindowProperty(QWindow *window, const QByteArray &name, const QByteArray &value);
0055 
0056     static bool useXdgDesktopPortal();
0057 
0058     KHintsSettings *m_hints = nullptr;
0059     KFontSettingsData *m_fontsData = nullptr;
0060     QScopedPointer<KWaylandIntegration> m_kwaylandIntegration;
0061     QScopedPointer<X11Integration> m_x11Integration;
0062 };
0063 
0064 #endif // KDEPLATFORMTHEME_H