命名规范
This commit is contained in:
@@ -5,87 +5,87 @@
|
||||
|
||||
|
||||
|
||||
BaseWidgetMenu::BaseWidgetMenu(QWidget* parent) : QWidget(parent){
|
||||
setObjectName("BaseWidgetMenu");
|
||||
Base_Widget_Menu::Base_Widget_Menu(QWidget* parent) : QWidget(parent){
|
||||
setObjectName("Base_Widget_Menu");
|
||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||
mMainLayout = new QVBoxLayout(this);
|
||||
mFirstLayout = new QHBoxLayout();
|
||||
mMainLayout->addLayout(mFirstLayout, 1);
|
||||
mSecondLayout = new QHBoxLayout();
|
||||
mMainLayout->addLayout(mSecondLayout, 1);
|
||||
mRollObject.mEnterFunc = [](AbstractMenuButton* btn){
|
||||
main_layout = new QVBoxLayout(this);
|
||||
first_layout = new QHBoxLayout();
|
||||
main_layout->addLayout(first_layout, 1);
|
||||
second_layout = new QHBoxLayout();
|
||||
main_layout->addLayout(second_layout, 1);
|
||||
roll_object.enter_func = [](Abstract_Menu_Button* btn){
|
||||
btn->setChecked(true);
|
||||
};
|
||||
mRollObject.mLeaveFunc = [](AbstractMenuButton* btn){
|
||||
roll_object.leave_func = [](Abstract_Menu_Button* btn){
|
||||
btn->setChecked(false);
|
||||
};
|
||||
hide();
|
||||
}
|
||||
|
||||
void BaseWidgetMenu::paintEvent(QPaintEvent *event) {
|
||||
void Base_Widget_Menu::paintEvent(QPaintEvent *event) {
|
||||
QPainter painter(this);
|
||||
painter.setPen(Qt::NoPen);
|
||||
QPalette palette = QApplication::style()->standardPalette();
|
||||
const QBrush& base1Brush = palette.brush(QPalette::Window);
|
||||
painter.setBrush(base1Brush);
|
||||
const QBrush& base1_brush = palette.brush(QPalette::Window);
|
||||
painter.setBrush(base1_brush);
|
||||
painter.drawRect(rect());
|
||||
painter.end();
|
||||
}
|
||||
|
||||
void BaseWidgetMenu::hideEvent(QHideEvent *event) {
|
||||
void Base_Widget_Menu::hideEvent(QHideEvent *event) {
|
||||
for(auto btn : sons){
|
||||
btn->hide();
|
||||
}
|
||||
emit hideThat();
|
||||
emit hide_that();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void BaseWidgetMenu::showEvent(QShowEvent *event) {
|
||||
if(!mRollObject.mWidgets.empty()) mRollObject.mEnterFunc(mRollObject.cur());
|
||||
emit showThat();
|
||||
void Base_Widget_Menu::showEvent(QShowEvent *event) {
|
||||
if(!roll_object.widgets.empty()) roll_object.enter_func(roll_object.cur());
|
||||
emit show_that();
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void BaseWidgetMenu::addMenuButtonOnLayout1(const QVector<AbstractMenuButton *>& buttons, int stretch) {
|
||||
for(AbstractMenuButton* btn : buttons){
|
||||
mFirstLayout->addWidget(btn, 1);
|
||||
mRollObject.mWidgets.push_back(btn);
|
||||
btn->mParentMenu = this;
|
||||
void Base_Widget_Menu::add_menu_button_on_layout1(const QVector<Abstract_Menu_Button *>& buttons, int stretch) {
|
||||
for(Abstract_Menu_Button* btn : buttons){
|
||||
first_layout->addWidget(btn, 1);
|
||||
roll_object.widgets.push_back(btn);
|
||||
btn->parent_menu = this;
|
||||
}
|
||||
if(stretch != 0) {
|
||||
mFirstLayout->addStretch(stretch);
|
||||
mFirstLayout->addSpacing(mSecondLayout->spacing() * stretch);
|
||||
first_layout->addStretch(stretch);
|
||||
first_layout->addSpacing(second_layout->spacing() * stretch);
|
||||
};
|
||||
}
|
||||
|
||||
void BaseWidgetMenu::addMenuButtonOnLayout2(const QVector<AbstractMenuButton *>& buttons, int stretch) {
|
||||
for(AbstractMenuButton* btn : buttons){
|
||||
mSecondLayout->addWidget(btn, 1);
|
||||
mRollObject.mWidgets.push_back(btn);
|
||||
btn->mParentMenu = this;
|
||||
void Base_Widget_Menu::add_menu_button_on_layout2(const QVector<Abstract_Menu_Button *>& buttons, int stretch) {
|
||||
for(Abstract_Menu_Button* btn : buttons){
|
||||
second_layout->addWidget(btn, 1);
|
||||
roll_object.widgets.push_back(btn);
|
||||
btn->parent_menu = this;
|
||||
}
|
||||
|
||||
if(stretch != 0) {
|
||||
mSecondLayout->addStretch(stretch);
|
||||
mSecondLayout->addSpacing(mSecondLayout->spacing() * stretch);
|
||||
second_layout->addStretch(stretch);
|
||||
second_layout->addSpacing(second_layout->spacing() * stretch);
|
||||
};
|
||||
}
|
||||
|
||||
void BaseWidgetMenu::addMenuButtonOnLayout1(const QVector<AbstractMenuButton *>& buttons) {
|
||||
addMenuButtonOnLayout1(buttons, 5 - buttons.size());
|
||||
void Base_Widget_Menu::add_menu_button_on_layout1(const QVector<Abstract_Menu_Button *>& buttons) {
|
||||
add_menu_button_on_layout1(buttons, 5 - buttons.size());
|
||||
}
|
||||
|
||||
void BaseWidgetMenu::addMenuButtonOnLayout2(const QVector<AbstractMenuButton *>& buttons) {
|
||||
addMenuButtonOnLayout2(buttons, 5 - buttons.size());
|
||||
void Base_Widget_Menu::add_menu_button_on_layout2(const QVector<Abstract_Menu_Button *>& buttons) {
|
||||
add_menu_button_on_layout2(buttons, 5 - buttons.size());
|
||||
}
|
||||
|
||||
BaseWidgetMenu* BaseWidgetMenu::createSubWidgetMenu(AbstractMenuButton *btn) {
|
||||
auto ret = new BaseWidgetMenu(parentWidget());
|
||||
ret->parentBtn = btn;
|
||||
Base_Widget_Menu* Base_Widget_Menu::create_sub_widget_menu(Abstract_Menu_Button *btn) {
|
||||
auto ret = new Base_Widget_Menu(parentWidget());
|
||||
ret->parent_btn = btn;
|
||||
ret->hide();
|
||||
ret->father = this;
|
||||
sons.push_back(ret);
|
||||
btn->mOwnMenu = ret;
|
||||
btn->own_menu = ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -93,24 +93,24 @@ BaseWidgetMenu* BaseWidgetMenu::createSubWidgetMenu(AbstractMenuButton *btn) {
|
||||
|
||||
|
||||
|
||||
void BaseWidgetMenu::keyPressEvent(QKeyEvent *event) {
|
||||
BackEnd* g = BackEnd::instance();
|
||||
void Base_Widget_Menu::keyPressEvent(QKeyEvent *event) {
|
||||
Back_End* g = Back_End::instance();
|
||||
if (g->match(event, "右移")) {
|
||||
mRollObject.rollRight();
|
||||
roll_object.roll_right();
|
||||
}
|
||||
else if (g->match(event, "左移")) {
|
||||
mRollObject.rollLeft();
|
||||
roll_object.roll_left();
|
||||
}
|
||||
else if (g->match(event, "增加")) {
|
||||
auto v = dynamic_cast<ValueMenuButton*>(mRollObject.cur());
|
||||
auto v = dynamic_cast<Value_Menu_Button*>(roll_object.cur());
|
||||
if(v){
|
||||
v->mValueChanged(v, true);
|
||||
v->value_changed(v, true);
|
||||
}
|
||||
}
|
||||
else if (g->match(event, "减小")) {
|
||||
auto v = dynamic_cast<ValueMenuButton*>(mRollObject.cur());
|
||||
auto v = dynamic_cast<Value_Menu_Button*>(roll_object.cur());
|
||||
if(v){
|
||||
v->mValueChanged(v, false);
|
||||
v->value_changed(v, false);
|
||||
}
|
||||
}
|
||||
else if (g->match(event, "确定")){
|
||||
@@ -125,8 +125,8 @@ void BaseWidgetMenu::keyPressEvent(QKeyEvent *event) {
|
||||
|
||||
|
||||
|
||||
void BaseWidgetMenu::confirm() {
|
||||
BaseWidgetMenu* m = mRollObject.cur()->mOwnMenu;
|
||||
void Base_Widget_Menu::confirm() {
|
||||
Base_Widget_Menu* m = roll_object.cur()->own_menu;
|
||||
if(m){
|
||||
m->resize(size());
|
||||
m->move(geometry().topLeft() + QPoint(0, -height()));
|
||||
@@ -134,17 +134,17 @@ void BaseWidgetMenu::confirm() {
|
||||
m->setFocus();
|
||||
m->show();
|
||||
} else {
|
||||
mRollObject.cur()->emit clicked();
|
||||
if(mRollObject.cur()->mClickHide){
|
||||
rootNode()->hide();
|
||||
roll_object.cur()->emit clicked();
|
||||
if(roll_object.cur()->click_hide){
|
||||
root_node()->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BaseWidgetMenu::esc(BaseWidgetMenu* menu){
|
||||
void Base_Widget_Menu::esc(Base_Widget_Menu* menu){
|
||||
if(menu->root()){
|
||||
MainWidget::instance()->getCurrentBaseWidget()->setFocus();
|
||||
Main_Widget::instance()->get_current_base_widget()->setFocus();
|
||||
} else {
|
||||
menu->father->setFocus();
|
||||
}
|
||||
@@ -152,7 +152,7 @@ void BaseWidgetMenu::esc(BaseWidgetMenu* menu){
|
||||
}
|
||||
|
||||
|
||||
void AbstractMenuButton::hideRoot() {
|
||||
MainWidget::instance()->getCurrentBaseWidget()->setFocus();
|
||||
mParentMenu->rootNode()->hide();
|
||||
void Abstract_Menu_Button::hide_root() {
|
||||
Main_Widget::instance()->get_current_base_widget()->setFocus();
|
||||
parent_menu->root_node()->hide();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user