| 25 | { |
| 26 | |
| 27 | FloatControllerPanel::FloatControllerPanel(const std::shared_ptr<ClientContext>& ctx, QWidget* parent) : BaseWidget(ctx, parent) { |
| 28 | this->setWindowFlags(Qt::FramelessWindowHint); |
| 29 | this->setFixedSize(kInitialWidth, 372); |
| 30 | this->setStyleSheet("background:#00000000;"); |
| 31 | auto root_layout = new QVBoxLayout(); |
| 32 | WidgetHelper::ClearMargins(root_layout); |
| 33 | int border_spacing = 5; |
| 34 | QSize btn_size = QSize(30, 30); |
| 35 | int offset = 5; |
| 36 | root_layout->setContentsMargins(offset, offset, offset, offset); |
| 37 | root_layout->addSpacing(border_spacing); |
| 38 | { |
| 39 | auto layout = new QHBoxLayout(); |
| 40 | |
| 41 | //屏幕索引切换按钮 |
| 42 | for (int i = 0; i < kMaxGameViewCount; i++) { |
| 43 | auto ci = new ComputerIcon(ctx, i, this); |
| 44 | ci->setFixedSize(QSize(26, 26)); |
| 45 | ci->UpdateSelectedState(true); |
| 46 | ci->Hide(); |
| 47 | layout->addSpacing(5); |
| 48 | layout->addWidget(ci); |
| 49 | computer_icons_.push_back(ci); |
| 50 | |
| 51 | ci->SetOnClickListener([=, this](auto w) { |
| 52 | bool recording = context_->GetRecording(); |
| 53 | if (recording) { |
| 54 | TcDialog dialog(tr("Tips"), tr("Currently, screen recording is in progress. Switching display is prohibited. If you want to switch displays, please stop the screen recording..."), nullptr); |
| 55 | auto pos = mapToGlobal(this->parentWidget()->pos()); |
| 56 | pos.setX(pos.x() + this->parentWidget()->width() / 2 - dialog.width() / 2); |
| 57 | pos.setY(pos.y() + this->parentWidget()->height() / 2 - dialog.height() / 2); |
| 58 | dialog.move(pos); |
| 59 | dialog.exec(); |
| 60 | return; |
| 61 | } |
| 62 | HideAllSubPanels(); |
| 63 | SwitchMonitor(ci); |
| 64 | }); |
| 65 | } |
| 66 | |
| 67 | //分屏按钮 |
| 68 | { |
| 69 | auto split_screen_btn = new FloatIcon(ctx, this); |
| 70 | split_screen_btn_ = split_screen_btn; |
| 71 | split_screen_btn->setFixedSize(btn_size); |
| 72 | split_screen_btn->SetIcons(":resources/image/separate_monitor.svg", ":resources/image/separate_monitor.svg"); |
| 73 | layout->addWidget(split_screen_btn); |
| 74 | |
| 75 | split_screen_btn->SetOnClickListener([=, this](QWidget* w) { |
| 76 | if (!context_->full_functionality_) { |
| 77 | TcDialog dialog(tr("Tips"), tr("You need to upgrade to the Super Edition to use the multi-screen display feature."), nullptr); |
| 78 | auto pos = mapToGlobal(this->parentWidget()->pos()); |
| 79 | pos.setX(pos.x() + this->parentWidget()->width() / 2 - dialog.width() / 2); |
| 80 | pos.setY(pos.y() + this->parentWidget()->height() / 2 - dialog.height() / 2); |
| 81 | dialog.move(pos); |
| 82 | dialog.exec(); |
| 83 | return; |
| 84 | } |
nothing calls this directly
no test coverage detected