Index: scribus/ui/notesstyleseditor.ui =================================================================== --- scribus/ui/notesstyleseditor.ui (revision 27767) +++ scribus/ui/notesstyleseditor.ui (working copy) @@ -6,8 +6,8 @@ 0 0 - 324 - 576 + 510 + 360 @@ -19,7 +19,7 @@ Notes Styles Editor - + 9 @@ -32,306 +32,654 @@ 9 - - + + 6 + + + + + 6 + + + + + Style: + + + + + + + + 0 + 0 + + + + Select the notes style to edit + + + + + + + + 0 + 0 + + + + Delete the current notes style + + + + + + + 14 + 14 + + + + + + + + + 0 + 0 + + + + Start a new notes style + + + + + + + 14 + 14 + + + + + + + + + + 0 + + + + + Name: + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 6 + 20 + + + + + + + + + 0 + 0 + + + + Name for the new notes style + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 8 + + + + + + + + + + N&umbering + + + FootRadio + + + + + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 9 + + + 6 + + + + + Note Type + + + + + + + + + &Footnotes + + + + + + + &Endnotes + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Format + + + + + + + + 0 + 0 + + + + + + + + Scope + + + + + + + + 0 + 0 + + + + + + + + Start at + + + + + + + + 0 + 0 + + + + + 70 + 28 + + + + + 70 + 28 + + + + The number at which this notes style's numbering starts + + + + + + + Prefix + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + + 70 + 16777215 + + + + + + + + Suffix + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + + 70 + 16777215 + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + &Mark && Note Styles + + + charStyleCombo + + + + + + + + + + + 6 + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 20 + 20 + + + + + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 215 + 0 + + + + + 215 + 16777215 + + + + Character style used to format the note reference mark + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Show the note mark as superscript in the main text + + + Superscript in &Text + + + + + + + Show the note mark as superscript in the note itself + + + Superscript in &Notes + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 8 + + + + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 20 + 20 + + + + + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 215 + 0 + + + + + 215 + 16777215 + + + + Paragraph style used to format the note text + + + + + + + + + + Frame &Behavior + + + + 6 + + + + + Automatically grow or shrink the notes frame height to fit its content + + + Auto &Height + + + + + + + Automatically grow or shrink the notes frame width to fit its content + + + Auto &Width + + + + + + + Automatically remove the notes frame when it becomes empty + + + &Remove if Empty + + + + + + + Automatically weld the notes frame to its marker frame + + + Auto Weldin&g + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 6 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Save changes to the current notes style + + + &Save Changes + + + + 14 + 14 + + + + - - - - - - 0 - 0 - - - - - - - - Add New Style - - - - - - - - - - - New Style Name - - - - - - - - - - - 0 - 0 - - - - Footnotes - - - - - - - - 0 - 0 - - - - Endnotes - - - - - - - Numbering - - - - - - - - 0 - 0 - - - - - - - - Range - - - - - - - - 0 - 0 - - - - - - - - Start Number - - - - - - - - 0 - 0 - - - - - - - - Prefix - - - - - - - - - - Suffix - - - - - - - - - - Superscript in text - - - - - - - - - - - - - - Superscript in notes - - - - - - - - - - - - - - 2 - - - Mark Character Style - - - Qt::RichText - - - - - - - - 0 - 0 - - - - - - - - Note Paragraph Style - - - - - - - - 0 - 0 - - - - - - - - Auto Height - - - - - - - - - - - - - - Auto Width - - - - - - - - - - - - - - Auto Welding - - - - - - - - - - - - - - Remove if empty - - - - - - - - - - - - - - - - - - - 0 - 0 - - - - Apply - - - - - - - - 0 - 0 - - - - Delete - - - - - - - - 0 - 0 - - - - OK - - - - + + + Close the Notes Styles Editor + + + OK + + + + 14 + 14 + + + Index: scribus/ui/notesstyleseditor.cpp =================================================================== --- scribus/ui/notesstyleseditor.cpp (revision 27767) +++ scribus/ui/notesstyleseditor.cpp (working copy) @@ -1,5 +1,8 @@ +#include +#include #include +#include "iconmanager.h" #include "notesstyleseditor.h" #include "pageitem_noteframe.h" #include "prefsmanager.h" @@ -20,12 +23,14 @@ m_prefs = PrefsManager::instance().prefsFile->getContext(pname); setBlockSignals(true); - + + setupIcons(); + setDoc(nullptr); NSlistBox->setInsertPolicy(QComboBox::InsertAlphabetically); - RangeBox->addItem(tr("Document"), static_cast(NSRdocument)); - RangeBox->addItem(tr("Story"), static_cast(NSRstory)); + ScopeBox->addItem(tr("Document"), static_cast(NSRdocument)); + ScopeBox->addItem(tr("Story"), static_cast(NSRstory)); languageChange(); @@ -43,6 +48,59 @@ storeSize(); } +void NotesStylesEditor::setupIcons() +{ + IconManager& im = IconManager::instance(); + + NewButton->setIcon(im.loadIcon("paragraph-style-new")); + DeleteButton->setIcon(im.loadIcon("delete")); + ApplyButton->setIcon(im.loadIcon("alert-ok")); + OKButton->setIcon(im.loadIcon("close")); + + charStyleComboLabel->setPixmap(im.loadPixmap("character-style")); + paraStyleComboLabel->setPixmap(im.loadPixmap("paragraph-style")); + + SuperMasterCheck->setIcon(im.loadIcon("character-superscript")); + SuperNoteCheck->setIcon(im.loadIcon("character-superscript")); + + AutoH->setIcon(im.loadIcon("action-scale-height")); + AutoW->setIcon(im.loadIcon("action-scale-width")); + AutoWeld->setIcon(im.loadIcon("action-link")); + AutoRemove->setIcon(im.loadIcon("action-remove")); +} + +void NotesStylesEditor::alignLabelColumns() +{ + //Keep "Style:" and "Name:" aligned with each other only, sized to + //their actual rendered text (not a hardcoded guess, so this stays + //correct for any language, font, or DPI). "Numbering" is deliberately + //excluded: it is longer than either, and sharing its width would pad + //"Style:"/"Name:" well past what their own text needs, opening a gap + //between each label and its field. Left-alignment with "Numbering" + //needs no width matching at all - as the first item in its own + //layout, it already starts at the same x regardless of its width. + const QList outerLabels = { EditingLabel, NewNameLabel }; + int outerWidth = 0; + for (QLabel* lbl : outerLabels) + outerWidth = qMax(outerWidth, lbl->sizeHint().width()); + for (QLabel* lbl : outerLabels) + lbl->setMinimumWidth(outerWidth); + + //Separately, keep the Numbering group's own field labels aligned with + //each other. A small uniform padding on top of the widest label's + //width gives every row some breathing room before its field starts, + //while keeping all six fields - including the Type row's radio + //buttons - aligned with each other, since all six labels still share + //the exact same width. + const QList innerLabels = { TypeLabel, NumberingLabel, ScopeLabel, StartLabel, PrefixLabel, SuffixLabel }; + int innerWidth = 0; + for (QLabel* lbl : innerLabels) + innerWidth = qMax(innerWidth, lbl->sizeHint().width()); + innerWidth += 6; + for (QLabel* lbl : innerLabels) + lbl->setMinimumWidth(innerWidth); +} + void NotesStylesEditor::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) @@ -60,19 +118,6 @@ retranslateUi(this); - if (m_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(tr("OK")); - OKButton->setToolTip(""); - ApplyButton->setText(tr("Apply")); - } - bool paraStyleBlocked = paraStyleCombo->blockSignals(true); int paraStyleIndex = paraStyleCombo->currentIndex(); paraStyleCombo->setDoc(m_Doc); @@ -87,14 +132,16 @@ charStyleCombo->setCurrentIndex(charStyleIndex); charStyleCombo->blockSignals(charStyleBlocked); - bool rangeBlocked = RangeBox->blockSignals(true); - int rangeIndex = RangeBox->currentIndex(); - RangeBox->clear(); - RangeBox->addItem(tr("Document"), static_cast(NSRdocument)); - RangeBox->addItem(tr("Story"), static_cast(NSRstory)); - if (rangeIndex >= 0) - RangeBox->setCurrentIndex(rangeIndex); - RangeBox->blockSignals(rangeBlocked); + bool scopeBlocked = ScopeBox->blockSignals(true); + int scopeIndex = ScopeBox->currentIndex(); + ScopeBox->clear(); + ScopeBox->addItem(tr("Document"), static_cast(NSRdocument)); + ScopeBox->addItem(tr("Story"), static_cast(NSRstory)); + if (scopeIndex >= 0) + ScopeBox->setCurrentIndex(scopeIndex); + ScopeBox->blockSignals(scopeBlocked); + + alignLabelColumns(); setBlockSignals(wasSignalsBlocked); } @@ -146,6 +193,18 @@ NSlistBox->setEnabled(false); else { + //preserve any not-yet-saved draft entries across the refresh - + //without this, an unrelated action that happens to call + //updateNSList() (e.g. deleting a different, saved style) would + //silently wipe out a style the user is still in the middle of + //creating + QMap drafts; + foreach (const QString &name, m_changesMap.keys()) + { + if (isDraftNotesStyle(name)) + drafts.insert(name, m_changesMap.value(name)); + } + NSlistBox->clear(); m_changesMap.clear(); for (int a = 0; a < m_Doc->m_docNotesStylesList.count(); ++a) @@ -153,7 +212,15 @@ NSlistBox->addItem(m_Doc->m_docNotesStylesList.at(a)->name()); m_changesMap.insert(m_Doc->m_docNotesStylesList.at(a)->name(), *(m_Doc->m_docNotesStylesList.at(a))); } - if (!m_Doc->m_docNotesStylesList.isEmpty()) + QMapIterator it(drafts); + while (it.hasNext()) + { + it.next(); + NSlistBox->addItem(it.key()); + markDraftItem(NSlistBox->count() - 1); + m_changesMap.insert(it.key(), it.value()); + } + if (!m_Doc->m_docNotesStylesList.isEmpty() || !drafts.isEmpty()) NSlistBox->setEnabled(true); } NSlistBox->blockSignals(wasSignalsBlocked); @@ -172,6 +239,27 @@ return (ns != nullptr) && (ns == m_Doc->m_docNotesStylesList.at(0)); } +bool NotesStylesEditor::isDraftNotesStyle(const QString& nsName) const +{ + //a "draft" is an entry that exists in m_changesMap/NSlistBox but has + //never been saved into the document yet (created via NewButton, not + //yet committed via ApplyButton) - derived from the document itself + //rather than tracked separately, so there is nothing to keep in sync + if (m_Doc == nullptr) + return false; + return (m_Doc->getNotesStyle(nsName) == nullptr); +} + +void NotesStylesEditor::markDraftItem(int index) +{ + //visually distinguish an unsaved draft entry in the list (italic) + //without touching its text, since that text doubles as the + //m_changesMap lookup key throughout this class + QFont draftFont = NSlistBox->font(); + draftFont.setItalic(true); + NSlistBox->setItemData(index, draftFont, Qt::FontRole); +} + void NotesStylesEditor::setBlockSignals(bool block) { foreach (QWidget* obj, findChildren()) @@ -190,16 +278,17 @@ setBlockSignals(true); NSlistBox->setCurrentIndex(NSlistBox->findText(NS->name())); NewNameEdit->setText(NS->name()); - if (isDefaultNotesStyle(NS->name())) - NewNameEdit->setEnabled(false); - else - NewNameEdit->setEnabled(true); + //the style name is only editable for a not-yet-saved draft (auto- + //unlocked, since it has no real name to protect yet); unlike + //paragraph/character styles, the "default" notes style isn't + //special-cased elsewhere in the document engine + NewNameEdit->setEnabled(isDraftNotesStyle(NS->name())); FootRadio->setChecked(!NS->isEndNotes()); EndRadio->setEnabled(true); EndRadio->setChecked(NS->isEndNotes()); NumberingBox->setCurrentFormat(NS->getType()); - int rangeIndex = RangeBox->findData((int) NS->range()); - RangeBox->setCurrentIndex((rangeIndex >= 0) ? rangeIndex : 0); + int scopeIndex = ScopeBox->findData((int) NS->range()); + ScopeBox->setCurrentIndex((scopeIndex >= 0) ? scopeIndex : 0); StartSpinBox->setValue(NS->start()); PrefixEdit->setText(NS->prefix()); SuffixEdit->setText(NS->suffix()); @@ -233,127 +322,144 @@ readNotesStyle(arg1); } +void NotesStylesEditor::markChanged() +{ + //there is only one commit button (Save Changes) regardless of + //whether the current entry is a draft or an existing style + ApplyButton->setEnabled(true); +} + void NotesStylesEditor::on_ApplyButton_clicked() { - if (m_addNewNsMode) - { - QString newName = NSlistBox->currentText(); - NotesStyle newNS = m_changesMap.value(newName); - if (!m_Doc->validateNSet(newNS)) - return; - - m_addNewNsMode = false; - OKButton->setText(tr("OK")); - OKButton->setToolTip(""); - ApplyButton->setText(tr("Apply")); - m_Doc->newNotesStyle(newNS); - updateNSList(); - NSlistBox->setCurrentIndex(NSlistBox->findText(newNS.name())); - } - else + //remember current NStyle + QString currNS = NSlistBox->currentText(); + NotesStyle* NS = nullptr; + + foreach (const QString &nsName, m_changesMap.keys()) { - //remember current NStyle - QString currNS = NSlistBox->currentText(); - NotesStyle* NS = nullptr; - - foreach (const QString &nsName, m_changesMap.keys()) - { - NotesStyle n = m_changesMap.value(nsName); + NotesStyle n = m_changesMap.value(nsName); - //validate settings - if (!m_Doc->validateNSet(n)) - { - NSlistBox->setCurrentIndex(NSlistBox->findText(n.name())); - break; - } - //rename - if (nsName != n.name()) + //validate settings + if (!m_Doc->validateNSet(n)) + { + NSlistBox->setCurrentIndex(NSlistBox->findText(n.name())); + break; + } + //brand new style that has never been saved - create it now with + //whatever settings were configured. There is nothing to rename or + //diff against an existing entry, since it doesn't exist in the + //document yet; creating it captures all of its settings in one go. + if (isDraftNotesStyle(nsName)) + { + NotesStyle* createdNS = m_Doc->newNotesStyle(n); + if (createdNS != nullptr) { - //new name for existing set - QString newName = n.name(); - getUniqueName(newName, m_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); + currNS = createdNS->name(); m_Doc->setNotesChanged(true); } - //change settings and update marks - NS = m_Doc->getNotesStyle(n.name()); - Q_ASSERT(NS != nullptr); - if (*NS != n) - { - SimpleState* ss = nullptr; - if (UndoManager::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); - } + continue; } - if (m_Doc->notesChanged()) + //rename + if (nsName != n.name()) { - updateNSList(); - m_Doc->flag_updateMarksLabels = true; - m_Doc->changed(); - m_Doc->regionsChanged()->update(QRectF()); + //new name for existing set + QString newName = n.name(); + getUniqueName(newName, m_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); } - //restore NStyle index - readNotesStyle(currNS); + //change settings and update marks + NS = m_Doc->getNotesStyle(n.name()); + Q_ASSERT(NS != nullptr); + if (*NS != n) + { + SimpleState* ss = nullptr; + if (UndoManager::undoEnabled()) + { + ss = new SimpleState(UndoManager::EditNotesStyle); + ss->set("NSTYLE", QString("edit")); + m_Doc->undoSetNotesStyle(ss, NS); + } + //converting foot <--> end notes or changing footnotes scope + 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()); + + if (isDraftNotesStyle(nsName)) + { + //discard a not-yet-saved draft - nothing has been persisted yet, + //so no confirmation is needed (the same reasoning most apps use + //for closing an empty untitled document without prompting), and + //there is nothing in the document to actually delete + m_changesMap.remove(nsName); + int index = NSlistBox->findText(nsName); + NSlistBox->removeItem(index); + NSlistBox->setCurrentIndex(qMax(0, index - 1)); + on_NSlistBox_currentTextChanged(NSlistBox->currentText()); + return; + } + int t = ScMessageBox::warning(m_Doc->scMW(), tr("Warning! Deleting Notes Style"), "" + tr("You are going to delete notes style %1. All notes and marks using that style are also going to be deleted.").arg(nsName) + "", QMessageBox::Ok | QMessageBox::Abort, @@ -367,53 +473,30 @@ setDoc(m_Doc); } +void NotesStylesEditor::on_OKButton_clicked() +{ + close(); +} + void NotesStylesEditor::on_NewButton_clicked() { + //clone the currently selected style's settings as a starting point, + //add it to the list as a plain entry (no special "mode" - it behaves + //like any other entry except that it doesn't exist in the document + //until Save Changes is clicked), and auto-unlock its name for editing QString oldName = NSlistBox->currentText(); NotesStyle newNS = m_changesMap.value(oldName); QString newName = oldName; getUniqueName(newName, m_changesMap.keys(), "_"); newNS.setName(newName); m_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); - m_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 (m_addNewNsMode) - { - //in adding new style mode go back to normal editing mode - OKButton->setText(tr("OK")); - NewButton->setEnabled(true); - m_addNewNsMode = false; - QString newName = NSlistBox->currentText(); - m_changesMap.remove(newName); - int index = NSlistBox->findText(newName); - NSlistBox->removeItem(index); - NSlistBox->setCurrentIndex(index - 1); - on_NSlistBox_currentTextChanged(NSlistBox->currentText()); - } - else - { - if (ApplyButton->isEnabled()) - //apply changes - on_ApplyButton_clicked(); + NSlistBox->addItem(newName); + markDraftItem(NSlistBox->count() - 1); + setNotesStyle(&newNS); - //in normal mode close - close(); - } + NewNameEdit->setFocus(); + NewNameEdit->selectAll(); } void NotesStylesEditor::on_NewNameEdit_textChanged(const QString &arg1) @@ -421,7 +504,7 @@ NotesStyle ns = m_changesMap.value(NSlistBox->currentText()); ns.setName(arg1); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_FootRadio_toggled(bool checked) @@ -444,7 +527,7 @@ } m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); setBlockSignals(wasSignalsBlocked); } @@ -467,7 +550,7 @@ } m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); setBlockSignals(wasSignalsBlocked); } @@ -479,16 +562,16 @@ ns.setType(formatType); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } -void NotesStylesEditor::on_RangeBox_currentIndexChanged(int index) +void NotesStylesEditor::on_ScopeBox_currentIndexChanged(int index) { NotesStyle ns = m_changesMap.value(NSlistBox->currentText()); - ns.setRange((NumerationRange) RangeBox->itemData(index).toInt()); + ns.setRange((NumerationRange) ScopeBox->itemData(index).toInt()); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_StartSpinBox_valueChanged(int arg1) @@ -497,7 +580,7 @@ ns.setStart(arg1); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_PrefixEdit_textChanged(const QString &arg1) @@ -506,7 +589,7 @@ ns.setPrefix(arg1); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_SuffixEdit_textChanged(const QString &arg1) @@ -515,7 +598,7 @@ ns.setSuffix(arg1); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_SuperMasterCheck_toggled(bool checked) @@ -524,7 +607,7 @@ ns.setSuperscriptInMaster(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_SuperNoteCheck_toggled(bool checked) @@ -533,7 +616,7 @@ ns.setSuperscriptInNote(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_AutoH_toggled(bool checked) @@ -542,7 +625,7 @@ ns.setAutoNotesHeight(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_AutoW_toggled(bool checked) @@ -551,7 +634,7 @@ ns.setAutoNotesWidth(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_AutoWeld_toggled(bool checked) @@ -560,7 +643,7 @@ ns.setAutoWeldNotesFrames(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_AutoRemove_toggled(bool checked) @@ -569,7 +652,7 @@ ns.setAutoRemoveEmptyNotesFrames(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_paraStyleCombo_currentIndexChanged(const int &arg1) @@ -580,7 +663,7 @@ else ns.setNotesParStyle(paraStyleCombo->itemText(arg1)); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_charStyleCombo_currentIndexChanged(const int &arg1) @@ -591,5 +674,5 @@ else ns.setMarksCharStyle(charStyleCombo->itemText(arg1)); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } Index: scribus/ui/notesstyleseditor.h =================================================================== --- scribus/ui/notesstyleseditor.h (revision 27767) +++ scribus/ui/notesstyleseditor.h (working copy) @@ -25,13 +25,17 @@ private: ScribusDoc *m_Doc { nullptr }; PrefsContext *m_prefs { nullptr }; - bool m_addNewNsMode { false }; QMap m_changesMap; // void readNotesStyle(const QString& nsName); void changeNotesStyle(); void setBlockSignals(bool block); bool isDefaultNotesStyle(const QString& nsName) const; + bool isDraftNotesStyle(const QString& nsName) const; + void markDraftItem(int index); + void setupIcons(); + void markChanged(); + void alignLabelColumns(); public slots: void setDoc(ScribusDoc *doc); @@ -48,7 +52,7 @@ void on_FootRadio_toggled(bool checked); void on_EndRadio_toggled(bool checked); void on_NumberingBox_currentIndexChanged(int index); - void on_RangeBox_currentIndexChanged(int index); + void on_ScopeBox_currentIndexChanged(int index); void on_StartSpinBox_valueChanged(int arg1); void on_PrefixEdit_textChanged(const QString &arg1); void on_SuffixEdit_textChanged(const QString &arg1);