File indexing completed on 2024-12-08 04:27:18
0001 /* 0002 SPDX-FileCopyrightText: 2012 Jean-Baptiste Mardelle <jb@kdenlive.org> 0003 SPDX-FileCopyrightText: 2014 Till Theato <root@ttill.de> 0004 SPDX-FileCopyrightText: 2020 Julius Künzel <jk.kdedev@smartlab.uber.space> 0005 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 #pragma once 0009 0010 #include <QObject> 0011 #include <QMap> 0012 0013 class KSelectAction; 0014 class QAction; 0015 class QButtonGroup; 0016 class QAbstractButton; 0017 class QHBoxLayout; 0018 0019 class LayoutManagement : public QObject 0020 { 0021 Q_OBJECT 0022 0023 public: 0024 explicit LayoutManagement(QObject *parent); 0025 /** @brief Load a layout by its name. */ 0026 bool loadLayout(const QString &layoutId, bool selectButton); 0027 0028 private Q_SLOTS: 0029 /** @brief Saves the widget layout. */ 0030 void slotSaveLayout(); 0031 /** @brief Loads a layout from its button. */ 0032 void activateLayout(QAbstractButton *button); 0033 /** @brief Loads a saved widget layout. */ 0034 void slotLoadLayout(QAction *action); 0035 /** @brief Manage layout. */ 0036 void slotManageLayouts(); 0037 /** @brief Arrange the Qt::DockWidgetAreas in rows. */ 0038 void slotDockAreaRows(); 0039 /** @brief Arrange the Qt::DockWidgetAreas in columns. */ 0040 void slotDockAreaColumns(); 0041 0042 private: 0043 /** @brief Saves the given layout asking the user for a name. 0044 * @param layout 0045 * @param suggestedName name that is filled in to the save layout dialog 0046 * @return names of the saved layout. First is the visible name, second the internal name (they are different if the layout is a default one) 0047 */ 0048 std::pair<QString, QString> saveLayout(const QString &layout, const QString &suggestedName); 0049 /** @brief Populates the "load layout" menu. */ 0050 void initializeLayouts(); 0051 const QString translatedName(const QString &name); 0052 QWidget *m_container; 0053 QButtonGroup *m_containerGrp; 0054 QHBoxLayout *m_containerLayout; 0055 KSelectAction *m_loadLayout; 0056 QList <QAction *> m_layoutActions; 0057 QMap <QString, QString> m_translatedNames; 0058 0059 Q_SIGNALS: 0060 /** @brief Layout changed, ensure title bars are correctly displayed. */ 0061 void updateTitleBars(); 0062 /** @brief Connect/disconnect stuff to update titlebars on dock location changed. */ 0063 void connectDocks(bool doConnect); 0064 };