From patchwork Thu Nov 1 21:45:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yordan Karadzhov X-Patchwork-Id: 10759635 Return-Path: Received: from mail-eopbgr810081.outbound.protection.outlook.com ([40.107.81.81]:10264 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727001AbeKBGub (ORCPT ); Fri, 2 Nov 2018 02:50:31 -0400 From: Yordan Karadzhov To: "rostedt@goodmis.org" CC: "linux-trace-devel@vger.kernel.org" Subject: [PATCH 6/8] kernel-shark-qt: Fix bug when resizing the KS window for session Date: Thu, 1 Nov 2018 21:45:43 +0000 Message-ID: <20181101214512.18684-7-ykaradzhov@vmware.com> References: <20181101214512.18684-1-ykaradzhov@vmware.com> In-Reply-To: <20181101214512.18684-1-ykaradzhov@vmware.com> Content-Language: en-US MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 5617 Currently the session export/import code cannot deal with the case when the KernelShark GUI is in Full Screen mode. This patch fixes this. Signed-off-by: Yordan Karadzhov --- kernel-shark-qt/src/KsMainWindow.cpp | 9 +++------ kernel-shark-qt/src/KsMainWindow.hpp | 10 +++++++--- kernel-shark-qt/src/KsSession.cpp | 21 +++++++++++++++++---- kernel-shark-qt/src/KsSession.hpp | 4 +++- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/kernel-shark-qt/src/KsMainWindow.cpp b/kernel-shark-qt/src/KsMainWindow.cpp index 4f9a6e2..89b1b58 100644 --- a/kernel-shark-qt/src/KsMainWindow.cpp +++ b/kernel-shark-qt/src/KsMainWindow.cpp @@ -64,7 +64,6 @@ KsMainWindow::KsMainWindow(QWidget *parent) _colSlider(this), _colorPhaseSlider(Qt::Horizontal, this), _fullScreenModeAction("Full Screen Mode", this), - _isFullScreen(false), _aboutAction("About", this), _contentsAction("Contents", this) { @@ -245,7 +244,7 @@ void KsMainWindow::_createActions() _fullScreenModeAction.setStatusTip("Full Screen Mode"); connect(&_fullScreenModeAction, &QAction::triggered, - this, &KsMainWindow::_fullScreenMode); + this, &KsMainWindow::_changeScreenMode); /* Help menu */ _aboutAction.setIcon(QIcon::fromTheme("help-about")); @@ -732,18 +731,16 @@ void KsMainWindow::_setColorPhase(int f) _graph.glPtr()->model()->update(); } -void KsMainWindow::_fullScreenMode() +void KsMainWindow::_changeScreenMode() { - if (_isFullScreen) { + if (isFullScreen()) { _fullScreenModeAction.setText("Full Screen Mode"); _fullScreenModeAction.setIcon(QIcon::fromTheme("view-fullscreen")); showNormal(); - _isFullScreen = false; } else { _fullScreenModeAction.setText("Exit Full Screen Mode"); _fullScreenModeAction.setIcon(QIcon::fromTheme("view-restore")); showFullScreen(); - _isFullScreen = true; } } diff --git a/kernel-shark-qt/src/KsMainWindow.hpp b/kernel-shark-qt/src/KsMainWindow.hpp index 0e14c80..d711ec1 100644 --- a/kernel-shark-qt/src/KsMainWindow.hpp +++ b/kernel-shark-qt/src/KsMainWindow.hpp @@ -61,6 +61,12 @@ public: void resizeEvent(QResizeEvent* event); + /** Set the Full Screen mode. */ + void setFullScreenMode(bool f) { + if ((!isFullScreen() && f) || (isFullScreen() && !f) ) + _changeScreenMode(); + } + private: QSplitter _splitter; @@ -136,8 +142,6 @@ private: QAction _fullScreenModeAction; - bool _isFullScreen; - // Help menu. QAction _aboutAction; @@ -179,7 +183,7 @@ private: void _setColorPhase(int); - void _fullScreenMode(); + void _changeScreenMode(); void _aboutInfo(); diff --git a/kernel-shark-qt/src/KsSession.cpp b/kernel-shark-qt/src/KsSession.cpp index b7ef81c..2242a12 100644 --- a/kernel-shark-qt/src/KsSession.cpp +++ b/kernel-shark-qt/src/KsSession.cpp @@ -12,6 +12,7 @@ // KernelShark #include "libkshark.h" #include "KsSession.hpp" +#include "KsMainWindow.hpp" /** Create a KsSession object. */ KsSession::KsSession() @@ -175,10 +176,15 @@ void KsSession::saveMainWindowSize(const QMainWindow &window) { kshark_config_doc *windowConf = kshark_config_alloc(KS_CONFIG_JSON); int width = window.width(), height = window.height(); - json_object *jwindow = json_object_new_array(); + json_object *jwindow; - json_object_array_put_idx(jwindow, 0, json_object_new_int(width)); - json_object_array_put_idx(jwindow, 1, json_object_new_int(height)); + if (window.isFullScreen()) { + jwindow = json_object_new_string("FullScreen"); + } else { + jwindow = json_object_new_array(); + json_object_array_put_idx(jwindow, 0, json_object_new_int(width)); + json_object_array_put_idx(jwindow, 1, json_object_new_int(height)); + } windowConf->conf_doc = jwindow; kshark_config_doc_add(_config, "MainWindow", windowConf); @@ -189,7 +195,7 @@ void KsSession::saveMainWindowSize(const QMainWindow &window) * * @param window: Input location for the KsMainWindow widget. */ -void KsSession::loadMainWindowSize(QMainWindow *window) +void KsSession::loadMainWindowSize(KsMainWindow *window) { kshark_config_doc *windowConf = kshark_config_alloc(KS_CONFIG_JSON); json_object *jwindow, *jwidth, *jheight; @@ -200,12 +206,19 @@ void KsSession::loadMainWindowSize(QMainWindow *window) if (_config->format == KS_CONFIG_JSON) { jwindow = KS_JSON_CAST(windowConf->conf_doc); + if (json_object_get_type(jwindow) == json_type_string && + QString(json_object_get_string(jwindow)) == "FullScreen") { + window->setFullScreenMode(true); + return; + } + jwidth = json_object_array_get_idx(jwindow, 0); jheight = json_object_array_get_idx(jwindow, 1); width = json_object_get_int(jwidth); height = json_object_get_int(jheight); + window->setFullScreenMode(false); window->resize(width, height); } } diff --git a/kernel-shark-qt/src/KsSession.hpp b/kernel-shark-qt/src/KsSession.hpp index 4f5a2c4..f5ed5a1 100644 --- a/kernel-shark-qt/src/KsSession.hpp +++ b/kernel-shark-qt/src/KsSession.hpp @@ -20,6 +20,8 @@ #include "KsTraceGraph.hpp" #include "KsTraceViewer.hpp" +class KsMainWindow; + /** * The KsSession class provides instruments for importing/exporting the state * of the different components of the GUI from/to Json documents. These @@ -57,7 +59,7 @@ public: void saveMainWindowSize(const QMainWindow &window); - void loadMainWindowSize(QMainWindow *window); + void loadMainWindowSize(KsMainWindow *window); void saveSplitterSize(const QSplitter &splitter);