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

278 lines
9.7 KiB
C
Raw Normal View History

2016-06-30 21:39:04 +03:00
/************************************************************************
* file name : main_window.h
* ----------------- :
* creation time : 2016/06/26
* author : Victor Zarubkin
* email : v.s.zarubkin@gmail.com
* ----------------- :
* description : The file contains declaration of MainWindow for easy_profiler GUI.
* ----------------- :
* change log : * 2016/06/26 Victor Zarubkin: initial commit.
* : *
* ----------------- :
2016-09-06 21:49:32 +03:00
* license : Lightweight profiler library for c++
* : Copyright(C) 2016-2019 Sergey Yagovtsev, Victor Zarubkin
2016-09-06 21:49:32 +03:00
* :
2017-03-30 06:14:23 +03:00
* : Licensed under either of
* : * MIT license (LICENSE.MIT or http://opensource.org/licenses/MIT)
* : * Apache License, Version 2.0, (LICENSE.APACHE or http://www.apache.org/licenses/LICENSE-2.0)
* : at your option.
2016-11-13 16:39:59 +03:00
* :
2017-03-30 06:14:23 +03:00
* : The MIT License
* :
* : Permission is hereby granted, free of charge, to any person obtaining a copy
* : of this software and associated documentation files (the "Software"), to deal
* : in the Software without restriction, including without limitation the rights
* : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* : of the Software, and to permit persons to whom the Software is furnished
* : to do so, subject to the following conditions:
* :
* : The above copyright notice and this permission notice shall be included in all
* : copies or substantial portions of the Software.
* :
* : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* : INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* : PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* : LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* : TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* : USE OR OTHER DEALINGS IN THE SOFTWARE.
* :
* : The Apache License, Version 2.0 (the "License")
* :
* : You may not use this file except in compliance with the License.
2016-11-13 16:39:59 +03:00
* : You may obtain a copy of the License at
* :
* : http://www.apache.org/licenses/LICENSE-2.0
* :
* : Unless required by applicable law or agreed to in writing, software
* : distributed under the License is distributed on an "AS IS" BASIS,
* : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* : See the License for the specific language governing permissions and
* : limitations under the License.
************************************************************************/
#ifndef EASY_PROFILER_GUI__MAIN_WINDOW__H
#define EASY_PROFILER_GUI__MAIN_WINDOW__H
#include <atomic>
#include <chrono>
2016-09-18 20:20:37 +03:00
#include <sstream>
#include <string>
#include <thread>
2016-09-18 20:20:37 +03:00
#include <QMainWindow>
2017-11-16 22:32:28 +03:00
#include <QDockWidget>
#include <QTimer>
#include <QStringList>
2016-09-18 20:20:37 +03:00
#include "file_reader.h"
#include "socket_listener.h"
2016-09-18 20:20:37 +03:00
#ifdef max
2016-09-16 02:11:11 +03:00
#undef max
2016-09-18 20:20:37 +03:00
#endif
#ifdef min
2016-09-16 02:11:11 +03:00
#undef min
2016-09-18 20:20:37 +03:00
#endif
//////////////////////////////////////////////////////////////////////////
#define EASY_GUI_USE_DESCRIPTORS_DOCK_WINDOW 0
class DockWidget : public QDockWidget
2017-11-16 22:32:28 +03:00
{
2017-11-17 21:22:53 +03:00
Q_OBJECT
class QPushButton* m_floatingButton;
2017-11-17 21:22:53 +03:00
public:
explicit DockWidget(const QString& title, QWidget* parent = nullptr);
~DockWidget() override;
private slots:
void toggleState();
void onTopLevelChanged();
}; // end of class DockWidget.
2017-11-16 22:32:28 +03:00
struct DialogWithGeometry EASY_FINAL
{
QByteArray geometry;
class Dialog* ptr = nullptr;
void create(QWidget* content, QWidget* parent = nullptr);
void saveGeometry();
void restoreGeometry();
}; // end of struct DialogWithGeometry.
class MainWindow : public QMainWindow
{
Q_OBJECT
protected:
using This = MainWindow;
using Parent = QMainWindow;
DialogWithGeometry m_descTreeDialog;
QStringList m_lastFiles;
2017-11-26 15:37:39 +03:00
QString m_theme;
QString m_lastAddress;
QDockWidget* m_treeWidget = nullptr;
QDockWidget* m_graphicsView = nullptr;
QDockWidget* m_fpsViewer = nullptr;
#if EASY_GUI_USE_DESCRIPTORS_DOCK_WINDOW != 0
2016-09-18 20:20:37 +03:00
QDockWidget* m_descTreeWidget = nullptr;
#endif
class RoundProgressDialog* m_progress = nullptr;
class BlockDescriptorsWidget* m_dialogDescTree = nullptr;
class RoundProgressDialog* m_listenerDialog = nullptr;
QTimer m_readerTimer;
QTimer m_listenerTimer;
QTimer m_fpsRequestTimer;
profiler::SerializedData m_serializedBlocks;
profiler::SerializedData m_serializedDescriptors;
profiler::BeginEndTime m_beginEndTime;
FileReader m_reader;
SocketListener m_listener;
std::chrono::system_clock::time_point m_listenStartTime;
2016-09-13 21:42:38 +03:00
class QLineEdit* m_addressEdit = nullptr;
class QLineEdit* m_portEdit = nullptr;
class QLineEdit* m_frameTimeEdit = nullptr;
2016-09-18 20:20:37 +03:00
class QMenu* m_loadActionMenu = nullptr;
class QAction* m_saveAction = nullptr;
class QAction* m_deleteAction = nullptr;
class QAction* m_captureAction = nullptr;
class QAction* m_connectAction = nullptr;
class QAction* m_eventTracingEnableAction = nullptr;
class QAction* m_eventTracingPriorityAction = nullptr;
uint32_t m_descriptorsNumberInFile = 0;
uint16_t m_lastPort = 0;
bool m_bNetworkFileRegime = false;
bool m_bOpenedCacheFile = false;
bool m_bCloseAfterSave = false;
public:
explicit MainWindow();
~MainWindow() override;
2016-08-04 23:46:04 +03:00
// Public virtual methods
void showEvent(QShowEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
void moveEvent(QMoveEvent* _event) override;
2016-08-04 23:46:04 +03:00
void closeEvent(QCloseEvent* close_event) override;
void changeEvent(QEvent* event) override;
void dragEnterEvent(QDragEnterEvent* drag_event) override;
void dragMoveEvent(QDragMoveEvent* drag_event) override;
void dragLeaveEvent(QDragLeaveEvent* drag_event) override;
void dropEvent(QDropEvent* drop_event) override;
2016-08-04 23:46:04 +03:00
signals:
void activationChanged();
protected slots:
2017-11-26 15:37:39 +03:00
void onThemeChange(bool);
void onOpenFileClicked(bool);
void onSaveFileClicked(bool);
void onDeleteClicked(bool);
void onExitClicked(bool);
void onEncodingChanged(bool);
2018-05-24 02:19:48 +03:00
void onRulerTextPosChanged(bool);
void onUnitsChanged(bool);
void onEnableDisableStatistics(bool);
void onCollapseItemsAfterCloseChanged(bool);
void onAllItemsExpandedByDefaultChange(bool);
void onBindExpandStatusChange(bool);
void onHierarchyFlagChange(bool);
void onDisplayRelevantStatsChange(bool);
void onExpandAllClicked(bool);
void onCollapseAllClicked(bool);
void onViewportInfoClicked(bool);
void onMaxBlocksCountChange(int _value);
void onSpacingChange(int _value);
void onMinSizeChange(int _value);
2019-10-27 14:27:53 +03:00
void onHistogramMinSizeChange(int _value);
void onNarrowSizeChange(int _value);
void onFpsIntervalChange(int _value);
void onFpsHistoryChange(int _value);
void onFpsMonitorLineWidthChange(int _value);
void onFileReaderTimeout();
void onFrameTimeRequestTimeout();
void onListenerTimerTimeout();
void onFileReaderCancel();
void onEditBlocksClicked(bool);
void onDescTreeDialogClose(int);
void onListenerDialogClose(int);
2016-09-08 21:03:05 +03:00
void onCaptureClicked(bool);
void onGetBlockDescriptionsClicked(bool);
2016-09-13 21:42:38 +03:00
void onConnectClicked(bool);
void onEventTracingPriorityChange(bool _checked);
void onEventTracingEnableChange(bool _checked);
void onFrameTimeEditFinish();
void onFrameTimeChanged();
void onSnapshotClicked(bool);
void onCustomWindowHeaderTriggered(bool _checked);
void onRightWindowHeaderPosition(bool _checked);
void onLeftWindowHeaderPosition(bool _checked);
2016-09-13 21:42:38 +03:00
void onBlockStatusChange(profiler::block_id_t _id, profiler::EasyBlockStatus _status);
void onSelectValue(profiler::thread_id_t _thread_id, uint32_t _value_index, const profiler::ArbitraryValue& _value);
void checkFrameTimeReady();
void validateLastDir();
2016-06-30 21:39:04 +03:00
private:
2016-08-04 23:46:04 +03:00
// Private non-virtual methods
void centerDialogs();
void closeProgressDialogAndClearReader();
void onLoadingFinish(profiler::block_index_t& _nblocks);
void onSavingFinish();
void configureSizes();
void clear();
void refreshDiagram();
void refreshHistogramImage();
void addFileToList(const QString& filename, bool changeWindowTitle = true);
void loadFile(const QString& filename);
void readStream(std::stringstream& data);
2016-08-07 19:35:58 +03:00
void loadSettings();
void loadGeometry();
2016-09-06 22:23:55 +03:00
void saveSettingsAndGeometry();
2016-06-30 21:39:04 +03:00
void setDisconnected(bool _showMessage = true);
2016-11-18 22:58:44 +03:00
2017-11-27 22:02:15 +03:00
void destroyProgressDialog();
void createProgressDialog(const QString& text);
void validateLineEdits();
}; // END of class MainWindow.
//////////////////////////////////////////////////////////////////////////
#endif // EASY_PROFILER_GUI__MAIN_WINDOW__H