This repository was archived by the owner on Jan 31, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathOverlayWidget.cpp
More file actions
70 lines (49 loc) · 2.14 KB
/
Copy pathOverlayWidget.cpp
File metadata and controls
70 lines (49 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) 2020 The Orbit Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "SessionSetup/OverlayWidget.h"
#include <QColor>
#include <QLabel>
#include <QPainter>
#include <QProgressBar>
#include <QPushButton>
#include "OrbitBase/Logging.h"
#include "ui_OverlayWidget.h"
namespace {
// This color is used as a "background" for the overlay. The alpha value makes it transparent
const QColor kOverlayShadeColor{100, 100, 100, 200};
} // namespace
namespace orbit_session_setup {
// The destructor needs to be defined here because it needs to see the type
// `Ui::LoadCaptureWidget`. The header file only contains a forward declaration.
OverlayWidget::~OverlayWidget() = default;
OverlayWidget::OverlayWidget(QWidget* parent)
: QWidget(parent), ui_(std::make_unique<Ui::OverlayWidget>()) {
ORBIT_CHECK(parent != nullptr);
parent->installEventFilter(this);
ui_->setupUi(this);
ui_->cancelButton->setEnabled(true);
QObject::connect(ui_->cancelButton, &QPushButton::clicked, this, [this] { emit Cancelled(); });
}
void OverlayWidget::paintEvent(QPaintEvent* /*event*/) {
QPainter(this).fillRect(rect(), kOverlayShadeColor);
}
bool OverlayWidget::eventFilter(QObject* obj, QEvent* event) {
if (obj == parent() && event->type() == QEvent::Resize) {
resize(parentWidget()->size());
}
return false;
}
void OverlayWidget::SetSpinning(bool value) { ui_->progressBar->setVisible(value); }
void OverlayWidget::SetCancelable(bool value) { ui_->cancelButton->setVisible(value); }
void OverlayWidget::SetStatusMessage(const QString& message) {
ui_->messageLabel->setText(message);
}
void OverlayWidget::SetButtonMessage(const QString& message) {
ui_->cancelButton->setText(message);
}
bool OverlayWidget::IsSpinning() const { return ui_->progressBar->isVisible(); }
bool OverlayWidget::IsCancelable() const { return ui_->cancelButton->isVisible(); }
QString OverlayWidget::GetStatusMessage() const { return ui_->messageLabel->text(); }
QString OverlayWidget::GetButtonMessage() const { return ui_->cancelButton->text(); }
} // namespace orbit_session_setup