r24226 by jghali - Code style fixes and refactoring

scribus-commit scribus-commit at lists.scribus.net
Wed Nov 11 13:44:30 UTC 2020


Author: jghali
Date: Wed Nov 11 13:44:29 2020
New Revision: 24226

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24226
Log:
Code style fixes and refactoring

Modified:
    trunk/Scribus/scribus/prefsmanager.cpp
    trunk/Scribus/scribus/prefsmanager.h
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribuscore.cpp

Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24226&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp	(original)
+++ trunk/Scribus/scribus/prefsmanager.cpp	Wed Nov 11 13:44:29 2020
@@ -923,12 +923,12 @@
 	}
 }
 
-void PrefsManager::ReadPrefs()
+void PrefsManager::readPrefs()
 {
 	QString prefsFile(m_prefsLocation + "scribus150.rc");
 	if (QFile::exists(prefsFile))
 	{
-		if (!ReadPref(prefsFile))
+		if (!readPref(prefsFile))
 		{
 			alertLoadPrefsFailed();
 			return;
@@ -936,7 +936,7 @@
 	}
 }
 
-void PrefsManager::ReadPrefsXML()
+void PrefsManager::readPrefsXML()
 {
 	if (!prefsFile)
 		return;
@@ -993,7 +993,7 @@
 }
 
 
-void PrefsManager::SavePrefs()
+void PrefsManager::savePrefs()
 {
 	// If closing because of a crash don't save prefs as we can
 	// accidentally nuke the settings if the crash is before prefs are loaded
@@ -1018,13 +1018,13 @@
 		appPrefs.uiPrefs.RecentDocs.append(ScCore->primaryMainWindow()->m_recentDocsList[m]);
 	}
 	ScCore->primaryMainWindow()->getDefaultPrinter(appPrefs.printerPrefs.PrinterName, appPrefs.printerPrefs.PrinterFile, appPrefs.printerPrefs.PrinterCommand);
-	SavePrefsXML();
-	if (!WritePref(m_prefsLocation + "scribus150.rc"))
+	savePrefsXML();
+	if (!writePref(m_prefsLocation + "scribus150.rc"))
 		alertSavePrefsFailed();
 	emit prefsChanged();
 }
 
-void PrefsManager::SavePrefsXML()
+void PrefsManager::savePrefsXML()
 {
 	if (prefsFile)
 	{
@@ -1365,14 +1365,13 @@
 	return appPrefs.displayPrefs.showPageShadow;
 }
 
-bool PrefsManager::WritePref(const QString& ho)
+bool PrefsManager::writePref(const QString& filePath)
 {
 	QDomDocument docu("scribusrc");
-	QString st="<SCRIBUSRC></SCRIBUSRC>";
+	QString st = "<SCRIBUSRC></SCRIBUSRC>";
 	docu.setContent(st);
 	QDomElement elem = docu.documentElement();
 	elem.setAttribute("VERSION", "1.5.0");
-
 
 	QDomElement dcUI = docu.createElement("UI");
 	dcUI.setAttribute("ShowStartupDialog", static_cast<int>(appPrefs.uiPrefs.showStartupDialog));
@@ -1396,12 +1395,12 @@
 	deDocumentSetup.setAttribute("UnitIndex", appPrefs.docSetupPrefs.docUnitIndex);
 	deDocumentSetup.setAttribute("PageSize", appPrefs.docSetupPrefs.pageSize);
 	deDocumentSetup.setAttribute("PageOrientation", appPrefs.docSetupPrefs.pageOrientation);
-	deDocumentSetup.setAttribute("PageWidth",ScCLocale::toQStringC(appPrefs.docSetupPrefs.pageWidth));
-	deDocumentSetup.setAttribute("PageHeight",ScCLocale::toQStringC(appPrefs.docSetupPrefs.pageHeight));
-	deDocumentSetup.setAttribute("MarginTop",ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.top()));
-	deDocumentSetup.setAttribute("MarginBottom",ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.bottom()));
-	deDocumentSetup.setAttribute("MarginLeft",ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.left()));
-	deDocumentSetup.setAttribute("MarginRight",ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.right()));
+	deDocumentSetup.setAttribute("PageWidth", ScCLocale::toQStringC(appPrefs.docSetupPrefs.pageWidth));
+	deDocumentSetup.setAttribute("PageHeight", ScCLocale::toQStringC(appPrefs.docSetupPrefs.pageHeight));
+	deDocumentSetup.setAttribute("MarginTop", ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.top()));
+	deDocumentSetup.setAttribute("MarginBottom", ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.bottom()));
+	deDocumentSetup.setAttribute("MarginLeft", ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.left()));
+	deDocumentSetup.setAttribute("MarginRight", ScCLocale::toQStringC(appPrefs.docSetupPrefs.margins.right()));
 	deDocumentSetup.setAttribute("MarginPreset", appPrefs.docSetupPrefs.marginPreset);
 	deDocumentSetup.setAttribute("PagePositioning", appPrefs.docSetupPrefs.pagePositioning);
 	deDocumentSetup.setAttribute("AutoSave", static_cast<int>(appPrefs.docSetupPrefs.AutoSave));
