r23863 by jghali - Make CustomFDialog widgets private

scribus-commit scribus-commit at lists.scribus.net
Sat May 30 22:02:43 UTC 2020


Author: jghali
Date: Sat May 30 22:02:43 2020
New Revision: 23863

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23863
Log:
Make CustomFDialog widgets private

Modified:
    trunk/Scribus/scribus/canvasmode_normal.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/ui/customfdialog.cpp
    trunk/Scribus/scribus/ui/customfdialog.h
    trunk/Scribus/scribus/ui/gtdialogs.cpp
    trunk/Scribus/scribus/ui/osgeditor.cpp
    trunk/Scribus/scribus/ui/storyeditor.cpp

Modified: trunk/Scribus/scribus/canvasmode_normal.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23863&path=/trunk/Scribus/scribus/canvasmode_normal.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_normal.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_normal.cpp	Sat May 30 22:02:43 2020
@@ -1866,12 +1866,12 @@
 		if (m_doc->m_Selection->count() > 0)
 		{
 			PageItem *newItem = m_doc->m_Selection->itemAt(0);
-			if (dia.optionCombo->currentIndex() == 1)
+			if (dia.currentOptionIndex() == 1)
 			{
 				if ((newItem->width() > m_doc->currentPage()->width()) || (newItem->height() > m_doc->currentPage()->height()))
 					m_doc->rescaleGroup(newItem, qMin(qMin(m_doc->currentPage()->width() / newItem->width(), m_doc->currentPage()->height() / newItem->height()), 1.0));
 			}
-			else if (dia.optionCombo->currentIndex() == 2)
+			else if (dia.currentOptionIndex() == 2)
 			{
 				m_doc->rescaleGroup(newItem, qMax(qMin(m_doc->currentPage()->width() / newItem->width(), m_doc->currentPage()->height() / newItem->height()), 1.0));
 			}

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23863&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Sat May 30 22:02:43 2020
@@ -3978,10 +3978,9 @@
 			docDir = m_prefsManager.prefsFile->getContext("dirs")->get("images", ".");
 
 		QStringList fileNames;
-		fileNames.clear();
 		CustomFDialog *dia = new CustomFDialog(qApp->activeWindow(), docDir, tr("Open"), formatD, fdShowPreview | fdExistingFilesI | fdDisableOk);
 		if (dia->exec() == QDialog::Accepted)
-			fileNames = dia->fileDialog->selectedFiles();
+			fileNames = dia->selectedFiles();
 		delete dia;
 		//QStringList fileNames = CFileDialog( docDir, tr("Open"), formatD, "", fdShowPreview | fdExistingFiles);
 		if (!fileNames.isEmpty())
@@ -8273,46 +8272,46 @@
 		dia->setExtension(f.suffix());
 		dia->setZipExtension(f.suffix() + ".gz");
 		dia->setSelection(defaultFilename);
-		if (useCompression != nullptr && dia->saveZip != nullptr)
-			dia->saveZip->setChecked(*useCompression);
+		if (useCompression != nullptr)
+			dia->setSaveZipFile(*useCompression);
 	}
 	if (optionFlags & fdDirectoriesOnly)
 	{
-		if (useCompression != nullptr && dia->saveZip != nullptr)
-			dia->saveZip->setChecked(*useCompression);
+		if (useCompression != nullptr)
+			dia->setSaveZipFile(*useCompression);
 		if (useFonts != nullptr)
-			dia->withFonts->setChecked(*useFonts);
+			dia->setIncludeFonts(*useFonts);
 		if (useProfiles != nullptr)
-			dia->withProfiles->setChecked(*useProfiles);
-	}
-	QString retval("");
+			dia->setIncludeProfiles(*useProfiles);
+	}
+	QString retVal;
 	if (dia->exec() == QDialog::Accepted)
 	{
 		LoadEnc.clear();
 		if (!(optionFlags & fdDirectoriesOnly))
 		{
-			LoadEnc = (optionFlags & fdShowCodecs) ? dia->optionCombo->currentText() : QString();
+			LoadEnc = (optionFlags & fdShowCodecs) ? dia->textCodec() : QString();
 			if (optionFlags & fdCompressFile)
 			{
-				if (dia->saveZip->isChecked())
+				if (dia->saveZipFile())
 					dia->handleCompress();
 			}
 		}
 		else
 		{
-			if (useCompression != nullptr && dia->saveZip != nullptr)
-				*useCompression = dia->saveZip->isChecked();
+			if (useCompression != nullptr && dia->isSaveZipFileShown())
+				*useCompression = dia->saveZipFile();
 			if (useFonts != nullptr)
-				*useFonts = dia->withFonts->isChecked();
+				*useFonts = dia->includeFonts();
 			if (useProfiles != nullptr)
-				*useProfiles = dia->withProfiles->isChecked();
+				*useProfiles = dia->includeProfiles();
 		}
 		this->repaint();
-		retval = dia->selectedFile();
+		retVal = dia->selectedFile();
 		qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
 	}
 	delete dia;
