AppUI: 添加右键菜单 (WIP)

This commit is contained in:
CalciteM Team 2019-08-27 13:05:17 +08:00
parent 0073169822
commit 7206e73428
2 changed files with 19 additions and 0 deletions

View File

@ -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();

View File

@ -63,6 +63,11 @@ private slots:
// 初始化
void initialize();
#ifdef MOBILE_APP_UI
// 上下文菜单
void ctxMenu(const QPoint &pos);
#endif /* MOBILE_APP_UI */
// 动态增加的菜单栏动作的槽函数
void actionRules_triggered();