@@ -1438,8 +1437,8 @@
 	deGuides.setAttribute("ShowRulers", static_cast<int>(appPrefs.guidesPrefs.rulersShown));
 	deGuides.setAttribute("ShowBleed", static_cast<int>(appPrefs.guidesPrefs.showBleed));
 	deGuides.setAttribute("RulerMode", static_cast<int>(appPrefs.guidesPrefs.rulerMode));
-	deGuides.setAttribute("MinorGridSpacing",ScCLocale::toQStringC(appPrefs.guidesPrefs.minorGridSpacing));
-	deGuides.setAttribute("MajorGridSpacing",ScCLocale::toQStringC(appPrefs.guidesPrefs.majorGridSpacing));
+	deGuides.setAttribute("MinorGridSpacing", ScCLocale::toQStringC(appPrefs.guidesPrefs.minorGridSpacing));
+	deGuides.setAttribute("MajorGridSpacing", ScCLocale::toQStringC(appPrefs.guidesPrefs.majorGridSpacing));
 	deGuides.setAttribute("MinorGridColor", appPrefs.guidesPrefs.minorGridColor.name());
 	deGuides.setAttribute("MajorGridColor", appPrefs.guidesPrefs.majorGridColor.name());
 	deGuides.setAttribute("GuidesColor", appPrefs.guidesPrefs.guideColor.name());
@@ -1583,8 +1582,8 @@
 	dcItemTools.setAttribute("ImageFillColorShade", appPrefs.itemToolPrefs.imageFillColorShade);
 	dcItemTools.setAttribute("ImageStrokeColor", appPrefs.itemToolPrefs.imageStrokeColor);
 	dcItemTools.setAttribute("ImageStrokeColorShade", appPrefs.itemToolPrefs.imageStrokeColorShade);
-	dcItemTools.setAttribute("ImageScaleX",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageScaleX));
-	dcItemTools.setAttribute("ImageScaleY",ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageScaleY));
+	dcItemTools.setAttribute("ImageScaleX", ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageScaleX));
+	dcItemTools.setAttribute("ImageScaleY", ScCLocale::toQStringC(appPrefs.itemToolPrefs.imageScaleY));
 	dcItemTools.setAttribute("PolygonCorners", appPrefs.itemToolPrefs.polyCorners);
 	dcItemTools.setAttribute("PolygonFactor", ScCLocale::toQStringC(appPrefs.itemToolPrefs.polyFactor));
 	dcItemTools.setAttribute("PolygonRotation", ScCLocale::toQStringC(appPrefs.itemToolPrefs.polyRotation));
@@ -1695,8 +1694,8 @@
 		dcVerifierProfile.setAttribute("CheckForGIF", static_cast<int>(checkerProfile.checkForGIF));
 		dcVerifierProfile.setAttribute("IgnoreOffLayers", static_cast<int>(checkerProfile.ignoreOffLayers));
 		dcVerifierProfile.setAttribute("CheckOffConflictLayers", static_cast<int>(checkerProfile.checkOffConflictLayers));
-		dcVerifierProfile.setAttribute("MinimumResolution",ScCLocale::toQStringC(checkerProfile.minResolution));
-		dcVerifierProfile.setAttribute("MaximumResolution",ScCLocale::toQStringC(checkerProfile.maxResolution));
+		dcVerifierProfile.setAttribute("MinimumResolution", ScCLocale::toQStringC(checkerProfile.minResolution));
+		dcVerifierProfile.setAttribute("MaximumResolution", ScCLocale::toQStringC(checkerProfile.maxResolution));
 		dcVerifierProfile.setAttribute("CheckNotCMYKOrSpot", static_cast<int>(checkerProfile.checkNotCMYKOrSpot));
 		dcVerifierProfile.setAttribute("CheckDeviceColorsAndOutputIntent", static_cast<int>(checkerProfile.checkDeviceColorsAndOutputIntent));
 		dcVerifierProfile.setAttribute("CheckFontNotEmbedded", static_cast<int>(checkerProfile.checkFontNotEmbedded));
