r19584 by jghali - #12772: fix five references to uninitialized variables

scribus-commit scribus-commit at lists.scribus.net
Mon Oct 13 23:53:42 UTC 2014


Author: jghali
Date: Mon Oct 13 23:53:42 2014
New Revision: 19584

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=19584
Log:
#12772: fix five references to uninitialized variables

Modified:
    trunk/Scribus/scribus/prefsmanager.cpp
    trunk/Scribus/scribus/prefsstructs.h
    trunk/Scribus/scribus/scribuscore.cpp
    trunk/Scribus/scribus/scribusview.cpp
    trunk/Scribus/scribus/ui/aligndistribute.cpp
    trunk/Scribus/scribus/ui/fontcombo.cpp
    trunk/Scribus/scribus/ui/notesstyleseditor.cpp

Modified: trunk/Scribus/scribus/prefsmanager.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19584&path=/trunk/Scribus/scribus/prefsmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/prefsmanager.cpp (original)
+++ trunk/Scribus/scribus/prefsmanager.cpp Mon Oct 13 23:53:42 2014
@@ -155,7 +155,9 @@
 	ColorSetManager csm;
 	csm.initialiseDefaultPrefs(appPrefs);
 
+	appPrefs.uiPrefs.mouseMoveTimeout = 150;
 	appPrefs.uiPrefs.wheelJump = 40;
+	appPrefs.uiPrefs.style = "";
 	/** Set Default window position and size to sane default values which should work on every screen */
 //	appPrefs.uiPrefs.mainWinSettings.xPosition = 0;
 //	appPrefs.uiPrefs.mainWinSettings.yPosition = 0;
@@ -166,6 +168,14 @@
 	appPrefs.uiPrefs.mainWinSettings.yPosition=(d->availableGeometry().height()-appPrefs.uiPrefs.mainWinSettings.height)/2;
 	appPrefs.uiPrefs.mainWinSettings.maximized = false;
 	appPrefs.uiPrefs.mainWinState = QByteArray();
+	appPrefs.uiPrefs.RecentDocs.clear();
+	appPrefs.uiPrefs.recentDocCount = 5;
+	appPrefs.uiPrefs.showStartupDialog = true;
+	appPrefs.uiPrefs.showSplashOnStartup = true;
+	appPrefs.uiPrefs.useSmallWidgets = false;
+	appPrefs.uiPrefs.useTabs = false;
+	appPrefs.uiPrefs.stickyTools = false;
+	appPrefs.uiPrefs.grayscaleIcons = false;
 	appPrefs.guidesPrefs.marginsShown = true;
 	appPrefs.guidesPrefs.framesShown = true;
 	appPrefs.guidesPrefs.layerMarkersShown = false;
@@ -202,12 +212,8 @@
 	appPrefs.typoPrefs.valueStrikeThruWidth = -1;
 	appPrefs.guidesPrefs.valueBaselineGrid = 14.4;
 	appPrefs.guidesPrefs.offsetBaselineGrid = 0.0;
-	appPrefs.uiPrefs.style = "";
-	appPrefs.uiPrefs.grayscaleIcons = false; // can be a little slower on startup.. but its a nice effect to play with
 	appPrefs.displayPrefs.showToolTips = true;
 	appPrefs.displayPrefs.showMouseCoordinates = true;
-	appPrefs.uiPrefs.mouseMoveTimeout = 150;
-	appPrefs.uiPrefs.stickyTools = false;
 	//FIXME
 	//Black here causes issues when a colour set is loaded without "Black" in it.
 	//"Black" is created with wrong values. Eg SVG colour set
@@ -292,9 +298,7 @@
 //	appPrefs.PSize = 40;
 	appPrefs.printerPrefs.ClipMargin = false;
 	appPrefs.printerPrefs.GCRMode = false;
-	appPrefs.uiPrefs.RecentDocs.clear();
 	appPrefs.scrapbookPrefs.RecentScrapbooks.clear();
-	appPrefs.uiPrefs.recentDocCount = 5;
 	appPrefs.scrapbookPrefs.doCopyToScrapbook = true;
 	appPrefs.scrapbookPrefs.persistentScrapbook = false;
 	appPrefs.scrapbookPrefs.writePreviews = true;
@@ -414,10 +418,6 @@
 	// lorem ipsum defaults
 	appPrefs.miscPrefs.useStandardLI = false;
 	appPrefs.miscPrefs.paragraphsLI = 10;
-	appPrefs.uiPrefs.showStartupDialog = true;
-	appPrefs.uiPrefs.showSplashOnStartup = true;
-	appPrefs.uiPrefs.useSmallWidgets = false;
-	appPrefs.uiPrefs.useTabs = false;
 	initDefaultCheckerPrefs(&appPrefs.verifierPrefs.checkerPrefsList);
 	appPrefs.verifierPrefs.curCheckProfile = CommonStrings::PostScript;
 	appPrefs.verifierPrefs.showPagesWithoutErrors=false;

