| 19 | { |
| 20 | |
| 21 | ThirdResolutionPanel::ThirdResolutionPanel(const std::shared_ptr<ClientContext>& ctx, QWidget* parent) : BaseWidget(ctx, parent) { |
| 22 | this->setWindowFlags(Qt::FramelessWindowHint); |
| 23 | this->setStyleSheet("background:#00000000;"); |
| 24 | int offset = 5; |
| 25 | setFixedSize(210, 360); |
| 26 | auto item_height = 35; |
| 27 | auto border_spacing = 10; |
| 28 | auto item_size = QSize(this->width(), item_height); |
| 29 | auto root_layout = new NoMarginVLayout(); |
| 30 | root_layout->setContentsMargins(offset, offset, offset, offset); |
| 31 | settings_ = Settings::Instance(); |
| 32 | |
| 33 | listview_ = new SingleSelectedList(this); |
| 34 | listview_->setFixedSize(QSize(this->width() - 2*offset, this->height()-2*offset)); |
| 35 | |
| 36 | listview_->SetOnItemClickListener([=, this](int idx, QWidget*) { |
| 37 | auto item = listview_->GetItems().at(idx); |
| 38 | auto split_size = item->name_.split("x"); |
| 39 | if (split_size.size() < 2) { |
| 40 | return; |
| 41 | } |
| 42 | int width = split_size.at(0).toInt(); |
| 43 | int height = split_size.at(1).toInt(); |
| 44 | if (width <= 0 || height <= 0) { |
| 45 | LOGE("Error monitor resolution size: {}", item->name_.toStdString()); |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | auto monitor_name = monitor_.name_; |
| 50 | if (monitor_name.empty()) { |
| 51 | LOGE("Target monitor name is empty"); |
| 52 | return; |
| 53 | } |
| 54 | context_->SendAppMessage(MsgClientChangeMonitorResolution{ |
| 55 | .monitor_name_ = monitor_name, |
| 56 | .width_ = width, |
| 57 | .height_ = height, |
| 58 | }); |
| 59 | }); |
| 60 | |
| 61 | root_layout->addWidget(listview_); |
| 62 | root_layout->addStretch(); |
| 63 | setLayout(root_layout); |
| 64 | |
| 65 | msg_listener_->Listen<MsgClientMonitorChanged>([=, this](const MsgClientMonitorChanged& msg) { |
| 66 | context_->PostUITask([=, this]() { |
| 67 | this->SelectCapturingMonitorSize(); |
| 68 | }); |
| 69 | }); |
| 70 | } |
| 71 | |
| 72 | void ThirdResolutionPanel::paintEvent(QPaintEvent *event) { |
| 73 | QPainter painter(this); |
nothing calls this directly
no test coverage detected