2 * This file is part of the SmuView project.
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 * Copyright (C) 2016 Soeren Apel <soeren@apelpie.net>
6 * Copyright (C) 2017-2021 Frank Stettner <frank-stettner@gmx.net>
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef UI_TABS_BASETAB_HPP
23 #define UI_TABS_BASETAB_HPP
27 #include <QDockWidget>
28 #include <QMainWindow>
33 #include "src/ui/views/baseview.hpp"
55 * Use a QMainWindow (as tab widget) to allow for a tool bar.
57 class BaseTab
: public QMainWindow
62 explicit BaseTab(Session
&session
, QWidget
*parent
= nullptr);
65 const Session
&session() const;
68 virtual QString
title() = 0;
69 views::BaseView
*get_view_from_view_id(const string
&id
);
70 virtual bool request_close() = 0;
73 TabDockWidget
*create_dock_widget(views::BaseView
*view
,
74 QDockWidget::DockWidgetFeatures features
);
76 /** This event is handling the saving of the settings. */
77 void closeEvent(QCloseEvent
*event
) override
;
82 * id_ is used for accessing the tab (e.g. for the python bindings UiProxy).
86 * settings_id_ is used for the objectNames of the tab and its views for
87 * identification in the settings (e.g. geometry and status).
90 map
<views::BaseView
*, TabDockWidget
*> view_docks_map_
;
91 map
<string
, views::BaseView
*> view_id_map_
;
93 virtual void save_settings() const = 0;
94 virtual void restore_settings() = 0;
98 * When using QDockWidget::DockWidgetFeatures instead of int for features,
99 * the given flags are or'ed to the default flags instead of replacing
102 void add_view(views::BaseView
*view
, Qt::DockWidgetArea area
,
103 int features
= QDockWidget::DockWidgetMovable
|
104 QDockWidget::DockWidgetFloatable
| QDockWidget::DockWidgetClosable
);
106 * When using QDockWidget::DockWidgetFeatures instead of int for features,
107 * the given flags are or'ed to the default flags instead of replacing
110 void add_view_ontop(views::BaseView
*view
, views::BaseView
*existing_view
,
111 int features
= QDockWidget::DockWidgetMovable
|
112 QDockWidget::DockWidgetFloatable
| QDockWidget::DockWidgetClosable
);
115 void remove_view(const std::string
&view_id
);
123 #endif // UI_TABS_BASETAB_HPP