File indexing completed on 2024-05-19 04:49:50

0001 /****************************************************************************************
0002  * Copyright (c) 2009 Nikolaj Hald Nielsen <nhn@kde.org>                                *
0003  * Copyright (c) 2009 Téo Mrnjavac <teo@kde.org>                                        *
0004  *                                                                                      *
0005  * This program is free software; you can redistribute it and/or modify it under        *
0006  * the terms of the GNU General Public License as published by the Free Software        *
0007  * Foundation; either version 2 of the License, or (at your option) any later           *
0008  * version.                                                                             *
0009  *                                                                                      *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0013  *                                                                                      *
0014  * You should have received a copy of the GNU General Public License along with         *
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0016  ****************************************************************************************/
0017 
0018 #ifndef PLAYLISTLAYOUTEDITDIALOG_H
0019 #define PLAYLISTLAYOUTEDITDIALOG_H
0020 
0021 #include "playlist/layouts/LayoutEditWidget.h"
0022 #include "playlist/layouts/LayoutItemConfig.h"
0023 
0024 #include <QDialog>
0025 
0026 #include "ui_PlaylistLayoutEditDialog.h"
0027 
0028 namespace Playlist {
0029 
0030 /**
0031  *  Dialog for adding, deleting, copying and editing playlist layouts. The order in which the layouts are
0032  *  shown can also be changed.
0033  *  @author Nikolaj Hald Nielsen <nhn@kde.org>
0034  */
0035 class PlaylistLayoutEditDialog : public QDialog, private Ui::PlaylistLayoutEditDialog
0036 {
0037     Q_OBJECT
0038 
0039     public:
0040 
0041         /**
0042          * Constructor for PlaylistLayoutEditDialog.
0043          * Populates the token pool, loads the available layouts from the LayoutManager in the right area and loads the configuration of the currently active layout.
0044          * @param parent The parent widget.
0045          */
0046         explicit PlaylistLayoutEditDialog( QWidget *parent = nullptr );
0047 
0048         /**
0049          * Destructor.
0050          */
0051         ~PlaylistLayoutEditDialog() override;
0052 
0053     public Q_SLOTS:
0054 
0055         /**
0056          * Set the currently selected layout.
0057          * Loads the configuration of the layout layoutName from the m_layoutsMap to the LayoutItemConfig area.
0058          * @param layoutName The name of the layout to select.
0059          */
0060         void setLayout( const QString &layoutName );
0061 
0062     protected Q_SLOTS:
0063 
0064         /**
0065          * Previews the current layout in the playlist without saving it.
0066          */
0067         void preview();
0068 
0069         /**
0070          * Accepts the currently changed layouts and stores them. Closes the dialog.
0071          */
0072         void accept() override;
0073 
0074         /**
0075          * Reject the changed layouts and close the dialog.
0076          */
0077         void reject() override;
0078 
0079         /**
0080          * Accepts the currently changed layouts and stores them.
0081          */
0082         void apply();
0083 
0084         /**
0085          * Creates a new PlaylistLayout with a given name and loads it in the right area to configure it.
0086          * The new layout is not saved in the LayoutManager but in m_layoutsMap.
0087          */
0088         void newLayout();
0089 
0090         /**
0091          * Creates a new PlaylistLayout with a given name as a copy of an existing layout and loads it in the right area to configure it.
0092          * The new layout is not saved in the LayoutManager but in m_layoutsMap.
0093          */
0094         void copyLayout();
0095 
0096         /**
0097          * Deletes the current layout selected in the layoutListWidget.
0098          */
0099         void deleteLayout();
0100 
0101         /**
0102          * Renames the current layout selected in the layoutListWidget.
0103          */
0104         void renameLayout();
0105 
0106         /**
0107          * Moves the currently selected layout up one place (if not already at the top). This is applied immediately.
0108          */
0109         void moveUp();
0110 
0111         /**
0112          * Moves the currently selected layout down one place (if not already at the bottom). This is applied immediately.
0113          */
0114         void moveDown();
0115 
0116         /**
0117          * Disables the delete and rename buttons if the selected layout is one of the default layouts and enables them otherwise.
0118          */
0119         void toggleEditButtons();
0120 
0121         /**
0122          * Activates/Deactivates the up and down buttons depending on whether the currently selected item can be moved up and or down.
0123          */
0124         void toggleUpDownButtons();
0125 
0126         /** Writes back the current UI values to the m_layoutsMap. */
0127         void setLayoutChanged();
0128 
0129     private:
0130         /**
0131          * Changes which layout tabs are enabled based on the grouping mode selected
0132          */
0133         void setEnabledTabs();
0134 
0135         /**
0136          * Populates the grouping mode combo box with options
0137          */
0138         void setupGroupByCombo();
0139 
0140 
0141         Playlist::LayoutEditWidget *m_partsEdit[Playlist::PlaylistLayout::NumParts];
0142 
0143         QMap<QString, PlaylistLayout> *m_layoutsMap;
0144 
0145         /** The name of the currently active layout */
0146         QString m_layoutName;
0147 
0148         QString m_firstActiveLayout;
0149 };
0150 
0151 }
0152 
0153 #endif