mirror of
https://github.com/yse/easy_profiler.git
synced 2024-12-26 16:11:02 +08:00
Port to Qt6
This commit is contained in:
parent
04a472121e
commit
bfeb4ee6f8
@ -4,9 +4,10 @@ set(CMAKE_AUTOMOC ON)
|
|||||||
set(CMAKE_AUTORCC ON)
|
set(CMAKE_AUTORCC ON)
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
find_package(Qt5Widgets)
|
find_package(Qt6Widgets)
|
||||||
|
find_package(Qt6Core5Compat)
|
||||||
|
|
||||||
if (Qt5Widgets_FOUND)
|
if (Qt6Widgets_FOUND)
|
||||||
message(STATUS "Using Qt v${Qt5Widgets_VERSION}")
|
message(STATUS "Using Qt v${Qt5Widgets_VERSION}")
|
||||||
if (NOT("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") AND WIN32)
|
if (NOT("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") AND WIN32)
|
||||||
set(APPLICATION_PLATFORM WIN32)
|
set(APPLICATION_PLATFORM WIN32)
|
||||||
@ -70,7 +71,7 @@ if (Qt5Widgets_FOUND)
|
|||||||
resources.qrc
|
resources.qrc
|
||||||
resources.rc
|
resources.rc
|
||||||
)
|
)
|
||||||
target_link_libraries(profiler_gui Qt5::Widgets easy_profiler)
|
target_link_libraries(profiler_gui Qt6::Widgets Qt6::Core5Compat easy_profiler)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_compile_definitions(profiler_gui PRIVATE -D_WIN32_WINNT=0x0600)
|
target_compile_definitions(profiler_gui PRIVATE -D_WIN32_WINNT=0x0600)
|
||||||
endif ()
|
endif ()
|
||||||
|
@ -767,7 +767,7 @@ void ArbitraryValuesChartItem::paintMouseIndicator(QPainter* _painter, qreal _to
|
|||||||
valueString = profiler_gui::autoTimeStringRealNs(value, 3);
|
valueString = profiler_gui::autoTimeStringRealNs(value, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int textWidth = _painter->fontMetrics().width(valueString) + 3;
|
const int textWidth = _painter->fontMetrics().boundingRect(valueString).width() + 3;
|
||||||
const QRectF rect(0, y - _font_h - 2, _width - 3, 4 + (_font_h << 1));
|
const QRectF rect(0, y - _font_h - 2, _width - 3, 4 + (_font_h << 1));
|
||||||
|
|
||||||
_painter->setPen(Qt::blue);
|
_painter->setPen(Qt::blue);
|
||||||
@ -810,7 +810,7 @@ void ArbitraryValuesChartItem::paintMouseIndicator(QPainter* _painter, qreal _to
|
|||||||
valueString = QString::number(value, 'f', 3);
|
valueString = QString::number(value, 'f', 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int textWidth = _painter->fontMetrics().width(valueString) + 6;
|
const int textWidth = _painter->fontMetrics().boundingRect(valueString).width() + 6;
|
||||||
const int textWidthHalf = textWidth >> 1;
|
const int textWidthHalf = textWidth >> 1;
|
||||||
|
|
||||||
qreal left = x - textWidthHalf;
|
qreal left = x - textWidthHalf;
|
||||||
@ -2034,7 +2034,7 @@ void ArbitraryValuesWidget::showEvent(QShowEvent* event)
|
|||||||
const auto indicatorSize = header->isSortIndicatorShown() ? px(11) : 0;
|
const auto indicatorSize = header->isSortIndicatorShown() ? px(11) : 0;
|
||||||
for (int i = 0; i < static_cast<int>(m_columnsMinimumWidth.size()); ++i)
|
for (int i = 0; i < static_cast<int>(m_columnsMinimumWidth.size()); ++i)
|
||||||
{
|
{
|
||||||
auto minSize = static_cast<int>(fm.width(headerItem->text(i)) * profiler_gui::FONT_METRICS_FACTOR + padding);
|
auto minSize = static_cast<int>(fm.boundingRect(headerItem->text(i)).width() * profiler_gui::FONT_METRICS_FACTOR + padding);
|
||||||
m_columnsMinimumWidth[i] = minSize;
|
m_columnsMinimumWidth[i] = minSize;
|
||||||
|
|
||||||
if (header->isSortIndicatorShown() && header->sortIndicatorSection() == i)
|
if (header->isSortIndicatorShown() && header->sortIndicatorSection() == i)
|
||||||
@ -2850,7 +2850,7 @@ QTreeWidgetItem* ArbitraryValuesWidget::buildTreeForThread(const profiler::Block
|
|||||||
item->setText(int_cast(ArbitraryColumns::Value), profiler_gui::valueString(*value, childIndex));
|
item->setText(int_cast(ArbitraryColumns::Value), profiler_gui::valueString(*value, childIndex));
|
||||||
|
|
||||||
const auto sizeHintWidth = valueItem->sizeHint(CheckColumn).width();
|
const auto sizeHintWidth = valueItem->sizeHint(CheckColumn).width();
|
||||||
item->setWidthHint(std::max(sizeHintWidth, fm.width(valueItem->text(CheckColumn))) + 32);
|
item->setWidthHint(std::max(sizeHintWidth, fm.boundingRect(valueItem->text(CheckColumn)).width()) + 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto typeString = profiler_gui::valueTypeString(*value);
|
auto typeString = profiler_gui::valueTypeString(*value);
|
||||||
@ -2893,7 +2893,7 @@ QTreeWidgetItem* ArbitraryValuesWidget::buildTreeForThread(const profiler::Block
|
|||||||
valueItem->setText(int_cast(ArbitraryColumns::Value), profiler_gui::shortValueString(*value));
|
valueItem->setText(int_cast(ArbitraryColumns::Value), profiler_gui::shortValueString(*value));
|
||||||
|
|
||||||
auto sizeHintWidth = valueItem->sizeHint(CheckColumn).width();
|
auto sizeHintWidth = valueItem->sizeHint(CheckColumn).width();
|
||||||
valueItem->setWidthHint(std::max(sizeHintWidth, fm.width(valueItem->text(CheckColumn))) + 32);
|
valueItem->setWidthHint(std::max(sizeHintWidth, fm.boundingRect(valueItem->text(CheckColumn)).width()) + 32);
|
||||||
|
|
||||||
*(usedItems + typeIndex) = valueItem;
|
*(usedItems + typeIndex) = valueItem;
|
||||||
|
|
||||||
@ -2912,7 +2912,7 @@ QTreeWidgetItem* ArbitraryValuesWidget::buildTreeForThread(const profiler::Block
|
|||||||
item->setText(int_cast(ArbitraryColumns::Value), profiler_gui::valueString(*value, childIndex));
|
item->setText(int_cast(ArbitraryColumns::Value), profiler_gui::valueString(*value, childIndex));
|
||||||
|
|
||||||
sizeHintWidth = valueItem->sizeHint(CheckColumn).width();
|
sizeHintWidth = valueItem->sizeHint(CheckColumn).width();
|
||||||
item->setWidthHint(std::max(sizeHintWidth, fm.width(valueItem->text(CheckColumn))) + 32);
|
item->setWidthHint(std::max(sizeHintWidth, fm.boundingRect(valueItem->text(CheckColumn)).width()) + 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto typeString = profiler_gui::valueTypeString(*value);
|
auto typeString = profiler_gui::valueTypeString(*value);
|
||||||
|
@ -144,7 +144,7 @@ ArbitraryValueToolTip::ArbitraryValueToolTip(const QString& _name
|
|||||||
|
|
||||||
QFontMetrics fm(EASY_GLOBALS.font.default_font);
|
QFontMetrics fm(EASY_GLOBALS.font.default_font);
|
||||||
QFontMetrics fm2(font);
|
QFontMetrics fm2(font);
|
||||||
pane->setMinimumWidth(fm.width(firstString) + 24);
|
pane->setMinimumWidth(fm.boundingRect(firstString).width() + 24);
|
||||||
pane->setMaximumHeight((fm.height() + fm.leading() + 1) * rowsCount);
|
pane->setMaximumHeight((fm.height() + fm.leading() + 1) * rowsCount);
|
||||||
|
|
||||||
setMaximumHeight(pane->maximumHeight() + fm2.height() + fm2.leading() + 10);
|
setMaximumHeight(pane->maximumHeight() + fm2.height() + fm2.leading() + 10);
|
||||||
|
@ -231,7 +231,7 @@ void BackgroundItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*,
|
|||||||
qreal first_x = first * sceneStep;
|
qreal first_x = first * sceneStep;
|
||||||
|
|
||||||
const auto textWidth = QFontMetricsF(_painter->font(), sceneView).
|
const auto textWidth = QFontMetricsF(_painter->font(), sceneView).
|
||||||
width(QString::number(static_cast<quint64>(0.5 + first_x * factor))) * profiler_gui::FONT_METRICS_FACTOR + px(10);
|
boundingRect(QString::number(static_cast<quint64>(0.5 + first_x * factor))).width() * profiler_gui::FONT_METRICS_FACTOR + px(10);
|
||||||
|
|
||||||
const int n = 1 + static_cast<int>(textWidth / step);
|
const int n = 1 + static_cast<int>(textWidth / step);
|
||||||
int next = first % n;
|
int next = first % n;
|
||||||
@ -1288,7 +1288,7 @@ void BlocksGraphicsView::scaleTo(qreal _scale)
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void BlocksGraphicsView::enterEvent(QEvent* _event)
|
void BlocksGraphicsView::enterEvent(QEnterEvent* _event)
|
||||||
{
|
{
|
||||||
Parent::enterEvent(_event);
|
Parent::enterEvent(_event);
|
||||||
m_bHovered = true;
|
m_bHovered = true;
|
||||||
@ -1323,7 +1323,7 @@ void BlocksGraphicsView::wheelEvent(QWheelEvent* _event)
|
|||||||
m_idleTime = 0;
|
m_idleTime = 0;
|
||||||
|
|
||||||
if (!m_bEmpty)
|
if (!m_bEmpty)
|
||||||
onWheel(mapToDiagram(mapToScene(_event->pos()).x()), _event->delta());
|
onWheel(mapToDiagram(mapToScene(_event->position().toPoint()).x()), _event->angleDelta().y());
|
||||||
|
|
||||||
_event->accept();
|
_event->accept();
|
||||||
}
|
}
|
||||||
@ -3078,7 +3078,7 @@ void ThreadNamesWidget::onTreeChange()
|
|||||||
qreal maxLength = 100;
|
qreal maxLength = 100;
|
||||||
const auto& graphicsItems = m_view->getItems();
|
const auto& graphicsItems = m_view->getItems();
|
||||||
for (auto graphicsItem : graphicsItems)
|
for (auto graphicsItem : graphicsItems)
|
||||||
maxLength = std::max(maxLength, (10 + fm.width(graphicsItem->threadName())) * profiler_gui::FONT_METRICS_FACTOR);
|
maxLength = std::max(maxLength, (10 + fm.boundingRect(graphicsItem->threadName()).width()) * profiler_gui::FONT_METRICS_FACTOR);
|
||||||
|
|
||||||
auto vbar = verticalScrollBar();
|
auto vbar = verticalScrollBar();
|
||||||
auto viewBar = m_view->verticalScrollBar();
|
auto viewBar = m_view->verticalScrollBar();
|
||||||
@ -3247,7 +3247,7 @@ void ThreadNamesWidget::repaintScene()
|
|||||||
scene()->update();
|
scene()->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadNamesWidget::enterEvent(QEvent* _event)
|
void ThreadNamesWidget::enterEvent(QEnterEvent* _event)
|
||||||
{
|
{
|
||||||
Parent::enterEvent(_event);
|
Parent::enterEvent(_event);
|
||||||
m_bHovered = true;
|
m_bHovered = true;
|
||||||
@ -3342,7 +3342,7 @@ void ThreadNamesWidget::wheelEvent(QWheelEvent* _event)
|
|||||||
_event->accept();
|
_event->accept();
|
||||||
|
|
||||||
const auto prev = vbar->value();
|
const auto prev = vbar->value();
|
||||||
vbar->setValue(vbar->value() - _event->delta());
|
vbar->setValue(vbar->value() - _event->angleDelta().y());
|
||||||
|
|
||||||
if (prev != vbar->value())
|
if (prev != vbar->value())
|
||||||
{
|
{
|
||||||
|
@ -230,7 +230,7 @@ public:
|
|||||||
|
|
||||||
// Public virtual methods
|
// Public virtual methods
|
||||||
|
|
||||||
void enterEvent(QEvent* _event) override;
|
void enterEvent(QEnterEvent* _event) override;
|
||||||
void leaveEvent(QEvent* _event) override;
|
void leaveEvent(QEvent* _event) override;
|
||||||
void wheelEvent(QWheelEvent* _event) override;
|
void wheelEvent(QWheelEvent* _event) override;
|
||||||
void mousePressEvent(QMouseEvent* _event) override;
|
void mousePressEvent(QMouseEvent* _event) override;
|
||||||
@ -384,7 +384,7 @@ public:
|
|||||||
explicit ThreadNamesWidget(BlocksGraphicsView* _view, int _additionalHeight, QWidget* _parent = nullptr);
|
explicit ThreadNamesWidget(BlocksGraphicsView* _view, int _additionalHeight, QWidget* _parent = nullptr);
|
||||||
~ThreadNamesWidget() override;
|
~ThreadNamesWidget() override;
|
||||||
|
|
||||||
void enterEvent(QEvent* _event) override;
|
void enterEvent(QEnterEvent* _event) override;
|
||||||
void leaveEvent(QEvent* _event) override;
|
void leaveEvent(QEvent* _event) override;
|
||||||
void mousePressEvent(QMouseEvent* _event) override;
|
void mousePressEvent(QMouseEvent* _event) override;
|
||||||
void mouseDoubleClickEvent(QMouseEvent* _event) override;
|
void mouseDoubleClickEvent(QMouseEvent* _event) override;
|
||||||
|
@ -446,7 +446,7 @@ bool BlocksTreeWidget::eventFilter(QObject* _object, QEvent* _event)
|
|||||||
|
|
||||||
for (int i = 0; i < COL_COLUMNS_NUMBER; ++i)
|
for (int i = 0; i < COL_COLUMNS_NUMBER; ++i)
|
||||||
{
|
{
|
||||||
m_columnsMinimumWidth[i] = static_cast<int>(fm.width(headerItem()->text(i)) * profiler_gui::FONT_METRICS_FACTOR + padding);
|
m_columnsMinimumWidth[i] = static_cast<int>(fm.boundingRect(headerItem()->text(i)).width() * profiler_gui::FONT_METRICS_FACTOR + padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
EASY_CONSTEXPR int Margins = 20;
|
EASY_CONSTEXPR int Margins = 20;
|
||||||
@ -1645,7 +1645,7 @@ void StatsWidget::saveSettings()
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsWidget::enterEvent(QEvent* event)
|
void StatsWidget::enterEvent(QEnterEvent* event)
|
||||||
{
|
{
|
||||||
Parent::enterEvent(event);
|
Parent::enterEvent(event);
|
||||||
m_tree->updateHintLabelOnHover(true);
|
m_tree->updateHintLabelOnHover(true);
|
||||||
|
@ -211,7 +211,7 @@ public:
|
|||||||
explicit StatsWidget(QWidget* _parent = nullptr);
|
explicit StatsWidget(QWidget* _parent = nullptr);
|
||||||
~StatsWidget() override;
|
~StatsWidget() override;
|
||||||
|
|
||||||
void enterEvent(QEvent* event) override;
|
void enterEvent(QEnterEvent* event) override;
|
||||||
void leaveEvent(QEvent* event) override;
|
void leaveEvent(QEvent* event) override;
|
||||||
void keyPressEvent(QKeyEvent* _event) override;
|
void keyPressEvent(QKeyEvent* _event) override;
|
||||||
void contextMenuEvent(QContextMenuEvent* _event) override;
|
void contextMenuEvent(QContextMenuEvent* _event) override;
|
||||||
|
@ -104,7 +104,7 @@ BookmarkEditor::BookmarkEditor(size_t bookmarkIndex, bool isNew, QWidget* parent
|
|||||||
connect(m_colorButton, &QPushButton::clicked, this, &This::onColorButtonClicked);
|
connect(m_colorButton, &QPushButton::clicked, this, &This::onColorButtonClicked);
|
||||||
|
|
||||||
auto palette = m_colorButton->palette();
|
auto palette = m_colorButton->palette();
|
||||||
palette.setBrush(QPalette::Background, QBrush(QColor::fromRgb(bookmark.color)));
|
palette.setBrush(QPalette::Window, QBrush(QColor::fromRgb(bookmark.color)));
|
||||||
m_colorButton->setPalette(palette);
|
m_colorButton->setPalette(palette);
|
||||||
m_colorButton->setStyleSheet(QString("background-color: %1;").arg(QColor::fromRgb(bookmark.color).name()));
|
m_colorButton->setStyleSheet(QString("background-color: %1;").arg(QColor::fromRgb(bookmark.color).name()));
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ void BookmarkEditor::onSaveClicked(bool)
|
|||||||
auto& bookmark = EASY_GLOBALS.bookmarks[m_bookmarkIndex];
|
auto& bookmark = EASY_GLOBALS.bookmarks[m_bookmarkIndex];
|
||||||
|
|
||||||
bookmark.text = m_textEdit->toPlainText().trimmed().toStdString();
|
bookmark.text = m_textEdit->toPlainText().trimmed().toStdString();
|
||||||
bookmark.color = m_colorButton->palette().brush(QPalette::Background).color().rgb();
|
bookmark.color = m_colorButton->palette().brush(QPalette::Window).color().rgb();
|
||||||
EASY_GLOBALS.bookmark_default_color = bookmark.color;
|
EASY_GLOBALS.bookmark_default_color = bookmark.color;
|
||||||
EASY_GLOBALS.has_local_changes = true;
|
EASY_GLOBALS.has_local_changes = true;
|
||||||
|
|
||||||
@ -175,11 +175,11 @@ void BookmarkEditor::onColorButtonClicked(bool)
|
|||||||
{
|
{
|
||||||
auto palette = m_colorButton->palette();
|
auto palette = m_colorButton->palette();
|
||||||
|
|
||||||
QColorDialog colorDialog(palette.brush(QPalette::Background).color(), this);
|
QColorDialog colorDialog(palette.brush(QPalette::Window).color(), this);
|
||||||
colorDialog.exec();
|
colorDialog.exec();
|
||||||
|
|
||||||
auto color = colorDialog.currentColor();
|
auto color = colorDialog.currentColor();
|
||||||
palette.setBrush(QPalette::Background, QBrush(color));
|
palette.setBrush(QPalette::Window, QBrush(color));
|
||||||
m_colorButton->setPalette(palette);
|
m_colorButton->setPalette(palette);
|
||||||
|
|
||||||
m_colorButton->setStyleSheet(QString("background-color: %1;").arg(color.name()));
|
m_colorButton->setStyleSheet(QString("background-color: %1;").arg(color.name()));
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QRegExp>
|
||||||
|
|
||||||
#include "descriptors_tree_widget.h"
|
#include "descriptors_tree_widget.h"
|
||||||
|
|
||||||
@ -338,7 +339,7 @@ void DescriptorsTreeWidget::showEvent(QShowEvent* event)
|
|||||||
const auto indicatorSize = header->isSortIndicatorShown() ? px(11) : 0;
|
const auto indicatorSize = header->isSortIndicatorShown() ? px(11) : 0;
|
||||||
for (int i = 0; i < DESC_COL_COLUMNS_NUMBER; ++i)
|
for (int i = 0; i < DESC_COL_COLUMNS_NUMBER; ++i)
|
||||||
{
|
{
|
||||||
auto minSize = static_cast<int>(fm.width(headerItem->text(i)) * profiler_gui::FONT_METRICS_FACTOR + padding);
|
auto minSize = static_cast<int>(fm.boundingRect(headerItem->text(i)).width() * profiler_gui::FONT_METRICS_FACTOR + padding);
|
||||||
m_columnsMinimumWidth[i] = minSize;
|
m_columnsMinimumWidth[i] = minSize;
|
||||||
|
|
||||||
if (header->isSortIndicatorShown() && header->sortIndicatorSection() == i)
|
if (header->isSortIndicatorShown() && header->sortIndicatorSection() == i)
|
||||||
@ -552,8 +553,8 @@ void DescriptorsTreeWidget::build()
|
|||||||
if (p.item == nullptr)
|
if (p.item == nullptr)
|
||||||
{
|
{
|
||||||
auto item = new DescriptorsTreeItem(0);
|
auto item = new DescriptorsTreeItem(0);
|
||||||
auto fullName = QString(desc->file()).remove(QRegExp("^(\\.{2}\\\\+)+")); // without leading "..\"
|
auto fullName = QString(desc->file()).remove(QRegExp("^(\\.{2}\\\\+)+").pattern()); // without leading "..\"
|
||||||
auto fileName = QString(desc->file()).remove(QRegExp("^(.+(\\\\|\\/)+)+"));
|
auto fileName = QString(desc->file()).remove(QRegExp("^(.+(\\\\|\\/)+)+").pattern());
|
||||||
auto dir = fullName.left(fullName.length() - fileName.length());
|
auto dir = fullName.left(fullName.length() - fileName.length());
|
||||||
|
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
|
@ -223,7 +223,9 @@ void FpsGraphicsItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*,
|
|||||||
|
|
||||||
_painter->setPen(Qt::NoPen);
|
_painter->setPen(Qt::NoPen);
|
||||||
_painter->setBrush(Qt::white);
|
_painter->setBrush(Qt::white);
|
||||||
_painter->drawRect(0, top + 1, std::max({fontMetrics.width(txtTop), fontMetrics.width(txtMid), fontMetrics.width(txtBtm)}) + 8, bottom - top - 1);
|
_painter->drawRect(0, top + 1, std::max({fontMetrics.boundingRect(txtTop).width(),
|
||||||
|
fontMetrics.boundingRect(txtMid).width(),
|
||||||
|
fontMetrics.boundingRect(txtBtm).width()}) + 8, bottom - top - 1);
|
||||||
|
|
||||||
_painter->setPen(Qt::black);
|
_painter->setPen(Qt::black);
|
||||||
_painter->setBrush(Qt::NoBrush);
|
_painter->setBrush(Qt::NoBrush);
|
||||||
|
@ -154,7 +154,7 @@ void GraphicsHistogramItem::paintMouseIndicator(QPainter* _painter, qreal _top,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_painter->drawText(rect, Qt::AlignLeft | Qt::AlignVCenter, mouseStr);
|
_painter->drawText(rect, Qt::AlignLeft | Qt::AlignVCenter, mouseStr);
|
||||||
mouseIndicatorLeft = _painter->fontMetrics().width(mouseStr) + 3;
|
mouseIndicatorLeft = _painter->fontMetrics().boundingRect(mouseStr).width() + 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
_painter->drawLine(QLineF(mouseIndicatorLeft, _mouse_y, mouseIndicatorRight, _mouse_y));
|
_painter->drawLine(QLineF(mouseIndicatorLeft, _mouse_y, mouseIndicatorRight, _mouse_y));
|
||||||
|
@ -539,7 +539,7 @@ void GraphicsSliderArea::wheelEvent(QWheelEvent* _event)
|
|||||||
|
|
||||||
if (m_imageItem->isVisible())
|
if (m_imageItem->isVisible())
|
||||||
{
|
{
|
||||||
if (_event->delta() > 0)
|
if (_event->angleDelta().y() > 0)
|
||||||
m_imageItem->increaseTopValue();
|
m_imageItem->increaseTopValue();
|
||||||
else
|
else
|
||||||
m_imageItem->decreaseTopValue();
|
m_imageItem->decreaseTopValue();
|
||||||
@ -554,7 +554,7 @@ void GraphicsSliderArea::wheelEvent(QWheelEvent* _event)
|
|||||||
|
|
||||||
if (m_imageItem->isVisible())
|
if (m_imageItem->isVisible())
|
||||||
{
|
{
|
||||||
if (_event->delta() > 0)
|
if (_event->angleDelta().y() > 0)
|
||||||
m_imageItem->increaseBottomValue();
|
m_imageItem->increaseBottomValue();
|
||||||
else
|
else
|
||||||
m_imageItem->decreaseBottomValue();
|
m_imageItem->decreaseBottomValue();
|
||||||
@ -565,16 +565,16 @@ void GraphicsSliderArea::wheelEvent(QWheelEvent* _event)
|
|||||||
|
|
||||||
if (!bindMode())
|
if (!bindMode())
|
||||||
{
|
{
|
||||||
const auto w = m_slider->halfwidth() * (_event->delta() < 0 ? profiler_gui::SCALING_COEFFICIENT : profiler_gui::SCALING_COEFFICIENT_INV);
|
const auto w = m_slider->halfwidth() * (_event->angleDelta().y() < 0 ? profiler_gui::SCALING_COEFFICIENT : profiler_gui::SCALING_COEFFICIENT_INV);
|
||||||
setValue(mapToScene(_event->pos()).x() - m_minimumValue - w);
|
setValue(mapToScene(_event->position().toPoint()).x() - m_minimumValue - w);
|
||||||
emit EASY_GLOBALS.events.chartWheeled(m_value + w * m_windowScale, _event->delta());
|
emit EASY_GLOBALS.events.chartWheeled(m_value + w * m_windowScale, _event->angleDelta().y());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto x = static_cast<qreal>(_event->pos().x()) / m_windowScale;
|
auto x = static_cast<qreal>(_event->position().x()) / m_windowScale;
|
||||||
if (m_bBindMode) // check m_bBindMode because it may differ from bindMode() for arbitrary value complexity chart
|
if (m_bBindMode) // check m_bBindMode because it may differ from bindMode() for arbitrary value complexity chart
|
||||||
x *= sliderWidth() / range();
|
x *= sliderWidth() / range();
|
||||||
emit EASY_GLOBALS.events.chartWheeled(m_value + x, _event->delta());
|
emit EASY_GLOBALS.events.chartWheeled(m_value + x, _event->angleDelta().y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
@ -96,6 +97,7 @@
|
|||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidgetAction>
|
#include <QWidgetAction>
|
||||||
|
#include <QActionGroup>
|
||||||
|
|
||||||
#include <easy/easy_net.h>
|
#include <easy/easy_net.h>
|
||||||
#include <easy/profiler.h>
|
#include <easy/profiler.h>
|
||||||
@ -429,7 +431,7 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos
|
|||||||
//QRegExp rx("^0*(2(5[0-5]|[0-4]\\d)|1?\\d{1,2})(\\.0*(2(5[0-5]|[0-4]\\d)|1?\\d{1,2})){3}$");
|
//QRegExp rx("^0*(2(5[0-5]|[0-4]\\d)|1?\\d{1,2})(\\.0*(2(5[0-5]|[0-4]\\d)|1?\\d{1,2})){3}$");
|
||||||
//m_addressEdit->setValidator(new QRegExpValidator(rx, m_addressEdit));
|
//m_addressEdit->setValidator(new QRegExpValidator(rx, m_addressEdit));
|
||||||
m_addressEdit->setText(m_lastAddress);
|
m_addressEdit->setText(m_lastAddress);
|
||||||
m_addressEdit->setFixedWidth((m_addressEdit->fontMetrics().width(QString("255.255.255.255")) * 3) / 2);
|
m_addressEdit->setFixedWidth((m_addressEdit->fontMetrics().boundingRect(QString("255.255.255.255")).width() * 3) / 2);
|
||||||
toolbar->addWidget(m_addressEdit);
|
toolbar->addWidget(m_addressEdit);
|
||||||
|
|
||||||
lbl = new QLabel("Port:", toolbar);
|
lbl = new QLabel("Port:", toolbar);
|
||||||
@ -438,7 +440,7 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos
|
|||||||
m_portEdit = new QLineEdit();
|
m_portEdit = new QLineEdit();
|
||||||
m_portEdit->setValidator(new QIntValidator(1, 65535, m_portEdit));
|
m_portEdit->setValidator(new QIntValidator(1, 65535, m_portEdit));
|
||||||
m_portEdit->setText(QString::number(m_lastPort));
|
m_portEdit->setText(QString::number(m_lastPort));
|
||||||
m_portEdit->setFixedWidth(m_portEdit->fontMetrics().width(QString("000000")) + 10);
|
m_portEdit->setFixedWidth(m_portEdit->fontMetrics().boundingRect(QString("000000")).width() + 10);
|
||||||
toolbar->addWidget(m_portEdit);
|
toolbar->addWidget(m_portEdit);
|
||||||
|
|
||||||
connect(m_addressEdit, &QLineEdit::returnPressed, [this] { onConnectClicked(true); });
|
connect(m_addressEdit, &QLineEdit::returnPressed, [this] { onConnectClicked(true); });
|
||||||
@ -889,15 +891,15 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos
|
|||||||
connect(action, &QAction::triggered, this, &This::onEncodingChanged);
|
connect(action, &QAction::triggered, this, &This::onEncodingChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
qSort(actions.begin(), actions.end(), [](QAction* lhs, QAction* rhs) {
|
std::sort(actions.begin(), actions.end(),
|
||||||
|
[](QAction* lhs, QAction* rhs)
|
||||||
|
{
|
||||||
return lhs->text().compare(rhs->text(), Qt::CaseInsensitive) < 0;
|
return lhs->text().compare(rhs->text(), Qt::CaseInsensitive) < 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
submenu->addActions(actions);
|
submenu->addActions(actions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
submenu = menu->addMenu("Appearance");
|
submenu = menu->addMenu("Appearance");
|
||||||
|
|
||||||
actionGroup = new QActionGroup(this);
|
actionGroup = new QActionGroup(this);
|
||||||
@ -1618,9 +1620,9 @@ void MainWindow::onDescTreeDialogClose(int)
|
|||||||
|
|
||||||
void MainWindow::validateLineEdits()
|
void MainWindow::validateLineEdits()
|
||||||
{
|
{
|
||||||
m_addressEdit->setFixedWidth((m_addressEdit->fontMetrics().width(QString("255.255.255.255")) * 3) / 2);
|
m_addressEdit->setFixedWidth((m_addressEdit->fontMetrics().boundingRect(QString("255.255.255.255")).width() * 3) / 2);
|
||||||
m_portEdit->setFixedWidth(m_portEdit->fontMetrics().width(QString("000000")) + 10);
|
m_portEdit->setFixedWidth(m_portEdit->fontMetrics().boundingRect(QString("000000")).width() + 10);
|
||||||
m_frameTimeEdit->setFixedWidth(m_frameTimeEdit->fontMetrics().width(QString("000.000")) + 5);
|
m_frameTimeEdit->setFixedWidth(m_frameTimeEdit->fontMetrics().boundingRect(QString("000.000")).width() + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -434,7 +434,7 @@ void RoundProgressIndicator::updateSize()
|
|||||||
const QFontMetrics fm(font());
|
const QFontMetrics fm(font());
|
||||||
const QString text = QStringLiteral("100%");
|
const QString text = QStringLiteral("100%");
|
||||||
const int margins = m_indicatorWidth * 4 + px(2);
|
const int margins = m_indicatorWidth * 4 + px(2);
|
||||||
const int size = static_cast<int>(std::max(fm.width(text), fm.height()) * profiler_gui::FONT_METRICS_FACTOR) + margins;
|
const int size = static_cast<int>(std::max(fm.boundingRect(text).width(), fm.height()) * profiler_gui::FONT_METRICS_FACTOR) + margins;
|
||||||
|
|
||||||
setFixedSize(size, size);
|
setFixedSize(size, size);
|
||||||
|
|
||||||
@ -514,7 +514,7 @@ void RoundProgressIndicator::paintEvent(QPaintEvent* /*event*/)
|
|||||||
{
|
{
|
||||||
// Draw text
|
// Draw text
|
||||||
p.setWidth(px(1));
|
p.setWidth(px(1));
|
||||||
p.setColor(palette().foreground().color());
|
p.setColor(palette().window().color());
|
||||||
painter.setPen(p);
|
painter.setPen(p);
|
||||||
painter.setFont(font());
|
painter.setFont(font());
|
||||||
painter.drawText(r, Qt::AlignCenter, m_text);
|
painter.drawText(r, Qt::AlignCenter, m_text);
|
||||||
@ -555,7 +555,7 @@ void RoundProgressIndicator::paintStopButton(QPainter& painter, QRect& r)
|
|||||||
painter.drawRect(r);
|
painter.drawRect(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RoundProgressIndicator::enterEvent(QEvent* event) {
|
void RoundProgressIndicator::enterEvent(QEnterEvent* event) {
|
||||||
Parent::enterEvent(event);
|
Parent::enterEvent(event);
|
||||||
profiler_gui::updateProperty(this, "hover", true);
|
profiler_gui::updateProperty(this, "hover", true);
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ 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 enterEvent(QEnterEvent* event) override;
|
||||||
void leaveEvent(QEvent* event) override;
|
void leaveEvent(QEvent* event) override;
|
||||||
void mousePressEvent(QMouseEvent* event) override;
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
void mouseReleaseEvent(QMouseEvent* event) override;
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
@ -88,14 +88,14 @@ void TextHighlighter::highlightBlock(const QString& text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QRegExp expression(m_pattern, m_caseSensitivity);
|
QRegExp expression(m_pattern, m_caseSensitivity);
|
||||||
int index = text.indexOf(expression);
|
int index = text.indexOf(expression.pattern());
|
||||||
while (index >= 0)
|
while (index >= 0)
|
||||||
{
|
{
|
||||||
const auto length = expression.cap().length();
|
const auto length = expression.cap().length();
|
||||||
setFormat(index, length, m_textCharFormat);
|
setFormat(index, length, m_textCharFormat);
|
||||||
|
|
||||||
auto prevIndex = index;
|
auto prevIndex = index;
|
||||||
index = text.indexOf(expression, index + length);
|
index = text.indexOf(expression.pattern(), index + length);
|
||||||
if (index <= prevIndex)
|
if (index <= prevIndex)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -623,7 +623,7 @@ QSize TreeWidgetItemDelegate::sizeHint(const QStyleOptionViewItem& option, const
|
|||||||
// unfortunately, Qt does not take padding into account, so have to add it manually...
|
// unfortunately, Qt does not take padding into account, so have to add it manually...
|
||||||
const auto padding = px(15);
|
const auto padding = px(15);
|
||||||
auto text = displayData.toString();
|
auto text = displayData.toString();
|
||||||
const auto width = static_cast<int>((m_treeWidget->fontMetrics().width(text) + padding) * 1.05);
|
const auto width = static_cast<int>((m_treeWidget->fontMetrics().boundingRect(text).width() + padding) * 1.05);
|
||||||
|
|
||||||
const auto brushData = m_treeWidget->model()->data(index, BlockColorRole);
|
const auto brushData = m_treeWidget->model()->data(index, BlockColorRole);
|
||||||
if (brushData.isNull())
|
if (brushData.isNull())
|
||||||
|
@ -333,7 +333,7 @@ void WindowHeader::showEvent(QShowEvent* event)
|
|||||||
if (!m_pixmap->windowIcon().isNull())
|
if (!m_pixmap->windowIcon().isNull())
|
||||||
{
|
{
|
||||||
const int size = std::max(m_title->fontMetrics().height(), 16);
|
const int size = std::max(m_title->fontMetrics().height(), 16);
|
||||||
if (m_pixmap->pixmap()->height() != size)
|
if (m_pixmap->pixmap().height() != size)
|
||||||
m_pixmap->setPixmap(m_pixmap->windowIcon().pixmap(size, size));
|
m_pixmap->setPixmap(m_pixmap->windowIcon().pixmap(size, size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user