0
0
mirror of https://github.com/yse/easy_profiler.git synced 2024-12-26 08:01:51 +08:00

#0 [UI] refactoring

This commit is contained in:
Victor Zarubkin 2018-05-24 02:19:48 +03:00
parent 7503199eed
commit 2b75e65535
7 changed files with 41 additions and 41 deletions

View File

@ -353,7 +353,7 @@ GraphicsRulerItem* BlocksGraphicsView::createRuler(bool _main)
{
auto ruler = new GraphicsRulerItem(_main);
ruler->setColor(_main ? ::profiler_gui::CHRONOMETER_COLOR : ::profiler_gui::CHRONOMETER_COLOR2);
ruler->setColor(_main ? ::profiler_gui::RULER_COLOR : ::profiler_gui::RULER_COLOR2);
ruler->setBoundingRect(sceneRect());
ruler->hide();
scene()->addItem(ruler);
@ -2391,8 +2391,8 @@ void ThreadNameItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem*,
}
};
drawTimeText(time1, th, ::profiler_gui::CHRONOMETER_COLOR.rgb() & 0x00ffffff);
drawTimeText(time2, th, ::profiler_gui::CHRONOMETER_COLOR2.rgb() & 0x00ffffff);
drawTimeText(time1, th, ::profiler_gui::RULER_COLOR.rgb() & 0x00ffffff);
drawTimeText(time2, th, ::profiler_gui::RULER_COLOR2.rgb() & 0x00ffffff);
}
//////////////////////////////////////////////////////////////////////////

View File

