本文整理汇总了C++中ContextMenu::addItem方法的典型用法代码示例。如果您正苦于以下问题:C++ ContextMenu::addItem方法的具体用法?C++ ContextMenu::addItem怎么用?C++ ContextMenu::addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContextMenu
的用法示例。
在下文中一共展示了ContextMenu::addItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MainMenu
TopMenu::TopMenu(Widget* parent, const int height , bool useIcon)
: MainMenu( parent, Rect( 0, 0, parent->width(), height ) ),
_d( new Impl )
{
setupUI( ":/gui/topmenu.gui" );
setGeometry( Rect( 0, 0, parent->width(), height ) );
_d->initBackground( size() );
_d->useIcon = useIcon;
GET_DWIDGET_FROM_UI( _d, lbPopulation )
GET_DWIDGET_FROM_UI( _d, lbFunds )
GET_DWIDGET_FROM_UI( _d, lbDate )
if( _d->lbPopulation )
{
_d->lbPopulation->setPosition( Point( width() - populationLabelOffset, 0 ) );
_d->lbPopulation->setIcon( useIcon ? Picture( "population", 1 ) : Picture() );
}
if( _d->lbFunds )
{
_d->lbFunds->setPosition( Point( width() - fundLabelOffset, 0) );
_d->lbFunds->setIcon( useIcon ? Picture( "paneling", 332 ) : Picture() );
}
if( _d->lbDate )
_d->lbDate->setPosition( Point( width() - dateLabelOffset, 0) );
ContextMenuItem* tmp = addItem( _("##gmenu_file##"), -1, true, true, false, false );
ContextMenu* file = tmp->addSubMenu();
ContextMenuItem* restart = file->addItem( _("##gmenu_file_restart##"), -1, true, false, false, false );
ContextMenuItem* load = file->addItem( _("##mainmenu_loadgame##"), -1, true, false, false, false );
ContextMenuItem* save = file->addItem( _("##gmenu_file_save##"), -1, true, false, false, false );
ContextMenuItem* mainMenu = file->addItem( _("##gmenu_file_mainmenu##"), -1, true, false, false, false );
ContextMenuItem* exit = file->addItem( _("##gmenu_exit_game##"), -1, true, false, false, false );
CONNECT( restart, onClicked(), &_d->onRestartSignal, Signal0<>::_emit );
CONNECT( exit, onClicked(), &_d->onExitSignal, Signal0<>::_emit );
CONNECT( save, onClicked(), &_d->onSaveSignal, Signal0<>::_emit );
CONNECT( load, onClicked(), &_d->onLoadSignal, Signal0<>::_emit );
CONNECT( mainMenu, onClicked(), &_d->onEndSignal, Signal0<>::_emit );
tmp = addItem( _("##gmenu_options##"), -1, true, true, false, false );
ContextMenu* options = tmp->addSubMenu();
ContextMenuItem* screen = options->addItem( _("##screen_settings##"), -1, true, false, false, false );
ContextMenuItem* sound = options->addItem( _("##sound_settings##"), -1, true, false, false, false );
ContextMenuItem* speed = options->addItem( _("##speed_settings##"), -1, true, false, false, false );
ContextMenuItem* cityopts = options->addItem( _("##city_settings##"), -1, true, false, false, false );
CONNECT( screen, onClicked(), &_d->onShowVideoOptionsSignal, Signal0<>::_emit );
CONNECT( speed, onClicked(), &_d->onShowGameSpeedOptionsSignal, Signal0<>::_emit );
CONNECT( sound, onClicked(), &_d->onShowSoundOptionsSignal, Signal0<>::_emit );
CONNECT( cityopts, onClicked(), &_d->onShowCityOptionsSignal, Signal0<>::_emit );
tmp = addItem( _("##gmenu_help##"), -1, true, true, false, false );
ContextMenu* helpMenu = tmp->addSubMenu();
ContextMenuItem* aboutItem = helpMenu->addItem( _("##gmenu_about##"), -1 );
ContextMenuItem* shortkeysItem = helpMenu->addItem( _("##gmenu_shortkeys##"), -1 );
CONNECT( aboutItem, onClicked(), _d.data(), Impl::showAboutInfo );
CONNECT( shortkeysItem, onClicked(), _d.data(), Impl::showShortKeyInfo );
tmp = addItem( _("##gmenu_advisors##"), -1, true, true, false, false );
ContextMenu* advisersMenu = tmp->addSubMenu();
advisersMenu->addItem( _("##visit_labor_advisor##"), advisor::employers );
advisersMenu->addItem( _("##visit_military_advisor##" ), advisor::military );
advisersMenu->addItem( _("##visit_imperial_advisor##" ), advisor::empire );
advisersMenu->addItem( _("##visit_rating_advisor##" ), advisor::ratings );
advisersMenu->addItem( _("##visit_trade_advisor##" ), advisor::trading );
advisersMenu->addItem( _("##visit_population_advisor##" ), advisor::population );
advisersMenu->addItem( _("##visit_health_advisor##" ), advisor::health );
advisersMenu->addItem( _("##visit_education_advisor##" ), advisor::education );
advisersMenu->addItem( _("##visit_religion_advisor##" ), advisor::religion );
advisersMenu->addItem( _("##visit_entertainment_advisor##"), advisor::entertainment );
advisersMenu->addItem( _("##visit_financial_advisor##" ), advisor::finance );
advisersMenu->addItem( _("##visit_chief_advisor##" ), advisor::main );
CONNECT( advisersMenu, onItemAction(), _d.data(), Impl::resolveAdvisorShow );
_d->updateDate();
}