r14205 by cbradney - Start of work on new doc setup prefs pane

scribus-commit scribus-commit at lists.scribus.net
Wed Oct 21 00:15:23 CEST 2009


Revision: 14205
Author: cbradney
Date: 2009-10-20T19:31:24.236140Z
Commit message: Start of work on new doc setup prefs pane

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

Diffs:
Index: scribus/ui/prefs_documentsetup.h
===================================================================
--- scribus/ui/prefs_documentsetup.h	(revision 14204)
+++ scribus/ui/prefs_documentsetup.h	(revision 14205)
@@ -9,17 +9,30 @@
 #define PREFS_DOCUMENTSETUP_H
 
 #include "ui_prefs_documentsetupbase.h"
+#include "prefs_pane.h"
 #include "scribusapi.h"
 
-class SCRIBUS_API Prefs_DocumentSetup : public QWidget, Ui::Prefs_DocumentSetup
+class SCRIBUS_API Prefs_DocumentSetup : public Prefs_Pane, Ui::Prefs_DocumentSetup
 {
 	Q_OBJECT
 
 	public:
 		Prefs_DocumentSetup(QWidget* parent=0);
 		~Prefs_DocumentSetup();
+		virtual void restoreDefaults(struct ApplicationPrefs *prefsData);
+		virtual void saveGuiToPrefs(struct ApplicationPrefs *prefsData) const;
 
-//		setValues();
+	public slots:
+		void languageChange();
+
+	private:
+		void unitChange();
+		double unitRatio;
+		int choosenLayout;
+		double pageW;
+		double pageH;
+		QString prefsPageSizeName;
 };
 
 #endif // PREFS_DOCUMENTSETUP_H
+
Index: scribus/ui/prefs_documentsetup.cpp
===================================================================
--- scribus/ui/prefs_documentsetup.cpp	(revision 14204)
+++ scribus/ui/prefs_documentsetup.cpp	(revision 14205)
@@ -6,15 +6,99 @@
 */
 
 #include "prefs_documentsetup.h"
+#include "commonstrings.h"
+#include "pagesize.h"
+#include "prefsstructs.h"
+#include "units.h"
+#include "util.h"
 
 Prefs_DocumentSetup::Prefs_DocumentSetup(QWidget* parent)
-	: QWidget(parent)
+	: Prefs_Pane(parent)
 {
 	setupUi(this);
-
+	pageWidthSpinBox->setMaximum(16777215);
+	pageHeightSpinBox->setMaximum(16777215);
+	languageChange();
 }
 
 Prefs_DocumentSetup::~Prefs_DocumentSetup()
 {
 }
 
