1 /* 2 For general Scribus (>=1.3.2) copyright and licensing information please refer 3 to the COPYING file provided with the program. Following this notice may exist 4 a copyright and/or license notice that predates the release of Scribus 1.3.2 5 for which a new license (GPL+exception) is in place. 6 */ 7 /*************************************************************************** 8 customfdialog.h - description 9 ------------------- 10 begin : Fri Nov 30 2001 11 copyright : (C) 2001 by Franz Schmid 12 email : Franz.Schmid@altmuehlnet.de 13 ***************************************************************************/ 14 15 /*************************************************************************** 16 * * 17 * This program is free software; you can redistribute it and/or modify * 18 * it under the terms of the GNU General Public License as published by * 19 * the Free Software Foundation; either version 2 of the License, or * 20 * (at your option) any later version. * 21 * * 22 ***************************************************************************/ 23 24 #ifndef CUSTOMFDIALOG_H 25 #define CUSTOMFDIALOG_H 26 27 #include <QDialog> 28 #include <QFileIconProvider> 29 #include <QLabel> 30 class QPushButton; 31 class QComboBox; 32 class QCheckBox; 33 class QHBoxLayout; 34 class QVBoxLayout; 35 class QFrame; 36 class ScFileWidget; 37 class QIcon; 38 39 #include "scribusapi.h" 40 41 /** 42 *@author Franz Schmid 43 */ 44 class SCRIBUS_API ImIconProvider : public QFileIconProvider 45 { 46 public: 47 ImIconProvider(); ~ImIconProvider()48 ~ImIconProvider() {}; 49 QIcon icon(const QFileInfo &fi) const; 50 QStringList fmts; 51 QIcon imagepm; 52 QIcon docpm; 53 QIcon pspm; 54 QIcon pdfpm; 55 QIcon txtpm; 56 QIcon oosxdpm; 57 QIcon oosxwpm; 58 QIcon vectorpm; 59 }; 60 61 class SCRIBUS_API FDialogPreview : public QLabel 62 { 63 Q_OBJECT 64 public: 65 FDialogPreview(QWidget *pa); ~FDialogPreview()66 ~FDialogPreview() {}; 67 68 void updatePix(); 69 void genPreview(const QString& name); 70 }; 71 72 enum fdFlags 73 { 74 fdNone = 0, 75 fdShowPreview = 1, // display text/image previewer 76 fdExistingFiles = 2, // When set, set to the QFileDialog::ExistingFile mode when true, QFileDialog::AnyFile otherwise 77 fdCompressFile = 4, // Show and handle the "Compress" behaviour and CheckBox (true) 78 fdShowCodecs = 8, // Show and handle text codecs and ComboBox (true) 79 fdDirectoriesOnly = 16, // Show only directories 80 fdHidePreviewCheckBox = 32, // Hide preview Checkbox 81 fdExistingFilesI = 64, // For multiple files 82 fdShowImportOptions = 128, // Show Vector Images Import Options 83 fdDisableOk = 256 // Disable Ok button, used for file open, import etc 84 }; 85 86 /*! \brief A Scribus own file dialog. 87 Used almost everywhere. You can see extension handling 88 in e.g. bool SVGExportPlugin::run(QString filename). 89 */ 90 class SCRIBUS_API CustomFDialog : public QDialog 91 { 92 Q_OBJECT 93 public: 94 /*! \brief Create Scribus file dialog. 95 \param parent a reference to the QWidget parent. 96 \param wDir starting working directory 97 \param caption text caption of the dialog window 98 \param filter a mask/filter. E.g.: *.txt 99 \param flags combination of fdFlags, default to fdExistingFiles 100 */ 101 CustomFDialog(QWidget *parent, const QString& wDir, const QString& caption = "", const QString& filter = "", int flags = fdExistingFiles); 102 ~CustomFDialog(); 103 104 void setSelection(const QString& fileName); 105 QString selectedFile() const; 106 QStringList selectedFiles() const; 107 108 /*! \brief Set the default extension of the resulting file name. 109 \param e string extension without any "." 110 */ 111 void setExtension(const QString& e); 112 /*! \brief Get the file extension 113 \retval QString see setExtension(QString e) */ 114 const QString& extension() const; 115 116 /*! \brief Set the "compress" extension of the resulting file name. 117 \param e string extension without any "." 118 */ 119 void setZipExtension(const QString& e); 120 /*! \brief Get the zipped file extension 121 \retval QString see setZipExtension(QString e) */ 122 const QString& zipExtension() const; 123 124 bool isTextCodecShown() const; 125 void setTextCodec(const QString& textCodec); 126 QString textCodec() const; 127 128 bool isSaveZipFileShown() const; 129 void setSaveZipFile(bool value); 130 bool saveZipFile() const; 131 132 bool isIncludeFontsShown() const; 133 void setIncludeFonts(bool value); 134 bool includeFonts() const; 135 136 bool isIncludeProfilesShown() const; 137 void setIncludeProfiles(bool value); 138 bool includeProfiles() const; 139 140 int currentOptionIndex() const; 141 142 void addWidgets(QWidget *widgets); 143 144 private slots: 145 //! \brief Go to the document home dir. 146 void fileClicked(const QString &path); 147 void okClicked(); 148 void togglePreview(); 149 150 public slots: 151 //! \brief Switch the filename extensions by compress checkbox state. 152 void handleCompress(); 153 154 protected: 155 QVBoxLayout *vboxLayout { nullptr }; 156 QVBoxLayout *vboxLayout1 { nullptr }; 157 QHBoxLayout *hboxLayout { nullptr }; 158 QFrame* Layout { nullptr }; 159 QFrame* LayoutC { nullptr }; 160 QHBoxLayout* Layout1 { nullptr }; 161 QHBoxLayout* Layout1C { nullptr }; 162 163 QCheckBox* saveZip { nullptr }; 164 QCheckBox* withFonts { nullptr }; 165 QCheckBox* withProfiles { nullptr }; 166 QComboBox *optionCombo { nullptr }; 167 QLabel *optionLabel { nullptr }; 168 ScFileWidget *fileDialog { nullptr }; 169 FDialogPreview *filePreview { nullptr }; 170 QCheckBox *showPreview { nullptr }; 171 QPushButton* okButton { nullptr }; 172 QPushButton* cancelButton { nullptr }; 173 174 //! \brief Property with default extension 175 QString m_ext; 176 //! \brief Property with default compress extension 177 QString m_extZip; 178 //! \brief Option flags given by user in ctore 179 int m_optionFlags; 180 bool m_previewIsShown; 181 }; 182 183 #endif 184