@@ -1943,10 +1942,10 @@
 
 	// write file
 	bool result = false;
-	QFile f(ho);
+	QFile f(filePath);
 	if (!f.open(QIODevice::WriteOnly))
 	{
-		m_lastError = tr("Could not open preferences file \"%1\" for writing: %2").arg(ho, qApp->translate("QFile",f.errorString().toLatin1().constData()));
+		m_lastError = tr("Could not open preferences file \"%1\" for writing: %2").arg(filePath, qApp->translate("QFile",f.errorString().toLatin1().constData()));
 	}
 	else
 	{
@@ -1956,20 +1955,20 @@
 		if (f.error()==QFile::NoError)
 			result = true;
 		else
-			m_lastError = tr("Writing to preferences file \"%1\" failed: QIODevice status code %2").arg(ho, f.errorString());
+			m_lastError = tr("Writing to preferences file \"%1\" failed: QIODevice status code %2").arg(filePath, f.errorString());
 	}
 	if (f.isOpen())
 		f.close();
 	return result;
 }
 
-bool PrefsManager::ReadPref(const QString& ho)
+bool PrefsManager::readPref(const QString& filePath)
 {
 	QDomDocument docu("scridoc");
-	QFile f(ho);
+	QFile f(filePath);
 	if (!f.open(QIODevice::ReadOnly))
 	{
-		m_lastError = tr("Failed to open prefs file \"%1\": %2").arg(ho, qApp->translate("QFile",f.errorString().toLatin1().constData()) );
+		m_lastError = tr("Failed to open prefs file \"%1\": %2").arg(filePath, qApp->translate("QFile",f.errorString().toLatin1().constData()) );
 		return false;
 	}
 	QTextStream ts(&f);
@@ -1979,22 +1978,23 @@
 	int errorColumn = 0;
 	if (!docu.setContent(ts.readAll(), &errorMsg, &errorLine, &errorColumn))
 	{
-		m_lastError = tr("Failed to read prefs XML from \"%1\": %2 at line %3, col %4").arg(ho, errorMsg).arg(errorLine).arg(errorColumn);
+		m_lastError = tr("Failed to read prefs XML from \"%1\": %2 at line %3, col %4").arg(filePath, errorMsg).arg(errorLine).arg(errorColumn);
 		f.close();
 		return false;
 	}
 	f.close();
+
 	ScDomElement elem = docu.documentElement();
 	if (elem.tagName() != "SCRIBUSRC")
 		return false;
 	//Ignore scribus*.rc files prior to 1.5.0 due to changes
-	bool prefs150FileFound=false;
+	bool prefs150FileFound = false;
 	if (elem.hasAttribute("VERSION"))
 	{
 		if (elem.attribute("VERSION") == "1.5.0")
-			prefs150FileFound=true;
-	}
-	m_firstTimeIgnoreOldPrefs=!prefs150FileFound;
+			prefs150FileFound = true;
+	}
+	m_firstTimeIgnoreOldPrefs = !prefs150FileFound;
 	if (!prefs150FileFound)
 		return false;
 	appPrefs.colorPrefs.DColors.clear();
@@ -2003,7 +2003,7 @@
 	csm.findPaletteLocations();
 	csm.findPalettes();
 	csm.findUserPalettes();
-	QDomNode DOC=elem.firstChild();
+	QDomNode DOC = elem.firstChild();
 	if (!DOC.namedItem("CheckProfile").isNull())
 		appPrefs.verifierPrefs.checkerPrefsList.clear();
 	while (!DOC.isNull())
@@ -2846,7 +2846,7 @@
 	return m_lastError;
 }
 
-// It's hard to say whether this should be here and called from SavePrefs, or
+// It's hard to say whether this should be here and called from savePrefs, or
 // triggered by a signal sent from here and displayed by ScribusMainWindow.
 void PrefsManager::alertSavePrefsFailed() const
 {
@@ -2860,7 +2860,7 @@
 			+ "</qt>");
 }
 
