diff --git a/profiler_gui/blocks_tree_widget.cpp b/profiler_gui/blocks_tree_widget.cpp index 48757ee..c093e6f 100644 --- a/profiler_gui/blocks_tree_widget.cpp +++ b/profiler_gui/blocks_tree_widget.cpp @@ -359,11 +359,11 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event) { action = menu.addAction("Expand all"); connect(action, &QAction::triggered, this, &This::onExpandAllClicked); - { QIcon icon(":/Expand"); if (!icon.isNull()) action->setIcon(icon); } + SET_ICON(action, ":/Expand"); action = menu.addAction("Collapse all"); connect(action, &QAction::triggered, this, &This::onCollapseAllClicked); - { QIcon icon(":/Collapse"); if (!icon.isNull()) action->setIcon(icon); } + SET_ICON(action, ":/Colapse"); if (item != nullptr && col >= 0) { @@ -371,11 +371,11 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event) action = menu.addAction("Expand all children"); connect(action, &QAction::triggered, this, &This::onExpandAllChildrenClicked); - { QIcon icon(":/Expand"); if (!icon.isNull()) action->setIcon(icon); } + SET_ICON(action, ":/Expand"); action = menu.addAction("Collapse all children"); connect(action, &QAction::triggered, this, &This::onCollapseAllChildrenClicked); - { QIcon icon(":/Collapse"); if (!icon.isNull()) action->setIcon(icon); } + SET_ICON(action, ":/Collapse"); } menu.addSeparator(); @@ -389,9 +389,9 @@ void EasyTreeWidget::contextMenuEvent(QContextMenuEvent* _event) auto f = action->font(); f.setBold(true); action->setFont(f); - { QIcon icon(":/Color"); if (!icon.isNull()) action->setIcon(icon); } + SET_ICON(action, ":/Color"); } - else { QIcon icon(":/NoColor"); if (!icon.isNull()) action->setIcon(icon); } + else SET_ICON(action, ":/NoColor"); if (item != nullptr && item->parent() != nullptr) { diff --git a/profiler_gui/globals.h b/profiler_gui/globals.h index 7512274..eb654ca 100644 --- a/profiler_gui/globals.h +++ b/profiler_gui/globals.h @@ -35,6 +35,7 @@ #include #include #include +#include #include "common_types.h" #include "globals_qobjects.h" @@ -130,6 +131,8 @@ inline ::profiler::BlocksTree& blocksTree(::profiler::block_index_t i) { } #endif +#define SET_ICON(objectName, iconName) { QIcon icon(iconName); if (!icon.isNull()) objectName->setIcon(icon); } + ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// diff --git a/profiler_gui/icons/collapse.svg b/profiler_gui/icons/collapse.svg index 090484a..b40e8ee 100644 --- a/profiler_gui/icons/collapse.svg +++ b/profiler_gui/icons/collapse.svg @@ -4,9 +4,12 @@ + + + diff --git a/profiler_gui/icons/expand.svg b/profiler_gui/icons/expand.svg index c66e1e7..b5fd471 100644 --- a/profiler_gui/icons/expand.svg +++ b/profiler_gui/icons/expand.svg @@ -3,10 +3,12 @@ - + + + + diff --git a/profiler_gui/icons/lan.svg b/profiler_gui/icons/lan.svg index e7df402..676c16a 100644 --- a/profiler_gui/icons/lan.svg +++ b/profiler_gui/icons/lan.svg @@ -15,7 +15,7 @@ h18.936V14.258c0-1.793,1.453-3.246,3.246-3.246c1.789,0,3.246,1.453,3.246,3.246C31.92,14.258,31.92,42.935,31.92,42.935z"/> - diff --git a/profiler_gui/icons/logo.svg b/profiler_gui/icons/logo.svg index 6c3b090..85d3761 100644 --- a/profiler_gui/icons/logo.svg +++ b/profiler_gui/icons/logo.svg @@ -12,9 +12,9 @@ C638.876,263.557,533.698,142.786,395.233,117.99z M342.758,637.52c-125.907,0-228.339-102.433-228.339-228.362 c0-125.896,102.433-228.305,228.339-228.305c125.895,0,228.339,102.41,228.339,228.305 C571.097,535.087,468.665,637.52,342.758,637.52z"/> - - diff --git a/profiler_gui/icons/off.svg b/profiler_gui/icons/off.svg index 7f18abd..4268fb7 100644 --- a/profiler_gui/icons/off.svg +++ b/profiler_gui/icons/off.svg @@ -7,7 +7,7 @@ - diff --git a/profiler_gui/icons/open-folder.svg b/profiler_gui/icons/open-folder.svg index 767696a..10f1164 100644 --- a/profiler_gui/icons/open-folder.svg +++ b/profiler_gui/icons/open-folder.svg @@ -5,7 +5,8 @@ viewBox="0 0 250.604 250.604" style="enable-background:new 0 0 250.604 250.604;" xml:space="preserve"> + diff --git a/profiler_gui/icons/reload.svg b/profiler_gui/icons/reload.svg index fb9034e..7ad5e0c 100644 --- a/profiler_gui/icons/reload.svg +++ b/profiler_gui/icons/reload.svg @@ -7,7 +7,7 @@ - diff --git a/profiler_gui/icons/statistics.svg b/profiler_gui/icons/statistics.svg index bec725a..0a7076c 100644 --- a/profiler_gui/icons/statistics.svg +++ b/profiler_gui/icons/statistics.svg @@ -8,7 +8,7 @@ - diff --git a/profiler_gui/icons/wifi.svg b/profiler_gui/icons/wifi.svg index 014ff0a..856852e 100644 --- a/profiler_gui/icons/wifi.svg +++ b/profiler_gui/icons/wifi.svg @@ -4,11 +4,14 @@ + + + diff --git a/profiler_gui/main_window.cpp b/profiler_gui/main_window.cpp index 91d729a..5e08488 100644 --- a/profiler_gui/main_window.cpp +++ b/profiler_gui/main_window.cpp @@ -34,6 +34,7 @@ * : along with this program.If not, see . ************************************************************************/ +#include #include #include #include @@ -61,12 +62,12 @@ const int LOADER_TIMER_INTERVAL = 40; EasyMainWindow::EasyMainWindow() : Parent(), m_treeWidget(nullptr), m_graphicsView(nullptr), m_progress(nullptr) { + { QIcon icon(":/logo"); if (!icon.isNull()) QApplication::setWindowIcon(icon); } + setObjectName("ProfilerGUI_MainWindow"); setWindowTitle("EasyProfiler Reader beta"); setDockNestingEnabled(true); resize(800, 600); - - { QIcon icon(":/logo"); if (!icon.isNull()) setWindowIcon(icon); } setStatusBar(new QStatusBar()); @@ -93,16 +94,16 @@ EasyMainWindow::EasyMainWindow() : Parent(), m_treeWidget(nullptr), m_graphicsVi auto action = menu->addAction("&Open"); connect(action, &QAction::triggered, this, &This::onOpenFileClicked); - { QIcon icon(":/Open"); if (!icon.isNull()) action->setIcon(icon); } + SET_ICON(action, ":/Open"); action = menu->addAction("&Reload"); connect(action, &QAction::triggered, this, &This::onReloadFileClicked); - { QIcon icon(":/Reload"); if (!icon.isNull()) action->setIcon(icon); } + SET_ICON(action, ":/Reload"); menu->addSeparator(); action = menu->addAction("&Exit"); connect(action, &QAction::triggered, this, &This::onExitClicked); - { QIcon icon(":/Exit"); if (!icon.isNull()) action->setIcon(icon); } + SET_ICON(action, ":/Exit"); menuBar()->addMenu(menu); @@ -112,11 +113,11 @@ EasyMainWindow::EasyMainWindow() : Parent(), m_treeWidget(nullptr), m_graphicsVi action = menu->addAction("Expand all"); connect(action, &QAction::triggered, this, &This::onExpandAllClicked); - { QIcon icon(":/Expand"); if (!icon.isNull()) action->setIcon(icon); } + SET_ICON(action, ":/Expand"); action = menu->addAction("Collapse all"); connect(action, &QAction::triggered, this, &This::onCollapseAllClicked); - { QIcon icon(":/Collapse"); if (!icon.isNull()) action->setIcon(icon); } + SET_ICON(action, ":/Collapse"); menu->addSeparator(); action = menu->addAction("Draw items' borders"); @@ -182,16 +183,12 @@ EasyMainWindow::EasyMainWindow() : Parent(), m_treeWidget(nullptr), m_graphicsVi auto f = action->font(); f.setBold(true); action->setFont(f); - QIcon icon(":/Stats"); - if (!icon.isNull()) - action->setIcon(icon); + SET_ICON(action, ":/Stats"); } else { action->setText("Statistics disabled"); - QIcon icon(":/Stats-off"); - if (!icon.isNull()) - action->setIcon(icon); + SET_ICON(action, ":/Stats-off"); } menu->addAction(action); @@ -247,7 +244,8 @@ EasyMainWindow::~EasyMainWindow() void EasyMainWindow::onOpenFileClicked(bool) { auto filename = QFileDialog::getOpenFileName(this, "Open profiler log", m_lastFile, "Profiler Log File (*.prof);;All Files (*.*)"); - loadFile(filename); + if (!filename.isEmpty()) + loadFile(filename); } ////////////////////////////////////////////////////////////////////////// @@ -311,16 +309,12 @@ void EasyMainWindow::onEnableDisableStatistics(bool _checked) if (_checked) { action->setText("Statistics enabled"); - QIcon icon(":/Stats"); - if (!icon.isNull()) - action->setIcon(icon); + SET_ICON(action, ":/Stats"); } else { action->setText("Statistics disabled"); - QIcon icon(":/Stats-off"); - if (!icon.isNull()) - action->setIcon(icon); + SET_ICON(action, ":/Stats-off"); } } }