From 3e9df0b074588c79af63c48f00c1324034e3da2a Mon Sep 17 00:00:00 2001 From: mlangkabel Date: Tue, 6 Aug 2019 13:04:54 +0200 Subject: [PATCH] ui: fix z-index of custom trail dialog and row height of "show directory path" option in preferences --- src/lib/component/ComponentFactory.cpp | 4 ++-- src/lib/component/ComponentFactory.h | 2 +- src/lib/component/ComponentManager.cpp | 2 +- src/lib/component/view/ViewFactory.h | 2 +- .../QtProjectWizardContentPreferences.cpp | 1 + src/lib_gui/qt/utility/utilityQt.cpp | 10 ++++++++++ src/lib_gui/qt/utility/utilityQt.h | 4 ++++ src/lib_gui/qt/view/QtCustomTrailView.cpp | 6 ++++-- src/lib_gui/qt/view/QtScreenSearchView.cpp | 16 ++++++++++------ src/lib_gui/qt/view/QtTooltipView.cpp | 3 ++- src/lib_gui/qt/view/QtViewFactory.cpp | 7 ++++--- src/lib_gui/qt/view/QtViewFactory.h | 2 +- 12 files changed, 41 insertions(+), 18 deletions(-) diff --git a/src/lib/component/ComponentFactory.cpp b/src/lib/component/ComponentFactory.cpp index 40fd245a..87103051 100644 --- a/src/lib/component/ComponentFactory.cpp +++ b/src/lib/component/ComponentFactory.cpp @@ -69,9 +69,9 @@ std::shared_ptr ComponentFactory::createCodeComponent(ViewLayout* vie return std::make_shared(view, controller); } -std::shared_ptr ComponentFactory::createCustomTrailComponent() +std::shared_ptr ComponentFactory::createCustomTrailComponent(ViewLayout* viewLayout) { - std::shared_ptr view = m_viewFactory->createCustomTrailView(); + std::shared_ptr view = m_viewFactory->createCustomTrailView(viewLayout); std::shared_ptr controller = std::make_shared(m_storageAccess); return std::make_shared(view, controller); diff --git a/src/lib/component/ComponentFactory.h b/src/lib/component/ComponentFactory.h index 660e5e13..1e094122 100644 --- a/src/lib/component/ComponentFactory.h +++ b/src/lib/component/ComponentFactory.h @@ -21,7 +21,7 @@ public: std::shared_ptr createActivationComponent(); std::shared_ptr createBookmarkComponent(ViewLayout* viewLayout); std::shared_ptr createCodeComponent(ViewLayout* viewLayout); - std::shared_ptr createCustomTrailComponent(); + std::shared_ptr createCustomTrailComponent(ViewLayout* viewLayout); std::shared_ptr createErrorComponent(ViewLayout* viewLayout); std::shared_ptr createGraphComponent(ViewLayout* viewLayout); std::shared_ptr createRefreshComponent(ViewLayout* viewLayout); diff --git a/src/lib/component/ComponentManager.cpp b/src/lib/component/ComponentManager.cpp index 25feac96..999b9848 100644 --- a/src/lib/component/ComponentManager.cpp +++ b/src/lib/component/ComponentManager.cpp @@ -99,7 +99,7 @@ void ComponentManager::setupMain(ViewLayout* viewLayout, Id appId) std::shared_ptr statusBarComponent = m_componentFactory.createStatusBarComponent(viewLayout); m_components.push_back(statusBarComponent); - std::shared_ptr customTrailComponent = m_componentFactory.createCustomTrailComponent(); + std::shared_ptr customTrailComponent = m_componentFactory.createCustomTrailComponent(viewLayout); m_components.push_back(customTrailComponent); } diff --git a/src/lib/component/view/ViewFactory.h b/src/lib/component/view/ViewFactory.h index a1916cb9..652e539b 100644 --- a/src/lib/component/view/ViewFactory.h +++ b/src/lib/component/view/ViewFactory.h @@ -39,7 +39,7 @@ public: virtual std::shared_ptr createBookmarkButtonsView(ViewLayout* viewLayout) const = 0; virtual std::shared_ptr createBookmarkView(ViewLayout* viewLayout) const = 0; virtual std::shared_ptr createCodeView(ViewLayout* viewLayout) const = 0; - virtual std::shared_ptr createCustomTrailView() const = 0; + virtual std::shared_ptr createCustomTrailView(ViewLayout* viewLayout) const = 0; virtual std::shared_ptr createErrorView(ViewLayout* viewLayout) const = 0; virtual std::shared_ptr createGraphView(ViewLayout* viewLayout) const = 0; virtual std::shared_ptr createRefreshView(ViewLayout* viewLayout) const = 0; diff --git a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp index c8431a83..694fad32 100644 --- a/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp +++ b/src/lib_gui/qt/project_wizard/content/QtProjectWizardContentPreferences.cpp @@ -106,6 +106,7 @@ void QtProjectWizardContentPreferences::populate(QGridLayout* layout, int& row) // directory in code m_showDirectoryInCode = addCheckBox("Directory in File Title", "Show directory of file in code title", "

