r14204 by cbradney - Allow new path prefs pane to load/save data, and ui prefs to activate theme/fonts size changes

scribus-commit scribus-commit at lists.scribus.net
Tue Oct 20 22:40:28 CEST 2009


Revision: 14204
Author: cbradney
Date: 2009-10-20T17:58:00.341271Z
Commit message: Allow new path prefs pane to load/save data, and ui prefs to activate theme/fonts size changes

Changeset: 
M  /trunk/Scribus/scribus/scribus.cpp
M  /trunk/Scribus/scribus/ui/prefs_paths.cpp
M  /trunk/Scribus/scribus/ui/preferencesdialog.cpp
M  /trunk/Scribus/scribus/ui/prefs_paths.h
M  /trunk/Scribus/scribus/ui/prefs_pathsbase.ui

Diffs:
Index: scribus/ui/prefs_paths.cpp
===================================================================
--- scribus/ui/prefs_paths.cpp	(revision 14203)
+++ scribus/ui/prefs_paths.cpp	(revision 14204)
@@ -5,16 +5,76 @@
 for which a new license (GPL+exception) is in place.
 */
 
+#include <QFileDialog>
+#include <QString>
+
 #include "prefs_paths.h"
+#include "prefsstructs.h"
 
 Prefs_Paths::Prefs_Paths(QWidget* parent)
-	: QWidget(parent)
+	: Prefs_Pane(parent)
 {
 	setupUi(this);
+	languageChange();
 
+	connect(docDirChangeButton, SIGNAL(clicked()), this, SLOT(changeDocs()));
+	connect(profileDirChangeButton, SIGNAL(clicked()), this, SLOT(changeProfs()));
+	connect(scriptDirChangeButton, SIGNAL(clicked()), this, SLOT(changeScripts()));
+	connect(templateDirChangeButton, SIGNAL(clicked()), this, SLOT(changeDocumentTemplates()));
 }
 
 Prefs_Paths::~Prefs_Paths()
 {
 }
 
+void Prefs_Paths::languageChange()
+{
+	docDirLineEdit->setToolTip( "<qt>" + tr( "Default documents directory" ) + "</qt>" );
+	profileDirLineEdit->setToolTip( "<qt>" + tr( "Default ICC profiles directory. This cannot be changed with a document open. By default, Scribus will look in the System Directories under Mac OSX and Windows. On Linux and Unix, Scribus will search $home/.color/icc,/usr/share/color/icc and /usr/local/share/color/icc " ) + "</qt>" );
+	scriptDirLineEdit->setToolTip( "<qt>" + tr( "Default Scripter scripts directory" ) + "</qt>" );
+	templateDirLineEdit->setToolTip( "<qt>"+ tr("Additional directory for document templates")+"</qt>" );
+}
+
+void Prefs_Paths::restoreDefaults(struct ApplicationPrefs *prefsData)
+{
+	docDirLineEdit->setText(prefsData->pathPrefs.documents);
+	profileDirLineEdit->setText(prefsData->pathPrefs.colorProfiles);
+	scriptDirLineEdit->setText(prefsData->pathPrefs.scripts);
+	templateDirLineEdit->setText(prefsData->pathPrefs.documentTemplates);
+}
+
+void Prefs_Paths::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
+{
+	prefsData->pathPrefs.documents=docDirLineEdit->text();
+	prefsData->pathPrefs.colorProfiles=profileDirLineEdit->text();
+	prefsData->pathPrefs.scripts=scriptDirLineEdit->text();
+	prefsData->pathPrefs.documentTemplates=templateDirLineEdit->text();
+}
+
+void Prefs_Paths::changeDocs()
+{
+	QString s = QFileDialog::getExistingDirectory(this, tr("Choose a Directory"), docDirLineEdit->text());
+	if (!s.isEmpty())
+		docDirLineEdit->setText( QDir::convertSeparators(s) );
+}
+
+void Prefs_Paths::changeProfs()
+{
+	QString s = QFileDialog::getExistingDirectory(this, tr("Choose a Directory"), profileDirLineEdit->text());
+	if (!s.isEmpty())
+		profileDirLineEdit->setText( QDir::convertSeparators(s) );
+}
+
+void Prefs_Paths::changeScripts()
+{
+	QString s = QFileDialog::getExistingDirectory(this, tr("Choose a Directory"), scriptDirLineEdit->text());
+	if (!s.isEmpty())
+		scriptDirLineEdit->setText( QDir::convertSeparators(s) );
+}
+
+void Prefs_Paths::changeDocumentTemplates()
+{
+	QString s = QFileDialog::getExistingDirectory(this, tr("Choose a Directory"), templateDirLineEdit->text());
+	if (!s.isEmpty())
+		templateDirLineEdit->setText( QDir::convertSeparators(s) );
+}
Index: scribus/ui/prefs_pathsbase.ui
===================================================================
--- scribus/ui/prefs_pathsbase.ui	(revision 14203)
+++ scribus/ui/prefs_pathsbase.ui	(revision 14204)
@@ -53,7 +53,7 @@
        <item>
         <layout class="QGridLayout" name="gridLayout">
          <item row="0" column="0">
