r21532 by craig - #13248: Enhance and fix option to load prefs file from a specified directory, change to passing a full path instead
scribus-commit
scribus-commit at lists.scribus.net
Mon Nov 21 23:12:11 UTC 2016
Author: craig
Date: Mon Nov 21 23:12:11 2016
New Revision: 21532
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21532
Log:
#13248: Enhance and fix option to load prefs file from a specified directory, change to passing a full path instead
Modified:
trunk/Scribus/scribus/prefsfile.cpp
trunk/Scribus/scribus/prefsmanager.cpp
trunk/Scribus/scribus/prefsmanager.h
trunk/Scribus/scribus/scpaths.cpp
trunk/Scribus/scribus/scribusapp.cpp
trunk/Scribus/scribus/scribusapp.h
trunk/Scribus/scribus/scribuscore.cpp
trunk/Scribus/scribus/scribuscore.h
Modified: trunk/Scribus/scribus/prefsfile.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21532&path=/trunk/Scribus/scribus/prefsfile.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsfile.cpp (original)
+++ trunk/Scribus/scribus/prefsfile.cpp Mon Nov 21 23:12:11 2016
@@ -24,6 +24,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
+#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QString>
Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21532&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp (original)
+++ trunk/Scribus/scribus/prefsmanager.cpp Mon Nov 21 23:12:11 2016
@@ -121,7 +121,7 @@
setupPreferencesLocation();
m_importingFrom12=copyOldAppConfigAndData();
- prefsFile = new PrefsFile( m_prefsLocation + "/prefs150.xml" );
+ prefsFile = new PrefsFile( m_prefsLocation + "prefs150.xml" );
if (m_importingFrom12)
convert12Preferences();
//<<CB TODO Reset keyboard shortcuts of all 1.3 users as too many
@@ -273,7 +273,6 @@
appPrefs.opToolPrefs.magMin = 1;
appPrefs.opToolPrefs.magMax = 32000;
appPrefs.opToolPrefs.magStep = 25;
-// qDebug()<<ScQApp->currGUILanguage();
appPrefs.docSetupPrefs.docUnitIndex = unitIndexFromString(LocaleManager::instance()->unitForLocale(ScQApp->currGUILanguage()));
appPrefs.itemToolPrefs.polyCorners = 4;
appPrefs.itemToolPrefs.polyFactor = 0.5;
@@ -882,17 +881,12 @@
}
}
-void PrefsManager::ReadPrefs(const QString & fname)
-{
- QString realFile;
- if (fname.isEmpty())
- realFile = m_prefsLocation + "/scribus150.rc";
- else
- realFile = fname;
-
- if (QFile::exists(realFile))
- {
- if (!ReadPref(realFile))
+void PrefsManager::ReadPrefs()
+{
+ QString prefsFile(m_prefsLocation + "scribus150.rc");
+ if (QFile::exists(prefsFile))
+ {
+ if (!ReadPref(prefsFile))
{
alertLoadPrefsFailed();
return;
@@ -977,7 +971,7 @@
}
-void PrefsManager::SavePrefs(const QString & fname)
+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
@@ -998,12 +992,7 @@
}
ScCore->primaryMainWindow()->getDefaultPrinter(appPrefs.printerPrefs.PrinterName, appPrefs.printerPrefs.PrinterFile, appPrefs.printerPrefs.PrinterCommand);
SavePrefsXML();
- QString realFile;
- if (fname.isNull())
- realFile = m_prefsLocation+"/scribus150.rc";
- else
- realFile = fname;
- if (!WritePref(realFile))
+ if (!WritePref(m_prefsLocation+"scribus150.rc"))
alertSavePrefsFailed();
emit prefsChanged();
}
Modified: trunk/Scribus/scribus/prefsmanager.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21532&path=/trunk/Scribus/scribus/prefsmanager.h
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.h (original)
+++ trunk/Scribus/scribus/prefsmanager.h Mon Nov 21 23:12:11 2016
@@ -100,13 +100,13 @@
/*! \brief Read the preferences.
\param fname optional filename with preferences. If is not given,
the defualt is used. */
- void ReadPrefs(const QString & fname=QString::null);
+ void ReadPrefs();
void ReadPrefsXML();
/*! \brief Save the preferences.
\param fname optional filename with preferences. If is not given,
the defualt is used. */
- void SavePrefs(const QString & fname=QString::null);
+ void SavePrefs();
void SavePrefsXML();
/*! \brief Writes the preferences physically to the file.
Modified: trunk/Scribus/scribus/scpaths.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21532&path=/trunk/Scribus/scribus/scpaths.cpp
==============================================================================
--- trunk/Scribus/scribus/scpaths.cpp (original)
+++ trunk/Scribus/scribus/scpaths.cpp Mon Nov 21 23:12:11 2016
@@ -12,6 +12,9 @@
#include <QStandardPaths>
#include "scconfig.h"
+#include "scribusapp.h"
+
+extern ScribusQApp* ScQApp;
// On Qt/Mac we need CoreFoundation to discover the location
// of the app bundle.
@@ -530,6 +533,9 @@
QString ScPaths::preferencesDir(bool createIfNotExists)
{
+ //If we have been passed a dir on cmd line, use this. Start up errors if it does not exist.
+ if (!ScQApp->userPrefsDir().isEmpty())
+ return ScQApp->userPrefsDir();
QString prefsDir;
#ifdef APPLICATION_CONFIG_DIR
prefsDir = QDir::homePath() + "/" + APPLICATION_CONFIG_DIR + "/";
Modified: trunk/Scribus/scribus/scribusapp.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21532&path=/trunk/Scribus/scribus/scribusapp.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusapp.cpp (original)
+++ trunk/Scribus/scribus/scribusapp.cpp Mon Nov 21 23:12:11 2016
@@ -268,10 +268,10 @@
std::cout << tr("Option %1 requires an argument.").arg(arg).toLocal8Bit().data() << std::endl;
std::exit(EXIT_FAILURE);
}
- m_prefsUserFile = QFile::decodeName(args[argi + 1].toLocal8Bit());
- if (!QFileInfo(m_prefsUserFile).exists())
- {
- std::cout << tr("Preferences file %1 does not exist, aborting.").arg(m_prefsUserFile).toLocal8Bit().data() << std::endl;
+ m_prefsUserDir = QFile::decodeName(args[argi + 1].toLocal8Bit());
+ if (!QDir(m_prefsUserDir).exists())
+ {
+ std::cout << tr("Preferences directory %1 does not exist, aborting.").arg(m_prefsUserDir).toLocal8Bit().data() << std::endl;
std::exit(EXIT_FAILURE);
} else {
++argi;
@@ -369,7 +369,7 @@
*/
// if (useGUI)
if (true)
- retVal=ScCore->startGUI(m_showSplash, m_showFontInfo, m_showProfileInfo, m_lang, m_prefsUserFile);
+ retVal=ScCore->startGUI(m_showSplash, m_showFontInfo, m_showProfileInfo, m_lang);
// A hook for plugins and scripts to trigger on. Some plugins and scripts
// require the app to be fully set up (in particular, the main window to be
@@ -397,7 +397,7 @@
PrefsPfad = Pff;
else
PrefsPfad = ScPaths::preferencesDir();
- QString prefsXMLFile=QDir::toNativeSeparators(PrefsPfad + "/prefs150.xml");
+ QString prefsXMLFile=QDir::toNativeSeparators(PrefsPfad + "prefs150.xml");
QFileInfo infoPrefsFile(prefsXMLFile);
if (infoPrefsFile.exists())
{
Modified: trunk/Scribus/scribus/scribusapp.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21532&path=/trunk/Scribus/scribus/scribusapp.h
==============================================================================
--- trunk/Scribus/scribus/scribusapp.h (original)
+++ trunk/Scribus/scribus/scribusapp.h Mon Nov 21 23:12:11 2016
@@ -70,6 +70,7 @@
void neverSplash(bool splashOff);
bool neverSplashExists();
const QString& currGUILanguage() { return m_GUILang; }
+ const QString& userPrefsDir() { return m_prefsUserDir; }
ScDLManager* dlManager() { return m_scDLMgr; }
QString pythonScript; // script to be run in python from CLI
QStringList pythonScriptArgs; // command line arguments and flags for script from CLI
@@ -98,7 +99,7 @@
bool m_showFontInfo;
bool m_showProfileInfo;
//! \brief If is there user given prefs file...
- QString m_prefsUserFile;
+ QString m_prefsUserDir;
QList<QString> m_filesToLoad;
QString m_fileName;
ScDLManager *m_scDLMgr;
Modified: trunk/Scribus/scribus/scribuscore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21532&path=/trunk/Scribus/scribus/scribuscore.cpp
==============================================================================
--- trunk/Scribus/scribus/scribuscore.cpp (original)
+++ trunk/Scribus/scribus/scribuscore.cpp Mon Nov 21 23:12:11 2016
@@ -106,7 +106,7 @@
return ScQApp->currGUILanguage();
}
-int ScribusCore::startGUI(bool showSplash, bool showFontInfo, bool showProfileInfo, const QString newGuiLanguage, const QString prefsUserFile)
+int ScribusCore::startGUI(bool showSplash, bool showFontInfo, bool showProfileInfo, const QString newGuiLanguage)
{
ScribusMainWindow* scribus = new ScribusMainWindow();
Q_CHECK_PTR(scribus);
@@ -114,7 +114,7 @@
return(EXIT_FAILURE);
m_ScMWList.append(scribus);
m_currScMW=0;
- int retVal=initScribusCore(showSplash, showFontInfo, showProfileInfo,newGuiLanguage, prefsUserFile);
+ int retVal=initScribusCore(showSplash, showFontInfo, showProfileInfo,newGuiLanguage);
if (retVal == EXIT_FAILURE)
return(EXIT_FAILURE);
@@ -160,7 +160,7 @@
}
int ScribusCore::initScribusCore(bool showSplash, bool showFontInfo, bool showProfileInfo,
- const QString newGuiLanguage, const QString prefsUserFile)
+ const QString newGuiLanguage)
{
CommonStrings::languageChange();
m_iconManager = IconManager::instance();
@@ -187,10 +187,7 @@
setSplashStatus( tr("Initializing Keyboard Shortcuts") );
m_prefsManager->initDefaultActionKeys();
setSplashStatus( tr("Reading Preferences") );
- if (prefsUserFile.isEmpty())
- m_prefsManager->ReadPrefs();
- else
- m_prefsManager->ReadPrefs(prefsUserFile);
+ m_prefsManager->ReadPrefs();
m_prefsManager->appPrefs.uiPrefs.showSplashOnStartup=showSplash;
if (!m_iconManager->setActiveFromPrefs(m_prefsManager->appPrefs.uiPrefs.iconSet))
{
Modified: trunk/Scribus/scribus/scribuscore.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21532&path=/trunk/Scribus/scribus/scribuscore.h
==============================================================================
--- trunk/Scribus/scribus/scribuscore.h (original)
+++ trunk/Scribus/scribus/scribuscore.h Mon Nov 21 23:12:11 2016
@@ -65,7 +65,7 @@
int runScript() {return 0;}
*/
int init(bool useGUI, const QList<QString>& filesToUse);
- int initScribusCore(bool showSplash, bool showFontInfo, bool showProfileInfo, const QString newGuiLanguage, const QString prefsUserFile);
+ int initScribusCore(bool showSplash, bool showFontInfo, bool showProfileInfo, const QString newGuiLanguage);
bool initialized() const {return m_ScribusInitialized;}
const QString& getGuiLanguage() const;
@@ -76,7 +76,7 @@
void closeSplash();
void setSplashStatus(const QString&);
bool usingGUI() const;
- int startGUI(bool showSplash, bool showFontInfo, bool showProfileInfo, const QString newGuiLanguage, const QString prefsUserFile);
+ int startGUI(bool showSplash, bool showFontInfo, bool showProfileInfo, const QString newGuiLanguage);
/**
* @brief Are we trying to adhere to Apple Mac HIG ?
* @retval bool true if we are on Qt/Mac
@@ -123,8 +123,6 @@
ScColorTransform defaultCMYKToRGBTrans;
ScColorTransform defaultLabToRGBTrans;
ScColorTransform defaultLabToCMYKTrans;
- //CB FIXME protect
-// QWidget *m_PaletteParent;
protected:
void initCMS();
More information about the scribus-commit
mailing list