r14046 by cbradney - Make new prefs display panel actually save the Prefs to PrefsManager now

scribus-commit scribus-commit at lists.scribus.net
Sun Sep 27 00:00:28 CEST 2009


Revision: 14046
Author: cbradney
Date: 2009-09-26T21:59:45.222240Z
Commit message: Make new prefs display panel actually save the Prefs to PrefsManager now

Changeset: 
M  /trunk/Scribus/scribus/prefsmanager.cpp
M  /trunk/Scribus/scribus/scribus.cpp
M  /trunk/Scribus/scribus/CMakeLists.txt
M  /trunk/Scribus/scribus/ui/preferencesdialog.cpp
M  /trunk/Scribus/scribus/prefsmanager.h
M  /trunk/Scribus/scribus/ui/prefs_display.cpp
M  /trunk/Scribus/scribus/ui/preferencesdialog.h
M  /trunk/Scribus/scribus/ui/prefs_display.h
M  /trunk/Scribus/scribus/ui/prefs_displaybase.ui

Diffs:
Index: scribus/prefsmanager.cpp
===================================================================
--- scribus/prefsmanager.cpp	(revision 14045)
+++ scribus/prefsmanager.cpp	(revision 14046)
@@ -91,6 +91,11 @@
 	return &appPrefs;
 }
 