-	return retval;
+	return retVal;
 }
 
 

Modified: trunk/Scribus/scribus/ui/customfdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23863&path=/trunk/Scribus/scribus/ui/customfdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/customfdialog.cpp	(original)
+++ trunk/Scribus/scribus/ui/customfdialog.cpp	Sat May 30 22:02:43 2020
@@ -331,13 +331,6 @@
 	hboxLayout1->addWidget( cancelButton );
 	vboxLayout->addLayout(hboxLayout1);
 
-	saveZip = nullptr;
-	withFonts = nullptr;
-	withProfiles = nullptr;
-	optionCombo = nullptr;
-	optionLabel = nullptr;
-	Layout = LayoutC = nullptr;
-	Layout1 = Layout1C = nullptr;
 	if (flags & fdDirectoriesOnly)
 	{
 		Layout = new QFrame(this);
@@ -495,6 +488,9 @@
 	resize(minimumSizeHint());
 }
 
+CustomFDialog::~CustomFDialog()
+{
+}
 
 void CustomFDialog::fileClicked(const QString &path)
 {
@@ -537,14 +533,14 @@
 	repaint();
 }
 
-void CustomFDialog::setSelection(const QString& sel)
-{
-	fileDialog->selectFile( QFileInfo(sel).fileName() );
+void CustomFDialog::setSelection(const QString& fileName)
+{
+	fileDialog->selectFile( QFileInfo(fileName).fileName() );
 	if (m_previewIsShown)
-		filePreview->genPreview(sel);
-}
-
-QString CustomFDialog::selectedFile()
+		filePreview->genPreview(fileName);
+}
+
+QString CustomFDialog::selectedFile() const
 {
 	QStringList sel = fileDialog->selectedFiles();
 	if (!sel.isEmpty())
@@ -552,13 +548,14 @@
 	return QString();
 }
 
+QStringList CustomFDialog::selectedFiles() const
+{
+	return fileDialog->selectedFiles();
+}
+
 void CustomFDialog::addWidgets(QWidget *widgets)
 {
 	vboxLayout->addWidget(widgets);
-}
-
-CustomFDialog::~CustomFDialog()
-{
 }
 
 void CustomFDialog::handleCompress()
@@ -608,6 +605,15 @@
 	return m_extZip;
 }
 
+bool CustomFDialog::isTextCodecShown() const
+{
+	if ((m_optionFlags & fdShowCodecs) == 0)
+		return false;
+	if (optionCombo)
+		return optionCombo->isVisible();
+	return false;
+}
+
 void CustomFDialog::setTextCodec(const QString& textCodec)
 {
 	if ((m_optionFlags & fdShowCodecs) == 0)
@@ -633,3 +639,73 @@
 		return optionCombo->currentText();
 	return QString();
 }