-          <widget class="QLabel" name="textLabel7">
+          <widget class="QLabel" name="docDirLabel">
            <property name="text">
             <string>Documents:</string>
            </property>
@@ -61,12 +61,12 @@
             <bool>false</bool>
            </property>
            <property name="buddy">
-            <cstring>Docs</cstring>
+            <cstring>docDirLineEdit</cstring>
            </property>
           </widget>
          </item>
          <item row="0" column="1">
-          <widget class="QLineEdit" name="Docs">
+          <widget class="QLineEdit" name="docDirLineEdit">
            <property name="minimumSize">
             <size>
              <width>268</width>
@@ -76,7 +76,7 @@
           </widget>
          </item>
          <item row="0" column="2">
-          <widget class="QPushButton" name="FileC">
+          <widget class="QPushButton" name="docDirChangeButton">
            <property name="minimumSize">
             <size>
              <width>88</width>
@@ -92,7 +92,7 @@
           </widget>
          </item>
          <item row="1" column="0">
-          <widget class="QLabel" name="textLabel8">
+          <widget class="QLabel" name="profileDirLabel">
            <property name="text">
             <string>Color Profiles:</string>
            </property>
@@ -100,12 +100,12 @@
             <bool>false</bool>
            </property>
            <property name="buddy">
-            <cstring>profileLineEdit</cstring>
+            <cstring>profileDirLineEdit</cstring>
            </property>
           </widget>
          </item>
          <item row="1" column="1">
-          <widget class="QLineEdit" name="profileLineEdit">
+          <widget class="QLineEdit" name="profileDirLineEdit">
            <property name="minimumSize">
             <size>
              <width>268</width>
@@ -115,7 +115,7 @@
           </widget>
          </item>
          <item row="1" column="2">
-          <widget class="QPushButton" name="FileC2">
+          <widget class="QPushButton" name="profileDirChangeButton">
            <property name="text">
             <string>C&amp;hange...</string>
            </property>
@@ -125,7 +125,7 @@
           </widget>
          </item>
          <item row="2" column="0">
-          <widget class="QLabel" name="textLabel9">
+          <widget class="QLabel" name="scriptDirLabel">
            <property name="text">
             <string>Scripts:</string>
            </property>
@@ -133,12 +133,12 @@
             <bool>false</bool>
            </property>
            <property name="buddy">
-            <cstring>scriptLineEdit</cstring>
+            <cstring>scriptDirLineEdit</cstring>
            </property>
           </widget>
          </item>
          <item row="2" column="1">
-          <widget class="QLineEdit" name="scriptLineEdit">
+          <widget class="QLineEdit" name="scriptDirLineEdit">
            <property name="minimumSize">
             <size>
              <width>268</width>
@@ -148,7 +148,7 @@
           </widget>
          </item>
          <item row="2" column="2">
-          <widget class="QPushButton" name="FileC3">
+          <widget class="QPushButton" name="scriptDirChangeButton">
            <property name="text">
             <string>Ch&amp;ange...</string>
            </property>
@@ -158,7 +158,7 @@
           </widget>
          </item>
          <item row="3" column="0">
-          <widget class="QLabel" name="textLabel10">
+          <widget class="QLabel" name="templateDirLabel">
            <property name="text">
             <string>Document Templates:</string>
            </property>
@@ -166,12 +166,12 @@
             <bool>false</bool>
            </property>
            <property name="buddy">
-            <cstring>docTemplateDirLineEdit</cstring>
+            <cstring>templateDirLineEdit</cstring>
            </property>
           </widget>
          </item>
          <item row="3" column="1">
-          <widget class="QLineEdit" name="docTemplateDirLineEdit">
+          <widget class="QLineEdit" name="templateDirLineEdit">
            <property name="minimumSize">
             <size>
              <width>268</width>
@@ -181,7 +181,7 @@
           </widget>
          </item>
          <item row="3" column="2">
