diff --git a/NineChess/src/ninechesswindow.cpp b/NineChess/src/ninechesswindow.cpp index 2095afb3..363a069d 100644 --- a/NineChess/src/ninechesswindow.cpp +++ b/NineChess/src/ninechesswindow.cpp @@ -306,8 +306,22 @@ void NineChessWindow::initialize() QWidget::setWindowFlags(Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint); #endif // SHOW_MAXIMIZED_ON_LOAD + +#ifdef MOBILE_APP_UI + ui.pushButton_option->setContextMenuPolicy(Qt::ActionsContextMenu); + connect(ui.pushButton_option, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ctxMenu(const QPoint &))); +#endif /* MOBILE_APP_UI */ } +#ifdef MOBILE_APP_UI +void NineChessWindow::ctxMenu(const QPoint &pos) +{ + QMenu *menu = new QMenu; + menu->addAction(tr("Test Item"), this, SLOT(on_actionNew_N_triggered())); + menu->exec(ui.pushButton_option->mapToGlobal(pos)); +} +#endif /* MOBILE_APP_UI */ + void NineChessWindow::ruleInfo() { int s = game->getStepsLimit(); diff --git a/NineChess/src/ninechesswindow.h b/NineChess/src/ninechesswindow.h index ac7a9235..918baa2b 100644 --- a/NineChess/src/ninechesswindow.h +++ b/NineChess/src/ninechesswindow.h @@ -63,6 +63,11 @@ private slots: // 初始化 void initialize(); +#ifdef MOBILE_APP_UI + // 上下文菜单 + void ctxMenu(const QPoint &pos); +#endif /* MOBILE_APP_UI */ + // 动态增加的菜单栏动作的槽函数 void actionRules_triggered();