mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-27 08:41:02 +08:00
[ui] Use RoundProgressDialog instead of QProgressDialog
This commit is contained in:
parent
abcfa4ac47
commit
f547c62182
@ -61,7 +61,6 @@
|
|||||||
* : limitations under the License.
|
* : limitations under the License.
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
@ -72,14 +71,15 @@
|
|||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
#include <QMenu>
|
||||||
#include <QMoveEvent>
|
#include <QMoveEvent>
|
||||||
#include <QProgressDialog>
|
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QSignalBlocker>
|
#include <QSignalBlocker>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "blocks_tree_widget.h"
|
#include "blocks_tree_widget.h"
|
||||||
#include "arbitrary_value_tooltip.h"
|
#include "arbitrary_value_tooltip.h"
|
||||||
#include "round_progress_widget.h"
|
#include "round_progress_widget.h"
|
||||||
@ -370,8 +370,8 @@ BlocksTreeWidget::BlocksTreeWidget(QWidget* _parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_hintLabel = new QLabel("Use Right Mouse Button on the Diagram to build a hierarchy...\n"
|
m_hintLabel = new QLabel("Use Right Mouse Button on the Diagram to build a hierarchy...\n"
|
||||||
"1. Press the button >> Move mouse >> Release the button\n"
|
"Way 1: Press the button >> Move mouse >> Release the button\n"
|
||||||
"2. Or just click the right mouse button on any block", this);
|
"Way 2: Just click the right mouse button on any block", this);
|
||||||
m_hintLabel->setObjectName(QStringLiteral("BlocksTreeWidget_HintLabel"));
|
m_hintLabel->setObjectName(QStringLiteral("BlocksTreeWidget_HintLabel"));
|
||||||
m_hintLabel->setProperty("hovered", false);
|
m_hintLabel->setProperty("hovered", false);
|
||||||
m_hintLabel->setAlignment(Qt::AlignCenter);
|
m_hintLabel->setAlignment(Qt::AlignCenter);
|
||||||
@ -464,13 +464,7 @@ bool BlocksTreeWidget::eventFilter(QObject* _object, QEvent* _event)
|
|||||||
|
|
||||||
void BlocksTreeWidget::updateHintLabelOnHover(bool hover)
|
void BlocksTreeWidget::updateHintLabelOnHover(bool hover)
|
||||||
{
|
{
|
||||||
m_hintLabel->setProperty("hovered", hover);
|
profiler_gui::updateProperty(m_hintLabel, "hovered", hover);
|
||||||
m_hintLabel->style()->unpolish(m_hintLabel);
|
|
||||||
m_hintLabel->style()->polish(m_hintLabel);
|
|
||||||
if (m_hintLabel->isVisible())
|
|
||||||
{
|
|
||||||
m_hintLabel->update();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlocksTreeWidget::onHeaderSectionResized(int logicalIndex, int /*oldSize*/, int newSize)
|
void BlocksTreeWidget::onHeaderSectionResized(int logicalIndex, int /*oldSize*/, int newSize)
|
||||||
@ -1153,9 +1147,7 @@ void BlocksTreeWidget::createProgressDialog()
|
|||||||
{
|
{
|
||||||
destroyProgressDialog();
|
destroyProgressDialog();
|
||||||
|
|
||||||
m_progress = new RoundProgressDialog("Building tree...", this);
|
m_progress = new RoundProgressDialog(QStringLiteral("Building tree..."), this);
|
||||||
m_progress->setWindowFlags(Qt::FramelessWindowHint);
|
|
||||||
m_progress->setAttribute(Qt::WA_TranslucentBackground);
|
|
||||||
m_progress->setValue(0);
|
m_progress->setValue(0);
|
||||||
m_progress->show();
|
m_progress->show();
|
||||||
|
|
||||||
|
@ -55,11 +55,15 @@
|
|||||||
#ifndef EASY_PROFILER_GUI_COMMON_FUNCTIONS_H
|
#ifndef EASY_PROFILER_GUI_COMMON_FUNCTIONS_H
|
||||||
#define EASY_PROFILER_GUI_COMMON_FUNCTIONS_H
|
#define EASY_PROFILER_GUI_COMMON_FUNCTIONS_H
|
||||||
|
|
||||||
#include <QRgb>
|
|
||||||
#include <QString>
|
|
||||||
#include <QFont>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include <QFont>
|
||||||
|
#include <QRgb>
|
||||||
|
#include <QString>
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
#include "common_types.h"
|
#include "common_types.h"
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -220,6 +224,19 @@ double value2real(const ::profiler::ArbitraryValue& _serializedValue, int _index
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void updateProperty(QWidget* widget, const char* name, T&& property)
|
||||||
|
{
|
||||||
|
widget->setProperty(name, std::forward<T>(property));
|
||||||
|
widget->style()->unpolish(widget);
|
||||||
|
widget->style()->polish(widget);
|
||||||
|
|
||||||
|
if (widget->isVisible())
|
||||||
|
{
|
||||||
|
widget->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // END of namespace profiler_gui.
|
} // END of namespace profiler_gui.
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -70,6 +70,7 @@
|
|||||||
namespace profiler_gui {
|
namespace profiler_gui {
|
||||||
|
|
||||||
const QString ORGANAZATION_NAME = "EasyProfiler";
|
const QString ORGANAZATION_NAME = "EasyProfiler";
|
||||||
|
const QString DEFAULT_WINDOW_TITLE = "EasyProfiler";
|
||||||
const QString APPLICATION_NAME = "Easy profiler gui application";
|
const QString APPLICATION_NAME = "Easy profiler gui application";
|
||||||
|
|
||||||
const QColor RULER_COLOR = QColor::fromRgba(0x40000000 | (::profiler::colors::RichBlue & 0x00ffffff));// 0x402020c0);
|
const QColor RULER_COLOR = QColor::fromRgba(0x40000000 | (::profiler::colors::RichBlue & 0x00ffffff));// 0x402020c0);
|
||||||
|
@ -85,7 +85,6 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QProgressDialog>
|
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
@ -99,14 +98,16 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
|
|
||||||
#include "main_window.h"
|
|
||||||
#include "arbitrary_value_inspector.h"
|
#include "arbitrary_value_inspector.h"
|
||||||
#include "blocks_tree_widget.h"
|
|
||||||
#include "blocks_graphics_view.h"
|
#include "blocks_graphics_view.h"
|
||||||
|
#include "blocks_tree_widget.h"
|
||||||
#include "descriptors_tree_widget.h"
|
#include "descriptors_tree_widget.h"
|
||||||
#include "fps_widget.h"
|
|
||||||
#include "globals.h"
|
|
||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
|
#include "globals.h"
|
||||||
|
#include "fps_widget.h"
|
||||||
|
#include "round_progress_widget.h"
|
||||||
|
|
||||||
|
#include "main_window.h"
|
||||||
|
|
||||||
#include <easy/easy_net.h>
|
#include <easy/easy_net.h>
|
||||||
#include <easy/profiler.h>
|
#include <easy/profiler.h>
|
||||||
@ -122,8 +123,6 @@
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define EASY_DEFAULT_WINDOW_TITLE "EasyProfiler"
|
|
||||||
|
|
||||||
const int LOADER_TIMER_INTERVAL = 40;
|
const int LOADER_TIMER_INTERVAL = 40;
|
||||||
const auto NETWORK_CACHE_FILE = "easy_profiler_stream.cache";
|
const auto NETWORK_CACHE_FILE = "easy_profiler_stream.cache";
|
||||||
|
|
||||||
@ -280,10 +279,7 @@ void DockWidget::toggleState()
|
|||||||
|
|
||||||
void DockWidget::onTopLevelChanged()
|
void DockWidget::onTopLevelChanged()
|
||||||
{
|
{
|
||||||
m_floatingButton->setProperty("floating", isFloating());
|
profiler_gui::updateProperty(m_floatingButton, "floating", isFloating());
|
||||||
m_floatingButton->style()->unpolish(m_floatingButton);
|
|
||||||
m_floatingButton->style()->polish(m_floatingButton);
|
|
||||||
m_floatingButton->update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::configureSizes()
|
void MainWindow::configureSizes()
|
||||||
@ -347,7 +343,7 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos
|
|||||||
{ QIcon icon(":/images/logo"); if (!icon.isNull()) QApplication::setWindowIcon(icon); }
|
{ QIcon icon(":/images/logo"); if (!icon.isNull()) QApplication::setWindowIcon(icon); }
|
||||||
|
|
||||||
setObjectName("ProfilerGUI_MainWindow");
|
setObjectName("ProfilerGUI_MainWindow");
|
||||||
setWindowTitle(EASY_DEFAULT_WINDOW_TITLE);
|
setWindowTitle(profiler_gui::DEFAULT_WINDOW_TITLE);
|
||||||
setDockNestingEnabled(true);
|
setDockNestingEnabled(true);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setStatusBar(nullptr);
|
setStatusBar(nullptr);
|
||||||
@ -1093,9 +1089,9 @@ void MainWindow::addFileToList(const QString& filename, bool changeWindowTitle)
|
|||||||
if (changeWindowTitle)
|
if (changeWindowTitle)
|
||||||
{
|
{
|
||||||
if (m_bOpenedCacheFile)
|
if (m_bOpenedCacheFile)
|
||||||
setWindowTitle(QString(EASY_DEFAULT_WINDOW_TITLE " - [%1] - UNSAVED network cache file").arg(filename));
|
setWindowTitle(QString("%1 - [%2] - UNSAVED network cache file").arg(profiler_gui::DEFAULT_WINDOW_TITLE).arg(filename));
|
||||||
else
|
else
|
||||||
setWindowTitle(QString(EASY_DEFAULT_WINDOW_TITLE " - [%1]").arg(filename));
|
setWindowTitle(QString("%1 - [%2]").arg(profiler_gui::DEFAULT_WINDOW_TITLE).arg(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1125,9 +1121,9 @@ void MainWindow::addFileToList(const QString& filename, bool changeWindowTitle)
|
|||||||
if (changeWindowTitle)
|
if (changeWindowTitle)
|
||||||
{
|
{
|
||||||
if (m_bOpenedCacheFile)
|
if (m_bOpenedCacheFile)
|
||||||
setWindowTitle(QString(EASY_DEFAULT_WINDOW_TITLE " - [%1] - UNSAVED network cache file").arg(m_lastFiles.front()));
|
setWindowTitle(QString("%1 - [%2] - UNSAVED network cache file").arg(profiler_gui::DEFAULT_WINDOW_TITLE).arg(m_lastFiles.front()));
|
||||||
else
|
else
|
||||||
setWindowTitle(QString(EASY_DEFAULT_WINDOW_TITLE " - [%1]").arg(m_lastFiles.front()));
|
setWindowTitle(QString("%1 - [%2]").arg(profiler_gui::DEFAULT_WINDOW_TITLE).arg(m_lastFiles.front()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1325,7 +1321,7 @@ void MainWindow::clear()
|
|||||||
m_bNetworkFileRegime = false;
|
m_bNetworkFileRegime = false;
|
||||||
m_bOpenedCacheFile = false;
|
m_bOpenedCacheFile = false;
|
||||||
|
|
||||||
setWindowTitle(EASY_DEFAULT_WINDOW_TITLE);
|
setWindowTitle(profiler_gui::DEFAULT_WINDOW_TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -1567,6 +1563,16 @@ void MainWindow::showEvent(QShowEvent* show_event)
|
|||||||
configureSizes();
|
configureSizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::resizeEvent(QResizeEvent* event)
|
||||||
|
{
|
||||||
|
Parent::resizeEvent(event);
|
||||||
|
if (m_progress != nullptr)
|
||||||
|
{
|
||||||
|
const auto pos = rect().center();
|
||||||
|
m_progress->move(pos.x() - (m_progress->width() >> 1), pos.y() - (m_progress->height() >> 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent* close_event)
|
void MainWindow::closeEvent(QCloseEvent* close_event)
|
||||||
{
|
{
|
||||||
if (!m_bCloseAfterSave && (m_bNetworkFileRegime || EASY_GLOBALS.has_local_changes))
|
if (!m_bCloseAfterSave && (m_bNetworkFileRegime || EASY_GLOBALS.has_local_changes))
|
||||||
@ -1875,14 +1881,16 @@ void MainWindow::createProgressDialog(const QString& text)
|
|||||||
{
|
{
|
||||||
destroyProgressDialog();
|
destroyProgressDialog();
|
||||||
|
|
||||||
m_progress = new QProgressDialog(text, QStringLiteral("Cancel"), 0, 100, this);
|
m_progress = new RoundProgressDialog(text, this);
|
||||||
connect(m_progress, &QProgressDialog::canceled, this, &This::onFileReaderCancel);
|
m_progress->setCancelButtonEnabled(true);
|
||||||
|
connect(m_progress, &RoundProgressDialog::canceled, this, &This::onFileReaderCancel);
|
||||||
|
|
||||||
m_progress->setFixedWidth(px(300));
|
|
||||||
m_progress->setWindowTitle(EASY_DEFAULT_WINDOW_TITLE);
|
|
||||||
m_progress->setModal(true);
|
m_progress->setModal(true);
|
||||||
m_progress->setValue(0);
|
m_progress->setValue(0);
|
||||||
m_progress->show();
|
m_progress->show();
|
||||||
|
|
||||||
|
const auto pos = rect().center();
|
||||||
|
m_progress->move(pos.x() - (m_progress->width() >> 1), pos.y() - (m_progress->height() >> 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setDisconnected(bool _showMessage)
|
void MainWindow::setDisconnected(bool _showMessage)
|
||||||
@ -2145,7 +2153,7 @@ void MainWindow::onLoadingFinish(profiler::block_index_t& _nblocks)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_bOpenedCacheFile = false;
|
m_bOpenedCacheFile = false;
|
||||||
setWindowTitle(EASY_DEFAULT_WINDOW_TITLE " - UNSAVED network cache");
|
setWindowTitle(QString("%1 - UNSAVED network cache").arg(profiler_gui::DEFAULT_WINDOW_TITLE));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_serializedBlocks = std::move(serialized_blocks);
|
m_serializedBlocks = std::move(serialized_blocks);
|
||||||
@ -2878,7 +2886,7 @@ void MainWindow::onSelectValue(profiler::thread_id_t _thread_id, uint32_t _value
|
|||||||
|
|
||||||
void DialogWithGeometry::create(QWidget* content, QWidget* parent)
|
void DialogWithGeometry::create(QWidget* content, QWidget* parent)
|
||||||
{
|
{
|
||||||
ptr = new Dialog(parent, EASY_DEFAULT_WINDOW_TITLE, content, WindowHeader::AllButtons, QMessageBox::NoButton);
|
ptr = new Dialog(parent, profiler_gui::DEFAULT_WINDOW_TITLE, content, WindowHeader::AllButtons, QMessageBox::NoButton);
|
||||||
ptr->setProperty("stayVisible", true);
|
ptr->setProperty("stayVisible", true);
|
||||||
ptr->setAttribute(Qt::WA_DeleteOnClose, true);
|
ptr->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
|
|
||||||
#include <easy/easy_socket.h>
|
#include <easy/easy_socket.h>
|
||||||
#include <easy/reader.h>
|
#include <easy/reader.h>
|
||||||
|
#include "round_progress_widget.h"
|
||||||
|
|
||||||
#ifdef max
|
#ifdef max
|
||||||
#undef max
|
#undef max
|
||||||
@ -273,7 +274,7 @@ protected:
|
|||||||
QDockWidget* m_descTreeWidget = nullptr;
|
QDockWidget* m_descTreeWidget = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class QProgressDialog* m_progress = nullptr;
|
class RoundProgressDialog* m_progress = nullptr;
|
||||||
class BlockDescriptorsWidget* m_dialogDescTree = nullptr;
|
class BlockDescriptorsWidget* m_dialogDescTree = nullptr;
|
||||||
class Dialog* m_listenerDialog = nullptr;
|
class Dialog* m_listenerDialog = nullptr;
|
||||||
QTimer m_readerTimer;
|
QTimer m_readerTimer;
|
||||||
@ -312,6 +313,7 @@ public:
|
|||||||
// Public virtual methods
|
// Public virtual methods
|
||||||
|
|
||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
void closeEvent(QCloseEvent* close_event) override;
|
void closeEvent(QCloseEvent* close_event) override;
|
||||||
void changeEvent(QEvent* event) override;
|
void changeEvent(QEvent* event) override;
|
||||||
void dragEnterEvent(QDragEnterEvent* drag_event) override;
|
void dragEnterEvent(QDragEnterEvent* drag_event) override;
|
||||||
|
@ -48,15 +48,23 @@
|
|||||||
* : limitations under the License.
|
* : limitations under the License.
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#include "round_progress_widget.h"
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <easy/utility.h>
|
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
#include <QMouseEvent>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QVariant>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include <easy/utility.h>
|
||||||
|
|
||||||
|
#include "common_functions.h"
|
||||||
|
#include "globals.h"
|
||||||
|
#include "round_progress_widget.h"
|
||||||
|
|
||||||
#ifdef max
|
#ifdef max
|
||||||
# undef max
|
# undef max
|
||||||
#endif
|
#endif
|
||||||
@ -67,9 +75,13 @@ RoundProgressIndicator::RoundProgressIndicator(QWidget* parent)
|
|||||||
, m_background(Qt::transparent)
|
, m_background(Qt::transparent)
|
||||||
, m_color(Qt::green)
|
, m_color(Qt::green)
|
||||||
, m_value(0)
|
, m_value(0)
|
||||||
|
, m_pressed(false)
|
||||||
|
, m_cancelButtonEnabled(false)
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
setAutoFillBackground(false);
|
||||||
|
setProperty("hover", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
RoundProgressIndicator::~RoundProgressIndicator()
|
RoundProgressIndicator::~RoundProgressIndicator()
|
||||||
@ -77,6 +89,17 @@ RoundProgressIndicator::~RoundProgressIndicator()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RoundProgressIndicator::cancelButtonEnabled() const
|
||||||
|
{
|
||||||
|
return m_cancelButtonEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoundProgressIndicator::setCancelButtonEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
m_cancelButtonEnabled = enabled;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
int RoundProgressIndicator::value() const
|
int RoundProgressIndicator::value() const
|
||||||
{
|
{
|
||||||
return m_value;
|
return m_value;
|
||||||
@ -136,7 +159,7 @@ void RoundProgressIndicator::showEvent(QShowEvent* event)
|
|||||||
|
|
||||||
const QFontMetrics fm(font());
|
const QFontMetrics fm(font());
|
||||||
const QString text = QStringLiteral("100%");
|
const QString text = QStringLiteral("100%");
|
||||||
const int size = std::max(fm.width(text), fm.height()) + 4 * 4;
|
const int size = std::max(fm.width(text), fm.height()) + px(4 * 4);
|
||||||
|
|
||||||
setFixedSize(size, size);
|
setFixedSize(size, size);
|
||||||
}
|
}
|
||||||
@ -147,11 +170,12 @@ void RoundProgressIndicator::paintEvent(QPaintEvent* /*event*/)
|
|||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
painter.setBrush(Qt::NoBrush);
|
painter.setBrush(Qt::NoBrush);
|
||||||
|
|
||||||
const auto r = rect().adjusted(4, 4, -4, -4);
|
const auto px4 = px(4);
|
||||||
|
auto r = rect().adjusted(px4, px4, -px4, -px4);
|
||||||
auto p = painter.pen();
|
auto p = painter.pen();
|
||||||
|
|
||||||
// Draw circle
|
// Draw circle
|
||||||
p.setWidth(4);
|
p.setWidth(px4);
|
||||||
p.setColor(m_background);
|
p.setColor(m_background);
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
painter.drawArc(r, 0, 360 * 16);
|
painter.drawArc(r, 0, 360 * 16);
|
||||||
@ -160,11 +184,87 @@ void RoundProgressIndicator::paintEvent(QPaintEvent* /*event*/)
|
|||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
painter.drawArc(r, 90 * 16, -1 * static_cast<int>(m_value) * 16 * 360 / 100);
|
painter.drawArc(r, 90 * 16, -1 * static_cast<int>(m_value) * 16 * 360 / 100);
|
||||||
|
|
||||||
|
const bool hover = property("hover").toBool();
|
||||||
|
|
||||||
|
if (hover && m_cancelButtonEnabled)
|
||||||
|
{
|
||||||
|
// Draw cancel button (red cross)
|
||||||
|
|
||||||
|
const auto hquarter = px4 + (r.width() >> 2);
|
||||||
|
const auto vquarter = px4 + (r.height() >> 2);
|
||||||
|
r.adjust(hquarter, vquarter, -hquarter, -vquarter);
|
||||||
|
|
||||||
|
p.setWidth(px(2));
|
||||||
|
p.setColor(QColor::fromRgb(m_pressed ? profiler::colors::Red900 : profiler::colors::Red500));
|
||||||
|
p.setCapStyle(Qt::SquareCap);
|
||||||
|
|
||||||
|
painter.setPen(p);
|
||||||
|
painter.setBrush(Qt::NoBrush);
|
||||||
|
painter.drawLine(r.topLeft(), r.bottomRight());
|
||||||
|
painter.drawLine(r.bottomLeft(), r.topRight());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Draw text
|
// Draw text
|
||||||
p.setWidth(1);
|
p.setWidth(px(1));
|
||||||
p.setColor(palette().foreground().color());
|
p.setColor(palette().foreground().color());
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
painter.drawText(r, Qt::AlignCenter, m_text);
|
painter.drawText(r, Qt::AlignCenter, m_text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoundProgressIndicator::enterEvent(QEvent* event) {
|
||||||
|
Parent::enterEvent(event);
|
||||||
|
profiler_gui::updateProperty(this, "hover", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoundProgressIndicator::leaveEvent(QEvent* event) {
|
||||||
|
Parent::leaveEvent(event);
|
||||||
|
profiler_gui::updateProperty(this, "hover", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoundProgressIndicator::mousePressEvent(QMouseEvent* event)
|
||||||
|
{
|
||||||
|
Parent::mousePressEvent(event);
|
||||||
|
m_pressed = true;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoundProgressIndicator::mouseReleaseEvent(QMouseEvent* event)
|
||||||
|
{
|
||||||
|
Parent::mouseReleaseEvent(event);
|
||||||
|
|
||||||
|
const bool hover = property("hover").toBool();
|
||||||
|
const bool pressed = m_pressed;
|
||||||
|
|
||||||
|
m_pressed = false;
|
||||||
|
update();
|
||||||
|
|
||||||
|
if (pressed && hover && m_cancelButtonEnabled)
|
||||||
|
{
|
||||||
|
emit cancelButtonClicked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoundProgressIndicator::mouseMoveEvent(QMouseEvent* event)
|
||||||
|
{
|
||||||
|
if (m_pressed)
|
||||||
|
{
|
||||||
|
const bool hover = property("hover").toBool();
|
||||||
|
if (rect().contains(event->pos()))
|
||||||
|
{
|
||||||
|
if (!hover)
|
||||||
|
{
|
||||||
|
profiler_gui::updateProperty(this, "hover", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (hover)
|
||||||
|
{
|
||||||
|
profiler_gui::updateProperty(this, "hover", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Parent::mouseMoveEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
RoundProgressWidget::RoundProgressWidget(QWidget* parent)
|
RoundProgressWidget::RoundProgressWidget(QWidget* parent)
|
||||||
@ -179,11 +279,9 @@ RoundProgressWidget::RoundProgressWidget(const QString& title, QWidget* parent)
|
|||||||
, m_indicator(new RoundProgressIndicator(this))
|
, m_indicator(new RoundProgressIndicator(this))
|
||||||
, m_titlePosition(RoundProgressWidget::Top)
|
, m_titlePosition(RoundProgressWidget::Top)
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||||
setAttribute(Qt::WA_TranslucentBackground);
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
setAutoFillBackground(false);
|
||||||
m_indicatorWrapper->setWindowFlags(Qt::FramelessWindowHint);
|
|
||||||
m_indicatorWrapper->setAttribute(Qt::WA_TranslucentBackground);
|
|
||||||
|
|
||||||
auto wlay = new QHBoxLayout(m_indicatorWrapper);
|
auto wlay = new QHBoxLayout(m_indicatorWrapper);
|
||||||
wlay->setContentsMargins(0, 0, 0, 0);
|
wlay->setContentsMargins(0, 0, 0, 0);
|
||||||
@ -192,6 +290,8 @@ RoundProgressWidget::RoundProgressWidget(const QString& title, QWidget* parent)
|
|||||||
auto lay = new QVBoxLayout(this);
|
auto lay = new QVBoxLayout(this);
|
||||||
lay->addWidget(m_title);
|
lay->addWidget(m_title);
|
||||||
lay->addWidget(m_indicatorWrapper);
|
lay->addWidget(m_indicatorWrapper);
|
||||||
|
|
||||||
|
connect(m_indicator, &RoundProgressIndicator::cancelButtonClicked, this, &RoundProgressWidget::canceled);
|
||||||
}
|
}
|
||||||
|
|
||||||
RoundProgressWidget::~RoundProgressWidget()
|
RoundProgressWidget::~RoundProgressWidget()
|
||||||
@ -262,6 +362,8 @@ void RoundProgressWidget::setTitlePosition(TitlePosition pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
emit titlePositionChanged();
|
emit titlePositionChanged();
|
||||||
|
|
||||||
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RoundProgressWidget::isTopTitlePosition() const
|
bool RoundProgressWidget::isTopTitlePosition() const
|
||||||
@ -274,12 +376,32 @@ void RoundProgressWidget::setTopTitlePosition(bool isTop)
|
|||||||
setTitlePosition(isTop ? RoundProgressWidget::Top : RoundProgressWidget::Bottom);
|
setTitlePosition(isTop ? RoundProgressWidget::Top : RoundProgressWidget::Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RoundProgressWidget::cancelButtonEnabled() const
|
||||||
|
{
|
||||||
|
return m_indicator->cancelButtonEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoundProgressWidget::setCancelButtonEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
m_indicator->setCancelButtonEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
RoundProgressDialog::RoundProgressDialog(const QString& title, QWidget* parent)
|
RoundProgressDialog::RoundProgressDialog(const QString& title, QWidget* parent)
|
||||||
: Parent(parent)
|
: Parent(parent)
|
||||||
, m_progress(new RoundProgressWidget(title, this))
|
, m_progress(new RoundProgressWidget(title, this))
|
||||||
|
, m_background(Qt::transparent)
|
||||||
{
|
{
|
||||||
|
setWindowTitle(profiler_gui::DEFAULT_WINDOW_TITLE);
|
||||||
|
setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
|
||||||
|
setAttribute(Qt::WA_TranslucentBackground);
|
||||||
|
setAutoFillBackground(false);
|
||||||
|
|
||||||
auto lay = new QVBoxLayout(this);
|
auto lay = new QVBoxLayout(this);
|
||||||
lay->addWidget(m_progress);
|
lay->addWidget(m_progress);
|
||||||
|
|
||||||
|
connect(m_progress, &RoundProgressWidget::valueChanged, this, &RoundProgressDialog::valueChanged);
|
||||||
|
connect(m_progress, &RoundProgressWidget::finished, this, &RoundProgressDialog::finished);
|
||||||
|
connect(m_progress, &RoundProgressWidget::canceled, this, &RoundProgressDialog::canceled);
|
||||||
}
|
}
|
||||||
|
|
||||||
RoundProgressDialog::~RoundProgressDialog()
|
RoundProgressDialog::~RoundProgressDialog()
|
||||||
@ -287,6 +409,33 @@ RoundProgressDialog::~RoundProgressDialog()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QColor RoundProgressDialog::background() const
|
||||||
|
{
|
||||||
|
return m_background;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoundProgressDialog::setBackground(QColor color)
|
||||||
|
{
|
||||||
|
m_background = std::move(color);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoundProgressDialog::setBackground(QString color)
|
||||||
|
{
|
||||||
|
m_background.setNamedColor(color);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RoundProgressDialog::cancelButtonEnabled() const
|
||||||
|
{
|
||||||
|
return m_progress->cancelButtonEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RoundProgressDialog::setCancelButtonEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
m_progress->setCancelButtonEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
void RoundProgressDialog::showEvent(QShowEvent* event)
|
void RoundProgressDialog::showEvent(QShowEvent* event)
|
||||||
{
|
{
|
||||||
Parent::showEvent(event);
|
Parent::showEvent(event);
|
||||||
@ -299,3 +448,12 @@ void RoundProgressDialog::setValue(int value)
|
|||||||
if (value == 100)
|
if (value == 100)
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RoundProgressDialog::paintEvent(QPaintEvent*)
|
||||||
|
{
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setBrush(m_background);
|
||||||
|
painter.drawRect(0, 0, width(), height());
|
||||||
|
}
|
||||||
|
@ -53,8 +53,8 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QWidget>
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
class RoundProgressIndicator : public QWidget
|
class RoundProgressIndicator : public QWidget
|
||||||
{
|
{
|
||||||
@ -67,6 +67,8 @@ Q_OBJECT
|
|||||||
QColor m_background;
|
QColor m_background;
|
||||||
QColor m_color;
|
QColor m_color;
|
||||||
int8_t m_value;
|
int8_t m_value;
|
||||||
|
bool m_pressed;
|
||||||
|
bool m_cancelButtonEnabled;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -83,6 +85,13 @@ public:
|
|||||||
QColor background() const;
|
QColor background() const;
|
||||||
QColor color() const;
|
QColor color() const;
|
||||||
|
|
||||||
|
bool cancelButtonEnabled() const;
|
||||||
|
void setCancelButtonEnabled(bool enabled);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void cancelButtonClicked();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void setBackground(QColor color);
|
void setBackground(QColor color);
|
||||||
@ -94,6 +103,11 @@ protected:
|
|||||||
|
|
||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
void paintEvent(QPaintEvent* event) override;
|
void paintEvent(QPaintEvent* event) override;
|
||||||
|
void enterEvent(QEvent* event) override;
|
||||||
|
void leaveEvent(QEvent* event) override;
|
||||||
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
|
|
||||||
}; // end of class RoundProgressIndicator.
|
}; // end of class RoundProgressIndicator.
|
||||||
|
|
||||||
@ -132,6 +146,9 @@ public:
|
|||||||
TitlePosition titlePosition() const;
|
TitlePosition titlePosition() const;
|
||||||
bool isTopTitlePosition() const;
|
bool isTopTitlePosition() const;
|
||||||
|
|
||||||
|
bool cancelButtonEnabled() const;
|
||||||
|
void setCancelButtonEnabled(bool enabled);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void setValue(int value);
|
void setValue(int value);
|
||||||
@ -144,6 +161,7 @@ signals:
|
|||||||
void valueChanged(int value);
|
void valueChanged(int value);
|
||||||
void finished();
|
void finished();
|
||||||
void titlePositionChanged();
|
void titlePositionChanged();
|
||||||
|
void canceled();
|
||||||
|
|
||||||
}; // end of class RoundProgressWidget.
|
}; // end of class RoundProgressWidget.
|
||||||
|
|
||||||
@ -155,20 +173,37 @@ class RoundProgressDialog : public QDialog
|
|||||||
using This = RoundProgressDialog;
|
using This = RoundProgressDialog;
|
||||||
|
|
||||||
RoundProgressWidget* m_progress;
|
RoundProgressWidget* m_progress;
|
||||||
|
QColor m_background;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Q_PROPERTY(QColor background READ background WRITE setBackground);
|
||||||
|
|
||||||
explicit RoundProgressDialog(const QString& title, QWidget* parent = nullptr);
|
explicit RoundProgressDialog(const QString& title, QWidget* parent = nullptr);
|
||||||
~RoundProgressDialog() override;
|
~RoundProgressDialog() override;
|
||||||
|
|
||||||
|
QColor background() const;
|
||||||
|
|
||||||
|
bool cancelButtonEnabled() const;
|
||||||
|
void setCancelButtonEnabled(bool enabled);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void showEvent(QShowEvent* event) override;
|
void showEvent(QShowEvent* event) override;
|
||||||
|
void paintEvent(QPaintEvent* event) override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
void setBackground(QColor color);
|
||||||
|
void setBackground(QString color);
|
||||||
void setValue(int value);
|
void setValue(int value);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void valueChanged(int value);
|
||||||
|
void finished();
|
||||||
|
void canceled();
|
||||||
|
|
||||||
}; // end of RoundProgressDialog.
|
}; // end of RoundProgressDialog.
|
||||||
|
|
||||||
#endif // ROUND_PROGRESS_WIDGET_H
|
#endif // ROUND_PROGRESS_WIDGET_H
|
||||||
|
@ -19,6 +19,9 @@ RoundProgressIndicator {
|
|||||||
qproperty-background: #c4c4c4;
|
qproperty-background: #c4c4c4;
|
||||||
background: transparent; }
|
background: transparent; }
|
||||||
|
|
||||||
|
RoundProgressDialog {
|
||||||
|
qproperty-background: rgba(255, 255, 255, 70%); }
|
||||||
|
|
||||||
MainWindow, QToolBar, QDialog {
|
MainWindow, QToolBar, QDialog {
|
||||||
background-color: white; }
|
background-color: white; }
|
||||||
|
|
||||||
@ -305,9 +308,9 @@ QMenu::indicator:exclusive:checked:disabled {
|
|||||||
|
|
||||||
/* ****************************************************************************************************************** */
|
/* ****************************************************************************************************************** */
|
||||||
QHeaderView::section {
|
QHeaderView::section {
|
||||||
height: 15.3ex;
|
height: 15ex;
|
||||||
min-height: 15.3ex;
|
min-height: 15ex;
|
||||||
max-height: 15.3ex;
|
max-height: 15ex;
|
||||||
background: #eeeeee;
|
background: #eeeeee;
|
||||||
/*{lin}font-weight: bold;*/ }
|
/*{lin}font-weight: bold;*/ }
|
||||||
|
|
||||||
|
@ -64,6 +64,10 @@ RoundProgressIndicator {
|
|||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RoundProgressDialog {
|
||||||
|
qproperty-background: rgba(255, 255, 255, 70%);
|
||||||
|
}
|
||||||
|
|
||||||
MainWindow, QToolBar, QDialog {
|
MainWindow, QToolBar, QDialog {
|
||||||
background-color: $BackgroundColor;
|
background-color: $BackgroundColor;
|
||||||
}
|
}
|
||||||
@ -411,9 +415,9 @@ QMenu::indicator:exclusive:checked:disabled {
|
|||||||
|
|
||||||
/* ****************************************************************************************************************** */
|
/* ****************************************************************************************************************** */
|
||||||
QHeaderView::section {
|
QHeaderView::section {
|
||||||
height: 15.3ex;
|
height: $InputHeight;
|
||||||
min-height: 15.3ex;
|
min-height: $InputHeight;
|
||||||
max-height: 15.3ex;
|
max-height: $InputHeight;
|
||||||
background: #eeeeee;
|
background: #eeeeee;
|
||||||
/*{lin}font-weight: bold;*/
|
/*{lin}font-weight: bold;*/
|
||||||
}
|
}
|
||||||
|
@ -195,10 +195,7 @@ void WindowHeader::onWindowStateChanged()
|
|||||||
{
|
{
|
||||||
if (m_maximizeButton != nullptr)
|
if (m_maximizeButton != nullptr)
|
||||||
{
|
{
|
||||||
m_maximizeButton->setProperty("max", parentWidget()->isMaximized());
|
profiler_gui::updateProperty(m_maximizeButton, "max", parentWidget()->isMaximized());
|
||||||
m_maximizeButton->style()->unpolish(m_maximizeButton);
|
|
||||||
m_maximizeButton->style()->polish(m_maximizeButton);
|
|
||||||
m_maximizeButton->update();
|
|
||||||
setButtonSize(m_maximizeButton, height());
|
setButtonSize(m_maximizeButton, height());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user