-          <widget class="QPushButton" name="FileC4">
+          <widget class="QPushButton" name="templateDirChangeButton">
            <property name="text">
             <string>Cha&amp;nge...</string>
            </property>
Index: scribus/ui/prefs_paths.h
===================================================================
--- scribus/ui/prefs_paths.h	(revision 14203)
+++ scribus/ui/prefs_paths.h	(revision 14204)
@@ -9,15 +9,43 @@
 #define PREFS_PATHS_H
 
 #include "ui_prefs_pathsbase.h"
+#include "prefs_pane.h"
 #include "scribusapi.h"
 
-class SCRIBUS_API Prefs_Paths : public QWidget, Ui::Prefs_Paths
+class SCRIBUS_API Prefs_Paths : public Prefs_Pane, Ui::Prefs_Paths
 {
 	Q_OBJECT
 
 	public:
 		Prefs_Paths(QWidget* parent=0);
 		~Prefs_Paths();
+		virtual void restoreDefaults(struct ApplicationPrefs *prefsData);
+		virtual void saveGuiToPrefs(struct ApplicationPrefs *prefsData) const;
+
+	public slots:
+		void languageChange();
+
+	protected slots:
+		/*!
+		\author Franz Schmid
+		\brief Runs QFileDialog to get Preferences (General) Path to Documents directory
+		 */
+		void changeDocs();
+		/*!
+		\author Franz Schmid
+		\brief Runs QFileDialog to get Preferences (General) Path to Colour Profiles directory
+		*/
+		void changeProfs();
+		/*!
+		\author Franz Schmid
+		\brief Runs QFileDialog to get Preferences (General) Path to Scripts directory
+		*/
+		void changeScripts();
+		/*!
+		\author Riku Leino
+		\brief Runs QFileDialog to get Preferences (General) Path to Document Templates directory
+		*/
+		void changeDocumentTemplates();
 };
 
 #endif // PREFS_PATHS_H
Index: scribus/ui/preferencesdialog.cpp
===================================================================
--- scribus/ui/preferencesdialog.cpp	(revision 14203)
+++ scribus/ui/preferencesdialog.cpp	(revision 14204)
@@ -105,6 +105,7 @@
 void PreferencesDialog::setupGui()
 {
 	prefs_UserInterface->restoreDefaults(&localPrefs);
+	prefs_Paths->restoreDefaults(&localPrefs);
 	prefs_Scrapbook->restoreDefaults(&localPrefs);
 	prefs_Display->restoreDefaults(&localPrefs);
 }
@@ -236,6 +237,7 @@
 void PreferencesDialog::saveGuiToPrefs()
 {
 	prefs_UserInterface->saveGuiToPrefs(&localPrefs);
+	prefs_Paths->saveGuiToPrefs(&localPrefs);
 	prefs_Scrapbook->saveGuiToPrefs(&localPrefs);
 	prefs_Display->saveGuiToPrefs(&localPrefs);
 }
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp	(revision 14203)
+++ scribus/scribus.cpp	(revision 14204)
@@ -7634,7 +7634,34 @@
 		struct ApplicationPrefs newPrefs(prefsDialog.prefs());
 		prefsManager->setNewPrefs(newPrefs);
 		prefsManager->SavePrefs();
+
+		// TODO:
+		// CB: Hoping to clean this into a nicer function
+		//
+
+		//TODO: and the other dirs?
+		DocDir = prefsManager->documentDir();
 		ScQApp->neverSplash(!prefsManager->appPrefs.uiPrefs.showSplashOnStartup);
+
+		QString newUILanguage = prefsManager->uiLanguage();
+		if (oldPrefs.uiPrefs.language != newUILanguage || ScQApp->currGUILanguage()!=newUILanguage)
+			ScQApp->changeGUILanguage(newUILanguage);
+		QString newUIStyle = prefsManager->guiStyle();
+		if (oldPrefs.uiPrefs.style != newUIStyle)
+		{
+			if (newUIStyle.isEmpty())
+				qApp->setStyle(prefsManager->guiSystemStyle());
+			else
+				qApp->setStyle(QStyleFactory::create(newUIStyle));
+		}
+		int newUIFontSize = prefsManager->guiFontSize();
+		if (oldPrefs.uiPrefs.applicationFontSize != newUIFontSize)
+		{
+			QFont apf = qApp->font();
+			apf.setPointSize(newUIFontSize);
+			qApp->setFont(apf);
+		}
+		propertiesPalette->Fonts->RebuildList(0);
 	}
 }
 




More information about the scribus-commit mailing list