+void Prefs_DocumentSetup::unitChange()
+{
+	int docUnitIndex = pageUnitsComboBox->currentIndex();
+	pageWidthSpinBox->setNewUnit(docUnitIndex);
+	pageHeightSpinBox->setNewUnit(docUnitIndex);
+	unitRatio = unitGetRatioFromIndex(docUnitIndex);
+	pageWidthSpinBox->setValue(pageW * unitRatio);
+	pageHeightSpinBox->setValue(pageH * unitRatio);
+}
+
+void Prefs_DocumentSetup::languageChange()
+{
+	int i=0;
+
+	pageOrientationComboBox->currentIndex();
+	pageOrientationComboBox->clear();
+	pageOrientationComboBox->addItem( tr( "Portrait" ) );
+	pageOrientationComboBox->addItem( tr( "Landscape" ) );
+	pageOrientationComboBox->setCurrentIndex(i<0?0:i);
+
+	i=pageUnitsComboBox->currentIndex();
+	pageUnitsComboBox->clear();
+	pageUnitsComboBox->addItems(unitGetTextUnitList());
+	pageUnitsComboBox->setCurrentIndex(i<0?0:i);
+}
+
+void Prefs_DocumentSetup::restoreDefaults(struct ApplicationPrefs *prefsData)
+{
+	unitRatio = unitGetRatioFromIndex(prefsData->docSetupPrefs.docUnitIndex);
+	prefsPageSizeName = prefsData->docSetupPrefs.pageSize;
+	PageSize *ps=new PageSize(prefsPageSizeName);
+	pageSizeComboBox->addItems(ps->sizeTRList());
+	pageSizeComboBox->addItem( CommonStrings::trCustomPageSize );
+	if (prefsData->docSetupPrefs.pageSize == CommonStrings::customPageSize)
+		setCurrentComboItem(pageSizeComboBox, CommonStrings::trCustomPageSize);
+	else
+		setCurrentComboItem(pageSizeComboBox, prefsPageSizeName);
+
+	pageOrientationComboBox->setCurrentIndex(prefsData->docSetupPrefs.pageOrientation);
+	pageUnitsComboBox->setCurrentIndex(prefsData->docSetupPrefs.docUnitIndex);
+	pageW = prefsData->docSetupPrefs.pageWidth;
+	pageH = prefsData->docSetupPrefs.pageHeight;
+	pageWidthSpinBox->setValue(pageW * unitRatio);
+	pageHeightSpinBox->setValue(pageH * unitRatio);
+
+	/*
+	docLayout->selectItem(prefsData->docSetupPrefs.pagePositioning);
+	docLayout->firstPage->setCurrentIndex(prefsData->pageSets[prefsData->docSetupPrefs.pagePositioning].FirstPage);
+
+
+	marginGroup->setNewMargins(prefsData->docSetupPrefs.margins);
+	marginGroup->setPageWidthHeight(prefsData->docSetupPrefs.pageWidth, prefsData->docSetupPrefs.pageHeight);
+	marginGroup->setPageSize(prefsPageSizeName);
+	marginGroup->setNewBleeds(prefsData->docSetupPrefs.bleeds);
+	marginGroup->setMarginPreset(prefsData->docSetupPrefs.marginPreset);
+	GroupAS->setChecked( prefsData->docSetupPrefs.AutoSave );
+	ASTime->setValue(prefsData->docSetupPrefs.AutoSaveTime / 1000 / 60);
+	connect(pageWidth, SIGNAL(valueChanged(double)), this, SLOT(setPageWidth(double)));
+	connect(pageHeight, SIGNAL(valueChanged(double)), this, SLOT(setPageHeight(double)));
+	connect(pageOrientationComboBox, SIGNAL(activated(int)), this, SLOT(setOrien(int)));
+	connect(pageSizeComboBox, SIGNAL(activated(const QString &)), this, SLOT(setPageSize()));
+	*/
+	unitChange();
+}
+
+void Prefs_DocumentSetup::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
+{
+	/*
+	pageSizeComboBox
+			pageOrientationComboBox
+			pageUnitsComboBox
+			pageWidthSpinBox
+			pageHeightSpinBox
+			*/
+}
+
+
Index: scribus/ui/preferencesdialog.cpp
===================================================================
--- scribus/ui/preferencesdialog.cpp	(revision 14204)
+++ scribus/ui/preferencesdialog.cpp	(revision 14205)
@@ -106,6 +106,7 @@
 {
 	prefs_UserInterface->restoreDefaults(&localPrefs);
 	prefs_Paths->restoreDefaults(&localPrefs);
+	prefs_DocumentSetup->restoreDefaults(&localPrefs);
 	prefs_Scrapbook->restoreDefaults(&localPrefs);
 	prefs_Display->restoreDefaults(&localPrefs);
 }
@@ -238,6 +239,7 @@
 {
 	prefs_UserInterface->saveGuiToPrefs(&localPrefs);
 	prefs_Paths->saveGuiToPrefs(&localPrefs);
+	prefs_DocumentSetup->saveGuiToPrefs(&localPrefs);
 	prefs_Scrapbook->saveGuiToPrefs(&localPrefs);
 	prefs_Display->saveGuiToPrefs(&localPrefs);
 }




More information about the scribus-commit mailing list