forked from quickshell/quickshell
service/tray!: redesign menus / dbusmenu and add native menu support
Reworks dbusmenu menus to be displayable with a system context menu. Breaks the entire DBusMenu api.
This commit is contained in:
parent
c31bbea837
commit
ec362637b8
18 changed files with 898 additions and 191 deletions
72
src/core/platformmenu.hpp
Normal file
72
src/core/platformmenu.hpp
Normal file
|
@ -0,0 +1,72 @@
|
|||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include <qaction.h>
|
||||
#include <qactiongroup.h>
|
||||
#include <qcontainerfwd.h>
|
||||
#include <qmenu.h>
|
||||
#include <qobject.h>
|
||||
#include <qpoint.h>
|
||||
#include <qqmlintegration.h>
|
||||
#include <qqmllist.h>
|
||||
#include <qtclasshelpermacros.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
#include "qsmenu.hpp"
|
||||
|
||||
namespace qs::menu::platform {
|
||||
|
||||
class PlatformMenuQMenu: public QMenu {
|
||||
public:
|
||||
explicit PlatformMenuQMenu() = default;
|
||||
~PlatformMenuQMenu() override;
|
||||
Q_DISABLE_COPY_MOVE(PlatformMenuQMenu);
|
||||
|
||||
void setVisible(bool visible) override;
|
||||
|
||||
PlatformMenuQMenu* containingMenu = nullptr;
|
||||
};
|
||||
|
||||
class PlatformMenuEntry: public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
explicit PlatformMenuEntry(QsMenuEntry* menu);
|
||||
~PlatformMenuEntry() override;
|
||||
Q_DISABLE_COPY_MOVE(PlatformMenuEntry);
|
||||
|
||||
bool display(QObject* parentWindow, int relativeX, int relativeY);
|
||||
|
||||
static void registerCreationHook(std::function<void(PlatformMenuQMenu*)> hook);
|
||||
|
||||
signals:
|
||||
void closed();
|
||||
void relayoutParent();
|
||||
|
||||
public slots:
|
||||
void relayout();
|
||||
|
||||
private slots:
|
||||
void onAboutToShow();
|
||||
void onAboutToHide();
|
||||
void onActionTriggered();
|
||||
void onChildDestroyed();
|
||||
void onEnabledChanged();
|
||||
void onTextChanged();
|
||||
void onIconChanged();
|
||||
void onButtonTypeChanged();
|
||||
void onCheckStateChanged();
|
||||
|
||||
private:
|
||||
void clearChildren();
|
||||
void addToQMenu(PlatformMenuQMenu* menu);
|
||||
|
||||
QsMenuEntry* menu;
|
||||
PlatformMenuQMenu* qmenu = nullptr;
|
||||
QAction* qaction = nullptr;
|
||||
QActionGroup* qactiongroup = nullptr;
|
||||
QVector<PlatformMenuEntry*> childEntries;
|
||||
};
|
||||
|
||||
} // namespace qs::menu::platform
|
Loading…
Add table
Add a link
Reference in a new issue