summaryrefslogtreecommitdiffstats
path: root/scribus/customfdialog.h
blob: 046be089a9413c1717c379dc74c8d12b4b6eb0e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
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.
*/
/***************************************************************************
                          customfdialog.h  -  description
                             -------------------
    begin                : Fri Nov 30 2001
    copyright            : (C) 2001 by Franz Schmid
    email                : Franz.Schmid@altmuehlnet.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef CUSTOMFDIALOG_H
#define CUSTOMFDIALOG_H

#include <QDialog>
#include <QFileIconProvider>
#include <QLabel>
class QPushButton;
class QComboBox;
class QCheckBox;
class QHBoxLayout;
class QVBoxLayout;
class QFrame;
class ScFileWidget;
class QIcon;

#include "scribusapi.h"

/**
  *@author Franz Schmid
  */
class SCRIBUS_API ImIconProvider : public QFileIconProvider
{
public:
	ImIconProvider();
	~ImIconProvider() {};
	QIcon icon(const QFileInfo &fi) const;
	QStringList fmts;
	QIcon imagepm;
	QIcon docpm;
	QIcon pspm;
	QIcon pdfpm;
	QIcon txtpm;
	QIcon oosxdpm;
	QIcon oosxwpm;
	QIcon vectorpm;
};

class SCRIBUS_API FDialogPreview : public QLabel
{
    Q_OBJECT
public:
	FDialogPreview(QWidget *pa);
	~FDialogPreview() {};
	void updtPix();
	void GenPreview(QString name);
};

typedef enum {
	fdNone = 0,
	fdShowPreview = 1, // display text/image previewer
	fdExistingFiles = 2, // When set, set to the QFileDialog::ExistingFile mode when true, QFileDialog::AnyFile otherwise
	fdCompressFile = 4, // Show and handle the "Compress" behaviour and CheckBox (true)
	fdShowCodecs = 8, // Show and handle text codecs and ComboBox (true)
	fdDirectoriesOnly = 16, // Show only directories
	fdHidePreviewCheckBox = 32 // Hide preview Checkbox
} fdFlags;

/*! \brief A Scribus own file dialog.
Used almost everywhere. You can see extension handling
in e.g. bool SVGExportPlugin::run(QString filename).
*/
class SCRIBUS_API CustomFDialog : public QDialog
{
    Q_OBJECT
public:
	/*! \brief Create Scribus file dialog.
	\param parent a reference to the QWidget parent.
	\param wDir starting working directory
	\param caption text caption of the dialog window
	\param filter a mask/filter. E.g.: *.txt
	\param flags combination of fdFlags, default to fdExistingFiles
	*/
	CustomFDialog(QWidget *parent, QString wDir, QString caption = "",  QString filter = "", int flags = fdExistingFiles);
	~CustomFDialog();

	/*! \brief Set the default extension of the resulting file name.
	\param e string extension without any "."
	*/
	void setExtension(QString e);
	/*! \brief Get the file extension
	\retval QString see setExtension(QString e) */
	QString extension();
	/*! \brief Set the "compress" extension of the resulting file name.
	\param e string extension without any "."
	*/
	void setZipExtension(QString e);
	/*! \brief Get the zipped file extension
	\retval QString see setZipExtension(QString e) */
	QString zipExtension();

	QCheckBox* SaveZip;
	QCheckBox* WithFonts;
	QCheckBox* WithProfiles;
	QFrame* Layout;
	QFrame* LayoutC;
	QComboBox *TxCodeM;
	QLabel *TxCodeT;
	ScFileWidget *fileDialog;
	FDialogPreview *pw;
	QCheckBox *showPreview;
	QPushButton* OKButton;
	QPushButton* CancelB;
	void setSelection(QString );
	QString selectedFile();
	void addWidgets(QWidget *widgets);
private slots:
	//! \brief Go to the document home dir.
	void fileClicked(const QString &path);
	void togglePreview();
public slots:
	//! \brief Switch the filename extensions by compress checkbox state.
	void handleCompress();
protected:
	QVBoxLayout *vboxLayout;
	QVBoxLayout *vboxLayout1;
	QHBoxLayout *hboxLayout;
	QHBoxLayout* Layout1;
	QHBoxLayout* Layout1C;
	//! \brief Property with default extension
	QString ext;
	//! \brief Property with default compress extension
	QString extZip;
	//! \brief Option flags given by user in ctore
	int optionFlags;
	bool previewIsShown;
};

#endif