Enable display of the parent directory of a code file relative to the project file.

", layout, row); + layout->setRowMinimumHeight(row - 1, 30); addGap(layout, row); diff --git a/src/lib_gui/qt/utility/utilityQt.cpp b/src/lib_gui/qt/utility/utilityQt.cpp index 50eb76ee..d1b2b7d9 100644 --- a/src/lib_gui/qt/utility/utilityQt.cpp +++ b/src/lib_gui/qt/utility/utilityQt.cpp @@ -12,6 +12,7 @@ #include "FilePath.h" #include "FileSystem.h" #include "logging.h" +#include "QtMainView.h" #include "ResourcePaths.h" #include "TextAccess.h" #include "utilityApp.h" @@ -230,6 +231,15 @@ namespace utility return icon; } + QtMainWindow* getMainWindowforMainView(ViewLayout* viewLayout) + { + if (QtMainView* mainView = dynamic_cast(viewLayout)) + { + return mainView->getMainWindow(); + } + return nullptr; + } + void copyNewFilesFromDirectory(QString src, QString dst) { QDir dir(src); diff --git a/src/lib_gui/qt/utility/utilityQt.h b/src/lib_gui/qt/utility/utilityQt.h index bb0ba3b3..10b54546 100644 --- a/src/lib_gui/qt/utility/utilityQt.h +++ b/src/lib_gui/qt/utility/utilityQt.h @@ -9,6 +9,8 @@ class QIcon; class QPixmap; class QString; class QWidget; +class QtMainWindow; +class ViewLayout; namespace utility { @@ -22,6 +24,8 @@ namespace utility QPixmap colorizePixmap(const QPixmap& pixmap, QColor color); QIcon createButtonIcon(const FilePath& iconPath, const std::string& colorId); + QtMainWindow* getMainWindowforMainView(ViewLayout* viewLayout); + void copyNewFilesFromDirectory(QString src, QString dst); } diff --git a/src/lib_gui/qt/view/QtCustomTrailView.cpp b/src/lib_gui/qt/view/QtCustomTrailView.cpp index e9c44fa7..6fae2b69 100644 --- a/src/lib_gui/qt/view/QtCustomTrailView.cpp +++ b/src/lib_gui/qt/view/QtCustomTrailView.cpp @@ -14,16 +14,18 @@ #include "MessageActivateTrail.h" #include "NodeTypeSet.h" #include "QtSmartSearchBox.h" +#include "QtMainWindow.h" #include "ResourcePaths.h" #include "TabId.h" #include "utilityQt.h" -QtCustomTrailView::QtCustomTrailView(ViewLayout*) - : QWidget(nullptr) +QtCustomTrailView::QtCustomTrailView(ViewLayout* viewLayout) + : QWidget(utility::getMainWindowforMainView(viewLayout)) , CustomTrailView(nullptr) , m_controllerProxy(this, TabId::app()) { setWindowTitle("Custom Trail"); + setWindowFlags(Qt::Window); QGridLayout* mainLayout = new QGridLayout(); mainLayout->setContentsMargins(0, 0, 0, 0); diff --git a/src/lib_gui/qt/view/QtScreenSearchView.cpp b/src/lib_gui/qt/view/QtScreenSearchView.cpp index e19a8b08..17e5d2f7 100644 --- a/src/lib_gui/qt/view/QtScreenSearchView.cpp +++ b/src/lib_gui/qt/view/QtScreenSearchView.cpp @@ -21,11 +21,13 @@ QtScreenSearchView::QtScreenSearchView(ViewLayout* viewLayout) m_bar->setMovable(false); m_bar->addWidget(m_widget); - QtMainWindow* mainWindow = dynamic_cast(getViewLayout())->getMainWindow(); - QObject::connect(m_widget, &QtScreenSearchBox::closePressed, this, &QtScreenSearchView::hide); - QObject::connect(mainWindow, &QtMainWindow::showScreenSearch, this, &QtScreenSearchView::show); - QObject::connect(mainWindow, &QtMainWindow::hideScreenSearch, this, &QtScreenSearchView::hide); + + if (QtMainWindow* mainWindow = utility::getMainWindowforMainView(getViewLayout())) + { + QObject::connect(mainWindow, &QtMainWindow::showScreenSearch, this, &QtScreenSearchView::show); + QObject::connect(mainWindow, &QtMainWindow::hideScreenSearch, this, &QtScreenSearchView::hide); + } } void QtScreenSearchView::createWidgetWrapper() @@ -70,8 +72,10 @@ void QtScreenSearchView::addResponder(const std::string& name) void QtScreenSearchView::show() { - QtMainWindow* mainWindow = dynamic_cast(getViewLayout())->getMainWindow(); - mainWindow->addToolBar(Qt::BottomToolBarArea, m_bar); + if (QtMainWindow* mainWindow = utility::getMainWindowforMainView(getViewLayout())) + { + mainWindow->addToolBar(Qt::BottomToolBarArea, m_bar); + } m_bar->show(); m_widget->setFocus(); diff --git a/src/lib_gui/qt/view/QtTooltipView.cpp b/src/lib_gui/qt/view/QtTooltipView.cpp index e9c8d6c6..af888971 100644 --- a/src/lib_gui/qt/view/QtTooltipView.cpp +++ b/src/lib_gui/qt/view/QtTooltipView.cpp @@ -6,11 +6,12 @@ #include "QtViewWidgetWrapper.h" #include "QtMainWindow.h" #include "ResourcePaths.h" +#include "utilityQt.h" QtTooltipView::QtTooltipView(ViewLayout* viewLayout) : TooltipView(viewLayout) { - m_widget = new QtTooltip(dynamic_cast(viewLayout)->getMainWindow()); + m_widget = new QtTooltip(utility::getMainWindowforMainView(viewLayout)); } void QtTooltipView::createWidgetWrapper() diff --git a/src/lib_gui/qt/view/QtViewFactory.cpp b/src/lib_gui/qt/view/QtViewFactory.cpp index efff1ec5..da4af7ae 100644 --- a/src/lib_gui/qt/view/QtViewFactory.cpp +++ b/src/lib_gui/qt/view/QtViewFactory.cpp @@ -20,6 +20,7 @@ #include "QtTabsView.h" #include "QtTooltipView.h" #include "QtUndoRedoView.h" +#include "utilityQt.h" std::shared_ptr QtViewFactory::createMainView(StorageAccess* storageAccess) const { @@ -52,9 +53,9 @@ std::shared_ptr QtViewFactory::createCodeView(ViewLayout* viewLayout) return View::createAndAddToLayout(viewLayout); } -std::shared_ptr QtViewFactory::createCustomTrailView() const +std::shared_ptr QtViewFactory::createCustomTrailView(ViewLayout* viewLayout) const { - return View::create(nullptr); + return View::create(viewLayout); } std::shared_ptr QtViewFactory::createErrorView(ViewLayout* viewLayout) const @@ -110,7 +111,7 @@ std::shared_ptr QtViewFactory::createUndoRedoView(ViewLayout* view std::shared_ptr QtViewFactory::createDialogView( ViewLayout* viewLayout, DialogView::UseCase useCase, StorageAccess* storageAccess) const { - return std::make_shared(dynamic_cast(viewLayout)->getMainWindow(), useCase, storageAccess); + return std::make_shared(utility::getMainWindowforMainView(viewLayout), useCase, storageAccess); } std::shared_ptr QtViewFactory::createGraphStyleImpl() const diff --git a/src/lib_gui/qt/view/QtViewFactory.h b/src/lib_gui/qt/view/QtViewFactory.h index b309e1d2..6e4e30ce 100644 --- a/src/lib_gui/qt/view/QtViewFactory.h +++ b/src/lib_gui/qt/view/QtViewFactory.h @@ -18,7 +18,7 @@ public: std::shared_ptr createBookmarkButtonsView(ViewLayout* viewLayout) const override; std::shared_ptr createBookmarkView(ViewLayout* viewLayout) const override; std::shared_ptr createCodeView(ViewLayout* viewLayout) const override; - std::shared_ptr createCustomTrailView() const override; + std::shared_ptr createCustomTrailView(ViewLayout* viewLayout) const override; std::shared_ptr createErrorView(ViewLayout* viewLayout) const override; std::shared_ptr createGraphView(ViewLayout* viewLayout) const override; std::shared_ptr createRefreshView(ViewLayout* viewLayout) const override;