-// It's hard to say whether this should be here and called from ReadPrefs, or
+// It's hard to say whether this should be here and called from readPrefs, or
 // triggered by a signal sent from here and displayed by ScribusMainWindow.
 void PrefsManager::alertLoadPrefsFailed() const
 {

Modified: trunk/Scribus/scribus/prefsmanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24226&path=/trunk/Scribus/scribus/prefsmanager.h
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.h	(original)
+++ trunk/Scribus/scribus/prefsmanager.h	Wed Nov 11 13:44:29 2020
@@ -100,26 +100,26 @@
 	/*! \brief Read the preferences.
 	\param fname optional filename with preferences. If is not given,
 	the default is used. */
-	void ReadPrefs();
-	void ReadPrefsXML();
+	void readPrefs();
+	void readPrefsXML();
 
 	/*! \brief Save the preferences.
 	\param fname optional filename with preferences. If is not given,
 	the defualt is used. */
-	void SavePrefs();
-	void SavePrefsXML();
+	void savePrefs();
+	void savePrefsXML();
 
 	/*! \brief Writes the preferences physically to the file.
 	Here is the XML file created itself.
 	\param ho a file name to write
 	\retval bool true on success, false on write error */
-	bool WritePref(const QString& ho);
+	bool writePref(const QString& filePath);
 	/*! \brief Reads the preferences physically from the file.
 	Here is the XML file parsed itself. Returns false on error. 
 	It's the caller's job to make sure the prefs file actually exists.
 	\param ho a file name to write
 	\retval bool true on success, false on write error */
-	bool ReadPref(const QString& ho);
+	bool readPref(const QString& filePath);
 
 	void setGhostscriptExecutable(const QString&);
 	void setImageEditorExecutable(const QString&);

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24226&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Wed Nov 11 13:44:29 2020
@@ -472,7 +472,7 @@
 	rebuildRecentFileMenu();
 	//For 1.3.5, we dump prefs first time around.
 	if (!m_prefsManager.firstTimeIgnoreOldPrefs())
-		m_prefsManager.ReadPrefsXML();
+		m_prefsManager.readPrefsXML();
 	if (m_prefsManager.appPrefs.verifierPrefs.checkerPrefsList.count() == 0)
 	{
 		m_prefsManager.initDefaultCheckerPrefs(m_prefsManager.appPrefs.verifierPrefs.checkerPrefsList);
@@ -1868,7 +1868,7 @@
 	m_prefsManager.appPrefs.scrapbookPrefs.RecentScrapbooks.clear();
 	m_prefsManager.appPrefs.scrapbookPrefs.RecentScrapbooks = scrapbookPalette->getOpenScrapbooks();
 	if (!emergencyActivated)
-		m_prefsManager.SavePrefs();
+		m_prefsManager.savePrefs();
 	UndoManager::deleteInstance();
 	FormatsManager::deleteInstance();
 //	qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
@@ -6590,7 +6590,7 @@
 	icm.setMaxCacheEntries(newPrefs.imageCachePrefs.maxCacheEntries);
 	icm.setCompressionLevel(newPrefs.imageCachePrefs.compressionLevel);
 
-	m_prefsManager.SavePrefs();
+	m_prefsManager.savePrefs();
 	m_mainWindowStatusLabel->setText( tr("Ready"));
 }
 

Modified: trunk/Scribus/scribus/scribuscore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24226&path=/trunk/Scribus/scribus/scribuscore.cpp
==============================================================================
--- trunk/Scribus/scribus/scribuscore.cpp	(original)
+++ trunk/Scribus/scribus/scribuscore.cpp	Wed Nov 11 13:44:29 2020
@@ -168,7 +168,7 @@
 	setSplashStatus( tr("Initializing Keyboard Shortcuts") );
 	m_prefsManager.initDefaultActionKeys();
 	setSplashStatus( tr("Reading Preferences") );
-	m_prefsManager.ReadPrefs();
+	m_prefsManager.readPrefs();
 	LocaleManager::instance().setUserPreferredLocale(m_prefsManager.appPrefs.uiPrefs.userPreferredLocale);
 	m_prefsManager.appPrefs.uiPrefs.showSplashOnStartup=showSplash;
 	if (!m_iconManager.setActiveFromPrefs(m_prefsManager.appPrefs.uiPrefs.iconSet))




More information about the scribus-commit mailing list