+
+bool CustomFDialog::isSaveZipFileShown() const
+{
+	if (saveZip)
+		return saveZip->isVisible();
+	return false;
+}
+
+void CustomFDialog::setSaveZipFile(bool value)
+{
+	if (!saveZip)
+		return;
+	saveZip->setChecked(value);
+}
+
+bool CustomFDialog::saveZipFile() const
+{
+	if (saveZip)
+		return saveZip->isChecked();
+	return false;
+}
+
+bool CustomFDialog::isIncludeFontsShown() const
+{
+	if (withFonts)
+		return withFonts->isVisible();
+	return false;
+}
+
+void CustomFDialog::setIncludeFonts(bool value)
+{
+	if (!withFonts)
+		return;
+	withFonts->setChecked(value);
+}
+
+bool CustomFDialog::includeFonts() const
+{
+	if (withFonts)
+		return withFonts->isChecked();
+	return false;
+}
+
+bool CustomFDialog::isIncludeProfilesShown() const
+{
+	if (withProfiles)
+		return withProfiles->isVisible();
+	return false;
+}
+
+void CustomFDialog::setIncludeProfiles(bool value)
+{
+	if (!withProfiles)
+		return;
+	withProfiles->setChecked(value);
+}
+
+bool CustomFDialog::includeProfiles() const
+{
+	if (withProfiles)
+		return withProfiles->isChecked();
+	return false;
+}
+
+int CustomFDialog::currentOptionIndex() const
+{
+	if (optionCombo)
+		return optionCombo->currentIndex();
+	return -1;
+}

Modified: trunk/Scribus/scribus/ui/customfdialog.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23863&path=/trunk/Scribus/scribus/ui/customfdialog.h
==============================================================================
--- trunk/Scribus/scribus/ui/customfdialog.h	(original)
+++ trunk/Scribus/scribus/ui/customfdialog.h	Sat May 30 22:02:43 2020
@@ -69,7 +69,8 @@
 	void genPreview(const QString& name);
 };
 
-typedef enum {
+enum fdFlags
+{
 	fdNone = 0,
 	fdShowPreview = 1, // display text/image previewer
 	fdExistingFiles = 2, // When set, set to the QFileDialog::ExistingFile mode when true, QFileDialog::AnyFile otherwise
@@ -80,7 +81,7 @@
 	fdExistingFilesI = 64, // For multiple files
 	fdShowImportOptions = 128, // Show Vector Images Import Options
 	fdDisableOk = 256 // Disable Ok button, used for file open, import etc
-} fdFlags;
+};
 
 /*! \brief A Scribus own file dialog.
 Used almost everywhere. You can see extension handling
@@ -100,6 +101,10 @@
 	CustomFDialog(QWidget *parent, const QString& wDir, const QString& caption = "",  const QString& filter = "", int flags = fdExistingFiles);
 	~CustomFDialog();
 
+	void setSelection(const QString& fileName);
+	QString selectedFile() const;
+	QStringList selectedFiles() const;
+
 	/*! \brief Set the default extension of the resulting file name.
 	\param e string extension without any "."
 	*/
@@ -116,24 +121,24 @@
 	\retval QString see setZipExtension(QString e) */
 	const QString& zipExtension() const;
 
+	bool isTextCodecShown() const;
 	void setTextCodec(const QString& textCodec);
 	QString textCodec() const;
 
-	QCheckBox* saveZip { nullptr };
-	QCheckBox* withFonts { nullptr };
-	QCheckBox* withProfiles { nullptr };
-	QFrame* Layout { nullptr };
-	QFrame* LayoutC { nullptr };
-	QComboBox *optionCombo { nullptr };
-	QLabel *optionLabel { nullptr };
-	ScFileWidget *fileDialog { nullptr };
-	FDialogPreview *filePreview { nullptr };
-	QCheckBox *showPreview { nullptr };
-	QPushButton* okButton { nullptr };
-	QPushButton* cancelButton { nullptr };
+	bool isSaveZipFileShown() const;
+	void setSaveZipFile(bool value);
+	bool saveZipFile() const;
 
-	void setSelection(const QString& );
-	QString selectedFile();
+	bool isIncludeFontsShown() const;
+	void setIncludeFonts(bool value);
+	bool includeFonts() const;
+
+	bool isIncludeProfilesShown() const;
+	void setIncludeProfiles(bool value);
+	bool includeProfiles() const;
+
+	int currentOptionIndex() const;
+
 	void addWidgets(QWidget *widgets);
 
 private slots:
@@ -147,11 +152,24 @@
 	void handleCompress();
 
 protected:
