Merge pull request #3381 from aws-lumberyard-dev/Atom/guthadam/atomtools_document_main_window_base_class
AtomTools: moved remaining document and window common code from ME and SMC to base class
This commit is contained in:
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(Q_MOC_RUN)
|
||||
#include <AtomToolsFramework/Document/AtomToolsDocumentNotificationBus.h>
|
||||
#include <AtomToolsFramework/Window/AtomToolsMainWindow.h>
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
#include <AzQtComponents/Components/Widgets/TabWidget.h>
|
||||
#endif
|
||||
|
||||
namespace AtomToolsFramework
|
||||
{
|
||||
//! AtomToolsDocumentMainWindow
|
||||
class AtomToolsDocumentMainWindow
|
||||
: public AtomToolsMainWindow
|
||||
, private AtomToolsDocumentNotificationBus::Handler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AZ_CLASS_ALLOCATOR(AtomToolsDocumentMainWindow, AZ::SystemAllocator, 0);
|
||||
|
||||
using Base = AtomToolsMainWindow;
|
||||
|
||||
AtomToolsDocumentMainWindow(QWidget* parent = 0);
|
||||
~AtomToolsDocumentMainWindow();
|
||||
|
||||
protected:
|
||||
void AddDocumentMenus();
|
||||
void AddDocumentTabBar();
|
||||
|
||||
QString GetDocumentPath(const AZ::Uuid& documentId) const;
|
||||
|
||||
AZ::Uuid GetDocumentTabId(const int tabIndex) const;
|
||||
|
||||
void AddDocumentTab(
|
||||
const AZ::Uuid& documentId,
|
||||
const AZStd::string& label,
|
||||
const AZStd::string& toolTip);
|
||||
|
||||
void RemoveDocumentTab(const AZ::Uuid& documentId);
|
||||
|
||||
void UpdateDocumentTab(
|
||||
const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip, bool isModified);
|
||||
|
||||
void SelectPrevDocumentTab();
|
||||
void SelectNextDocumentTab();
|
||||
|
||||
virtual QWidget* CreateDocumentTabView(const AZ::Uuid& documentId);
|
||||
virtual void OpenDocumentTabContextMenu();
|
||||
virtual bool GetCreateDocumentParams(AZStd::string& openPath, AZStd::string& savePath);
|
||||
virtual bool GetOpenDocumentParams(AZStd::string& openPath);
|
||||
|
||||
// AtomToolsDocumentNotificationBus::Handler overrides...
|
||||
void OnDocumentOpened(const AZ::Uuid& documentId) override;
|
||||
void OnDocumentClosed(const AZ::Uuid& documentId) override;
|
||||
void OnDocumentModified(const AZ::Uuid& documentId) override;
|
||||
void OnDocumentUndoStateChanged(const AZ::Uuid& documentId) override;
|
||||
void OnDocumentSaved(const AZ::Uuid& documentId) override;
|
||||
|
||||
void closeEvent(QCloseEvent* closeEvent) override;
|
||||
|
||||
template<typename Functor>
|
||||
QAction* CreateAction(const QString& text, Functor functor, const QKeySequence& shortcut = 0);
|
||||
|
||||
QAction* m_actionNew = {};
|
||||
QAction* m_actionOpen = {};
|
||||
QAction* m_actionClose = {};
|
||||
QAction* m_actionCloseAll = {};
|
||||
QAction* m_actionCloseOthers = {};
|
||||
QAction* m_actionSave = {};
|
||||
QAction* m_actionSaveAsCopy = {};
|
||||
QAction* m_actionSaveAsChild = {};
|
||||
QAction* m_actionSaveAll = {};
|
||||
|
||||
QAction* m_actionUndo = {};
|
||||
QAction* m_actionRedo = {};
|
||||
|
||||
QAction* m_actionNextTab = {};
|
||||
QAction* m_actionPreviousTab = {};
|
||||
|
||||
AzQtComponents::TabWidget* m_tabWidget = {};
|
||||
};
|
||||
} // namespace AtomToolsFramework
|
||||
+16
-22
@@ -7,18 +7,14 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AtomToolsFramework/Window/AtomToolsMainWindowRequestBus.h>
|
||||
|
||||
#include <AzCore/Memory/SystemAllocator.h>
|
||||
|
||||
#include <AzQtComponents/Components/DockMainWindow.h>
|
||||
#include <AzQtComponents/Components/FancyDocking.h>
|
||||
#include <AzQtComponents/Components/StyledDockWidget.h>
|
||||
#include <AzQtComponents/Components/Widgets/TabWidget.h>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QMenuBar>
|
||||
#include <QToolBar>
|
||||
|
||||
namespace AtomToolsFramework
|
||||
{
|
||||
@@ -38,28 +34,26 @@ namespace AtomToolsFramework
|
||||
bool IsDockWidgetVisible(const AZStd::string& name) const override;
|
||||
AZStd::vector<AZStd::string> GetDockWidgetNames() const override;
|
||||
|
||||
virtual void CreateMenu();
|
||||
virtual void CreateTabBar();
|
||||
|
||||
virtual void AddTabForDocumentId(
|
||||
const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip, AZStd::function<QWidget*()> widgetCreator);
|
||||
virtual void RemoveTabForDocumentId(const AZ::Uuid& documentId);
|
||||
virtual void UpdateTabForDocumentId(
|
||||
const AZ::Uuid& documentId, const AZStd::string& label, const AZStd::string& toolTip, bool isModified);
|
||||
virtual AZ::Uuid GetDocumentIdFromTab(const int tabIndex) const;
|
||||
|
||||
virtual void OpenTabContextMenu();
|
||||
virtual void SelectPreviousTab();
|
||||
virtual void SelectNextTab();
|
||||
|
||||
void SetStatusMessage(const QString& message);
|
||||
void SetStatusWarning(const QString& message);
|
||||
void SetStatusError(const QString& message);
|
||||
|
||||
AzQtComponents::FancyDocking* m_advancedDockManager = nullptr;
|
||||
AzQtComponents::TabWidget* m_tabWidget = nullptr;
|
||||
QLabel* m_statusMessage = nullptr;
|
||||
void AddCommonMenus();
|
||||
|
||||
virtual void OpenSettings();
|
||||
virtual void OpenHelp();
|
||||
virtual void OpenAbout();
|
||||
|
||||
AzQtComponents::FancyDocking* m_advancedDockManager = {};
|
||||
|
||||
QLabel* m_statusMessage = {};
|
||||
|
||||
QMenu* m_menuFile = {};
|
||||
QMenu* m_menuEdit = {};
|
||||
QMenu* m_menuView = {};
|
||||
QMenu* m_menuHelp = {};
|
||||
|
||||
AZStd::unordered_map<AZStd::string, AzQtComponents::StyledDockWidget*> m_dockWidgets;
|
||||
AZStd::unordered_map<AZStd::string, QAction*> m_dockActions;
|
||||
};
|
||||
} // namespace AtomToolsFramework
|
||||
|
||||
Reference in New Issue
Block a user