@ -92,7 +92,7 @@ namespace profiler_gui {
, max_fps_history(90)
, fps_timer_interval(500)
, fps_widget_line_width(2)
, chrono_text_position(ChronoTextPosition_Top)
, chrono_text_position(RulerTextPosition_Top)
, time_units(TimeUnits_ms)
, connected(false)
, fps_enabled(true)

View File

@ -72,10 +72,10 @@ namespace profiler_gui {
const QString ORGANAZATION_NAME = "EasyProfiler";
const QString APPLICATION_NAME = "Easy profiler gui application";
const QColor CHRONOMETER_COLOR = QColor::fromRgba(0x40000000 | (::profiler::colors::RichBlue & 0x00ffffff));// 0x402020c0);
const QColor CHRONOMETER_COLOR2 = QColor::fromRgba(0x40000000 | (::profiler::colors::Dark & 0x00ffffff));// 0x40408040);
const QColor RULER_COLOR = QColor::fromRgba(0x40000000 | (::profiler::colors::RichBlue & 0x00ffffff));// 0x402020c0);
const QColor RULER_COLOR2 = QColor::fromRgba(0x40000000 | (::profiler::colors::Dark & 0x00ffffff));// 0x40408040);
const QColor TEXT_COLOR = QColor::fromRgb(0xff504040);
const QColor SYSTEM_BORDER_COLOR = QColor::fromRgb(0xffcccccc);
const QColor SYSTEM_BORDER_COLOR = QColor::fromRgb(0xffc4c4c4);
EASY_CONSTEXPR QRgb SELECTED_THREAD_BACKGROUND = 0xffe0e060;
EASY_CONSTEXPR QRgb SELECTED_THREAD_FOREGROUND = 0xffffffff - (SELECTED_THREAD_BACKGROUND & 0x00ffffff);
@ -146,13 +146,13 @@ namespace profiler_gui {
//////////////////////////////////////////////////////////////////////////
enum ChronometerTextPosition : int8_t
enum RulerTextPosition : int8_t
{
ChronoTextPosition_Center = 0,
ChronoTextPosition_Top,
ChronoTextPosition_Bottom,
RulerTextPosition_Center = 0,
RulerTextPosition_Top,
RulerTextPosition_Bottom,
}; // END of enum ChronometerTextPosition.
}; // END of enum RulerTextPosition.
//////////////////////////////////////////////////////////////////////////
@ -217,7 +217,7 @@ namespace profiler_gui {
int max_fps_history; ///< Max frames history displayed in FPS Monitor
int fps_timer_interval; ///< Interval in milliseconds for sending network requests to the profiled application (used by FPS Monitor)
int fps_widget_line_width; ///< Line width in pixels of FPS lines for FPS Monitor
ChronometerTextPosition chrono_text_position; ///< Selected interval text position
RulerTextPosition chrono_text_position; ///< Selected interval text position
TimeUnits time_units; ///< Units type for time (milliseconds, microseconds, nanoseconds or auto-definition)
bool connected; ///< Is connected to source (to be able to capture profiling information)
bool fps_enabled; ///< Is FPS Monitor enabled

View File

@ -74,7 +74,7 @@
GraphicsRulerItem::GraphicsRulerItem(bool _main)
: Parent()
, m_color(::profiler_gui::CHRONOMETER_COLOR)
, m_color(profiler_gui::RULER_COLOR)
, m_left(0)
, m_right(0)
, m_bMain(_main)
@ -149,7 +149,7 @@ void GraphicsRulerItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem
QRectF rect((m_left - offset) * currentScale, visibleSceneRect.top(), ::std::max(selectedInterval * currentScale, 1.0), visibleSceneRect.height());
selectedInterval = units2microseconds(selectedInterval);
const QString text = ::profiler_gui::timeStringReal(EASY_GLOBALS.time_units, selectedInterval); // Displayed text
const QString text = profiler_gui::timeStringReal(EASY_GLOBALS.time_units, selectedInterval); // Displayed text
const auto textRect = QFontMetricsF(EASY_GLOBALS.font.ruler, sceneView).boundingRect(text); // Calculate displayed text boundingRect
const auto rgb = m_color.rgb() & 0x00ffffff;
@ -242,23 +242,23 @@ void GraphicsRulerItem::paint(QPainter* _painter, const QStyleOptionGraphicsItem
int textFlags = 0;
switch (EASY_GLOBALS.chrono_text_position)
{
case ::profiler_gui::ChronoTextPosition_Top:
case profiler_gui::RulerTextPosition_Top:
textFlags = Qt::AlignTop | Qt::AlignHCenter;
if (!m_bMain) rect.setTop(rect.top() + textRect.height() * 0.75);
break;
case ::profiler_gui::ChronoTextPosition_Center:
case profiler_gui::RulerTextPosition_Center:
textFlags = Qt::AlignCenter;
if (!m_bMain) rect.setTop(rect.top() + textRect.height() * 1.5);
break;
case ::profiler_gui::ChronoTextPosition_Bottom:
case profiler_gui::RulerTextPosition_Bottom:
textFlags = Qt::AlignBottom | Qt::AlignHCenter;
if (!m_bMain) rect.setHeight(rect.height() - textRect.height() * 0.75);
break;
}
const auto textRect_width = textRect.width() * ::profiler_gui::FONT_METRICS_FACTOR;
const auto textRect_width = textRect.width() * profiler_gui::FONT_METRICS_FACTOR;
if (textRect_width < rect.width())
{
// Text will be drawed inside rectangle

View File

@ -204,7 +204,7 @@ GraphicsSliderArea::GraphicsSliderArea(QWidget* _parent)
scene()->addItem(m_selectionIndicator);
m_selectionIndicator->setPos(0, 0);
m_selectionIndicator->setColor(0x40000000 | profiler_gui::CHRONOMETER_COLOR.rgba());
m_selectionIndicator->setColor(0x40000000 | profiler_gui::RULER_COLOR.rgba());
m_selectionIndicator->hide();
m_slider = new GraphicsSliderItem(6, true);

View File

@ -469,8 +469,8 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos
menu->addSeparator();
auto submenu = menu->addMenu("View");
submenu->setToolTipsVisible(true);
action = submenu->addAction("Draw items' borders");
action->setToolTip("Draw borders for blocks on diagram.\nThis reduces performance.");
action = submenu->addAction("Draw borders");
action->setToolTip("Draw borders for blocks on diagram.\nThis slightly reduces performance.");
action->setCheckable(true);
action->setChecked(EASY_GLOBALS.draw_graphics_items_borders);
connect(action, &QAction::triggered, [this](bool _checked){ EASY_GLOBALS.draw_graphics_items_borders = _checked; refreshDiagram(); });
@ -593,32 +593,32 @@ MainWindow::MainWindow() : Parent(), m_theme("default"), m_lastAddress("localhos
auto actionGroup = new QActionGroup(this);
actionGroup->setExclusive(true);
action = new QAction("Chrono text at top", actionGroup);
action->setToolTip("Draw duration of selected interval\nat the top of the screen.");
action = new QAction("Ruler text at top", actionGroup);
action->setToolTip("Draw duration of selected interval\nat the top of the diagram.");
action->setCheckable(true);
action->setData(static_cast<int>(profiler_gui::ChronoTextPosition_Top));
if (EASY_GLOBALS.chrono_text_position == profiler_gui::ChronoTextPosition_Top)
action->setData(static_cast<int>(profiler_gui::RulerTextPosition_Top));
if (EASY_GLOBALS.chrono_text_position == profiler_gui::RulerTextPosition_Top)
action->setChecked(true);
submenu->addAction(action);
connect(action, &QAction::triggered, this, &This::onChronoTextPosChanged);
connect(action, &QAction::triggered, this, &This::onRulerTextPosChanged);
action = new QAction("Chrono text at center", actionGroup);
action->setToolTip("Draw duration of selected interval\nat the center of the screen.");
action = new QAction("Ruler text at center", actionGroup);
action->setToolTip("Draw duration of selected interval\nat the center of the diagram.");
action->setCheckable(true);
action->setData(static_cast<int>(profiler_gui::ChronoTextPosition_Center));
if (EASY_GLOBALS.chrono_text_position == profiler_gui::ChronoTextPosition_Center)
action->setData(static_cast<int>(profiler_gui::RulerTextPosition_Center));
if (EASY_GLOBALS.chrono_text_position == profiler_gui::RulerTextPosition_Center)
action->setChecked(true);
submenu->addAction(action);
connect(action, &QAction::triggered, this, &This::onChronoTextPosChanged);
connect(action, &QAction::triggered, this, &This::onRulerTextPosChanged);
action = new QAction("Chrono text at bottom", actionGroup);
action->setToolTip("Draw duration of selected interval\nat the bottom of the screen.");
action = new QAction("Ruler text at bottom", actionGroup);
action->setToolTip("Draw duration of selected interval\nat the bottom of the diagram.");
action->setCheckable(true);
action->setData(static_cast<int>(profiler_gui::ChronoTextPosition_Bottom));
if (EASY_GLOBALS.chrono_text_position == profiler_gui::ChronoTextPosition_Bottom)
action->setData(static_cast<int>(profiler_gui::RulerTextPosition_Bottom));
if (EASY_GLOBALS.chrono_text_position == profiler_gui::RulerTextPosition_Bottom)
action->setChecked(true);
submenu->addAction(action);
connect(action, &QAction::triggered, this, &This::onChronoTextPosChanged);
connect(action, &QAction::triggered, this, &This::onRulerTextPosChanged);
submenu->addSeparator();
auto w = new QWidget(submenu);
@ -1233,10 +1233,10 @@ void MainWindow::onEncodingChanged(bool)
QTextCodec::setCodecForLocale(codec);
}
void MainWindow::onChronoTextPosChanged(bool)
void MainWindow::onRulerTextPosChanged(bool)
{
auto _sender = qobject_cast<QAction*>(sender());
EASY_GLOBALS.chrono_text_position = static_cast<profiler_gui::ChronometerTextPosition>(_sender->data().toInt());
EASY_GLOBALS.chrono_text_position = static_cast<profiler_gui::RulerTextPosition>(_sender->data().toInt());
refreshDiagram();
}
@ -1471,7 +1471,7 @@ void MainWindow::loadSettings()
auto val = settings.value("chrono_text_position");
if (!val.isNull())
EASY_GLOBALS.chrono_text_position = static_cast<profiler_gui::ChronometerTextPosition>(val.toInt());
EASY_GLOBALS.chrono_text_position = static_cast<profiler_gui::RulerTextPosition>(val.toInt());
val = settings.value("time_units");
if (!val.isNull())

View File

@ -318,7 +318,7 @@ protected slots:
void onDeleteClicked(bool);
void onExitClicked(bool);
void onEncodingChanged(bool);
void onChronoTextPosChanged(bool);
void onRulerTextPosChanged(bool);
void onUnitsChanged(bool);
void onEnableDisableStatistics(bool);
void onCollapseItemsAfterCloseChanged(bool);