r23596 by craig - Code cleanup

scribus-commit scribus-commit at lists.scribus.net
Sun Apr 12 20:44:05 UTC 2020


Author: craig
Date: Sun Apr 12 20:44:05 2020
New Revision: 23596

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23596
Log:
Code cleanup

Modified:
    trunk/Scribus/scribus/prefsfile.cpp
    trunk/Scribus/scribus/prefsfile.h
    trunk/Scribus/scribus/prefsmanager.cpp
    trunk/Scribus/scribus/prefsmanager.h
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribuscore.cpp
    trunk/Scribus/scribus/ui/fontcombo.cpp
    trunk/Scribus/scribus/ui/preferencesdialog.cpp
    trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp

Modified: trunk/Scribus/scribus/prefsfile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23596&path=/trunk/Scribus/scribus/prefsfile.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsfile.cpp	(original)
+++ trunk/Scribus/scribus/prefsfile.cpp	Sun Apr 12 20:44:05 2020
@@ -35,8 +35,6 @@
 
 PrefsFile::PrefsFile()
 {
-	m_prefsFilePath = "";
-	m_ioEnabled = false;
 }
 
 PrefsFile::PrefsFile(const QString& pFilePath, bool write)
@@ -170,18 +168,17 @@
 
 void PrefsFile::canWrite()
 {
-	if (m_ioEnabled)
+	if (!m_ioEnabled)
+		return;
+	QFile f(m_prefsFilePath);
+	QFileInfo fi(f);
+	if (fi.exists())
+		m_ioEnabled = fi.isWritable();
+	else
 	{
-		QFile f(m_prefsFilePath);
-		QFileInfo fi(f);
-		if (fi.exists())
-			m_ioEnabled = fi.isWritable();
-		else
-		{
-			QFile f2(m_prefsFilePath.left(m_prefsFilePath.lastIndexOf("/")));
-			QFileInfo fi2(f2);
-			m_ioEnabled = fi2.isWritable();
-		}
+		QFile f2(m_prefsFilePath.left(m_prefsFilePath.lastIndexOf("/")));
+		QFileInfo fi2(f2);
+		m_ioEnabled = fi2.isWritable();
 	}
 }
 

Modified: trunk/Scribus/scribus/prefsfile.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23596&path=/trunk/Scribus/scribus/prefsfile.h
==============================================================================
--- trunk/Scribus/scribus/prefsfile.h	(original)
+++ trunk/Scribus/scribus/prefsfile.h	Sun Apr 12 20:44:05 2020
@@ -42,16 +42,18 @@
 	ContextMap m_contexts;
 	ContextMap m_pluginContexts;
 	ContextMap m_userprefsContexts;
-	bool m_ioEnabled;
+	bool m_ioEnabled {false};
+
 	void load();
 	QString replaceIllegalChars(const QString& text);
 	void writeContexts(ContextMap* contextMap, QTextStream& stream);
 	void canWrite();
+
 public:
 	PrefsFile();
 	PrefsFile(const QString& pFilePath, bool write = true);
 	~PrefsFile();
-	bool          hasContext(const QString& contextName) const;
+	bool hasContext(const QString& contextName) const;
 	PrefsContext* getContext(const QString& contextName, bool persistent = true);
 	PrefsContext* getPluginContext(const QString& contextName, bool persistent = true);
 	PrefsContext* getUserPrefsContext(const QString& contextName, bool persistent = true);

Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23596&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp	(original)
+++ trunk/Scribus/scribus/prefsmanager.cpp	Sun Apr 12 20:44:05 2020
@@ -66,10 +66,7 @@
 
 extern bool emergencyActivated;
 
-PrefsManager::PrefsManager(QObject *parent) : QObject(parent),
-	prefsFile(nullptr),
-	m_importingFrom12(false),
-	m_firstTimeIgnoreOldPrefs(false)
+PrefsManager::PrefsManager(QObject *parent) : QObject(parent)
 {
 }
 
@@ -2792,10 +2789,7 @@
 	ScCore->showSplash(splashShowing);
 }
 