-	QVBoxLayout *vboxLayout;
-	QVBoxLayout *vboxLayout1;
-	QHBoxLayout *hboxLayout;
-	QHBoxLayout* Layout1;
-	QHBoxLayout* Layout1C;
+	QVBoxLayout *vboxLayout { nullptr };
+	QVBoxLayout *vboxLayout1 { nullptr };
+	QHBoxLayout *hboxLayout { nullptr };
+	QFrame*      Layout { nullptr };
+	QFrame*      LayoutC { nullptr };
+	QHBoxLayout* Layout1 { nullptr };
+	QHBoxLayout* Layout1C { nullptr };
+
+	QCheckBox* saveZip { nullptr };
+	QCheckBox* withFonts { nullptr };
+	QCheckBox* withProfiles { nullptr };
+	QComboBox *optionCombo { nullptr };
+	QLabel *optionLabel { nullptr };
+	ScFileWidget *fileDialog { nullptr };
+	FDialogPreview *filePreview { nullptr };
+	QCheckBox *showPreview { nullptr };
+	QPushButton* okButton { nullptr };
+	QPushButton* cancelButton { nullptr };
 
 	//! \brief Property with default extension
 	QString m_ext;

Modified: trunk/Scribus/scribus/ui/gtdialogs.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23863&path=/trunk/Scribus/scribus/ui/gtdialogs.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/gtdialogs.cpp	(original)
+++ trunk/Scribus/scribus/ui/gtdialogs.cpp	Sat May 30 22:02:43 2020
@@ -143,8 +143,6 @@
 		if (!m_fileName.isEmpty())
 			accepted = true;
 		m_encoding = m_fdia->encodingCombo->currentText();
-//		if (encoding == "UTF-16")
-//			encoding = "ISO-10646-UCS-2";
 		m_importer = m_fdia->importerCombo->currentIndex() - 1;
 		dirs->set("get_text", m_fileName.left(m_fileName.lastIndexOf("/")));
 	}

Modified: trunk/Scribus/scribus/ui/osgeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23863&path=/trunk/Scribus/scribus/ui/osgeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/osgeditor.cpp	(original)
+++ trunk/Scribus/scribus/ui/osgeditor.cpp	Sat May 30 22:02:43 2020
@@ -574,10 +574,9 @@
 	PrefsContext* dirs = PrefsManager::instance().prefsFile->getContext("dirs");
 	QString wdir = dirs->get("models", ".");
 	CustomFDialog dia(this, wdir, tr("Import 3-D Model"), filterString, fdHidePreviewCheckBox);
-	if (dia.exec() == QDialog::Accepted)
-		fileName = dia.selectedFile();
-	else
+	if (dia.exec() != QDialog::Accepted)
 		return;
+	fileName = dia.selectedFile();
 	if (loadedModel)
 	{
 		if (rootnode->getNumChildren() > 1)

Modified: trunk/Scribus/scribus/ui/storyeditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23863&path=/trunk/Scribus/scribus/ui/storyeditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/storyeditor.cpp	(original)
+++ trunk/Scribus/scribus/ui/storyeditor.cpp	Sat May 30 22:02:43 2020
@@ -3451,22 +3451,18 @@
 	if (Do_new())
 	{
 		EditorBar->setRepaint(false);
-		QString loadEnc;
-		QString fileName;
 		PrefsContext* dirs = prefsManager.prefsFile->getContext("dirs");
 		QString wdir = dirs->get("story_load", prefsManager.documentDir());
 		CustomFDialog dia(this, wdir, tr("Open"), tr("Text Files (*.txt);;All Files (*)"), fdExistingFiles | fdShowCodecs | fdDisableOk);
 		if (dia.exec() != QDialog::Accepted)
 			return;
-		loadEnc = dia.optionCombo->currentText();
-		if (loadEnc == "UTF-16")
-			loadEnc = "ISO-10646-UCS-2";
-		fileName =  dia.selectedFile();
+		QString textEncoding = dia.textCodec();
+		QString fileName =  dia.selectedFile();
 		if (!fileName.isEmpty())
 		{
 			dirs->set("story_load", fileName.left(fileName.lastIndexOf("/")));
 			QString txt;
-			if (Serializer::readWithEncoding(fileName, loadEnc, txt))
+			if (Serializer::readWithEncoding(fileName, textEncoding, txt))
 			{
 				txt.replace(QRegExp("\r"), "");
 				txt.replace(QRegExp("\n"), QChar(13));




More information about the scribus-commit mailing list