/*
For general Scribus (>=1.3.2) copyright and licensing information please refer
to the COPYING file provided with the program. Following this notice may exist
a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#ifndef PAGEPALETTE_MASTERPAGES_H
#define PAGEPALETTE_MASTERPAGES_H

class QCloseEvent;
class QHBoxLayout;
class QListWidget;
class QListWidgetItem;
class QToolButton;
class QVBoxLayout;

#include "scribusapi.h"
#include "ui_pagepalette_masterpagesbase.h"
class ScribusDoc;
class ScribusView;


/*! \brief A dialog to manage/edit Master Pages
*/
class SCRIBUS_API PagePalette_MasterPages : public QWidget, Ui::PagePalette_MasterPagesBase
{
	Q_OBJECT

	friend class PagePalette;

public:
	PagePalette_MasterPages( QWidget* parent, ScribusView *pCurrentView, const QString& masterPageName);
	~PagePalette_MasterPages() {};

	void setView(ScribusView* view, const QString& masterPageName = "");
	
	void updateMasterPageList(void);
	void updateMasterPageList(QString MasterPageName);

public slots:
	void iconSetChange();
	void languageChange();
	void styleChange();
	void selectMasterPage(const QString& name);

private:
	QString      m_currentPage;
	ScribusDoc  *m_doc;
	ScribusView *m_view;

protected:
	void connectSignals();
	void disconnectSignals();

	void changeEvent(QEvent *e) override;

	bool isReservedName(const QString& name) const;
	QString getNonReservedName(const QString& name) const;
	/*!
	 * \retval the current name or, if it's a standard one, the translated version
	*/
	QString getTranslatedReservedName(const QString& name) const;

private slots:
	void duplicateMasterPage();
	void deleteMasterPage();
	void newMasterPage();
	void renameMasterPage(QListWidgetItem * item);
	void importPage();
	void selectMasterPage(QListWidgetItem *item);

signals:
	void removePage(int);
	void finished();
};

#endif // MUSTERPAGES_H