-int PrefsManager::gsResolution()
-{
-	return appPrefs.extToolPrefs.gs_Resolution;
-}
+
 
 void PrefsManager::languageChange()
 {

Modified: trunk/Scribus/scribus/prefsmanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23596&path=/trunk/Scribus/scribus/prefsmanager.h
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.h	(original)
+++ trunk/Scribus/scribus/prefsmanager.h	Sun Apr 12 20:44:05 2020
@@ -137,7 +137,7 @@
 	QString latexEditorExecutable() const {return appPrefs.extToolPrefs.latexEditorExecutable;}
 	bool latexStartWithEmptyFrames() const {return appPrefs.extToolPrefs.latexStartWithEmptyFrames;}
 	//! \brief Get the users preferred preview resolution
-	int gsResolution();
+	int gsResolution() const {return appPrefs.extToolPrefs.gs_Resolution;}
 	int latexResolution() const {return appPrefs.extToolPrefs.latexResolution;}
 	bool latexForceDpi() const {return appPrefs.extToolPrefs.latexForceDpi;}
 	//! \brief Get the users preferred document directory
@@ -207,8 +207,7 @@
 public slots:
 	void languageChange();
 
-
-	private:
+private:
 	PrefsManager(QObject *parent = nullptr);
 	~PrefsManager();
 

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23596&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp	(original)
+++ trunk/Scribus/scribus/scribus.cpp	Sun Apr 12 20:44:05 2020
@@ -1391,8 +1391,8 @@
 	mainWindowXPosDataLabel->setFont(fo);
 	mainWindowYPosDataLabel = new QLabel( "", statusBar());
 	mainWindowYPosDataLabel->setFont(fo);
-	mainWindowXPosDataLabel->setMinimumWidth(mainWindowXPosDataLabel->fontMetrics().width("99999.999"));
-	mainWindowYPosDataLabel->setMinimumWidth(mainWindowYPosDataLabel->fontMetrics().width("99999.999"));
+	mainWindowXPosDataLabel->setMinimumWidth(mainWindowXPosDataLabel->fontMetrics().horizontalAdvance("99999.999"));
+	mainWindowYPosDataLabel->setMinimumWidth(mainWindowYPosDataLabel->fontMetrics().horizontalAdvance("99999.999"));
 	statusBarLanguageChange();
 
 	layerMenu->setObjectName("layerMenu");

Modified: trunk/Scribus/scribus/scribuscore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23596&path=/trunk/Scribus/scribus/scribuscore.cpp
==============================================================================
--- trunk/Scribus/scribus/scribuscore.cpp	(original)
+++ trunk/Scribus/scribus/scribuscore.cpp	Sun Apr 12 20:44:05 2020
@@ -404,12 +404,12 @@
 void ScribusCore::InitDefaultColorTransforms()
 {
 	QString defaultRGBString;
-	QString defaultRGBString1  = "sRGB display profile (ICC v2.2)";
-	QString defaultRGBString2  = "sRGB IEC61966-2.1";
-	QString defaultCMYKString1 = "ISO Coated v2 300% (basICColor)";
-	QString defaultCMYKString2 = "Fogra27L CMYK Coated Press";
-
-	// Ouvre le profile RGB par d�fault
+	QString defaultRGBString1("sRGB display profile (ICC v2.2)");
+	QString defaultRGBString2("sRGB IEC61966-2.1");
+	QString defaultCMYKString1("ISO Coated v2 300% (basICColor)");
+	QString defaultCMYKString2("Fogra27L CMYK Coated Press");
+
+	// Open the CMYK profile RGB by default
 	if (InputProfiles.contains(defaultRGBString1))
 	{
 		defaultRGBProfile = defaultEngine.openProfileFromFile(InputProfiles[defaultRGBString1]);
@@ -426,7 +426,7 @@
 		defaultRGBString = defaultRGBString2;
 	}
 
-	// Ouvre le profile CMYK par d�faut
+	// Open the CMYK profile CMYK by default
 	if (InputProfilesCMYK.contains(defaultCMYKString1))
 		defaultCMYKProfile = defaultEngine.openProfileFromFile(InputProfilesCMYK[defaultCMYKString1]);
 	else if (InputProfilesCMYK.contains(defaultCMYKString2))

Modified: trunk/Scribus/scribus/ui/fontcombo.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23596&path=/trunk/Scribus/scribus/ui/fontcombo.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/fontcombo.cpp	(original)
+++ trunk/Scribus/scribus/ui/fontcombo.cpp	Sun Apr 12 20:44:05 2020
@@ -579,7 +579,7 @@
 
 	if (system != QFontDatabase::Any)
 	{
-		int w = pixPainter.fontMetrics().width(text + QLatin1String("  "));
+		int w = pixPainter.fontMetrics().horizontalAdvance(text + QLatin1String("  "));
 		pixPainter.setFont(font2);
 		invpixPainter.setFont(font2);
 		QString sample = fontDb.writingSystemSample(system);

Modified: trunk/Scribus/scribus/ui/preferencesdialog.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23596&path=/trunk/Scribus/scribus/ui/preferencesdialog.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/preferencesdialog.cpp	(original)
+++ trunk/Scribus/scribus/ui/preferencesdialog.cpp	Sun Apr 12 20:44:05 2020
@@ -347,16 +347,14 @@
 			continue;
 		// If we got a plugin (which we know is enabled):
 		// Ask the plugin for a prefs widget
+		panel = nullptr;
 		bool wantPanel = plugin->newPrefsPanelWidget(prefsStackWidget, panel);
 		// If it gave us one...
-		if (wantPanel)
+		if (wantPanel && panel!=nullptr)
 		{
-			// Ensure that we got sane return values
-			Q_ASSERT(panel);
 			// plug it in to the dialog,
 			addWidget(panel);
-			// and connect a signal to tell it to save its
-			// settings.
+			// and connect a signal to tell it to save its settings.
 			connect(this, SIGNAL(accepted()), panel, SLOT(apply()));
 		}
 	}

Modified: trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23596&path=/trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp	(original)
+++ trunk/Scribus/scribus/ui/prefs_keyboardshortcuts.cpp	Sun Apr 12 20:44:05 2020
@@ -246,16 +246,15 @@
 QStringList Prefs_KeyboardShortcuts::scanForSets()
 {
 	keySetList.clear();
-	QString location = ScPaths::instance().shareDir();
-	QString keySetLocation = QDir::toNativeSeparators(location+"keysets/");
-	QDir keySetsDir(keySetLocation, "*.xml", QDir::Name, QDir::Files | QDir::NoSymLinks);
+	QString location(ScPaths::instance().shareDir());
+	QDir keySetsDir(QDir::toNativeSeparators(location+"keysets/"), "*.xml", QDir::Name, QDir::Files | QDir::NoSymLinks);
 	if ((!keySetsDir.exists()) || (keySetsDir.count() <= 0))
 		return QStringList();
 
 	QStringList appNames;
 	for (uint fileCounter = 0; fileCounter < keySetsDir.count(); ++fileCounter)
 	{
-		QString filename = QDir::toNativeSeparators(location+"keysets/"+keySetsDir[fileCounter]);
+		QString filename(QDir::toNativeSeparators(location+"keysets/"+keySetsDir[fileCounter]));
 
 		QDomDocument doc( "keymapentries" );
 		QFile file( filename );




More information about the scribus-commit mailing list