Skip to content

Commit 5f2f0ad

Browse files
committed
Add AppMenuBar singleton
1 parent f9020b2 commit 5f2f0ad

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

src/app/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ qt_add_executable(${APP_TARGET}
44
main.cpp
55
app.cpp
66
app.h
7+
appmenubar.cpp
8+
appmenubar.h
79
)
810

911
qt_add_qml_module(${APP_TARGET}

src/app/appmenubar.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
3+
#include "appmenubar.h"
4+
#include "uicomponents/menubarmodel.h"
5+
#include "uicomponents/menumodel.h"
6+
#include "uicomponents/menuitemmodel.h"
7+
8+
using namespace scratchcpp;
9+
using namespace scratchcpp::uicomponents;
10+
11+
AppMenuBar::AppMenuBar(QObject *parent) :
12+
QObject(parent),
13+
m_model(new MenuBarModel(this))
14+
{
15+
}
16+
17+
MenuBarModel *AppMenuBar::model() const
18+
{
19+
return m_model;
20+
}

src/app/appmenubar.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
3+
#pragma once
4+
5+
#include <QQmlEngine>
6+
7+
Q_MOC_INCLUDE("uicomponents/menubarmodel.h")
8+
9+
namespace scratchcpp
10+
{
11+
12+
namespace uicomponents
13+
{
14+
15+
class MenuBarModel;
16+
17+
}
18+
19+
class AppMenuBar : public QObject
20+
{
21+
Q_OBJECT
22+
QML_ELEMENT
23+
QML_SINGLETON
24+
Q_PROPERTY(uicomponents::MenuBarModel *model READ model NOTIFY modelChanged)
25+
26+
public:
27+
explicit AppMenuBar(QObject *parent = nullptr);
28+
29+
uicomponents::MenuBarModel *model() const;
30+
31+
signals:
32+
void modelChanged();
33+
34+
private:
35+
uicomponents::MenuBarModel *m_model = nullptr;
36+
};
37+
38+
} // namespace scratchcpp

0 commit comments

Comments
 (0)