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 + 400 + 360 @@ -19,7 +19,7 @@ Notes Styles Editor - + 9 @@ -32,306 +32,673 @@ 9 - - + + 6 + + + + + 6 + + + + + + 89 + 0 + + + + Editing: + + + + + + + + 0 + 0 + + + + Select the notes style to edit + + + + + + + + 0 + 0 + + + + Add a new notes style + + + + + + + 14 + 14 + + + + + + + + + + 0 + + + 4 + + + + + + 89 + 0 + + + + Style Name: + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 6 + 20 + + + + + + + + Name for the new notes style + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 6 + 20 + + + + + + + + Add the new notes style using the settings below + + + &Add Style + + + + 14 + 14 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 4 + 20 + + + + + + + + Cancel adding the new notes style + + + &Cancel + + + + 14 + 14 + + + + + + + + + + + + QGroupBox#groupNumbering::title { + subcontrol-origin: margin; + subcontrol-position: top left; + left: 0px; + padding: 0px; +} + + + N&umbering + + + + QFormLayout::AllNonFixedFieldsGrow + + + 9 + + + 6 + + + + + + 80 + 0 + + + + Type + + + + + + + + + &Footnotes + + + + + + + &Endnotes + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 80 + 0 + + + + Format + + + + + + + + 0 + 0 + + + + + + + + + 80 + 0 + + + + Range + + + + + + + + 0 + 0 + + + + + + + + + 80 + 0 + + + + Start at + + + + + + + + 0 + 0 + + + + + 70 + 28 + + + + + 70 + 28 + + + + The number at which this notes style's numbering starts + + + + + + + + 80 + 0 + + + + Prefix + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + + 70 + 16777215 + + + + + + + + + 80 + 0 + + + + Suffix + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + + 70 + 16777215 + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + &Marks && Styles + + + + 6 + + + + + + 0 + 0 + + + + + 20 + 20 + + + + + 20 + 20 + + + + + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Character style used to format the note reference mark + + + + + + + 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 + + + + Paragraph style used to format the note text + + + + + + + + + + Frame &Behavior + + + + + + 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 + + + + + + + + Delete the current notes style + + + &Delete + + + + 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 - - - - + + + Save changes to the current notes style + + + &Save Changes + + + + 14 + 14 + + + Index: scribus/ui/notesstyleseditor.cpp =================================================================== --- scribus/ui/notesstyleseditor.cpp (revision 27767) +++ scribus/ui/notesstyleseditor.cpp (working copy) @@ -1,5 +1,6 @@ #include +#include "iconmanager.h" #include "notesstyleseditor.h" #include "pageitem_noteframe.h" #include "prefsmanager.h" @@ -20,7 +21,12 @@ m_prefs = PrefsManager::instance().prefsFile->getContext(pname); setBlockSignals(true); - + + setupIcons(); + + AddStyleButton->setEnabled(false); + CancelButton->setEnabled(false); + setDoc(nullptr); NSlistBox->setInsertPolicy(QComboBox::InsertAlphabetically); @@ -43,6 +49,28 @@ 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")); + AddStyleButton->setIcon(im.loadIcon("alert-ok")); + CancelButton->setIcon(im.loadIcon("alert-error")); + + 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::changeEvent(QEvent *e) { if (e->type() == QEvent::LanguageChange) @@ -60,19 +88,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); @@ -190,10 +205,8 @@ 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 while creating a new notes style + NewNameEdit->setEnabled(m_addNewNsMode); FootRadio->setChecked(!NS->isEndNotes()); EndRadio->setEnabled(true); EndRadio->setChecked(NS->isEndNotes()); @@ -233,118 +246,132 @@ readNotesStyle(arg1); } -void NotesStylesEditor::on_ApplyButton_clicked() +void NotesStylesEditor::markChanged() { + //route the "unsaved changes" state to whichever commit button is + //currently active: AddStyleButton while adding a new notes style, + //ApplyButton otherwise 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())); - } + AddStyleButton->setEnabled(true); else + ApplyButton->setEnabled(true); +} + +void NotesStylesEditor::on_ApplyButton_clicked() +{ + //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)) + //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, 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); + } + //change settings and update marks + NS = m_Doc->getNotesStyle(n.name()); + Q_ASSERT(NS != nullptr); + if (*NS != n) + { + SimpleState* ss = nullptr; + if (UndoManager::undoEnabled()) { - NSlistBox->setCurrentIndex(NSlistBox->findText(n.name())); - break; + ss = new SimpleState(UndoManager::EditNotesStyle); + ss->set("NSTYLE", QString("edit")); + m_Doc->undoSetNotesStyle(ss, NS); } - //rename - if (nsName != n.name()) + //converting foot <--> end notes or changing footnotes range + if ((NS->isEndNotes() != n.isEndNotes()) || (NS->isEndNotes() && n.isEndNotes() && NS->range() != n.range())) { - //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); + foreach (PageItem_NoteFrame* nF, m_Doc->listNotesFrames(NS)) + m_Doc->delNoteFrame(nF, false); + if (n.isEndNotes()) + m_Doc->flag_updateEndNotes = true; } - //change settings and update marks - NS = m_Doc->getNotesStyle(n.name()); - Q_ASSERT(NS != nullptr); - if (*NS != n) + m_Doc->setNotesChanged(true); //notesframes width must be updated + *NS = n; + if (ss) { - 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); + 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); } + 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_AddStyleButton_clicked() +{ + QString newName = NSlistBox->currentText(); + NotesStyle newNS = m_changesMap.value(newName); + if (!m_Doc->validateNSet(newNS)) + return; + + m_addNewNsMode = false; + AddStyleButton->setEnabled(false); + CancelButton->setEnabled(false); + ApplyButton->show(); + + m_Doc->newNotesStyle(newNS); + updateNSList(); + NSlistBox->setCurrentIndex(NSlistBox->findText(newNS.name())); ApplyButton->setEnabled(false); NSlistBox->setEnabled(true); @@ -375,45 +402,38 @@ getUniqueName(newName, m_changesMap.keys(), "_"); newNS.setName(newName); m_changesMap.insert(newName, newNS); + + m_addNewNsMode = true; 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.")); + + ApplyButton->hide(); + AddStyleButton->setEnabled(true); + CancelButton->setEnabled(true); } -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(); +void NotesStylesEditor::on_CancelButton_clicked() +{ + //abort adding new notes style, go back to normal editing mode + m_addNewNsMode = false; + AddStyleButton->setEnabled(false); + CancelButton->setEnabled(false); + ApplyButton->show(); + ApplyButton->setEnabled(false); + NewButton->setEnabled(true); - //in normal mode close - close(); - } + QString newName = NSlistBox->currentText(); + m_changesMap.remove(newName); + int index = NSlistBox->findText(newName); + NSlistBox->removeItem(index); + NSlistBox->setCurrentIndex(index - 1); + NSlistBox->setEnabled(true); + on_NSlistBox_currentTextChanged(NSlistBox->currentText()); } void NotesStylesEditor::on_NewNameEdit_textChanged(const QString &arg1) @@ -421,7 +441,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 +464,7 @@ } m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); setBlockSignals(wasSignalsBlocked); } @@ -467,7 +487,7 @@ } m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); setBlockSignals(wasSignalsBlocked); } @@ -479,7 +499,7 @@ ns.setType(formatType); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_RangeBox_currentIndexChanged(int index) @@ -488,7 +508,7 @@ ns.setRange((NumerationRange) RangeBox->itemData(index).toInt()); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_StartSpinBox_valueChanged(int arg1) @@ -497,7 +517,7 @@ ns.setStart(arg1); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_PrefixEdit_textChanged(const QString &arg1) @@ -506,7 +526,7 @@ ns.setPrefix(arg1); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_SuffixEdit_textChanged(const QString &arg1) @@ -515,7 +535,7 @@ ns.setSuffix(arg1); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_SuperMasterCheck_toggled(bool checked) @@ -524,7 +544,7 @@ ns.setSuperscriptInMaster(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_SuperNoteCheck_toggled(bool checked) @@ -533,7 +553,7 @@ ns.setSuperscriptInNote(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_AutoH_toggled(bool checked) @@ -542,7 +562,7 @@ ns.setAutoNotesHeight(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_AutoW_toggled(bool checked) @@ -551,7 +571,7 @@ ns.setAutoNotesWidth(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_AutoWeld_toggled(bool checked) @@ -560,7 +580,7 @@ ns.setAutoWeldNotesFrames(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_AutoRemove_toggled(bool checked) @@ -569,7 +589,7 @@ ns.setAutoRemoveEmptyNotesFrames(checked); m_changesMap.insert(NSlistBox->currentText(), ns); - ApplyButton->setEnabled(true); + markChanged(); } void NotesStylesEditor::on_paraStyleCombo_currentIndexChanged(const int &arg1) @@ -580,7 +600,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 +611,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) @@ -32,6 +32,8 @@ void changeNotesStyle(); void setBlockSignals(bool block); bool isDefaultNotesStyle(const QString& nsName) const; + void setupIcons(); + void markChanged(); public slots: void setDoc(ScribusDoc *doc); @@ -43,7 +45,8 @@ void on_NSlistBox_currentTextChanged(const QString &arg1); void on_ApplyButton_clicked(); void on_DeleteButton_clicked(); - void on_OKButton_clicked(); + void on_AddStyleButton_clicked(); + void on_CancelButton_clicked(); void on_NewNameEdit_textChanged(const QString &arg1); void on_FootRadio_toggled(bool checked); void on_EndRadio_toggled(bool checked);