+void PrefsManager::setNewPrefs(ApplicationPrefs& newPrefs)
+{
+	appPrefs=newPrefs;
+}
+
 PrefsFile* PrefsManager::applicationPrefsFile()
 {
 	return prefsFile;
Index: scribus/prefsmanager.h
===================================================================
--- scribus/prefsmanager.h	(revision 14045)
+++ scribus/prefsmanager.h	(revision 14046)
@@ -185,6 +185,7 @@
 	bool GetAllFonts(bool showFontInfo);
 
 	ApplicationPrefs* applicationPrefs();
+	void setNewPrefs(ApplicationPrefs& newPrefs);
 	PrefsFile* applicationPrefsFile();
 	bool importingFrom12x();
 
Index: scribus/ui/prefs_display.h
===================================================================
--- scribus/ui/prefs_display.h	(revision 14045)
+++ scribus/ui/prefs_display.h	(revision 14046)
@@ -9,20 +9,23 @@
 #define PREFS_DISPLAY_H
 
 #include "ui_prefs_displaybase.h"
+#include "prefs_pane.h"
 #include "scribusapi.h"
 
-class SCRIBUS_API Prefs_Display : public QWidget, Ui::Prefs_Display
+class SCRIBUS_API Prefs_Display : public Prefs_Pane, Ui::Prefs_Display
 {
 	Q_OBJECT
 
 	public:
 		Prefs_Display(QWidget* parent=0);
 		~Prefs_Display();
-		void restoreDefaults(struct ApplicationPrefs *prefsData);
+		virtual void restoreDefaults(struct ApplicationPrefs *prefsData);
+		virtual void saveGuiToPrefs(struct ApplicationPrefs *prefsData) const;
 
 	public slots:
 		void languageChange();
 
+
 	protected slots:
 		/*!
 		\author Franz Schmid
@@ -54,6 +57,7 @@
 		virtual void changeControlCharsColor();
 
 
+
 	protected:
 		int docUnitIndex;
 		QColor colorPaper;
Index: scribus/ui/preferencesdialog.h
===================================================================
--- scribus/ui/preferencesdialog.h	(revision 14045)
+++ scribus/ui/preferencesdialog.h	(revision 14046)
@@ -13,6 +13,7 @@
 #include <QStackedWidget>
 
 #include "scribusapi.h"
+#include "prefsstructs.h"
 #include "ui_preferencesdialogbase.h"
 
 #include "ui/prefs_colormanagement.h"
@@ -53,12 +54,20 @@
 		~PreferencesDialog();
 
 		virtual void changeEvent(QEvent *e);
+		ApplicationPrefs prefs() const { return localPrefs; }
 
 	public slots:
 		void itemSelected(QListWidgetItem* ic);
+		void restoreDefaults();
+		void setupGui();
+		void saveGuiToPrefs();
+		virtual void accept();
 
 	protected slots:
 		virtual void languageChange();
+		void applyButtonClicked();
+
+
 	private:
 		int addItem(QString name, QPixmap icon, QWidget *tab);
 		void setupListWidget();
@@ -94,6 +103,8 @@
 		int docUnitIndex;
 		ScribusMainWindow* mainWin;
 		PrefsManager* prefsManager;
+
+		ApplicationPrefs localPrefs;
 };
 
 #endif
Index: scribus/ui/prefs_display.cpp
===================================================================
--- scribus/ui/prefs_display.cpp	(revision 14045)
+++ scribus/ui/prefs_display.cpp	(revision 14046)
@@ -17,7 +17,7 @@
 #include "util_icon.h"
 
 Prefs_Display::Prefs_Display(QWidget* parent)
-	: QWidget(parent)
+	: Prefs_Pane(parent)
 {
 	setupUi(this);
 	languageChange();
@@ -204,20 +204,22 @@
 		p.drawLine(QPointF(xl, 6.0), QPointF(xl, 19.0));
 		p.save();
 		p.scale(1.0 / displayScale, 1.0);
+		double val;
 		switch (index)
 		{
 			case 2:
 			case 4:
-				p.drawText(static_cast<int>((xl+qRound(2/displayScale)) * displayScale), 12, QString::number(xl / iter2));
+				val=xl/iter2;
 				break;
 			case 3:
 			case 5:
-				p.drawText(static_cast<int>((xl+qRound(2/displayScale)) * displayScale), 12, QString::number(xl / iter));
+				val=xl/iter;
 				break;
 			default:
-				p.drawText(static_cast<int>((xl+qRound(2/displayScale)) * displayScale), 12, QString::number(xl / iter * 10));
+				val=xl/iter*10;
 				break;
 		}
+		p.drawText(static_cast<int>((xl+qRound(2/displayScale)) * displayScale), 12, QString::number(val));
 		p.restore();
 	}
 	p.end();
@@ -360,3 +362,34 @@
 		textControlCharsButton->setIcon(pm);
 	}
 }
+
+void Prefs_Display::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
+{
+	prefsData->guidesPrefs.showPic=showImagesCheckBox->isChecked();
+	prefsData->guidesPrefs.showControls=showControlCharsCheckBox->isChecked();
+	prefsData->guidesPrefs.rulerMode=showRulersRelativeToPageCheckBox->isChecked();
+	prefsData->guidesPrefs.linkShown=showTextChainsCheckBox->isChecked();
+	prefsData->guidesPrefs.framesShown=showFramesCheckBox->isChecked();
+	prefsData->guidesPrefs.layerMarkersShown=showLayerIndicatorsCheckBox->isChecked();
+	prefsData->displayPrefs.marginColored=showUnprintableAreaInMarginColorCheckBox->isChecked();
+	prefsData->guidesPrefs.showBleed=showBleedAreaCheckBox->isChecked();
+	prefsData->displayPrefs.showPageShadow=showPageShadowCheckBox->isChecked();
+	double unitRatio = unitGetRatioFromIndex(docUnitIndex);
+	prefsData->displayPrefs.scratch.Left=scratchSpaceLeftSpinBox->value()/unitRatio;
+	prefsData->displayPrefs.scratch.Right=scratchSpaceRightSpinBox->value()/unitRatio;
+	prefsData->displayPrefs.scratch.Top=scratchSpaceTopSpinBox->value()/unitRatio;
+	prefsData->displayPrefs.scratch.Bottom=scratchSpaceBottomSpinBox->value()/unitRatio;
+	prefsData->displayPrefs.pageGapHorizontal=pageGapHorizontalSpinBox->value();
+	prefsData->displayPrefs.pageGapVertical=pageGapVerticalSpinBox->value();
+
+	prefsData->displayPrefs.paperColor=colorPaper;
+	prefsData->displayPrefs.frameColor=colorFrame;
+	prefsData->displayPrefs.frameNormColor=colorFrameNorm;
+	prefsData->displayPrefs.frameGroupColor=colorFrameGroup;
+	prefsData->displayPrefs.frameLinkColor=colorFrameLinked;
+	prefsData->displayPrefs.frameLockColor=colorFrameLocked;
+	prefsData->displayPrefs.frameAnnotationColor=colorFrameAnnotation;
+	prefsData->displayPrefs.pageBorderColor=colorPageBorder;
+	prefsData->displayPrefs.controlCharColor=colorControlChars;
+	prefsData->displayPrefs.displayScale=displayScale;
+}
Index: scribus/ui/prefs_displaybase.ui
===================================================================
--- scribus/ui/prefs_displaybase.ui	(revision 14045)
+++ scribus/ui/prefs_displaybase.ui	(revision 14046)
@@ -44,9 +44,9 @@
       <property name="geometry">
        <rect>
         <x>0</x>
-        <y>-279</y>
+        <y>0</y>
         <width>678</width>
-        <height>1127</height>
+        <height>1143</height>
        </rect>
       </property>
       <layout class="QVBoxLayout" name="verticalLayout_5">
@@ -395,6 +395,22 @@
         </layout>
        </item>
        <item>
+        <spacer name="verticalSpacer_3">
+         <property name="orientation">
+          <enum>Qt::Vertical</enum>
+         </property>
+         <property name="sizeType">
+          <enum>QSizePolicy::Fixed</enum>
+         </property>
+         <property name="sizeHint" stdset="0">
+          <size>
+           <width>20</width>
+           <height>20</height>
+          </size>
+         </property>
+        </spacer>
+       </item>
+       <item>
         <widget class="QLabel" name="label_12">
          <property name="font">
           <font>
Index: scribus/ui/preferencesdialog.cpp
===================================================================
--- scribus/ui/preferencesdialog.cpp	(revision 14045)
+++ scribus/ui/preferencesdialog.cpp	(revision 14046)
@@ -79,17 +79,44 @@
 
 	connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
 	connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
+	connect(applyButton, SIGNAL(clicked()), this, SLOT(applyButtonClicked()));
 	connect(preferencesTypeList, SIGNAL(itemClicked(QListWidgetItem *)), this, SLOT(itemSelected(QListWidgetItem* )));
 
 	initPreferenceValues();
+	setupGui();
 
-	prefs_Display->restoreDefaults(&(prefsManager->appPrefs));
 }
 
+void PreferencesDialog::restoreDefaults()
+{
+	prefsManager->initDefaults();
+	setupGui();
+}
+
+void PreferencesDialog::initPreferenceValues()
+{
+	prefsManager=PrefsManager::instance();
+	localPrefs=prefsManager->appPrefs;
+	mainWin = (ScribusMainWindow*)parent();
+	docUnitIndex = localPrefs.docSetupPrefs.docUnitIndex;
+	unitRatio = unitGetRatioFromIndex(docUnitIndex);
+}
+
+void PreferencesDialog::setupGui()
+{
+	prefs_Display->restoreDefaults(&localPrefs);
+}
+
 PreferencesDialog::~PreferencesDialog()
 {
 }
 
+void PreferencesDialog::accept()
+{
+	saveGuiToPrefs();
+	QDialog::accept ();
+}
+
 void PreferencesDialog::setupListWidget()
 {
 	preferencesTypeList->setDragEnabled(false);
@@ -192,11 +219,15 @@
 	}*/
 }
 
-void PreferencesDialog::initPreferenceValues()
+void PreferencesDialog::applyButtonClicked()
 {
-	prefsManager=PrefsManager::instance();
-	ApplicationPrefs* prefsData=&(prefsManager->appPrefs);
-	mainWin = (ScribusMainWindow*)parent();
-	docUnitIndex = prefsData->docSetupPrefs.docUnitIndex;
-	unitRatio = unitGetRatioFromIndex(docUnitIndex);
+	Prefs_Pane* pp=qobject_cast<Prefs_Pane *>(prefsStackWidget->currentWidget());
+	if (pp)
+		pp->saveGuiToPrefs(&localPrefs);
 }
+
+void PreferencesDialog::saveGuiToPrefs()
+{
+	prefs_Display->saveGuiToPrefs(&localPrefs);
+}
+
Index: scribus/scribus.cpp
===================================================================
--- scribus/scribus.cpp	(revision 14045)
+++ scribus/scribus.cpp	(revision 14046)
@@ -7694,11 +7694,14 @@
 void ScribusMainWindow::slotPrefs150Org()
 {
 	slotSelect();
-
+	struct ApplicationPrefs oldPrefs(prefsManager->appPrefs);
 	PreferencesDialog prefsDialog(this);
 	if (prefsDialog.exec()==QDialog::Accepted)
-		qDebug()<<"New prefs window closed";
-//		prefsOrg(&prefsDialog);
+	{
+		struct ApplicationPrefs newPrefs(prefsDialog.prefs());
+		prefsManager->setNewPrefs(newPrefs);
+		prefsManager->SavePrefs();
+	}
 }
 
 void ScribusMainWindow::ShowSubs()
Index: scribus/CMakeLists.txt
===================================================================
--- scribus/CMakeLists.txt	(revision 14045)
+++ scribus/CMakeLists.txt	(revision 14046)
@@ -290,6 +290,7 @@
   ui/prefs_keyboardshortcuts.h
   ui/prefs_miscellaneous.h
   ui/prefs_paths.h
+  ui/prefs_pane.h
   ui/prefs_plugins.h
   ui/prefs_printer.h
   ui/prefs_scrapbook.h




More information about the scribus-commit mailing list