| 60 | } |
| 61 | |
| 62 | void Application::CreateLayout() { |
| 63 | auto root_widget = new RoundRectWidget(0xffffff, 0, this); |
| 64 | auto root_layout = new QHBoxLayout(); |
| 65 | WidgetHelper::ClearMargins(root_layout); |
| 66 | int margin = 20; |
| 67 | root_layout->setContentsMargins(0, margin, margin, margin); |
| 68 | |
| 69 | // 1. app menu |
| 70 | content_widget_ = new QStackedWidget(this); |
| 71 | content_widget_->setContentsMargins(0,0,0,0); |
| 72 | content_widget_->setStyleSheet("border:none;background-color:#ffffff;"); |
| 73 | |
| 74 | std::vector<AppItemDesc> menus = { |
| 75 | {tr("GAMES"), ":/resources/image/ic_stream.svg"}, |
| 76 | {tr("SETTINGS"), ":/resources/image/ic_settings.svg"}, |
| 77 | //{tr("ABOUT"), ":/resources/image/ic_settings.svg"} |
| 78 | }; |
| 79 | app_menu_ = new AppMenu(menus, this); |
| 80 | app_menu_->SetOnItemClickedCallback([this](const QString& name, int idx) { |
| 81 | content_widget_->setCurrentIndex(idx); |
| 82 | }); |
| 83 | |
| 84 | auto menu_layout = new NoMarginVLayout(); |
| 85 | menu_layout->addWidget(app_menu_); |
| 86 | menu_layout->addStretch(); |
| 87 | |
| 88 | auto lbl_version = new QLabel(); |
| 89 | lbl_version->setFixedWidth(app_menu_->width()); |
| 90 | lbl_version->setAlignment(Qt::AlignCenter); |
| 91 | lbl_version->setText(Settings::Instance()->version_.c_str()); |
| 92 | menu_layout->addWidget(lbl_version); |
| 93 | |
| 94 | root_layout->addLayout(menu_layout); |
| 95 | |
| 96 | // 2. stream list |
| 97 | |
| 98 | // streams |
| 99 | auto stream_content = new StreamContent(context_, this); |
| 100 | content_widget_->addWidget(stream_content); |
| 101 | stream_content_ = stream_content; |
| 102 | |
| 103 | // settings |
| 104 | auto settings_content = new SettingsContent(context_, this); |
| 105 | content_widget_->addWidget(settings_content); |
| 106 | |
| 107 | // about |
| 108 | auto about_content = new AboutContent(context_, this); |
| 109 | content_widget_->addWidget(about_content); |
| 110 | |
| 111 | root_layout->addWidget(content_widget_); |
| 112 | root_widget->setLayout(root_layout); |
| 113 | setCentralWidget(root_widget); |
| 114 | |
| 115 | content_widget_->setCurrentIndex(0); |
| 116 | } |
| 117 | |
| 118 | void Application::Init() { |
| 119 | msg_listener_ = context_->ObtainMessageListener(); |
nothing calls this directly
no test coverage detected