Modified: trunk/Scribus/scribus/prefsstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19584&path=/trunk/Scribus/scribus/prefsstructs.h
==============================================================================
--- trunk/Scribus/scribus/prefsstructs.h (original)
+++ trunk/Scribus/scribus/prefsstructs.h Mon Oct 13 23:53:42 2014
@@ -92,6 +92,16 @@
 
 struct WindowPrefs
 {
+	WindowPrefs() {
+		xPosition = 0;
+		yPosition = 0;
+		width   = 640;
+		height  = 480;
+		visible = true;
+		docked  = false;
+		maximized = false;
+	}
+
 	int xPosition;
 	int yPosition;
 	int width;
@@ -104,6 +114,20 @@
 //User Interface
 struct UIPrefs
 {
+	UIPrefs() {
+		mouseMoveTimeout = 150;
+		wheelJump = 40;
+		applicationFontSize = 12;
+		paletteFontSize = 10;
+		recentDocCount = 5;
+		useSmallWidgets = false;
+		useTabs = false;
+		showStartupDialog = true;
+		showSplashOnStartup = true;
+		stickyTools = false;
+		grayscaleIcons = false;
+	}
+
 	int mouseMoveTimeout; //! Mouse move timeout for move/resize operations
 	int wheelJump; //! Distance to jump with mouse wheel scrolling
 	int applicationFontSize; //! Font size to use in the application, apart from pßalettes

Modified: trunk/Scribus/scribus/scribuscore.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19584&path=/trunk/Scribus/scribus/scribuscore.cpp
==============================================================================
--- trunk/Scribus/scribus/scribuscore.cpp (original)
+++ trunk/Scribus/scribus/scribuscore.cpp Mon Oct 13 23:53:42 2014
@@ -154,7 +154,7 @@
 {
 	CommonStrings::languageChange();
 	int retVal=0;
-//FIXME	ExternalApp = 0;
+	// FIXME: Splash needs the prefs loaded by initDefaults() to know if it must force the image to grayscale
 	initSplash(showSplash);
 	LocaleManager::instance();
 	prefsManager = PrefsManager::instance();

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19584&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Mon Oct 13 23:53:42 2014
@@ -156,6 +156,7 @@
 	Ready(false),
 	oldX(0), oldY(0),
 	m_groupTransactions(0),
+	m_oldCanvasHeight(0), m_oldCanvasWidth(0),
 	m_groupTransaction(),
 	_isGlobalMode(true),
 	linkAfterDraw(false),

Modified: trunk/Scribus/scribus/ui/aligndistribute.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19584&path=/trunk/Scribus/scribus/ui/aligndistribute.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/aligndistribute.cpp (original)
+++ trunk/Scribus/scribus/ui/aligndistribute.cpp Mon Oct 13 23:53:42 2014
@@ -54,6 +54,7 @@
 	setupUi(this);
 	setSizePolicy( QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
 	currDoc=NULL;
+	guideDirection=-1;
 	setObjectName(name);
 	
 	//hide spare controls 

Modified: trunk/Scribus/scribus/ui/fontcombo.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19584&path=/trunk/Scribus/scribus/ui/fontcombo.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/fontcombo.cpp (original)
+++ trunk/Scribus/scribus/ui/fontcombo.cpp Mon Oct 13 23:53:42 2014
@@ -101,6 +101,7 @@
 		fontStyleLabel(0),
 		showLabels(labels)
 {
+	currDoc = NULL;
 	prefsManager = PrefsManager::instance();
 	ttfFont = loadIcon("font_truetype16.png");
 	otfFont = loadIcon("font_otf16.png");

Modified: trunk/Scribus/scribus/ui/notesstyleseditor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=19584&path=/trunk/Scribus/scribus/ui/notesstyleseditor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/notesstyleseditor.cpp (original)
+++ trunk/Scribus/scribus/ui/notesstyleseditor.cpp Mon Oct 13 23:53:42 2014
@@ -1,599 +1,599 @@
-#include <QMessageBox>
-
-#include "notesstyleseditor.h"
-#include "pageitem_noteframe.h"
-#include "prefsmanager.h"
-#include "prefsfile.h"
-#include "scribusdoc.h"
-
-#include "scribus.h"
-#include "undomanager.h"
-#include "util.h"
-
-NotesStylesEditor::NotesStylesEditor(QWidget *parent, const char *name)
-	: ScrPaletteBase(parent, name), m_Doc(NULL)
-{
-	setupUi(this);
-	QString pname(name);
-	if (pname.isEmpty())
-		pname = "notesStylesEditor";
-	m_prefs = PrefsManager::instance()->prefsFile->getContext(pname);
-
-	setBlockSignals(true);
-	
-	setDoc(0);
-	languageChange();
-	NSlistBox->setInsertPolicy(QComboBox::InsertAlphabetically);
-
-	NumberingBox->addItem("1 2 3");
-	NumberingBox->addItem("i ii iii");
-	NumberingBox->addItem("I II III");
-	NumberingBox->addItem("a b c");
-	NumberingBox->addItem("A B C");
-	NumberingBox->addItem("*");
-
-	RangeBox->addItem(tr("Document"));
-	RangeBox->addItem(tr("Section"));
-	RangeBox->addItem(tr("Story"));
-	RangeBox->addItem(tr("Page"));
-	RangeBox->addItem(tr("Frame"));
-
-	StartSpinBox->setMinimum(1);
-	StartSpinBox->setMaximum(99999);
-	changesMap.clear();
-	addNewNsMode = false;
-
-	setBlockSignals(isVisible());
-}
-
-NotesStylesEditor::~NotesStylesEditor()
-{
-	storeVisibility(this->isVisible());
-	storePosition();
-	storeSize();
-}
-
-void NotesStylesEditor::languageChange()
-{
-	bool wasSignalsBlocked = signalsBlocked();
-	setBlockSignals(true);
-
-	if (addNewNsMode)
-	{
-		OKButton->setText(tr("Cancel"));
-		OKButton->setToolTip(tr("Dialog is in adding new notes style mode. After pressing Cancel button dialog will be switched into normal notes styles edit mode."));
-		ApplyButton->setText(tr("Add Style"));
-	}
-	else
-	{
-		OKButton->setText("OK");
-		OKButton->setToolTip("");
-		ApplyButton->setText(tr("Apply"));
-	}
-	NewButton->setText(tr("Add New Style"));
-    NewButton->setToolTip(tr("New notes style will be add to document only after pressing Apply button.\nYou cannot switch to different notes style before you apply that new one or press Cancel button and exit from adding mode."));
-	NewNameLabel->setText(tr("New Style Name"));
-	FootRadio->setText(tr("Footnotes"));
-	EndRadio->setText(tr("Endnotes"));
-	NumberingLabel->setText(tr("Numbering"));
-	RangeLabel->setText(tr("Range"));
-	StartLabel->setText(tr("Start Number"));
-	PrefixLabel->setText(tr("Prefix"));
-	SuffixLabel->setText(tr("Suffix"));
-	SuperMasterLabel->setText(tr("Superscript in text"));
-	SuperNoteLabel->setText(tr("Superscript in notes"));
-	charStyleComboLabel->setText(tr("Mark Character Style"));
-	paraStyleComboLabel->setText(tr("Note Paragraph Style"));
-	AutoHLabel->setText(tr("Auto Height"));
-	AutoWLabel->setText(tr("Auto Width"));
-	AutoWeldLabel->setText(tr("Auto Welding"));
-	AutoRemoveLabel->setText(tr("Remove if empty"));
-	DeleteButton->setText(tr("Delete"));
-	setBlockSignals(wasSignalsBlocked);
-}
-
-void NotesStylesEditor::setDoc(ScribusDoc *doc)
-{
-	bool wasSignalsBlocked = signalsBlocked();
-	setBlockSignals(true);
-	if (m_Doc != NULL)
-		disconnect(m_Doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
-	m_Doc = doc;
-	paraStyleCombo->setDoc(m_Doc);
-	charStyleCombo->setDoc(m_Doc);
-	if (m_Doc != NULL)
-	{
-		updateNSList();
-		NSlistBox->setCurrentIndex(0);
-		readNotesStyle(NSlistBox->currentText());
-		setEnabled(true);
-		ApplyButton->setEnabled(false);
-		connect(m_Doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
-	}
-	else
-	{
-		changesMap.clear();
-		NewNameEdit->clear();
-		setEnabled(false);
-	}
-	setBlockSignals(wasSignalsBlocked);
-}
-
-void NotesStylesEditor::handleUpdateRequest(int updateFlags)
-{
-	bool wasSignalsBlocked = signalsBlocked();
-	setBlockSignals(true);
-	if ((updateFlags & reqCharStylesUpdate) || (updateFlags & reqTextStylesUpdate))
-		charStyleCombo->updateFormatList();
-	if ((updateFlags & reqParaStylesUpdate) || (updateFlags & reqTextStylesUpdate))
-		paraStyleCombo->updateFormatList();
-	readNotesStyle(NSlistBox->currentText());
-	setBlockSignals(wasSignalsBlocked);
-}
-
-void NotesStylesEditor::updateNSList()
-{
-	bool wasSignalsBlocked = signalsBlocked();
-	NSlistBox->blockSignals(true);
-	if (m_Doc == NULL)
-		NSlistBox->setEnabled(false);
-	else
-	{
-		NSlistBox->clear();
-		changesMap.clear();
-		for (int a = 0; a < m_Doc->m_docNotesStylesList.count(); ++a)
-		{
-			NSlistBox->addItem(m_Doc->m_docNotesStylesList.at(a)->name());
-			changesMap.insert(m_Doc->m_docNotesStylesList.at(a)->name(), *(m_Doc->m_docNotesStylesList.at(a)));
-		}
-		if (!m_Doc->m_docNotesStylesList.isEmpty())
-			NSlistBox->setEnabled(true);
-		if (NSlistBox->currentText() != tr("default"))
-			DeleteButton->setEnabled(true);
-		else
-			DeleteButton->setEnabled(false);
-	}
-	NSlistBox->blockSignals(wasSignalsBlocked);
-	
-	DeleteButton->setEnabled(NSlistBox->currentText() != tr("default"));
-}
-
-void NotesStylesEditor::setBlockSignals(bool block)
-{
-	foreach (QWidget* obj, findChildren<QWidget *>())
-	{
-		obj->blockSignals(block);
-	}
-	paraStyleCombo->blockSignals(block);
-	charStyleCombo->blockSignals(block);
-}
-
-void NotesStylesEditor::setNotesStyle(NotesStyle * NS)
-{
-	if (NS == NULL)
-		return;
-	bool wasSignalsBlocked = signalsBlocked();
-	setBlockSignals(true);
-	NSlistBox->setCurrentIndex(NSlistBox->findText(NS->name()));
-	NewNameEdit->setText(NS->name());
-	if (NS->name() == tr("default"))
-		NewNameEdit->setEnabled(false);
-	else
-		NewNameEdit->setEnabled(true);
-	FootRadio->setChecked(!NS->isEndNotes());
-	if (NS->range() == NSRframe)
-		EndRadio->setEnabled(false);
-	else
-		EndRadio->setEnabled(true);
-	EndRadio->setChecked(NS->isEndNotes());
-	NumberingBox->setCurrentIndex((int) NS->getType());
-	RangeBox->setCurrentIndex((int) NS->range());
-	StartSpinBox->setValue(NS->start());
-	PrefixEdit->setText(NS->prefix());
-	SuffixEdit->setText(NS->suffix());
-	SuperMasterCheck->setChecked(NS->isSuperscriptInMaster());
-	SuperNoteCheck->setChecked(NS->isSuperscriptInNote());
-	if (!NS->notesParStyle().isEmpty() && (NS->notesParStyle() != tr("No Style")))
-		paraStyleCombo->setCurrentIndex(paraStyleCombo->findText(NS->notesParStyle()));
-	if (!NS->marksChStyle().isEmpty() && (NS->marksChStyle() != tr("No Style")))
-		charStyleCombo->setCurrentIndex(charStyleCombo->findText(NS->marksChStyle()));
-	AutoH->setChecked(NS->isAutoNotesHeight());
-	AutoW->setChecked(NS->isAutoNotesWidth());
-	AutoWeld->setChecked(NS->isAutoWeldNotesFrames());
-	//for endnotes remove FRAME range (same effect as footnotes for frame)
-	//and disable autofixing size of notes frames
-	int rangeFrameIndex = RangeBox->findText(tr("Frame"));
-	if (NS->isEndNotes())
-	{
-		AutoW->setEnabled(false);
-		AutoWeld->setEnabled(false);
-		if (rangeFrameIndex >= 0)
-			RangeBox->removeItem(rangeFrameIndex);
-}
-	else
-	{
-		AutoW->setEnabled(true);
-		AutoWeld->setEnabled(true);
-		if (rangeFrameIndex == -1)
-			RangeBox->addItem(tr("Frame"));
-	}
-	AutoRemove->setChecked(NS->isAutoRemoveEmptyNotesFrames());
-
-	ApplyButton->setEnabled(false);
-	setBlockSignals(wasSignalsBlocked);
-}
-
-void NotesStylesEditor::readNotesStyle(QString nsName)
-{
-	NotesStyle * NS = m_Doc->getNotesStyle(nsName);
-	setNotesStyle(NS);
-}
-
-void NotesStylesEditor::on_NSlistBox_currentIndexChanged(const QString &arg1)
-{
-	if (arg1 != tr("default"))
-		DeleteButton->setEnabled(true);
-	else
-		DeleteButton->setEnabled(false);
-	readNotesStyle(arg1);
-}
-
-void NotesStylesEditor::on_ApplyButton_clicked()
-{
-	if (addNewNsMode)
-	{
-		QString newName = NSlistBox->currentText();
-		NotesStyle newNS = changesMap.value(newName);
-		if (m_Doc->validateNSet(newNS))
-		{
-			addNewNsMode = false;
-			OKButton->setText(tr("OK"));
-			OKButton->setToolTip("");
-			ApplyButton->setText(tr("Apply"));
-			m_Doc->newNotesStyle(newNS);
-			updateNSList();
-			NSlistBox->setCurrentIndex(NSlistBox->findText(newNS.name()));
-		}
-		else
-			return;
-	}
-	else
-	{
-		//remeber current NStyle
-		QString currNS = NSlistBox->currentText();
-		NotesStyle* NS = NULL;
-		
-		foreach (const QString &nsName, changesMap.keys())
-		{
-			NotesStyle n = changesMap.value(nsName);
-
-			//validate settings
-			if (!m_Doc->validateNSet(n))
-			{
-				NSlistBox->setCurrentIndex(NSlistBox->findText(n.name()));
-				break;
-			}
-			//rename
-			if (nsName != n.name())
-			{
-				//new name for existing set
-				QString newName = n.name();
-				getUniqueName(newName, changesMap.keys(),"=");
-				n.setName(newName);
-				NewNameEdit->setText(newName);
-				//current NSet name change
-				if (currNS == nsName)
-					currNS = newName;
-				NS = m_Doc->getNotesStyle(nsName);
-				m_Doc->renameNotesStyle(NS, newName);
-				m_Doc->setNotesChanged(true);
-			}
-			//change settings and update marks
-			NS = m_Doc->getNotesStyle(n.name());
-			Q_ASSERT(NS != NULL);
-			if (*NS != n)
-			{
-				SimpleState* ss = NULL;
-				if (UndoManager::instance()->undoEnabled())
-				{
-					ss = new SimpleState(UndoManager::EditNotesStyle);
-					ss->set("NSTYLE", QString("edit"));
-					m_Doc->undoSetNotesStyle(ss, NS);
-				}
-				//converting foot <--> end notes or changing footnotes range
-				if ((NS->isEndNotes() != n.isEndNotes()) || (NS->isEndNotes() && n.isEndNotes() && NS->range() != n.range()))
-				{
-					foreach (PageItem_NoteFrame* nF, m_Doc->listNotesFrames(NS))
-						m_Doc->delNoteFrame(nF, false);
-					if (n.isEndNotes())
-						m_Doc->flag_updateEndNotes = true;
-				}
-				m_Doc->setNotesChanged(true); //notesframes width must be updated
-				*NS = n;
-				if (ss)
-				{
-					ss->set("NEWname", NS->name());
-					ss->set("NEWstart", NS->start());
-					ss->set("NEWendNotes", NS->isEndNotes());
-					ss->set("NEWnumFormat", (int) NS->getType());
-					ss->set("NEWrange", (int) NS->range());
-					ss->set("NEWprefix", NS->prefix());
-					ss->set("NEWsuffix", NS->suffix());
-					ss->set("NEWautoH", NS->isAutoNotesHeight());
-					ss->set("NEWautoW", NS->isAutoNotesWidth());
-					ss->set("NEWautoWeld", NS->isAutoWeldNotesFrames());
-					ss->set("NEWautoRemove", NS->isAutoRemoveEmptyNotesFrames());
-					ss->set("NEWsuperMaster", NS->isSuperscriptInMaster());
-					ss->set("NEWsuperNote", NS->isSuperscriptInNote());
-					ss->set("NEWmarksChStyle", NS->marksChStyle());
-					ss->set("NEWnotesParStyle", NS->notesParStyle());
-					UndoManager::instance()->action(m_Doc, ss);
-				}
-				//invalidate all text frames with marks from current changed notes style
-				foreach (PageItem* item, m_Doc->DocItems)
-				{
-					if (item->isTextFrame() && !item->isNoteFrame() && item->asTextFrame()->hasNoteMark(NS))
-						item->invalid = true;
-				}
-				m_Doc->updateNotesNums(NS);
-				m_Doc->updateNotesFramesSettings(NS);
-				if (m_Doc->flag_updateEndNotes)
-					m_Doc->updateEndnotesFrames(NS);
-				m_Doc->updateNotesFramesStyles(NS);
-			}
-		}
-		if (m_Doc->notesChanged())
-		{
-			updateNSList();
-			m_Doc->flag_updateMarksLabels = true;
-			m_Doc->changed();
-			m_Doc->regionsChanged()->update(QRectF());
-		}
-		//restore NStyle index
-		readNotesStyle(currNS);
-	}
-
-	ApplyButton->setEnabled(false);
-	NSlistBox->setEnabled(true);
-	NewButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_DeleteButton_clicked()
-{
-	QString nsName = NSlistBox->currentText();
-	int t = QMessageBox::warning(m_Doc->scMW(), tr("Warning! Deleting Notes Style"), "<qt>" +
-								 tr("You are going to delete notes style %1. All notes and marks using that style are also going to be deleted.").arg(nsName) + "</qt>",
-								 QMessageBox::Ok, QMessageBox::Abort | QMessageBox::Default);
-	if (t == QMessageBox::Ok)
-	{
-		m_Doc->deleteNotesStyle(nsName);
-		m_Doc->changed();
-		m_Doc->regionsChanged()->update(QRectF());
-		setDoc(m_Doc);
-	}
-}
-
-void NotesStylesEditor::on_NewButton_clicked()
-{
-	QString oldName = NSlistBox->currentText();
-	NotesStyle newNS = changesMap.value(oldName);
-	QString newName = oldName;
-	getUniqueName(newName, changesMap.keys(), "_");
-	newNS.setName(newName);
-	changesMap.insert(newName, newNS);
-	setNotesStyle(&newNS);
-	
-	NewNameEdit->setEnabled(true);
-	NSlistBox->addItem(newName);
-	NSlistBox->setCurrentIndex(NSlistBox->findText(newName));
-	NSlistBox->setEnabled(false);
-	ApplyButton->setText(tr("Add Style"));
-	ApplyButton->setEnabled(true);
-	DeleteButton->setEnabled(false);
-	NewButton->setEnabled(false);
-	addNewNsMode = true;
-	OKButton->setText(tr("Cancel Adding"));
-	OKButton->setToolTip(tr("Notes Styles Editor is in adding new notes style mode. After pressing Cancel button Notes Styles Editor switch into normal notes styles edit mode."));
-}
-
-void NotesStylesEditor::on_OKButton_clicked()
-{
-	if (OKButton->text() != tr("OK"))
-	{
-		//in adding new style mode go back to normal editing mode
-		OKButton->setText(tr("OK"));
-		NewButton->setEnabled(true);
-		addNewNsMode = false;
-		QString newName = NSlistBox->currentText();
-		changesMap.remove(newName);
-		int index = NSlistBox->findText(newName);
-		NSlistBox->removeItem(index);
-		NSlistBox->setCurrentIndex(index-1);
-		on_NSlistBox_currentIndexChanged(NSlistBox->currentText());
-	}
-	else
-	{
-		if (ApplyButton->isEnabled())
-			//apply changes
-			on_ApplyButton_clicked();
-
-		//in normal mode close
-		close();
-	}
-}
-
-void NotesStylesEditor::on_NewNameEdit_textChanged(const QString &arg1)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setName(arg1);
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_FootRadio_toggled(bool checked)
-{
-	bool wasSignalsBlocked = signalsBlocked();
-	setBlockSignals(true);
-
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setEndNotes(!checked);
-	changesMap.insert(NSlistBox->currentText(), ns);
-	EndRadio->setChecked(!checked);
-	if (checked)
-	{
-		ns.setAutoNotesWidth(true);
-		AutoW->setEnabled(true);
-		AutoW->setChecked(true);
-		ns.setAutoWeldNotesFrames(true);
-		AutoWeld->setEnabled(true);
-		AutoWeld->setChecked(true);
-	}
-	
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-	setBlockSignals(wasSignalsBlocked);
-}
-
-void NotesStylesEditor::on_EndRadio_toggled(bool checked)
-{
-	bool wasSignalsBlocked = signalsBlocked();
-	setBlockSignals(true);
-
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setEndNotes(checked);
-	FootRadio->setChecked(!checked);
-	if (checked)
-	{
-		ns.setAutoNotesWidth(false);
-		AutoW->setChecked(false);
-		AutoW->setEnabled(false);
-		ns.setAutoWeldNotesFrames(false);
-		AutoWeld->setChecked(false);
-		AutoWeld->setEnabled(false);
-	}
-	
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-	setBlockSignals(wasSignalsBlocked);
-}
-
-void NotesStylesEditor::on_NumberingBox_currentIndexChanged(int index)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setType((NumFormat) index);
-
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_RangeBox_currentIndexChanged(int index)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setRange((NumerationRange) index);
-
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_StartSpinBox_valueChanged(int arg1)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setStart(arg1);
-
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_PrefixEdit_textChanged(const QString &arg1)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setPrefix(arg1);
-
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_SuffixEdit_textChanged(const QString &arg1)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setSuffix(arg1);
-
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_SuperMasterCheck_toggled(bool checked)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setSuperscriptInMaster(checked);
-
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_SuperNoteCheck_toggled(bool checked)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setSuperscriptInNote(checked);
-
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_AutoH_toggled(bool checked)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setAutoNotesHeight(checked);
-
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_AutoW_toggled(bool checked)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setAutoNotesWidth(checked);
-
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_AutoWeld_toggled(bool checked)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setAutoWeldNotesFrames(checked);
-
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_AutoRemove_toggled(bool checked)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	ns.setAutoRemoveEmptyNotesFrames(checked);
-
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_paraStyleCombo_currentIndexChanged(const int &arg1)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	if (arg1 == 0)
-		ns.setNotesParStyle("");
-	else
-		ns.setNotesParStyle(paraStyleCombo->itemText(arg1));
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
-
-void NotesStylesEditor::on_charStyleCombo_currentIndexChanged(const int &arg1)
-{
-	NotesStyle ns = changesMap.value(NSlistBox->currentText());
-	if (arg1 == 0)
-		ns.setMarksCharStyle("");
-	else
-		ns.setMarksCharStyle(charStyleCombo->itemText(arg1));
-	changesMap.insert(NSlistBox->currentText(), ns);
-	ApplyButton->setEnabled(true);
-}
+#include <QMessageBox>
+
+#include "notesstyleseditor.h"
+#include "pageitem_noteframe.h"
+#include "prefsmanager.h"
+#include "prefsfile.h"
+#include "scribusdoc.h"
+
+#include "scribus.h"
+#include "undomanager.h"
+#include "util.h"
+
+NotesStylesEditor::NotesStylesEditor(QWidget *parent, const char *name)
+	: ScrPaletteBase(parent, name), m_Doc(NULL)
+{
+	setupUi(this);
+	QString pname(name);
+	if (pname.isEmpty())
+		pname = "notesStylesEditor";
+	m_prefs = PrefsManager::instance()->prefsFile->getContext(pname);
+
+	setBlockSignals(true);
+	
+	addNewNsMode = false;
+	setDoc(0);
+	languageChange();
+	NSlistBox->setInsertPolicy(QComboBox::InsertAlphabetically);
+
+	NumberingBox->addItem("1 2 3");
+	NumberingBox->addItem("i ii iii");
+	NumberingBox->addItem("I II III");
+	NumberingBox->addItem("a b c");
+	NumberingBox->addItem("A B C");
+	NumberingBox->addItem("*");
+
+	RangeBox->addItem(tr("Document"));
+	RangeBox->addItem(tr("Section"));
+	RangeBox->addItem(tr("Story"));
+	RangeBox->addItem(tr("Page"));
+	RangeBox->addItem(tr("Frame"));
+
+	StartSpinBox->setMinimum(1);
+	StartSpinBox->setMaximum(99999);
+	changesMap.clear();
+
+	setBlockSignals(isVisible());
+}
+
+NotesStylesEditor::~NotesStylesEditor()
+{
+	storeVisibility(this->isVisible());
+	storePosition();
+	storeSize();
+}
+
+void NotesStylesEditor::languageChange()
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+
+	if (addNewNsMode)
+	{
+		OKButton->setText(tr("Cancel"));
+		OKButton->setToolTip(tr("Dialog is in adding new notes style mode. After pressing Cancel button dialog will be switched into normal notes styles edit mode."));
+		ApplyButton->setText(tr("Add Style"));
+	}
+	else
+	{
+		OKButton->setText("OK");
+		OKButton->setToolTip("");
+		ApplyButton->setText(tr("Apply"));
+	}
+	NewButton->setText(tr("Add New Style"));
+    NewButton->setToolTip(tr("New notes style will be add to document only after pressing Apply button.\nYou cannot switch to different notes style before you apply that new one or press Cancel button and exit from adding mode."));
+	NewNameLabel->setText(tr("New Style Name"));
+	FootRadio->setText(tr("Footnotes"));
+	EndRadio->setText(tr("Endnotes"));
+	NumberingLabel->setText(tr("Numbering"));
+	RangeLabel->setText(tr("Range"));
+	StartLabel->setText(tr("Start Number"));
+	PrefixLabel->setText(tr("Prefix"));
+	SuffixLabel->setText(tr("Suffix"));
+	SuperMasterLabel->setText(tr("Superscript in text"));
+	SuperNoteLabel->setText(tr("Superscript in notes"));
+	charStyleComboLabel->setText(tr("Mark Character Style"));
+	paraStyleComboLabel->setText(tr("Note Paragraph Style"));
+	AutoHLabel->setText(tr("Auto Height"));
+	AutoWLabel->setText(tr("Auto Width"));
+	AutoWeldLabel->setText(tr("Auto Welding"));
+	AutoRemoveLabel->setText(tr("Remove if empty"));
+	DeleteButton->setText(tr("Delete"));
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesStylesEditor::setDoc(ScribusDoc *doc)
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+	if (m_Doc != NULL)
+		disconnect(m_Doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
+	m_Doc = doc;
+	paraStyleCombo->setDoc(m_Doc);
+	charStyleCombo->setDoc(m_Doc);
+	if (m_Doc != NULL)
+	{
+		updateNSList();
+		NSlistBox->setCurrentIndex(0);
+		readNotesStyle(NSlistBox->currentText());
+		setEnabled(true);
+		ApplyButton->setEnabled(false);
+		connect(m_Doc->scMW(), SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
+	}
+	else
+	{
+		changesMap.clear();
+		NewNameEdit->clear();
+		setEnabled(false);
+	}
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesStylesEditor::handleUpdateRequest(int updateFlags)
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+	if ((updateFlags & reqCharStylesUpdate) || (updateFlags & reqTextStylesUpdate))
+		charStyleCombo->updateFormatList();
+	if ((updateFlags & reqParaStylesUpdate) || (updateFlags & reqTextStylesUpdate))
+		paraStyleCombo->updateFormatList();
+	readNotesStyle(NSlistBox->currentText());
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesStylesEditor::updateNSList()
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	NSlistBox->blockSignals(true);
+	if (m_Doc == NULL)
+		NSlistBox->setEnabled(false);
+	else
+	{
+		NSlistBox->clear();
+		changesMap.clear();
+		for (int a = 0; a < m_Doc->m_docNotesStylesList.count(); ++a)
+		{
+			NSlistBox->addItem(m_Doc->m_docNotesStylesList.at(a)->name());
+			changesMap.insert(m_Doc->m_docNotesStylesList.at(a)->name(), *(m_Doc->m_docNotesStylesList.at(a)));
+		}
+		if (!m_Doc->m_docNotesStylesList.isEmpty())
+			NSlistBox->setEnabled(true);
+		if (NSlistBox->currentText() != tr("default"))
+			DeleteButton->setEnabled(true);
+		else
+			DeleteButton->setEnabled(false);
+	}
+	NSlistBox->blockSignals(wasSignalsBlocked);
+	
+	DeleteButton->setEnabled(NSlistBox->currentText() != tr("default"));
+}
+
+void NotesStylesEditor::setBlockSignals(bool block)
+{
+	foreach (QWidget* obj, findChildren<QWidget *>())
+	{
+		obj->blockSignals(block);
+	}
+	paraStyleCombo->blockSignals(block);
+	charStyleCombo->blockSignals(block);
+}
+
+void NotesStylesEditor::setNotesStyle(NotesStyle * NS)
+{
+	if (NS == NULL)
+		return;
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+	NSlistBox->setCurrentIndex(NSlistBox->findText(NS->name()));
+	NewNameEdit->setText(NS->name());
+	if (NS->name() == tr("default"))
+		NewNameEdit->setEnabled(false);
+	else
+		NewNameEdit->setEnabled(true);
+	FootRadio->setChecked(!NS->isEndNotes());
+	if (NS->range() == NSRframe)
+		EndRadio->setEnabled(false);
+	else
+		EndRadio->setEnabled(true);
+	EndRadio->setChecked(NS->isEndNotes());
+	NumberingBox->setCurrentIndex((int) NS->getType());
+	RangeBox->setCurrentIndex((int) NS->range());
+	StartSpinBox->setValue(NS->start());
+	PrefixEdit->setText(NS->prefix());
+	SuffixEdit->setText(NS->suffix());
+	SuperMasterCheck->setChecked(NS->isSuperscriptInMaster());
+	SuperNoteCheck->setChecked(NS->isSuperscriptInNote());
+	if (!NS->notesParStyle().isEmpty() && (NS->notesParStyle() != tr("No Style")))
+		paraStyleCombo->setCurrentIndex(paraStyleCombo->findText(NS->notesParStyle()));
+	if (!NS->marksChStyle().isEmpty() && (NS->marksChStyle() != tr("No Style")))
+		charStyleCombo->setCurrentIndex(charStyleCombo->findText(NS->marksChStyle()));
+	AutoH->setChecked(NS->isAutoNotesHeight());
+	AutoW->setChecked(NS->isAutoNotesWidth());
+	AutoWeld->setChecked(NS->isAutoWeldNotesFrames());
+	//for endnotes remove FRAME range (same effect as footnotes for frame)
+	//and disable autofixing size of notes frames
+	int rangeFrameIndex = RangeBox->findText(tr("Frame"));
+	if (NS->isEndNotes())
+	{
+		AutoW->setEnabled(false);
+		AutoWeld->setEnabled(false);
+		if (rangeFrameIndex >= 0)
+			RangeBox->removeItem(rangeFrameIndex);
+}
+	else
+	{
+		AutoW->setEnabled(true);
+		AutoWeld->setEnabled(true);
+		if (rangeFrameIndex == -1)
+			RangeBox->addItem(tr("Frame"));
+	}
+	AutoRemove->setChecked(NS->isAutoRemoveEmptyNotesFrames());
+
+	ApplyButton->setEnabled(false);
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesStylesEditor::readNotesStyle(QString nsName)
+{
+	NotesStyle * NS = m_Doc->getNotesStyle(nsName);
+	setNotesStyle(NS);
+}
+
+void NotesStylesEditor::on_NSlistBox_currentIndexChanged(const QString &arg1)
+{
+	if (arg1 != tr("default"))
+		DeleteButton->setEnabled(true);
+	else
+		DeleteButton->setEnabled(false);
+	readNotesStyle(arg1);
+}
+
+void NotesStylesEditor::on_ApplyButton_clicked()
+{
+	if (addNewNsMode)
+	{
+		QString newName = NSlistBox->currentText();
+		NotesStyle newNS = changesMap.value(newName);
+		if (m_Doc->validateNSet(newNS))
+		{
+			addNewNsMode = false;
+			OKButton->setText(tr("OK"));
+			OKButton->setToolTip("");
+			ApplyButton->setText(tr("Apply"));
+			m_Doc->newNotesStyle(newNS);
+			updateNSList();
+			NSlistBox->setCurrentIndex(NSlistBox->findText(newNS.name()));
+		}
+		else
+			return;
+	}
+	else
+	{
+		//remeber current NStyle
+		QString currNS = NSlistBox->currentText();
+		NotesStyle* NS = NULL;
+		
+		foreach (const QString &nsName, changesMap.keys())
+		{
+			NotesStyle n = changesMap.value(nsName);
+
+			//validate settings
+			if (!m_Doc->validateNSet(n))
+			{
+				NSlistBox->setCurrentIndex(NSlistBox->findText(n.name()));
+				break;
+			}
+			//rename
+			if (nsName != n.name())
+			{
+				//new name for existing set
+				QString newName = n.name();
+				getUniqueName(newName, changesMap.keys(),"=");
+				n.setName(newName);
+				NewNameEdit->setText(newName);
+				//current NSet name change
+				if (currNS == nsName)
+					currNS = newName;
+				NS = m_Doc->getNotesStyle(nsName);
+				m_Doc->renameNotesStyle(NS, newName);
+				m_Doc->setNotesChanged(true);
+			}
+			//change settings and update marks
+			NS = m_Doc->getNotesStyle(n.name());
+			Q_ASSERT(NS != NULL);
+			if (*NS != n)
+			{
+				SimpleState* ss = NULL;
+				if (UndoManager::instance()->undoEnabled())
+				{
+					ss = new SimpleState(UndoManager::EditNotesStyle);
+					ss->set("NSTYLE", QString("edit"));
+					m_Doc->undoSetNotesStyle(ss, NS);
+				}
+				//converting foot <--> end notes or changing footnotes range
+				if ((NS->isEndNotes() != n.isEndNotes()) || (NS->isEndNotes() && n.isEndNotes() && NS->range() != n.range()))
+				{
+					foreach (PageItem_NoteFrame* nF, m_Doc->listNotesFrames(NS))
+						m_Doc->delNoteFrame(nF, false);
+					if (n.isEndNotes())
+						m_Doc->flag_updateEndNotes = true;
+				}
+				m_Doc->setNotesChanged(true); //notesframes width must be updated
+				*NS = n;
+				if (ss)
+				{
+					ss->set("NEWname", NS->name());
+					ss->set("NEWstart", NS->start());
+					ss->set("NEWendNotes", NS->isEndNotes());
+					ss->set("NEWnumFormat", (int) NS->getType());
+					ss->set("NEWrange", (int) NS->range());
+					ss->set("NEWprefix", NS->prefix());
+					ss->set("NEWsuffix", NS->suffix());
+					ss->set("NEWautoH", NS->isAutoNotesHeight());
+					ss->set("NEWautoW", NS->isAutoNotesWidth());
+					ss->set("NEWautoWeld", NS->isAutoWeldNotesFrames());
+					ss->set("NEWautoRemove", NS->isAutoRemoveEmptyNotesFrames());
+					ss->set("NEWsuperMaster", NS->isSuperscriptInMaster());
+					ss->set("NEWsuperNote", NS->isSuperscriptInNote());
+					ss->set("NEWmarksChStyle", NS->marksChStyle());
+					ss->set("NEWnotesParStyle", NS->notesParStyle());
+					UndoManager::instance()->action(m_Doc, ss);
+				}
+				//invalidate all text frames with marks from current changed notes style
+				foreach (PageItem* item, m_Doc->DocItems)
+				{
+					if (item->isTextFrame() && !item->isNoteFrame() && item->asTextFrame()->hasNoteMark(NS))
+						item->invalid = true;
+				}
+				m_Doc->updateNotesNums(NS);
+				m_Doc->updateNotesFramesSettings(NS);
+				if (m_Doc->flag_updateEndNotes)
+					m_Doc->updateEndnotesFrames(NS);
+				m_Doc->updateNotesFramesStyles(NS);
+			}
+		}
+		if (m_Doc->notesChanged())
+		{
+			updateNSList();
+			m_Doc->flag_updateMarksLabels = true;
+			m_Doc->changed();
+			m_Doc->regionsChanged()->update(QRectF());
+		}
+		//restore NStyle index
+		readNotesStyle(currNS);
+	}
+
+	ApplyButton->setEnabled(false);
+	NSlistBox->setEnabled(true);
+	NewButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_DeleteButton_clicked()
+{
+	QString nsName = NSlistBox->currentText();
+	int t = QMessageBox::warning(m_Doc->scMW(), tr("Warning! Deleting Notes Style"), "<qt>" +
+								 tr("You are going to delete notes style %1. All notes and marks using that style are also going to be deleted.").arg(nsName) + "</qt>",
+								 QMessageBox::Ok, QMessageBox::Abort | QMessageBox::Default);
+	if (t == QMessageBox::Ok)
+	{
+		m_Doc->deleteNotesStyle(nsName);
+		m_Doc->changed();
+		m_Doc->regionsChanged()->update(QRectF());
+		setDoc(m_Doc);
+	}
+}
+
+void NotesStylesEditor::on_NewButton_clicked()
+{
+	QString oldName = NSlistBox->currentText();
+	NotesStyle newNS = changesMap.value(oldName);
+	QString newName = oldName;
+	getUniqueName(newName, changesMap.keys(), "_");
+	newNS.setName(newName);
+	changesMap.insert(newName, newNS);
+	setNotesStyle(&newNS);
+	
+	NewNameEdit->setEnabled(true);
+	NSlistBox->addItem(newName);
+	NSlistBox->setCurrentIndex(NSlistBox->findText(newName));
+	NSlistBox->setEnabled(false);
+	ApplyButton->setText(tr("Add Style"));
+	ApplyButton->setEnabled(true);
+	DeleteButton->setEnabled(false);
+	NewButton->setEnabled(false);
+	addNewNsMode = true;
+	OKButton->setText(tr("Cancel Adding"));
+	OKButton->setToolTip(tr("Notes Styles Editor is in adding new notes style mode. After pressing Cancel button Notes Styles Editor switch into normal notes styles edit mode."));
+}
+
+void NotesStylesEditor::on_OKButton_clicked()
+{
+	if (OKButton->text() != tr("OK"))
+	{
+		//in adding new style mode go back to normal editing mode
+		OKButton->setText(tr("OK"));
+		NewButton->setEnabled(true);
+		addNewNsMode = false;
+		QString newName = NSlistBox->currentText();
+		changesMap.remove(newName);
+		int index = NSlistBox->findText(newName);
+		NSlistBox->removeItem(index);
+		NSlistBox->setCurrentIndex(index-1);
+		on_NSlistBox_currentIndexChanged(NSlistBox->currentText());
+	}
+	else
+	{
+		if (ApplyButton->isEnabled())
+			//apply changes
+			on_ApplyButton_clicked();
+
+		//in normal mode close
+		close();
+	}
+}
+
+void NotesStylesEditor::on_NewNameEdit_textChanged(const QString &arg1)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setName(arg1);
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_FootRadio_toggled(bool checked)
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setEndNotes(!checked);
+	changesMap.insert(NSlistBox->currentText(), ns);
+	EndRadio->setChecked(!checked);
+	if (checked)
+	{
+		ns.setAutoNotesWidth(true);
+		AutoW->setEnabled(true);
+		AutoW->setChecked(true);
+		ns.setAutoWeldNotesFrames(true);
+		AutoWeld->setEnabled(true);
+		AutoWeld->setChecked(true);
+	}
+	
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesStylesEditor::on_EndRadio_toggled(bool checked)
+{
+	bool wasSignalsBlocked = signalsBlocked();
+	setBlockSignals(true);
+
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setEndNotes(checked);
+	FootRadio->setChecked(!checked);
+	if (checked)
+	{
+		ns.setAutoNotesWidth(false);
+		AutoW->setChecked(false);
+		AutoW->setEnabled(false);
+		ns.setAutoWeldNotesFrames(false);
+		AutoWeld->setChecked(false);
+		AutoWeld->setEnabled(false);
+	}
+	
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+	setBlockSignals(wasSignalsBlocked);
+}
+
+void NotesStylesEditor::on_NumberingBox_currentIndexChanged(int index)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setType((NumFormat) index);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_RangeBox_currentIndexChanged(int index)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setRange((NumerationRange) index);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_StartSpinBox_valueChanged(int arg1)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setStart(arg1);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_PrefixEdit_textChanged(const QString &arg1)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setPrefix(arg1);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_SuffixEdit_textChanged(const QString &arg1)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setSuffix(arg1);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_SuperMasterCheck_toggled(bool checked)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setSuperscriptInMaster(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_SuperNoteCheck_toggled(bool checked)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setSuperscriptInNote(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_AutoH_toggled(bool checked)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setAutoNotesHeight(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_AutoW_toggled(bool checked)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setAutoNotesWidth(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_AutoWeld_toggled(bool checked)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setAutoWeldNotesFrames(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_AutoRemove_toggled(bool checked)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	ns.setAutoRemoveEmptyNotesFrames(checked);
+
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_paraStyleCombo_currentIndexChanged(const int &arg1)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	if (arg1 == 0)
+		ns.setNotesParStyle("");
+	else
+		ns.setNotesParStyle(paraStyleCombo->itemText(arg1));
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}
+
+void NotesStylesEditor::on_charStyleCombo_currentIndexChanged(const int &arg1)
+{
+	NotesStyle ns = changesMap.value(NSlistBox->currentText());
+	if (arg1 == 0)
+		ns.setMarksCharStyle("");
+	else
+		ns.setMarksCharStyle(charStyleCombo->itemText(arg1));
+	changesMap.insert(NSlistBox->currentText(), ns);
+	ApplyButton->setEnabled(true);
+}




More information about the scribus-commit mailing list