Files
ResInsight/ApplicationLibCode/UserInterface/RiuMainWindowBase.h
T

193 lines
5.8 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
2023-04-26 16:30:15 +02:00
#include <QByteArray>
#include <QMainWindow>
2026-05-19 18:29:29 +02:00
#include <QPointer>
2026-05-15 02:25:56 +02:00
#include <QString>
#include <QStringList>
2022-01-28 13:19:52 +01:00
#include "cafPdmUiDragDropInterface.h"
#include "ads_globals.h"
2022-07-07 12:03:02 +02:00
2022-01-28 13:19:52 +01:00
#include <memory>
#include <vector>
namespace ads
{
class CDockManager;
class CDockAreaWidget;
class CDockWidget;
} // namespace ads
namespace caf
{
class PdmObject;
class PdmUiTreeView;
class PdmUiItem;
2024-09-02 14:08:19 +02:00
class PdmUiPropertyView;
} // namespace caf
2019-04-02 19:18:00 +02:00
class QAction;
class QUndoView;
2026-05-19 18:08:18 +02:00
class RimViewWindow;
//==================================================================================================
///
//==================================================================================================
class RiuMainWindowBase : public QMainWindow
{
Q_OBJECT
public:
2026-05-28 18:32:16 +02:00
static const int DOCKSTATE_VERSION = 4;
2022-07-07 12:03:02 +02:00
RiuMainWindowBase();
~RiuMainWindowBase() override;
virtual QString mainWindowName() = 0;
2026-06-16 17:29:48 +02:00
virtual void initializeViewer( ads::CDockWidget* dockWidget, QWidget* viewer ) {};
virtual void setActiveViewer( QString viewerName );
virtual void onViewerRemoved() = 0;
virtual RimViewWindow* activeViewer() = 0;
2026-05-19 18:08:18 +02:00
virtual std::vector<RimViewWindow*> viewWindows() = 0;
void loadWinGeoAndDockToolBarLayout();
void saveWinGeoAndDockToolBarLayout();
void showWindow();
2022-01-28 13:19:52 +01:00
std::vector<caf::PdmUiTreeView*> projectTreeViews();
caf::PdmUiTreeView* projectTreeView( int treeId );
caf::PdmUiTreeView* getTreeViewWithItem( const caf::PdmUiItem* item );
void setExpanded( const caf::PdmUiItem* uiItem, bool expanded = true );
void selectAsCurrentItem( const caf::PdmObject* object, bool allowActiveViewChange = true );
void toggleItemInSelection( const caf::PdmObject* object, bool allowActiveViewChange = true );
2019-10-30 10:34:39 +01:00
void setBlockSubWindowActivatedSignal( bool block );
bool isBlockingSubWindowActivatedSignal() const;
2019-10-30 10:34:39 +01:00
void setBlockViewSelectionOnSubWindowActivated( bool block );
bool isBlockingViewSelectionOnSubWindowActivated() const;
void setBeingDestroyed();
bool isBeingDestroyed() const;
// Closing a main window hides it and removes all views from docking. The views must be recreated before the
// window is shown again.
bool hasBeenClosed() const;
void clearClosedState();
2022-07-07 12:03:02 +02:00
ads::CDockManager* dockManager() const;
2026-05-28 18:32:16 +02:00
QString dockWidgetStateString() const;
bool restoreDockWidgetState( QString dockStateString );
bool restoreLastDockWidgetState();
2026-05-28 18:32:16 +02:00
public slots:
void tileViewWindows();
protected:
2022-01-28 13:19:52 +01:00
void createTreeViews( int numberOfTrees );
void setUpCentralDockWidget();
2022-01-28 13:19:52 +01:00
void restoreTreeViewStates( QString treeStateString, QString treeIndexString );
2022-07-07 12:03:02 +02:00
ads::CDockAreaWidget* addTabbedWidgets( std::vector<ads::CDockWidget*> widgets,
ads::DockWidgetArea whereToDock,
ads::CDockAreaWidget* dockInside = nullptr );
void addDefaultEntriesToWindowsMenu();
virtual QStringList defaultDockStateNames() = 0;
void showEvent( QShowEvent* event ) override;
void closeEvent( QCloseEvent* event ) override;
virtual void onCentralWidgetContextMenu( QMenu& menu ) {};
std::vector<RimViewWindow*> removeActiveViewWindows();
protected slots:
void slotDockWidgetToggleViewActionTriggered();
2026-05-18 13:39:38 +02:00
void slotDockViewerVisibilityChanged( bool visible );
void slotDockViewerClosed();
void slotRefreshHelpActions();
void slotHideTabs( bool hideTabs );
void slotCentralWidgetContextMenu( const QPoint& pos );
void slotRedo();
void slotUndo();
void slotRefreshUndoRedoActions();
void setDefaultDockLayout();
2022-07-07 12:03:02 +02:00
void setDockLayout();
void deleteDockLayout();
void saveDockLayout();
void exportDockLayout();
2022-07-07 12:03:02 +02:00
2026-08-21 16:25:32 +02:00
void maximizeViewWindows();
void tileWindowsVertically();
void tileWindowsHorizontally();
private:
void tileWindows( ads::DockWidgetArea whereToDock );
2026-08-21 16:25:32 +02:00
protected:
2022-01-28 13:19:52 +01:00
bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control
// whether to select the corresponding active view or not
2026-08-21 16:25:32 +02:00
QAction* m_hideTabsAction;
QAction* m_tileWindowsAction;
QAction* m_maximizeWindowsAction;
QAction* m_tileHorizontallyAction;
QAction* m_tileVerticallyAction;
2026-08-21 16:25:32 +02:00
QAction* m_undoAction;
QAction* m_redoAction;
QUndoView* m_undoView;
2026-04-07 18:29:02 +02:00
QMenu* m_windowMenu;
2022-07-07 12:03:02 +02:00
2023-04-26 16:30:15 +02:00
QByteArray m_lastDockState;
2024-09-02 14:08:19 +02:00
std::vector<caf::PdmUiTreeView*> m_projectTreeViews;
std::vector<std::shared_ptr<caf::PdmUiPropertyView>> m_propertyViews;
QPointer<ads::CDockWidget> m_centralDockWidget;
private:
QString registryFolderName();
2022-01-28 13:19:52 +01:00
std::vector<std::unique_ptr<caf::PdmUiDragDropInterface>> m_dragDropInterfaces;
bool m_blockSubWindowActivation;
bool m_blockSubWindowProjectTreeSelection;
bool m_hasBeenVisible;
bool m_isBeingDestroyed;
bool m_hasBeenClosed;
2022-07-07 12:03:02 +02:00
ads::CDockManager* m_dockManager;
};