| 1 |
/**************************************************************************************** |
| 2 |
* Copyright (c) 2009 Nikolaj Hald Nielsen <[email protected]> * |
| 3 |
* Copyright (c) 2009 Téo Mrnjavac <[email protected]> * |
| 4 |
* * |
| 5 |
* This program is free software; you can redistribute it and/or modify it under * |
| 6 |
* the terms of the GNU General Public License as published by the Free Software * |
| 7 |
* Foundation; either version 2 of the License, or (at your option) any later * |
| 8 |
* version. * |
| 9 |
* * |
| 10 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY * |
| 11 |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * |
| 12 |
* PARTICULAR PURPOSE. See the GNU General Public License for more details. * |
| 13 |
* * |
| 14 |
* You should have received a copy of the GNU General Public License along with * |
| 15 |
* this program. If not, see <http://www.gnu.org/licenses/>. * |
| 16 |
****************************************************************************************/ |
| 17 |
|
| 18 |
#ifndef PLAYLISTLAYOUTEDITDIALOG_H |
| 19 |
#define PLAYLISTLAYOUTEDITDIALOG_H |
| 20 |
|
| 21 |
#include "playlist/layouts/LayoutEditWidget.h" |
| 22 |
#include "playlist/layouts/LayoutItemConfig.h" |
| 23 |
|
| 24 |
#include <QDialog> |
| 25 |
|
| 26 |
#include "ui_PlaylistLayoutEditDialog.h" |
| 27 |
|
| 28 |
namespace Playlist { |
| 29 |
|
| 30 |
/** |
| 31 |
* Dialog for adding, deleting, copying and editing playlist layouts. The order in which the layouts are |
| 32 |
* shown can also be changed. |
| 33 |
* @author Nikolaj Hald Nielsen <[email protected]> |
| 34 |
*/ |
| 35 |
class PlaylistLayoutEditDialog : public QDialog, private Ui::PlaylistLayoutEditDialog |
| 36 |
{ |
| 37 |
Q_OBJECT |
| 38 |
|
| 39 |
public: |
| 40 |
|
| 41 |
/** |
| 42 |
* Constructor for PlaylistLayoutEditDialog. |
| 43 |
* Populates the token pool, loads the available layouts from the LayoutManager in the right area and loads the configuration of the currently active layout. |
| 44 |
* @param parent The parent widget. |
| 45 |
*/ |
| 46 |
explicit PlaylistLayoutEditDialog( QWidget *parent = nullptr ); |
| 47 |
|
| 48 |
/** |
| 49 |
* Destructor. |
| 50 |
*/ |
| 51 |
~PlaylistLayoutEditDialog() override; |
| 52 |
|
| 53 |
public Q_SLOTS: |
| 54 |
|
| 55 |
/** |
| 56 |
* Set the currently selected layout. |
| 57 |
* Loads the configuration of the layout layoutName from the m_layoutsMap to the LayoutItemConfig area. |
| 58 |
* @param layoutName The name of the layout to select. |
| 59 |
*/ |
| 60 |
void setLayout( const QString &layoutName ); |
| 61 |
|
| 62 |
/** Needed so that canceling the edit dialog returns to the previous layout **/ |
| 63 |
void resetFirstActiveLayout(); |
| 64 |
|
| 65 |
protected Q_SLOTS: |
| 66 |
|
| 67 |
/** |
| 68 |
* Previews the current layout in the playlist without saving it. |
| 69 |
*/ |
| 70 |
void preview(); |
| 71 |
|
| 72 |
/** |
| 73 |
* Accepts the currently changed layouts and stores them. Closes the dialog. |
| 74 |
*/ |
| 75 |
void accept() override; |
| 76 |
|
| 77 |
/** |
| 78 |
* Reject the changed layouts and close the dialog. |
| 79 |
*/ |
| 80 |
void reject() override; |
| 81 |
|
| 82 |
/** |
| 83 |
* Accepts the currently changed layouts and stores them. |
| 84 |
*/ |
| 85 |
void apply(); |
| 86 |
|
| 87 |
/** |
| 88 |
* Creates a new PlaylistLayout with a given name and loads it in the right area to configure it. |
| 89 |
* The new layout is not saved in the LayoutManager but in m_layoutsMap. |
| 90 |
*/ |
| 91 |
void newLayout(); |
| 92 |
|
| 93 |
/** |
| 94 |
* 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. |
| 95 |
* The new layout is not saved in the LayoutManager but in m_layoutsMap. |
| 96 |
*/ |
| 97 |
void copyLayout(); |
| 98 |
|
| 99 |
/** |
| 100 |
* Deletes the current layout selected in the layoutListWidget. |
| 101 |
*/ |
| 102 |
void deleteLayout(); |
| 103 |
|
| 104 |
/** |
| 105 |
* Renames the current layout selected in the layoutListWidget. |
| 106 |
*/ |
| 107 |
void renameLayout(); |
| 108 |
|
| 109 |
/** |
| 110 |
* Moves the currently selected layout up one place (if not already at the top). This is applied immediately. |
| 111 |
*/ |
| 112 |
void moveUp(); |
| 113 |
|
| 114 |
/** |
| 115 |
* Moves the currently selected layout down one place (if not already at the bottom). This is applied immediately. |
| 116 |
*/ |
| 117 |
void moveDown(); |
| 118 |
|
| 119 |
/** |
| 120 |
* Disables the delete and rename buttons if the selected layout is one of the default layouts and enables them otherwise. |
| 121 |
*/ |
| 122 |
void toggleEditButtons(); |
| 123 |
|
| 124 |
/** |
| 125 |
* Activates/Deactivates the up and down buttons depending on whether the currently selected item can be moved up and or down. |
| 126 |
*/ |
| 127 |
void toggleUpDownButtons(); |
| 128 |
|
| 129 |
/** Writes back the current UI values to the m_layoutsMap. */ |
| 130 |
void setLayoutChanged(); |
| 131 |
|
| 132 |
private: |
| 133 |
/** |
| 134 |
* Changes which layout tabs are enabled based on the grouping mode selected |
| 135 |
*/ |
| 136 |
void setEnabledTabs(); |
| 137 |
|
| 138 |
/** |
| 139 |
* Populates the grouping mode combo box with options |
| 140 |
*/ |
| 141 |
void setupGroupByCombo(); |
| 142 |
|
| 143 |
|
| 144 |
Playlist::LayoutEditWidget *m_partsEdit[Playlist::PlaylistLayout::NumParts]; |
| 145 |
|
| 146 |
QMap<QString, PlaylistLayout> *m_layoutsMap; |
| 147 |
|
| 148 |
/** The name of the currently active layout */ |
| 149 |
QString m_layoutName; |
| 150 |
|
| 151 |
QString m_firstActiveLayout; |
| 152 |
}; |
| 153 |
|
| 154 |
} |
| 155 |
|
| 156 |
#endif |