为FluentMenu提供更完善的封装类型FluentMenuButton | #24
parent
291d112d11
commit
3a693de9fe
|
@ -128,6 +128,7 @@
|
||||||
<ClCompile Include="src\Editor\util\PaintingUtil.cpp" />
|
<ClCompile Include="src\Editor\util\PaintingUtil.cpp" />
|
||||||
<ClCompile Include="src\Editor\util\SvgFileLoader.cpp" />
|
<ClCompile Include="src\Editor\util\SvgFileLoader.cpp" />
|
||||||
<ClCompile Include="src\FluentMenu.cpp" />
|
<ClCompile Include="src\FluentMenu.cpp" />
|
||||||
|
<ClCompile Include="src\FluentMenuButton.cpp" />
|
||||||
<ClCompile Include="src\gl.c" />
|
<ClCompile Include="src\gl.c" />
|
||||||
<ClCompile Include="src\main.cpp" />
|
<ClCompile Include="src\main.cpp" />
|
||||||
<ClCompile Include="src\MainWindow.cpp" />
|
<ClCompile Include="src\MainWindow.cpp" />
|
||||||
|
@ -224,6 +225,7 @@
|
||||||
<ClInclude Include="src\Editor\util\PaintingUtil.h" />
|
<ClInclude Include="src\Editor\util\PaintingUtil.h" />
|
||||||
<ClInclude Include="src\Editor\util\SvgFileLoader.h" />
|
<ClInclude Include="src\Editor\util\SvgFileLoader.h" />
|
||||||
<QtMoc Include="src\FluentMenu.h" />
|
<QtMoc Include="src\FluentMenu.h" />
|
||||||
|
<ClInclude Include="src\FluentMenuButton.h" />
|
||||||
<ClInclude Include="src\Renderer\IblUtils.h" />
|
<ClInclude Include="src\Renderer\IblUtils.h" />
|
||||||
<ClInclude Include="src\Renderer\Painting\BaseStyle.h" />
|
<ClInclude Include="src\Renderer\Painting\BaseStyle.h" />
|
||||||
<ClInclude Include="src\Renderer\Painting\CubicBezierSignedDistance.h" />
|
<ClInclude Include="src\Renderer\Painting\CubicBezierSignedDistance.h" />
|
||||||
|
|
|
@ -264,6 +264,9 @@
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp">
|
<ClCompile Include="src\Editor\EditorWidgetComponent\ColorPicker.cpp">
|
||||||
<Filter>Source Files\Editor</Filter>
|
<Filter>Source Files\Editor</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\FluentMenuButton.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||||
|
@ -531,6 +534,9 @@
|
||||||
<ClInclude Include="src\Editor\DataManager\ProjectDataManager.h">
|
<ClInclude Include="src\Editor\DataManager\ProjectDataManager.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\FluentMenuButton.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtRcc Include="res\MainWindow.qrc">
|
<QtRcc Include="res\MainWindow.qrc">
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QtMaterialFlatButton" name="openButton">
|
<widget class="FluentMenuButton" name="openButton">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -181,9 +181,9 @@
|
||||||
<header>RendererGLWidget.h</header>
|
<header>RendererGLWidget.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QtMaterialFlatButton</class>
|
<class>FluentMenuButton</class>
|
||||||
<extends>QPushButton</extends>
|
<extends>QPushButton</extends>
|
||||||
<header location="global">qtmaterialflatbutton.h</header>
|
<header>../FluentMenuButton.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
#include "FluentMenuButton.h"
|
||||||
|
|
||||||
|
FluentMenuButton::FluentMenuButton(QWidget* parent)
|
||||||
|
: FluentMenuButton("Menu", parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FluentMenuButton::FluentMenuButton(const QString& text, QWidget* parent)
|
||||||
|
: QtMaterialFlatButton(text, parent)
|
||||||
|
{
|
||||||
|
menu = new FluentMenu(this);
|
||||||
|
setHaloVisible(false);
|
||||||
|
setOverlayStyle(::Material::TintedOverlay);
|
||||||
|
setCheckable(true);
|
||||||
|
|
||||||
|
QObject::connect(menu, &QMenu::aboutToShow, [&] {
|
||||||
|
setChecked(true);
|
||||||
|
});
|
||||||
|
QObject::connect(menu, &QMenu::aboutToHide, [&] {
|
||||||
|
setChecked(false);
|
||||||
|
});
|
||||||
|
QObject::connect(this, &QPushButton::clicked, [&]() {
|
||||||
|
menu->exec(mapToGlobal(QPoint(0, height())));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void FluentMenuButton::addMenuAction(QAction* action)
|
||||||
|
{
|
||||||
|
menu->addAction(action);
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
#pragma once
|
||||||
|
#include <qtmaterialflatbutton.h>
|
||||||
|
#include "FluentMenu.h"
|
||||||
|
class FluentMenuButton : public QtMaterialFlatButton
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit FluentMenuButton(QWidget* parent = nullptr);
|
||||||
|
explicit FluentMenuButton(const QString& text, QWidget* parent = nullptr);
|
||||||
|
void addMenuAction(QAction* action);
|
||||||
|
|
||||||
|
FluentMenu* menu = nullptr;
|
||||||
|
};
|
|
@ -8,29 +8,14 @@ Renderer::RendererWidget::RendererWidget(QWidget* parent)
|
||||||
{
|
{
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
FluentMenu* menu = new FluentMenu(this);
|
auto openAction = new QAction(QStringLiteral("´ò¿ª"), ui.openButton);
|
||||||
auto openAction = new QAction(QStringLiteral("´ò¿ª"), menu);
|
auto saveAction = new QAction(QStringLiteral("±£´æ"), ui.openButton);
|
||||||
auto saveAction = new QAction(QStringLiteral("±£´æ"), menu);
|
auto testAction = new QAction(QStringLiteral("²âÊÔ"), ui.openButton);
|
||||||
auto testAction = new QAction(QStringLiteral("²âÊÔ"), menu);
|
auto test2Action = new QAction(QStringLiteral("²âÊÔ2"), ui.openButton);
|
||||||
auto test2Action = new QAction(QStringLiteral("²âÊÔ2"), menu);
|
ui.openButton->addMenuAction(openAction);
|
||||||
menu->addAction(openAction);
|
ui.openButton->addMenuAction(saveAction);
|
||||||
menu->addAction(saveAction);
|
ui.openButton->addMenuAction(testAction);
|
||||||
menu->addAction(testAction);
|
ui.openButton->addMenuAction(test2Action);
|
||||||
menu->addAction(test2Action);
|
|
||||||
|
|
||||||
ui.openButton->setHaloVisible(false);
|
|
||||||
ui.openButton->setOverlayStyle(::Material::TintedOverlay);
|
|
||||||
ui.openButton->setCheckable(true);
|
|
||||||
|
|
||||||
QObject::connect(menu, &QMenu::aboutToShow, [&]() {
|
|
||||||
ui.openButton->setChecked(true);
|
|
||||||
});
|
|
||||||
QObject::connect(menu, &QMenu::aboutToHide, [&]() {
|
|
||||||
ui.openButton->setChecked(false);
|
|
||||||
});
|
|
||||||
QObject::connect(ui.openButton, &QPushButton::clicked, [&, menu]() {
|
|
||||||
menu->exec(ui.openButton->mapToGlobal(QPoint(0, ui.openButton->height())));
|
|
||||||
});
|
|
||||||
|
|
||||||
QObject::connect(ui.horizontalSlider, &QSlider::valueChanged,
|
QObject::connect(ui.horizontalSlider, &QSlider::valueChanged,
|
||||||
ui.openGLWidget, &Renderer::RendererGLWidget::setMainLightPitch);
|
ui.openGLWidget, &Renderer::RendererGLWidget::setMainLightPitch);
|
||||||
|
|
Loading…
Reference in New Issue