PeriDyno 1.0.0
Loading...
Searching...
No Matches
PModuleEditorToolBar.cpp
Go to the documentation of this file.
2
3#include <QLabel>
4#include <QToolButton>
5
6#include "Platform.h"
7
10
11namespace dyno
12{
14 QFrame(parent)
15 {
16 mLayout = new QHBoxLayout;
17
18 mActionSave = this->addAction(QToolButton::InstantPopup, new QAction(QPixmap(QString::fromStdString(getAssetPath() + "icon/ToolBarIco/File/Save.png")), tr("&Save...")));
19 mActionUpdate = this->addAction(QToolButton::InstantPopup, new QAction(QPixmap(QString::fromStdString(getAssetPath() + "icon/ToolBarIco/Node/refresh_green.png")), tr("&Update...")));
20 mActionReorder = this->addAction(QToolButton::InstantPopup, new QAction(QPixmap(QString::fromStdString(getAssetPath() + "icon/ToolBarIco/Node/realign_v2.png")), tr("&Realign...")));
21
22 mLayout->addStretch();
23
24 mResetButton = this->addPushButton(QPixmap(QString::fromStdString(getAssetPath() + "icon/ToolBarIco/Node/refresh_blue.png")), "Reset");
25 mAnimationButton = this->addPushButton(QPixmap(QString::fromStdString(getAssetPath() + "icon/ToolBarIco/Node/animation.png")), "Animation");
26 mRenderingButton = this->addPushButton(QPixmap(QString::fromStdString(getAssetPath() + "icon/ToolBarIco/Node/Display.png")), "Rendering");
27
28 mResetButton->setObjectName("mResetButton");
29 mAnimationButton->setObjectName("mAnimationButton");
30 mRenderingButton->setObjectName("mRenderingButton");
31
32 mResetButton->setChecked(false);
33 mAnimationButton->setChecked(true);
34 mRenderingButton->setChecked(false);
35
36 this->setLayout(mLayout);
37
38 connect(mResetButton, &QPushButton::released, this, &PModuleEditorToolBar::resetButtonClicked);
39 connect(mAnimationButton, &QPushButton::released, this, &PModuleEditorToolBar::animationButtonClicked);
40 connect(mRenderingButton, &QPushButton::released, this, &PModuleEditorToolBar::renderingButtonClicked);
41
42 this->setStyleSheet("border-radius: 4px; border: 1px solid rgb(120,120,120);");
43
44 mResetButton->setStyleSheet("border: none;");
45 mRenderingButton->setStyleSheet("border: none;");
46 mAnimationButton->setStyleSheet("border: none;");
47
48 }
49
50 QAction* PModuleEditorToolBar::addAction(QToolButton::ToolButtonPopupMode type, QAction* action, QMenu* menu /*= nullptr*/)
51 {
52 if (type == QToolButton::MenuButtonPopup)
53 {
54 mLayout->addWidget(new tt::CompactToolButton(action, menu, this));
55 }
56 else
57 {
58 const int iconSize = 48;
59 QToolButton* btn = new QToolButton(this);
60 btn->setProperty("TTInternal", QVariant(true));
61 btn->setAutoRaise(true);
62 btn->setDefaultAction(action);
63 btn->setIconSize(QSize(iconSize, iconSize));
64 btn->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
65 btn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
66 btn->setPopupMode(type);
67 btn->setStyle(new tt::TTToolButtonStyle());
68 if (menu)
69 btn->setMenu(menu);
70 mLayout->addWidget(btn);
71 }
72
73 return action;
74 }
75
76 QPushButton* PModuleEditorToolBar::addPushButton(QPixmap icon, QString text)
77 {
78 const int iconSize = 48;
79 QPushButton* button = new QPushButton;
80
81 button->setIconSize(QSize(iconSize, iconSize));
82 button->setFixedWidth(160);
83 button->setIcon(icon);//直接调用PushButton的setIcon和setText添加icon和文字,以修复Label布局下文字无法高亮的问题。
84 button->setText(text);//
85
86 button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
87
88 button->setCheckable(true);
89/*
90 QLabel* iconLabel = new QLabel;
91 QLabel* textLabel = new QLabel;
92
93 //iconLabel->setStyleSheet("background: transparent;");
94 //textLabel->setStyleSheet("background: transparent;");
95
96 iconLabel->resize(iconSize, iconSize);
97 iconLabel->setPixmap(icon);
98 textLabel->setText(text);
99
100 iconLabel->setMinimumWidth(iconSize);
101 textLabel->setMinimumWidth(60);
102 //textLabel->setFixedWidth(60);
103 QHBoxLayout* btnLayout = new QHBoxLayout();
104 btnLayout->setSpacing(0);
105
106 btnLayout->addSpacing(2);
107 btnLayout->addWidget(iconLabel);
108 btnLayout->addSpacing(2);
109 btnLayout->addWidget(textLabel);
110 btnLayout->addSpacing(2);
111 button->setLayout(btnLayout);
112
113// button->setStyleSheet(
114// "QPushButton{border: 1px solid #dcdfe6; padding: 10px; border-radius: 5px; background-color: #ffffff;}"
115// "QPushButton:hover{background-color: #ecf5ff; color: #409eff;}"
116// "QPushButton:checked{border: 1px solid #3a8ee6; color: #409eff;}");
117*/
118 mLayout->addWidget(button);
119
120 return button;
121 }
122
124 {
125 mResetButton->setChecked(true);
126 mAnimationButton->setChecked(false);
127 mRenderingButton->setChecked(false);
128
129 emit showResetPipeline();
130 }
131
133 {
134 mResetButton->setChecked(false);
135 mAnimationButton->setChecked(true);
136 mRenderingButton->setChecked(false);
137
139 }
140
142 {
143 mResetButton->setChecked(false);
144 mAnimationButton->setChecked(false);
145 mRenderingButton->setChecked(true);
146
148 }
149}
150
PModuleEditorToolBar(QWidget *parent=nullptr)
QAction * addAction(QToolButton::ToolButtonPopupMode type, QAction *action, QMenu *menu=nullptr)
QPushButton * addPushButton(QPixmap icon, QString text)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25