View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0018025 | Scribus | User Interface | public | 2026-10-20 11:04 | 2026-11-15 08:18 |
| Reporter | buttar | Assigned To | cbradney | ||
| Priority | normal | Severity | feature | Reproducibility | N/A |
| Status | resolved | Resolution | fixed | ||
| Platform | Linux | OS | Fedora Workstation | OS Version | 44 |
| Product Version | 1.7.4.svn | ||||
| Fixed in Version | 1.7.5.svn | ||||
| Summary | 0018025: [patch] Improve Guide Manager UI and editing UX | ||||
| Description | Guide Manager has a cramped Rows & Columns layout, redundant controls and inconsistent manual-guide editing interactions. Baseline: r27910 ## gmu1-guide-manager-layout-v1.00.patch - Stack Horizontal/Vertical guide groups and place Number and Gap controls on the same row. - Remove redundant Gap checkboxes and supporting logic while preserving manually entered values. - Correct signal handling to avoid unintended document modification. - Improve minor UI details, including spacing, alignment, sentence-case labels and default dialog sizing. ## gmu2-manual-guide-editing-ux-v1.00.patch - Introduce context-sensitive Add / Finish editing (+/✓) controls with consistent keyboard and focus-loss behaviour. - Support legitimate 0 mm guides and distinguish pending from committed entries. - Improve Qt editor lifecycle, model notifications, selection handling and widget ownership. | ||||
| Tags | #patch_is_ready | ||||
| Attached Files | gmu1-guide-manager-layout-v1.00.patch (23,982 bytes)
Index: scribus/ui/guidemanager.cpp
===================================================================
--- scribus/ui/guidemanager.cpp (revision 27910)
+++ scribus/ui/guidemanager.cpp (working copy)
@@ -85,8 +85,6 @@
connect(applyToAllStdButton, SIGNAL(clicked()), this, SLOT(applyToAllStdButton_clicked()));
connect(horizontalAutoCountSpin, SIGNAL(valueChanged(double)), this, SLOT(horizontalAutoCountSpin_valueChanged(double)));
connect(verticalAutoCountSpin, SIGNAL(valueChanged(double)), this, SLOT(verticalAutoCountSpin_valueChanged(double)));
- connect(horizontalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(horizontalAutoGapCheck_stateChanged(int)));
- connect(verticalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(verticalAutoGapCheck_stateChanged(int)));
connect(horizontalAutoGapSpin, SIGNAL(valueChanged(double)), this, SLOT(horizontalAutoGapSpin_valueChanged(double)));
connect(verticalAutoGapSpin, SIGNAL(valueChanged(double)), this, SLOT(verticalAutoGapSpin_valueChanged(double)));
@@ -164,42 +162,30 @@
void GuideManager::setupGui()
{
- disconnect(horizontalAutoGapCheck, SIGNAL(stateChanged(int)),
- this, SLOT(horizontalAutoGapCheck_stateChanged(int)));
- disconnect(verticalAutoGapCheck, SIGNAL(stateChanged(int)),
- this, SLOT(verticalAutoGapCheck_stateChanged(int)));
- disconnect(lockCheck, SIGNAL(stateChanged(int)),
- this, SLOT(lockCheck_stateChanged(int)));
-
- // restore values from new page
+ // Restore controls without treating a page change as a guide edit.
clearRestoreHorizontalList();
clearRestoreVerticalList();
- // restore: brand "auto guides into GUI restore algorithm"
- bool enable = currentPage->guides.horizontalAutoGap() > 0.0;
- horizontalAutoGapCheck->setChecked(enable);
- horizontalAutoGapSpin->setEnabled(enable);
- horizontalAutoGapSpin->setValue(currentPage->guides.horizontalAutoGap(), SC_PT);
+ QSignalBlocker horizontalCountBlock(horizontalAutoCountSpin);
+ QSignalBlocker horizontalGapBlock(horizontalAutoGapSpin);
+ QSignalBlocker verticalCountBlock(verticalAutoCountSpin);
+ QSignalBlocker verticalGapBlock(verticalAutoGapSpin);
+ QSignalBlocker horizontalPageBlock(horizontalPageAutoButton);
+ QSignalBlocker horizontalMarginsBlock(horizontalMarginsAutoButton);
+ QSignalBlocker horizontalSelectionBlock(horizontalSelectionAutoButton);
+ QSignalBlocker verticalPageBlock(verticalPageAutoButton);
+ QSignalBlocker verticalMarginsBlock(verticalMarginsAutoButton);
+ QSignalBlocker verticalSelectionBlock(verticalSelectionAutoButton);
+ QSignalBlocker lockBlock(lockCheck);
horizontalAutoCountSpin->setValue(currentPage->guides.horizontalAutoCount());
- if (horizontalAutoCountSpin->value()==0)
- {
- horizontalAutoGapSpin->setEnabled(false);
- horizontalAutoGapCheck->setEnabled(false);
- }
+ horizontalAutoGapSpin->setValue(currentPage->guides.horizontalAutoGap(), SC_PT);
+ horizontalAutoGapSpin->setEnabled(horizontalAutoCountSpin->value() > 0);
setHorizontalRefer(currentPage->guides.horizontalAutoRefer());
// allow the selection radio button?
horizontalSelectionAutoButton->setEnabled(m_doc->m_Selection->isNotEmpty());
- // verticals
- enable = currentPage->guides.verticalAutoGap() > 0.0;
- verticalAutoGapCheck->setChecked(enable);
- verticalAutoGapSpin->setEnabled(enable);
- verticalAutoGapSpin->setValue(currentPage->guides.verticalAutoGap(), SC_PT);
verticalAutoCountSpin->setValue(currentPage->guides.verticalAutoCount());
- if (verticalAutoCountSpin->value()==0)
- {
- verticalAutoGapSpin->setEnabled(false);
- verticalAutoGapCheck->setEnabled(false);
- }
+ verticalAutoGapSpin->setValue(currentPage->guides.verticalAutoGap(), SC_PT);
+ verticalAutoGapSpin->setEnabled(verticalAutoCountSpin->value() > 0);
setVerticalRefer(currentPage->guides.verticalAutoRefer());
// allow the selection radio button?
verticalSelectionAutoButton->setEnabled(m_doc->m_Selection->isNotEmpty());
@@ -207,12 +193,7 @@
// restore guide locking
lockCheck->setChecked(m_doc->GuideLock);
- connect(horizontalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(horizontalAutoGapCheck_stateChanged(int)));
- connect(verticalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(verticalAutoGapCheck_stateChanged(int)));
- connect(lockCheck, SIGNAL(stateChanged(int)), this, SLOT(lockCheck_stateChanged(int)));
-
m_drawGuides = true;
-// drawGuides(); let Canvas::DrawPageMarks take care of it and avoid a costly ScribusView::DrawNew()
}
void GuideManager::storePageValues(ScPage *page) const
@@ -220,18 +201,12 @@
if (!page || !m_doc)
return;
- double gapValue = 0.0;
- if (horizontalAutoGapCheck->isChecked())
- gapValue = horizontalAutoGapSpin->getValue(SC_PT);
- page->guides.setHorizontalAutoGap(gapValue);
+ page->guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
page->guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
page->guides.setHorizontalAutoRefer(horizontalRefer());
page->guides.addHorizontals(getAutoHorizontals(page), GuideManagerCore::Auto);
- gapValue = 0.0;
- if (verticalAutoGapCheck->isChecked())
- gapValue = verticalAutoGapSpin->getValue(SC_PT);
- page->guides.setVerticalAutoGap(gapValue);
+ page->guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
page->guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
page->guides.setVerticalAutoRefer(verticalRefer());
page->guides.addVerticals(getAutoVerticals(page), GuideManagerCore::Auto);
@@ -364,12 +339,7 @@
void GuideManager::horizontalAutoCountSpin_valueChanged(double val)
{
- bool enable = val != 0;
- horizontalAutoGapCheck->setEnabled(enable);
- if (enable && horizontalAutoGapCheck->isChecked())
- horizontalAutoGapSpin->setEnabled(true);
- else
- horizontalAutoGapSpin->setEnabled(false);
+ horizontalAutoGapSpin->setEnabled(val > 0);
currentPage->guides.setHorizontalAutoCount(static_cast<int>(val));
drawGuides();
m_doc->changed();
@@ -382,25 +352,9 @@
m_doc->changed();
}
-void GuideManager::horizontalAutoGapCheck_stateChanged( int )
-{
- horizontalAutoGapSpin->setEnabled(horizontalAutoGapCheck->isChecked());
- if (horizontalAutoGapCheck->isChecked())
- currentPage->guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
- else
- currentPage->guides.setHorizontalAutoGap(0.0);
- drawGuides();
- m_doc->changed();
-}
-
void GuideManager::verticalAutoCountSpin_valueChanged(double val)
{
- bool enable = val != 0;
- verticalAutoGapCheck->setEnabled(enable);
- if (enable && verticalAutoGapCheck->isChecked())
- verticalAutoGapSpin->setEnabled(true);
- else
- verticalAutoGapSpin->setEnabled(false);
+ verticalAutoGapSpin->setEnabled(val > 0);
currentPage->guides.setVerticalAutoCount(static_cast<int>(val));
drawGuides();
m_doc->changed();
@@ -413,25 +367,9 @@
m_doc->changed();
}
-void GuideManager::verticalAutoGapCheck_stateChanged( int )
-{
- verticalAutoGapSpin->setEnabled(verticalAutoGapCheck->isChecked());
- if (verticalAutoGapCheck->isChecked())
- currentPage->guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
- else
- currentPage->guides.setVerticalAutoGap(0.0);
- drawGuides();
- m_doc->changed();
-}
-
void GuideManager::tabWidget_currentChanged(int)
{
drawGuides();
- if (tabWidget->currentIndex() == 1)
- {
- horizontalAutoGapSpin->setEnabled(horizontalAutoGapCheck->isChecked());
- verticalAutoGapSpin->setEnabled(verticalAutoGapCheck->isChecked());
- }
}
Guides GuideManager::selectedHorizontals() const
@@ -460,9 +398,8 @@
void GuideManager::setGuideLock(bool guidesLocked)
{
- bool b = lockCheck->blockSignals(true);
+ QSignalBlocker blocker(lockCheck);
lockCheck->setChecked(guidesLocked);
- lockCheck->blockSignals(b);
}
void GuideManager::forceDrawGuides(const QItemSelection &, const QItemSelection &)
@@ -516,8 +453,16 @@
currentPage->guides.setVerticalAutoGap(0.0);
currentPage->guides.setHorizontalAutoRefer(0);
currentPage->guides.setVerticalAutoRefer(0);
+ {
+ QSignalBlocker horizontalGapBlock(horizontalAutoGapSpin);
+ QSignalBlocker verticalGapBlock(verticalAutoGapSpin);
+ horizontalAutoGapSpin->setValue(0.0);
+ verticalAutoGapSpin->setValue(0.0);
+ }
horizontalAutoCountSpin->setValue(0);
verticalAutoCountSpin->setValue(0);
+ horizontalAutoGapSpin->setEnabled(false);
+ verticalAutoGapSpin->setEnabled(false);
if (trans)
trans.commit();
@@ -562,17 +507,11 @@
{
GuideManagerCore guides;
- double gapValue = 0.0;
- if (horizontalAutoGapCheck->isChecked())
- gapValue = horizontalAutoGapSpin->getValue(SC_PT);
- guides.setHorizontalAutoGap(gapValue);
+ guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
guides.setHorizontalAutoRefer(horizontalRefer());
- gapValue = 0.0;
- if (verticalAutoGapCheck->isChecked())
- gapValue = verticalAutoGapSpin->getValue(SC_PT);
- guides.setVerticalAutoGap(gapValue);
+ guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
guides.setVerticalAutoRefer(verticalRefer());
@@ -583,17 +522,11 @@
{
GuideManagerCore guides;
- double gapValue = 0.0;
- if (horizontalAutoGapCheck->isChecked())
- gapValue = horizontalAutoGapSpin->getValue(SC_PT);
- guides.setHorizontalAutoGap(gapValue);
+ guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
guides.setHorizontalAutoRefer(horizontalRefer());
- gapValue = 0.0;
- if (verticalAutoGapCheck->isChecked())
- gapValue = verticalAutoGapSpin->getValue(SC_PT);
- guides.setVerticalAutoGap(gapValue);
+ guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
guides.setVerticalAutoRefer(verticalRefer());
@@ -678,6 +611,8 @@
return;
currentPage->guides.setHorizontalAutoRefer(0);
drawGuides();
+ if (currentPage->guides.horizontalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::horizontalMarginsAutoButton_toggled(bool state)
@@ -686,6 +621,8 @@
return;
currentPage->guides.setHorizontalAutoRefer(1);
drawGuides();
+ if (currentPage->guides.horizontalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::horizontalSelectionAutoButton_toggled(bool state)
@@ -696,6 +633,8 @@
if (horizontalSelectionAutoButton->isEnabled())
currentPage->guides.resetSelectionForPage(currentPage);
drawGuides();
+ if (currentPage->guides.horizontalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::verticalPageAutoButton_toggled(bool state)
@@ -704,7 +643,8 @@
return;
currentPage->guides.setVerticalAutoRefer(0);
drawGuides();
- m_doc->changed();
+ if (currentPage->guides.verticalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::verticalMarginsAutoButton_toggled(bool state)
@@ -713,7 +653,8 @@
return;
currentPage->guides.setVerticalAutoRefer(1);
drawGuides();
- m_doc->changed();
+ if (currentPage->guides.verticalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::verticalSelectionAutoButton_toggled(bool state)
@@ -724,5 +665,6 @@
if (verticalSelectionAutoButton->isEnabled())
currentPage->guides.resetSelectionForPage(currentPage);
drawGuides();
- m_doc->changed();
+ if (currentPage->guides.verticalAutoCount() > 0)
+ m_doc->changed();
}
Index: scribus/ui/guidemanager.h
===================================================================
--- scribus/ui/guidemanager.h (revision 27910)
+++ scribus/ui/guidemanager.h (working copy)
@@ -137,8 +137,6 @@
void delVerButton_clicked();
void applyToAllStdButton_clicked();
void lockCheck_stateChanged( int );
- void horizontalAutoGapCheck_stateChanged( int );
- void verticalAutoGapCheck_stateChanged( int );
void applyToAllAutoButton_clicked();
void horizontalAutoCountSpin_valueChanged( double );
void verticalAutoCountSpin_valueChanged( double );
Index: scribus/ui/guidemanager.ui
===================================================================
--- scribus/ui/guidemanager.ui (revision 27910)
+++ scribus/ui/guidemanager.ui (working copy)
@@ -8,10 +8,16 @@
<rect>
<x>0</x>
<y>0</y>
- <width>534</width>
- <height>364</height>
+ <width>400</width>
+ <height>370</height>
</rect>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>350</width>
+ <height>300</height>
+ </size>
+ </property>
<property name="windowTitle">
<string>Guide Manager</string>
</property>
@@ -55,7 +61,7 @@
<item>
<widget class="QGroupBox" name="horizontalGroupBox">
<property name="title">
- <string>&Horizontal Guides</string>
+ <string>&Horizontal guides</string>
</property>
<layout class="QGridLayout">
<property name="horizontalSpacing">
@@ -117,7 +123,7 @@
<item>
<widget class="QGroupBox" name="verticalGroupBox">
<property name="title">
- <string>&Vertical Guides</string>
+ <string>&Vertical guides</string>
</property>
<layout class="QGridLayout">
<property name="horizontalSpacing">
@@ -225,6 +231,9 @@
<string>&Rows && Columns</string>
</attribute>
<layout class="QGridLayout">
+ <property name="verticalSpacing">
+ <number>8</number>
+ </property>
<property name="leftMargin">
<number>9</number>
</property>
@@ -240,16 +249,19 @@
<item row="0" column="0">
<widget class="QGroupBox" name="horizontalAutoGroup">
<property name="title">
- <string>&Horizontal Guides</string>
+ <string>&Horizontal guides</string>
</property>
- <layout class="QGridLayout">
- <property name="horizontalSpacing">
- <number>20</number>
- </property>
- <property name="verticalSpacing">
- <number>8</number>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalAutoControlsLayout">
+ <property name="spacing">
+ <number>16</number>
</property>
- <item row="0" column="0">
+ <item>
<widget class="FormWidget" name="horizontalRelativeForm" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
@@ -330,8 +342,14 @@
</layout>
</widget>
</item>
- <item row="0" column="1">
+ <item>
<widget class="FormWidget" name="horizontalNumberForm" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="label" stdset="0">
<string>Number</string>
</property>
@@ -379,51 +397,87 @@
</layout>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="horizontalAutoGapCheck">
- <property name="toolTip">
- <string>Set the gap between adjacent generated rows</string>
+ <item>
+ <widget class="FormWidget" name="horizontalGapForm" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="text">
- <string>Gap:</string>
+ <property name="label" stdset="0">
+ <string>Gap</string>
</property>
+ <layout class="QHBoxLayout" name="horizontalGapLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="ScrSpinBox" name="horizontalAutoGapSpin">
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Set the gap between adjacent generated rows</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
- <item row="1" column="1">
- <widget class="ScrSpinBox" name="horizontalAutoGapSpin">
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
+ <item>
+ <spacer name="horizontalAutoControlsSpacer">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
</property>
- <property name="maximumSize">
+ <property name="sizeType">
+ <enum>QSizePolicy::Policy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
<size>
- <width>100</width>
- <height>16777215</height>
+ <width>10</width>
+ <height>10</height>
</size>
</property>
- <property name="toolTip">
- <string>Set the gap between adjacent generated rows</string>
- </property>
- </widget>
+ </spacer>
</item>
</layout>
</widget>
</item>
- <item row="0" column="1">
+ <item row="1" column="0">
<widget class="QGroupBox" name="verticalAutoGroup">
<property name="title">
- <string>&Vertical Guides</string>
+ <string>&Vertical guides</string>
</property>
- <layout class="QGridLayout">
- <property name="horizontalSpacing">
- <number>20</number>
- </property>
- <property name="verticalSpacing">
- <number>8</number>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QHBoxLayout" name="verticalAutoControlsLayout">
+ <property name="spacing">
+ <number>16</number>
</property>
- <item row="0" column="0">
+ <item>
<widget class="FormWidget" name="verticalRelativeForm" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
@@ -504,8 +558,14 @@
</layout>
</widget>
</item>
- <item row="0" column="1">
+ <item>
<widget class="FormWidget" name="verticalNumberForm" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="label" stdset="0">
<string>Number</string>
</property>
@@ -553,39 +613,72 @@
</layout>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="verticalAutoGapCheck">
- <property name="toolTip">
- <string>Set the gap between adjacent generated columns</string>
+ <item>
+ <widget class="FormWidget" name="verticalGapForm" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="text">
- <string>Gap:</string>
+ <property name="label" stdset="0">
+ <string>Gap</string>
</property>
+ <layout class="QHBoxLayout" name="verticalGapLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="ScrSpinBox" name="verticalAutoGapSpin">
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Set the gap between adjacent generated columns</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
- <item row="1" column="1">
- <widget class="ScrSpinBox" name="verticalAutoGapSpin">
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
+ <item>
+ <spacer name="verticalAutoControlsSpacer">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Policy::Expanding</enum>
</property>
- <property name="maximumSize">
+ <property name="sizeHint" stdset="0">
<size>
- <width>100</width>
- <height>16777215</height>
+ <width>10</width>
+ <height>10</height>
</size>
</property>
- <property name="toolTip">
- <string>Set the gap between adjacent generated columns</string>
- </property>
- </widget>
+ </spacer>
</item>
</layout>
</widget>
</item>
- <item row="1" column="0" colspan="2">
+ <item row="2" column="0">
<layout class="QHBoxLayout" name="applyAutoLayout">
<item>
<spacer name="horizontalSpacerApplyLeft">
@@ -615,7 +708,7 @@
</item>
</layout>
</item>
- <item row="2" column="0" colspan="2">
+ <item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
gmu2-manual-guide-editing-ux-v1.00.patch (24,109 bytes)
Index: scribus/guidesdelegate.cpp
===================================================================
--- scribus/guidesdelegate.cpp (revision 27910)
+++ scribus/guidesdelegate.cpp (working copy)
@@ -5,6 +5,7 @@
for which a new license (GPL+exception) is in place.
*/
#include <QModelIndex>
+#include <QPointer>
#include "ui/scrspinbox.h"
#include "scribusdoc.h"
@@ -17,17 +18,6 @@
{
}
-// QWidget * GuidesDelegate::createEditor(QWidget *parent,
-// const QStyleOptionViewItem &/* option */,
-// const QModelIndex &/* index */) const
-// {
-// Q_ASSERT_X(m_doc != 0, "GuidesDelegate::createEditor",
-// "No reference to the doc");
-// ScrSpinBox *editor = new ScrSpinBox(0, m_doc->currentPage()->height(),
-// parent, m_doc->unitIndex());
-// return editor;
-// }
-
void GuidesDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
double value = index.model()->data(index, Qt::EditRole).toDouble();
@@ -54,6 +44,14 @@
m_doc = doc;
}
+void GuidesDelegate::finishEditing(QWidget *editor)
+{
+ QPointer<QWidget> guard(editor);
+ emit commitData(editor);
+ if (guard)
+ emit closeEditor(editor);
+}
+
// horizontals
@@ -70,6 +68,7 @@
double max = (m_doc->currentPage()->height() * uix) + (m_doc->bleeds()->bottom() * uix);
ScrSpinBox *editor = new ScrSpinBox(min, max, parent, m_doc->unitIndex());
editor->setConstants(&m_doc->constants());
+ emit editorOpened(editor);
return editor;
}
@@ -88,5 +87,6 @@
double max = (m_doc->currentPage()->width() * uix) + (m_doc->bleeds()->right() * uix);
ScrSpinBox *editor = new ScrSpinBox(min, max, parent, m_doc->unitIndex());
editor->setConstants(&m_doc->constants());
+ emit editorOpened(editor);
return editor;
}
Index: scribus/guidesdelegate.h
===================================================================
--- scribus/guidesdelegate.h (revision 27910)
+++ scribus/guidesdelegate.h (working copy)
@@ -24,11 +24,6 @@
public:
GuidesDelegate(QObject *parent = nullptr);
-// implemented in inheritance
-// QWidget *createEditor(QWidget *parent,
-// const QStyleOptionViewItem &option,
-// const QModelIndex &index) const;
-
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor,
@@ -39,8 +34,11 @@
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
- void unitChange(int docUnitDecimals);
void setDoc(ScribusDoc * doc);
+ void finishEditing(QWidget *editor);
+
+ signals:
+ void editorOpened(QWidget *editor) const;
// protected due const in createEditor
protected:
Index: scribus/guidesmodel.cpp
===================================================================
--- scribus/guidesmodel.cpp (revision 27910)
+++ scribus/guidesmodel.cpp (working copy)
@@ -12,31 +12,29 @@
#include "units.h"
-GuidesModel::GuidesModel(QObject * /*parent*/)
+GuidesModel::GuidesModel(QObject *parent)
+ : QAbstractTableModel(parent)
{
}
GuidesModel::~GuidesModel() = default;
-int GuidesModel::rowCount(const QModelIndex & /*parent*/) const
+int GuidesModel::rowCount(const QModelIndex &parent) const
{
- return m_values.count();
+ return parent.isValid() ? 0 : m_values.count();
}
-int GuidesModel::columnCount(const QModelIndex & /*parent*/) const
+int GuidesModel::columnCount(const QModelIndex &parent) const
{
- // for future RFEs - color per guide etc.
- return 1;
+ return parent.isValid() ? 0 : 1;
}
QVariant GuidesModel::data(const QModelIndex & index, int role) const
{
- if (!index.isValid())
+ if (!index.isValid() || index.model() != this || index.column() != 0 ||
+ index.row() < 0 || index.row() >= m_values.count())
return QVariant();
- // DisplayRole and EditRole *must* be split. There is rounding
- // in pts2value(), toString() sequence. It disallows to compare
- // these values with m_data list.
- // Call it with EditRole when you need exact value.
+ // Display is rounded to the document's precision; editing uses the value.
if (role == Qt::DisplayRole)
{
QLocale l;
@@ -50,28 +48,84 @@
if (role == Qt::UserRole)
return m_values.at(index.row());
- if (role == Qt::BackgroundRole && m_values.at(index.row()) == 0.0)
- return QVariant(QColor(Qt::red));
return QVariant();
}
bool GuidesModel::setData(const QModelIndex & index, const QVariant & value, int role)
{
- if (role != Qt::EditRole || !index.isValid())
+ if (role != Qt::EditRole || !index.isValid() || index.model() != this ||
+ index.column() != 0 || index.row() < 0 || index.row() >= m_values.count())
return false;
bool ok;
double newVal = value.toDouble(&ok);
if (!ok)
return false;
- m_values[index.row()] = value2pts(newVal, m_docUnitIndex) + m_rule;
- std::sort(m_values.begin(), m_values.end());
- emit dataChanged(index, index);
- emit valueChanged();
+
+ const int oldRow = index.row();
+ const double oldPos = m_values.at(oldRow);
+ const double newPos = value2pts(newVal, m_docUnitIndex) + m_rule;
+ const bool pending = (oldRow == m_pendingRow);
+ // A newly added row must be committed even when its value stays at zero.
+ // Existing guides, however, must not generate history for unchanged edits.
+ if (!pending)
+ {
+ QLocale locale;
+ const double shownValue = locale.toDouble(locale.toString(pts2value(oldPos - m_rule, m_docUnitIndex),
+ 'f', m_docUnitDecimals));
+ if (oldPos == newPos || shownValue == newVal)
+ return true;
+ }
+
+ // Do not replace an existing guide at the same position. For a pending
+ // row, disregard that row itself when checking whether a guide exists.
+ const bool occupied = m_values.contains(newPos) &&
+ (!pending || newPos != oldPos || m_values.count(newPos) > 1);
+ if (occupied)
+ {
+ beginRemoveRows(QModelIndex(), oldRow, oldRow);
+ m_values.removeAt(oldRow);
+ if (pending)
+ m_pendingRow = -1;
+ endRemoveRows();
+ }
+ else
+ {
+ int newRow = 0;
+ for (int i = 0; i < m_values.count(); ++i)
+ {
+ if (i != oldRow && m_values.at(i) < newPos)
+ ++newRow;
+ }
+ if (newRow != oldRow)
+ {
+ const int destination = newRow > oldRow ? newRow + 1 : newRow;
+ beginMoveRows(QModelIndex(), oldRow, oldRow, QModelIndex(), destination);
+ m_values.removeAt(oldRow);
+ m_values.insert(newRow, newPos);
+ endMoveRows();
+ }
+ else
+ m_values[oldRow] = newPos;
+ if (pending)
+ m_pendingRow = -1;
+ const QModelIndex changed = this->index(newRow, 0);
+ emit dataChanged(changed, changed);
+ }
+ if (pending)
+ {
+ if (!occupied)
+ emit guideAdded(newPos);
+ }
+ else
+ emit valueChanged(oldPos, newPos);
return true;
}
-Qt::ItemFlags GuidesModel::flags(const QModelIndex & /*index*/) const
+Qt::ItemFlags GuidesModel::flags(const QModelIndex &index) const
{
+ if (!index.isValid() || index.model() != this || index.column() != 0 ||
+ index.row() < 0 || index.row() >= m_values.count())
+ return Qt::NoItemFlags;
return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
}
@@ -84,42 +138,36 @@
void GuidesModel::removeValues(const Guides & guides)
{
+ if (guides.isEmpty())
+ return;
beginResetModel();
for (double d : guides)
m_values.removeAll(d);
+ m_pendingRow = -1;
endResetModel();
}
-// bool GuidesModel::removeRows(int row, int count, const QModelIndex & parent)
-// {
-// if (count <= 0 || row < 0 || (row + count - 1) > m_values.count())
-// return false;
-//
-// beginRemoveRows(parent, row, row + count - 1);
-// for (int i = 0; i < count; ++i)
-// m_values.removeAt(row);
-// endRemoveRows();
-// return true;
-// }
-
-// bool GuidesModel::insertRows( int row, int count, const QModelIndex & parent)
-// {
-// beginInsertRows(parent, row, row + count - 1);
-// for (int i = 0; i < count; ++i)
-// m_values.insert(row + count, 0.0);
-// endInsertRows();
-// return true;
-// }
+int GuidesModel::insertRow()
+{
+ if (m_pendingRow >= 0)
+ return m_pendingRow;
+ // The temporary editor row is distinct from a committed guide at zero.
+ // Store ruler-relative zero as the initial value shown in the editor.
+ beginInsertRows(QModelIndex(), 0, 0);
+ m_values.prepend(m_rule);
+ m_pendingRow = 0;
+ endInsertRows();
+ return m_pendingRow;
+}
-void GuidesModel::insertRow()
+void GuidesModel::discardPendingRow()
{
-// insertRows(rowCount(), 1);
- beginResetModel();
- if (m_values.contains(0.0))
+ if (m_pendingRow < 0)
return;
- m_values.append(0.0);
- std::sort(m_values.begin(), m_values.end());
- endResetModel();
+ beginRemoveRows(QModelIndex(), m_pendingRow, m_pendingRow);
+ m_values.removeAt(m_pendingRow);
+ m_pendingRow = -1;
+ endRemoveRows();
}
void GuidesModel::setValues(const Guides& values)
@@ -127,6 +175,7 @@
beginResetModel();
m_values = values;
std::sort(m_values.begin(), m_values.end());
+ m_pendingRow = -1;
endResetModel();
}
@@ -143,15 +192,3 @@
m_docUnitDecimals = docUnitDecimals;
endResetModel();
}
-
-#if 0
-// debug
-#include <QtDebug>
-void GuidesModel::printValues()
-{
- qDebug() << "GuidesModel dump start";
- for (int i = 0; i < m_values.count(); ++i)
- qDebug() << "GuidesModel dump: " << m_values[i];
- qDebug() << "GuidesModel end of dump";
-}
-#endif
Index: scribus/guidesmodel.h
===================================================================
--- scribus/guidesmodel.h (revision 27910)
+++ scribus/guidesmodel.h (working copy)
@@ -11,12 +11,8 @@
#include "scribusstructs.h"
-/*! \brief A model for guides lists.
-It holds guides as a double QList (it will be expanded later because of RFEs)
-and it handles its values editing too. The editor from GuidesDelegate
-is used.
-See Qt4 documentation for more info about its methods.
-FIXME: unit conversions for dipslay vs. internal
+/*! \brief A model for editing manual guide positions.
+Positions are stored in document points and displayed relative to the ruler.
\author Petr Vanek <petr@scribus.info>
*/
class GuidesModel : public QAbstractTableModel
@@ -38,11 +34,8 @@
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void removeValues(const Guides & guides);
- // qt4 api is "wrokarounded" with insertRow() and removeValues()
- // these removeRows() and insertRows() does not handle margin items correctly
-// bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
-// bool insertRows( int row, int count, const QModelIndex & parent = QModelIndex());
- void insertRow();
+ int insertRow();
+ void discardPendingRow();
//! \brief Set new values into the model.
void setValues(const Guides& values);
@@ -50,18 +43,16 @@
const Guides& values() const;
void unitChange(int docUnitIndex, int docUnitDecimals, double offset);
-#if 0
- //! debug only
- void printValues();
-#endif
signals:
/*! \brief Signal emitted when the user finishes editing one value.
*/
- void valueChanged();
+ void valueChanged(double oldPosition, double newPosition);
+ void guideAdded(double position);
private:
Guides m_values;
+ int m_pendingRow {-1};
int m_docUnitIndex {0};
int m_docUnitDecimals {0};
double m_rule {0.0};
Index: scribus/ui/guidemanager.cpp
===================================================================
--- scribus/ui/guidemanager.cpp (revision 27910)
+++ scribus/ui/guidemanager.cpp (working copy)
@@ -22,6 +22,8 @@
* *
***************************************************************************/
+#include <QEvent>
+#include <QMetaObject>
#include <QSignalBlocker>
#include "guidemanager.h"
@@ -56,6 +58,13 @@
delHorButton->setIcon(im.loadIcon("edit-delete"));
addVerButton->setIcon(im.loadIcon("list-add"));
delVerButton->setIcon(im.loadIcon("edit-delete"));
+ // Clicking the checkmark must not close the editor before the click handler.
+ // Tab still reaches these buttons through ordinary keyboard navigation.
+ addHorButton->setFocusPolicy(Qt::TabFocus);
+ addVerButton->setFocusPolicy(Qt::TabFocus);
+ standardPage->installEventFilter(this);
+ horizontalGroupBox->installEventFilter(this);
+ verticalGroupBox->installEventFilter(this);
horizontalPageAutoButton->setIcon(im.loadIcon("align-to-page"));
horizontalMarginsAutoButton->setIcon(im.loadIcon("align-to-margin"));
horizontalSelectionAutoButton->setIcon(im.loadIcon("align-to-last-selection"));
@@ -66,13 +75,61 @@
// MVC
horizontalModel = new GuidesModel(this);
verticalModel = new GuidesModel(this);
- GuidesHDelegate * hdelegate = new GuidesHDelegate();
- GuidesVDelegate * vdelegate = new GuidesVDelegate();
+ GuidesHDelegate * hdelegate = new GuidesHDelegate(horizontalView);
+ GuidesVDelegate * vdelegate = new GuidesVDelegate(verticalView);
horizontalView->setItemDelegateForColumn(0, hdelegate);
verticalView->setItemDelegateForColumn(0, vdelegate);
horizontalView->setModel(horizontalModel);
verticalView->setModel(verticalModel);
+ connect(hdelegate, &GuidesDelegate::editorOpened, this, [this](QWidget *editor) {
+ m_horizontalEditor = editor;
+ setAddButtonEditing(addHorButton, true, true);
+ connect(editor, &QObject::destroyed, this, [this, editor]() {
+ if (m_horizontalEditor == editor)
+ {
+ m_horizontalEditor = nullptr;
+ setAddButtonEditing(addHorButton, false, true);
+ }
+ });
+ });
+ connect(vdelegate, &GuidesDelegate::editorOpened, this, [this](QWidget *editor) {
+ m_verticalEditor = editor;
+ setAddButtonEditing(addVerButton, true, false);
+ connect(editor, &QObject::destroyed, this, [this, editor]() {
+ if (m_verticalEditor == editor)
+ {
+ m_verticalEditor = nullptr;
+ setAddButtonEditing(addVerButton, false, false);
+ }
+ });
+ });
+ connect(hdelegate, &QAbstractItemDelegate::closeEditor, this, [this](QWidget *editor) {
+ if (m_horizontalEditor == editor)
+ {
+ m_horizontalEditor = nullptr;
+ setAddButtonEditing(addHorButton, false, true);
+ // Allow QTableView to finish closing the editor before removing its row.
+ ScPage* page = currentPage;
+ QMetaObject::invokeMethod(this, [this, page]() {
+ if (currentPage == page)
+ discardPendingGuide(true);
+ }, Qt::QueuedConnection);
+ }
+ });
+ connect(vdelegate, &QAbstractItemDelegate::closeEditor, this, [this](QWidget *editor) {
+ if (m_verticalEditor == editor)
+ {
+ m_verticalEditor = nullptr;
+ setAddButtonEditing(addVerButton, false, false);
+ ScPage* page = currentPage;
+ QMetaObject::invokeMethod(this, [this, page]() {
+ if (currentPage == page)
+ discardPendingGuide(false);
+ }, Qt::QueuedConnection);
+ }
+ });
+
connect(addHorButton, SIGNAL(clicked()), this, SLOT(addHorButton_clicked()));
connect(delHorButton, SIGNAL(clicked()), this, SLOT(delHorButton_clicked()));
connect(horizontalView, SIGNAL(deleteKeyPressed()), this, SLOT(delHorButton_clicked()));
@@ -101,17 +158,15 @@
connect(lockCheck, SIGNAL(stateChanged(int)), this, SLOT(lockCheck_stateChanged(int)));
- connect(horizontalModel, SIGNAL(valueChanged()), this, SLOT(horizontalModel_valueChanged()));
- connect(verticalModel, SIGNAL(valueChanged()), this, SLOT(verticalModel_valueChanged()));
+ connect(horizontalModel, &GuidesModel::valueChanged, this, &GuideManager::horizontalModel_valueChanged);
+ connect(verticalModel, &GuidesModel::valueChanged, this, &GuideManager::verticalModel_valueChanged);
+ connect(horizontalModel, &GuidesModel::guideAdded, this, [this](double pos) { addGuide(true, pos); });
+ connect(verticalModel, &GuidesModel::guideAdded, this, [this](double pos) { addGuide(false, pos); });
connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabWidget_currentChanged(int)));
}
-GuideManager::~GuideManager()
-{
- delete horizontalView->itemDelegateForColumn(0);
- delete verticalView->itemDelegateForColumn(0);
-}
+GuideManager::~GuideManager() = default;
void GuideManager::setDoc(ScribusDoc* doc)
{
@@ -225,6 +280,38 @@
void GuideManager::languageChange()
{
retranslateUi(this);
+ setAddButtonEditing(addHorButton, m_horizontalEditor != nullptr, true);
+ setAddButtonEditing(addVerButton, m_verticalEditor != nullptr, false);
+}
+
+void GuideManager::discardPendingGuide(bool horizontal)
+{
+ if (!currentPage || (horizontal ? m_horizontalEditor : m_verticalEditor))
+ return;
+ (horizontal ? horizontalModel : verticalModel)->discardPendingRow();
+}
+
+void GuideManager::setAddButtonEditing(QToolButton *button, bool editing, bool horizontal)
+{
+ button->setIcon(IconManager::instance().loadIcon(editing ? "ok" : "list-add"));
+ button->setToolTip(editing ? tr("Finish editing")
+ : horizontal ? tr("Add a new horizontal guide")
+ : tr("Add a new vertical guide"));
+}
+
+bool GuideManager::eventFilter(QObject *watched, QEvent *event)
+{
+ if (event->type() == QEvent::MouseButtonPress &&
+ (watched == standardPage || watched == horizontalGroupBox || watched == verticalGroupBox))
+ {
+ // Guide-list blank space already finishes editing. Match it on the
+ // surrounding background without changing the selected guide.
+ if (m_horizontalEditor)
+ horizontalView->setFocus(Qt::MouseFocusReason);
+ else if (m_verticalEditor)
+ verticalView->setFocus(Qt::MouseFocusReason);
+ }
+ return ScrPaletteBase::eventFilter(watched, event);
}
void GuideManager::unitChange()
@@ -285,15 +372,31 @@
void GuideManager::addHorButton_clicked()
{
- horizontalModel->insertRow();
- horizontalView->setCurrentIndex(horizontalModel->index(0, 0, QModelIndex()));
+ if (m_verticalEditor)
+ qobject_cast<GuidesDelegate*>(verticalView->itemDelegateForColumn(0))->finishEditing(m_verticalEditor);
+ if (m_horizontalEditor)
+ {
+ qobject_cast<GuidesDelegate*>(horizontalView->itemDelegateForColumn(0))->finishEditing(m_horizontalEditor);
+ horizontalView->setFocus(Qt::OtherFocusReason);
+ return;
+ }
+ const int row = horizontalModel->insertRow();
+ horizontalView->setCurrentIndex(horizontalModel->index(row, 0));
horizontalView->edit(horizontalView->currentIndex());
}
void GuideManager::addVerButton_clicked()
{
- verticalModel->insertRow();
- verticalView->setCurrentIndex(verticalModel->index(0, 0, QModelIndex()));
+ if (m_horizontalEditor)
+ qobject_cast<GuidesDelegate*>(horizontalView->itemDelegateForColumn(0))->finishEditing(m_horizontalEditor);
+ if (m_verticalEditor)
+ {
+ qobject_cast<GuidesDelegate*>(verticalView->itemDelegateForColumn(0))->finishEditing(m_verticalEditor);
+ verticalView->setFocus(Qt::OtherFocusReason);
+ return;
+ }
+ const int row = verticalModel->insertRow();
+ verticalView->setCurrentIndex(verticalModel->index(row, 0));
verticalView->edit(verticalView->currentIndex());
}
@@ -409,7 +512,7 @@
void GuideManager::drawGuides()
{
- if (!m_doc || !m_drawGuides)
+ if (!m_doc || !currentPage || !m_drawGuides)
return;
currentPage->guides.addHorizontals(getAutoHorizontals(currentPage), GuideManagerCore::Auto);
@@ -533,22 +636,48 @@
return guides.getAutoHorizontals(page);
}
-void GuideManager::verticalModel_valueChanged()
+void GuideManager::addGuide(bool horizontal, double position)
{
- currentPage->guides.clearVerticals(GuideManagerCore::Standard);
- currentPage->guides.addVerticals(verticalModel->values(), GuideManagerCore::Standard);
+ if (!currentPage)
+ return;
+ const Guides existing = horizontal ? currentPage->guides.horizontals(GuideManagerCore::Standard)
+ : currentPage->guides.verticals(GuideManagerCore::Standard);
+ if (existing.contains(position))
+ return;
+ if (horizontal)
+ currentPage->guides.addHorizontal(position, GuideManagerCore::Standard);
+ else
+ currentPage->guides.addVertical(position, GuideManagerCore::Standard);
drawGuides();
m_doc->changed();
}
-void GuideManager::horizontalModel_valueChanged()
+void GuideManager::guideValueChanged(bool horizontal, double oldPosition, double newPosition)
{
- currentPage->guides.clearHorizontals(GuideManagerCore::Standard);
- currentPage->guides.addHorizontals(horizontalModel->values(), GuideManagerCore::Standard);
+ if (!currentPage || oldPosition == newPosition)
+ return;
+ const Guides existing = horizontal ? currentPage->guides.horizontals(GuideManagerCore::Standard)
+ : currentPage->guides.verticals(GuideManagerCore::Standard);
+ if (!existing.contains(oldPosition))
+ return;
+ if (horizontal)
+ currentPage->guides.moveHorizontal(oldPosition, newPosition, GuideManagerCore::Standard);
+ else
+ currentPage->guides.moveVertical(oldPosition, newPosition, GuideManagerCore::Standard);
drawGuides();
m_doc->changed();
}
+void GuideManager::verticalModel_valueChanged(double oldPosition, double newPosition)
+{
+ guideValueChanged(false, oldPosition, newPosition);
+}
+
+void GuideManager::horizontalModel_valueChanged(double oldPosition, double newPosition)
+{
+ guideValueChanged(true, oldPosition, newPosition);
+}
+
void GuideManager::setHorizontalRefer(int button)
{
switch (button)
Index: scribus/ui/guidemanager.h
===================================================================
--- scribus/ui/guidemanager.h (revision 27910)
+++ scribus/ui/guidemanager.h (working copy)
@@ -17,6 +17,7 @@
class GuidesModel;
class ScribusDoc;
+class QToolButton;
@@ -73,11 +74,12 @@
protected:
void changeEvent(QEvent *e) override;
+ bool eventFilter(QObject *watched, QEvent *event) override;
private:
- //! \brief Store the guide values in the Qt4 model
+ //! \brief Model for horizontal manual guides
GuidesModel * horizontalModel { nullptr };
- //! \brief Store the guide values in the Qt4 model
+ //! \brief Model for vertical manual guides
GuidesModel * verticalModel { nullptr };
ScribusDoc* m_doc { nullptr };
@@ -85,6 +87,8 @@
ScPage * currentPage { nullptr };
//! \brief A flag to prevent guides drawing when it's not needed
bool m_drawGuides { true };
+ QWidget *m_horizontalEditor { nullptr };
+ QWidget *m_verticalEditor { nullptr };
//! \brief Initialise the units. Spin boxes gets pt/mm/etc. extensions here.
void unitChange();
@@ -116,6 +120,10 @@
/*! \brief Draw guides into painter */
void drawGuides();
+ void guideValueChanged(bool horizontal, double oldPosition, double newPosition);
+ void addGuide(bool horizontal, double position);
+ void setAddButtonEditing(QToolButton *button, bool editing, bool horizontal);
+ void discardPendingGuide(bool horizontal);
/*! \brief These methods simulate old button group behaviour.
Is there a better way to do it? QButtonGroup? It's more code...
@@ -129,8 +137,8 @@
private slots:
//! Wrapper slot for drawGuides()
void forceDrawGuides(const QItemSelection &, const QItemSelection &);
- void verticalModel_valueChanged();
- void horizontalModel_valueChanged();
+ void verticalModel_valueChanged(double oldPosition, double newPosition);
+ void horizontalModel_valueChanged(double oldPosition, double newPosition);
void addHorButton_clicked();
void delHorButton_clicked();
void addVerButton_clicked();
Index: scribus/ui/guidemanager.ui
===================================================================
--- scribus/ui/guidemanager.ui (revision 27910)
+++ scribus/ui/guidemanager.ui (working copy)
@@ -82,6 +82,9 @@
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="horizontalGuideActionsLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
<item>
<widget class="QToolButton" name="addHorButton">
<property name="toolTip">
@@ -144,6 +147,9 @@
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalGuideActionsLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
<item>
<widget class="QToolButton" name="addVerButton">
<property name="toolTip">
| ||||
| Patch | Yes | ||||
|
|
looks clean. (and it doesn't need the useless click for the gaps…) |
|
|
I would rename the button to "Apply to All Pages" and put it on the left side... |
|
|
Noted. While we are at it, how about a little gap between Relative to cluster and the Number spinbox? |
|
|
I wonder what Martin has to say about this "new" usage of his widgets : - ) I would do a few and then ask if he can create some rules. |
|
|
Here is a a proposal with one single tab and less buttons. A few instructions for adapting the code based on it: - I would use + and - icons for the buttons creating and deleting the horizontal and vertical guides (in the future we need a clear policy on which icons to use for creating and deleting single resources; if a - does not exist, create one based on the +, without the vertical line) - I would use the trash can for the two lower buttons next to the lists: they delete all guides in the list left to them. - For the "Apply to all pages" button, for now I would use the same icons as for "Duplicate selected page" in the Arrange Pages palette (something with multiple pages on it). It's an action tool button that triggers the action once. - For the Lock button from the X Y Z tab in the Properties palette, both for the locked and unlocked state. It's a button with state that is active when is in the down state (exact same behavior as in the X Y Z tab) - The Form fields for the Rows and Columns do not have the same width and that should be fixed. It's already like this in the original "gmu-" patch attached to this ticket and I could not spot the reason for the difference. Some remarks: - Clearing all the guides will be two clicks instead of one; clearing all guides on all pages will be three clicks instead of one. I've never done any of those two actions and I don't believe there are users who will be slowed down in their workflow by this change - The "Lock guides" is at the bottom. It could also go just above "Row & Columns", but I prefer to have it down there for now: - The top widgets apply by default to the current page - The two buttons at the end are for the whole document. The first one on demand, the second is always for the whole document. - In my case, the main (or only) reason for opening the dialog is to go to the "Column and rows" setting: for all people that otherwise create their guides on the canvas, this change will speed up their work. guidemanager.ui (23,471 bytes)
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<author>Petr Vanek <petr@scribus.info></author>
<comment>Use designer to update source ui file. All manual changes in cpp/h files will be lost</comment>
<class>GuideManager</class>
<widget class="ScrPaletteBase" name="GuideManager">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>495</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
<string>Guide Manager</string>
</property>
<layout class="QGridLayout">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QGroupBox" name="horizontalGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>&Horizontal guides</string>
</property>
<layout class="QGridLayout">
<property name="horizontalSpacing">
<number>5</number>
</property>
<item row="0" column="1">
<layout class="QVBoxLayout" name="horizontalGuideActionsLayout">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QToolButton" name="addHorButton">
<property name="toolTip">
<string>Add a new horizontal guide</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="delHorButton">
<property name="toolTip">
<string>Delete the selected horizontal guide</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="delAllHorButton">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="GuidesView" name="horizontalView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="verticalGroupBox">
<property name="title">
<string>&Vertical guides</string>
</property>
<layout class="QGridLayout">
<property name="horizontalSpacing">
<number>5</number>
</property>
<item row="0" column="0">
<widget class="GuidesView" name="verticalView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
</widget>
</item>
<item row="0" column="1">
<layout class="QVBoxLayout" name="verticalGuideActionsLayout">
<property name="spacing">
<number>6</number>
</property>
<item>
<widget class="QToolButton" name="addVerButton">
<property name="toolTip">
<string>Add a new vertical guide</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="delVerButton">
<property name="toolTip">
<string>Delete the selected vertical guide</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="delAllVerButton">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="verticalAutoGroup">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Rows & Columns</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>16</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="FormWidget" name="verticalRelativeForm">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="label" stdset="0">
<string>Relative to</string>
</property>
<layout class="QHBoxLayout" name="verticalRelativeButtonsLayout">
<property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="verticalPageAutoButton">
<property name="toolTip">
<string>Relative to page</string>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="verticalMarginsAutoButton">
<property name="toolTip">
<string>Relative to margins</string>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="verticalSelectionAutoButton">
<property name="toolTip">
<string>Relative to selection</string>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="FormWidget" name="verticalNumberForm">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="label" stdset="0">
<string>Rows</string>
</property>
<layout class="QHBoxLayout" name="verticalNumberLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="ScrSpinBox" name="verticalAutoCountSpin">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Number of vertical guides to create</string>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="FormWidget" name="verticalGapForm">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="label" stdset="0">
<string>Gap</string>
</property>
<layout class="QHBoxLayout" name="verticalGapLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="ScrSpinBox" name="verticalAutoGapSpin">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Set the gap between adjacent generated columns</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="FormWidget" name="horizontalRelativeForm">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="label" stdset="0">
<string>Relative to</string>
</property>
<layout class="QHBoxLayout" name="horizontalRelativeButtonsLayout">
<property name="spacing">
<number>5</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="horizontalPageAutoButton">
<property name="toolTip">
<string>Relative to page</string>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="horizontalMarginsAutoButton">
<property name="toolTip">
<string>Relative to margins</string>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="horizontalSelectionAutoButton">
<property name="toolTip">
<string>Relative to selection</string>
</property>
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="FormWidget" name="horizontalNumberForm">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="label" stdset="0">
<string>Columns</string>
</property>
<layout class="QHBoxLayout" name="horizontalNumberLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="ScrSpinBox" name="horizontalAutoCountSpin">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Number of horizontal guides to create</string>
</property>
<property name="suffix">
<string/>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="value">
<double>0.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="FormWidget" name="horizontalGapForm">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="label" stdset="0">
<string>Gap</string>
</property>
<layout class="QHBoxLayout" name="horizontalGapLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="ScrSpinBox" name="horizontalAutoGapSpin">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Set the gap between adjacent generated rows</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalAutoControlsSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Policy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QToolButton" name="applyAllPagesButton">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="applyAllPagesLabel">
<property name="text">
<string>Apply to all pages</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="lockGuidesButton">
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lockGuidesLabel">
<property name="text">
<string>Lock guides</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>FormWidget</class>
<extends>QWidget</extends>
<header>ui/widgets/form_widget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ScrSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header location="global">ui/scrspinbox.h</header>
</customwidget>
<customwidget>
<class>ScrPaletteBase</class>
<extends>QWidget</extends>
<header>ui/scrpalettebase.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GuidesView</class>
<extends>QTableView</extends>
<header>guidesview.h</header>
</customwidget>
</customwidgets>
<includes>
<include location="local">ui/scrpalettebase.h</include>
<include location="local">ui/scrspinbox.h</include>
</includes>
<resources/>
<connections/>
</ui>
|
|
|
There is no "Clear all guides" button @ale. The trash can ones only clear the manual guides, not the auto ones. |
|
|
Ok, I could finalize my work on the patch that merges the two two tabs in one single dialog. Here a summary of the changes: - There are no tabs anymore. - Buttar's patches gmu1 and gmu2 are part of this patch. - For the rows and columns, the margins (and not the page) are used as the default choice. - There is no button for clearing all the guides in the document. And clearing the page's guides is a two click process (horizontal and vertical; plus setting rows and columns to zero, if needed). Considering that the "clear" actions are not so common, making the UI simpler to understand should more than compensate the removal of the dedicated actions. - I added a new icon name "list-clear": for now it uses the already existing trash can (but I would be happy to use something better!) - I'm using the icon for "multiple page duplicate" for "apply to all pages". It fits well enough the task, but we might want to have a specific icon for it in the future. - The + shortcut adds a new guide, when one of the lists are active (Del key was already recognized for deleting) - I have changed the name of functions and variables to use full names (from "addVerButton" to "addVerticalButton") - The dialog now uses the new signals and slots syntax. Finally, I did not review all changes in gmu1 and gmu2 but: - The parts I've tweaked or otherwise looked at were of good quality. - In my tests of the dialog, I could not detect anything not working as expected. guides-manager.diff (89,722 bytes)
diff --git a/resources/iconsets/1_7_0/1_7_0.xml b/resources/iconsets/1_7_0/1_7_0.xml
index 6880d7635..03cd4814e 100644
--- a/resources/iconsets/1_7_0/1_7_0.xml
+++ b/resources/iconsets/1_7_0/1_7_0.xml
@@ -383,7 +383,8 @@ On Dark: #e580ff; rgb(229, 128, 255); hsl(288, 100, 75)
<icon id="layer-move-up" file="16/object-level-up.svg" />
<icon id="layer-outline" file="16/object-outline.svg" />
<icon id="list-add" file="16/action-add.svg" />
- <icon id="list-remove" file="16/action-remove.svg" />
+ <icon id="list-remove" file="16/action-remove.svg" />
+ <icon id="list-clear" file="16/action-delete.svg" />
<icon id="lock" file="16/action-lock.svg" />
<icon id="lock-unlocked" file="16/action-unlock.svg" />
<icon id="page-3fold" file="16/page-type-threefold.svg" />
diff --git a/scribus/guidemanagercore.cpp b/scribus/guidemanagercore.cpp
index d969d89aa..12bf1225c 100644
--- a/scribus/guidemanagercore.cpp
+++ b/scribus/guidemanagercore.cpp
@@ -471,8 +471,7 @@ void GuideManagerCore::drawPage(ScPainter *p, ScribusDoc *doc, double lineWidth)
p->drawLine(FPoint(horizontalFrom, guide), FPoint(horizontalTo, guide));
// highlight selected standards
- if (guideManager->currentIndex() == 0
- && m_page->pageNr() == guideManager->pageNr())
+ if (m_page->pageNr() == guideManager->pageNr())
{
p->setPen(Qt::red, lineWidth, Qt::DashDotLine, Qt::FlatCap, Qt::MiterJoin);
Guides highlight = guideManager->selectedVerticals();
@@ -484,7 +483,7 @@ void GuideManagerCore::drawPage(ScPainter *p, ScribusDoc *doc, double lineWidth)
}
// all auto
- if (guideManager->currentIndex() == 1 && guideManager->isVisible())
+ if (guideManager->isVisible())
color = Qt::red;
else
color = doc->guidesPrefs().guideColor;
diff --git a/scribus/guidemanagercore.h b/scribus/guidemanagercore.h
index b3153a450..86c4ad289 100644
--- a/scribus/guidemanagercore.h
+++ b/scribus/guidemanagercore.h
@@ -132,8 +132,8 @@ private:
double m_verticalAutoGap {0.0};
int m_horizontalAutoCount {0};
int m_verticalAutoCount {0};
- int m_horizontalAutoRefer {0};
- int m_verticalAutoRefer {0};
+ int m_horizontalAutoRefer {1};
+ int m_verticalAutoRefer {1};
double closestHorAbove(double y) const;
double closestHorBelow(double y) const;
diff --git a/scribus/guidesdelegate.cpp b/scribus/guidesdelegate.cpp
index c2829f686..1938cd1e1 100644
--- a/scribus/guidesdelegate.cpp
+++ b/scribus/guidesdelegate.cpp
@@ -5,6 +5,7 @@ a copyright and/or license notice that predates the release of Scribus 1.3.2
for which a new license (GPL+exception) is in place.
*/
#include <QModelIndex>
+#include <QPointer>
#include "ui/scrspinbox.h"
#include "scribusdoc.h"
@@ -17,17 +18,6 @@ GuidesDelegate::GuidesDelegate(QObject *parent)
{
}
-// QWidget * GuidesDelegate::createEditor(QWidget *parent,
-// const QStyleOptionViewItem &/* option */,
-// const QModelIndex &/* index */) const
-// {
-// Q_ASSERT_X(m_doc != 0, "GuidesDelegate::createEditor",
-// "No reference to the doc");
-// ScrSpinBox *editor = new ScrSpinBox(0, m_doc->currentPage()->height(),
-// parent, m_doc->unitIndex());
-// return editor;
-// }
-
void GuidesDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
double value = index.model()->data(index, Qt::EditRole).toDouble();
@@ -54,6 +44,14 @@ void GuidesDelegate::setDoc(ScribusDoc * doc)
m_doc = doc;
}
+void GuidesDelegate::finishEditing(QWidget *editor)
+{
+ QPointer<QWidget> guard(editor);
+ emit commitData(editor);
+ if (guard)
+ emit closeEditor(editor);
+}
+
// horizontals
@@ -70,6 +68,7 @@ QWidget * GuidesHDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
double max = (m_doc->currentPage()->height() * uix) + (m_doc->bleeds()->bottom() * uix);
ScrSpinBox *editor = new ScrSpinBox(min, max, parent, m_doc->unitIndex());
editor->setConstants(&m_doc->constants());
+ emit editorOpened(editor);
return editor;
}
@@ -88,5 +87,6 @@ QWidget * GuidesVDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
double max = (m_doc->currentPage()->width() * uix) + (m_doc->bleeds()->right() * uix);
ScrSpinBox *editor = new ScrSpinBox(min, max, parent, m_doc->unitIndex());
editor->setConstants(&m_doc->constants());
+ emit editorOpened(editor);
return editor;
}
diff --git a/scribus/guidesdelegate.h b/scribus/guidesdelegate.h
index 4ccf5c881..3aa941907 100644
--- a/scribus/guidesdelegate.h
+++ b/scribus/guidesdelegate.h
@@ -24,11 +24,6 @@ class GuidesDelegate : public QItemDelegate
public:
GuidesDelegate(QObject *parent = nullptr);
-// implemented in inheritance
-// QWidget *createEditor(QWidget *parent,
-// const QStyleOptionViewItem &option,
-// const QModelIndex &index) const;
-
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor,
@@ -39,8 +34,11 @@ class GuidesDelegate : public QItemDelegate
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
- void unitChange(int docUnitDecimals);
void setDoc(ScribusDoc * doc);
+ void finishEditing(QWidget *editor);
+
+ signals:
+ void editorOpened(QWidget *editor) const;
// protected due const in createEditor
protected:
diff --git a/scribus/guidesmodel.cpp b/scribus/guidesmodel.cpp
index 2c303314a..6a507f6e8 100644
--- a/scribus/guidesmodel.cpp
+++ b/scribus/guidesmodel.cpp
@@ -12,31 +12,29 @@ for which a new license (GPL+exception) is in place.
#include "units.h"
-GuidesModel::GuidesModel(QObject * /*parent*/)
+GuidesModel::GuidesModel(QObject *parent)
+ : QAbstractTableModel(parent)
{
}
GuidesModel::~GuidesModel() = default;
-int GuidesModel::rowCount(const QModelIndex & /*parent*/) const
+int GuidesModel::rowCount(const QModelIndex &parent) const
{
- return m_values.count();
+ return parent.isValid() ? 0 : m_values.count();
}
-int GuidesModel::columnCount(const QModelIndex & /*parent*/) const
+int GuidesModel::columnCount(const QModelIndex &parent) const
{
- // for future RFEs - color per guide etc.
- return 1;
+ return parent.isValid() ? 0 : 1;
}
QVariant GuidesModel::data(const QModelIndex & index, int role) const
{
- if (!index.isValid())
+ if (!index.isValid() || index.model() != this || index.column() != 0 ||
+ index.row() < 0 || index.row() >= m_values.count())
return QVariant();
- // DisplayRole and EditRole *must* be split. There is rounding
- // in pts2value(), toString() sequence. It disallows to compare
- // these values with m_data list.
- // Call it with EditRole when you need exact value.
+ // Display is rounded to the document's precision; editing uses the value.
if (role == Qt::DisplayRole)
{
QLocale l;
@@ -50,28 +48,84 @@ QVariant GuidesModel::data(const QModelIndex & index, int role) const
if (role == Qt::UserRole)
return m_values.at(index.row());
- if (role == Qt::BackgroundRole && m_values.at(index.row()) == 0.0)
- return QVariant(QColor(Qt::red));
return QVariant();
}
bool GuidesModel::setData(const QModelIndex & index, const QVariant & value, int role)
{
- if (role != Qt::EditRole || !index.isValid())
+ if (role != Qt::EditRole || !index.isValid() || index.model() != this ||
+ index.column() != 0 || index.row() < 0 || index.row() >= m_values.count())
return false;
bool ok;
double newVal = value.toDouble(&ok);
if (!ok)
return false;
- m_values[index.row()] = value2pts(newVal, m_docUnitIndex) + m_rule;
- std::sort(m_values.begin(), m_values.end());
- emit dataChanged(index, index);
- emit valueChanged();
+
+ const int oldRow = index.row();
+ const double oldPos = m_values.at(oldRow);
+ const double newPos = value2pts(newVal, m_docUnitIndex) + m_rule;
+ const bool pending = (oldRow == m_pendingRow);
+ // A newly added row must be committed even when its value stays at zero.
+ // Existing guides, however, must not generate history for unchanged edits.
+ if (!pending)
+ {
+ QLocale locale;
+ const double shownValue = locale.toDouble(locale.toString(pts2value(oldPos - m_rule, m_docUnitIndex),
+ 'f', m_docUnitDecimals));
+ if (oldPos == newPos || shownValue == newVal)
+ return true;
+ }
+
+ // Do not replace an existing guide at the same position. For a pending
+ // row, disregard that row itself when checking whether a guide exists.
+ const bool occupied = m_values.contains(newPos) &&
+ (!pending || newPos != oldPos || m_values.count(newPos) > 1);
+ if (occupied)
+ {
+ beginRemoveRows(QModelIndex(), oldRow, oldRow);
+ m_values.removeAt(oldRow);
+ if (pending)
+ m_pendingRow = -1;
+ endRemoveRows();
+ }
+ else
+ {
+ int newRow = 0;
+ for (int i = 0; i < m_values.count(); ++i)
+ {
+ if (i != oldRow && m_values.at(i) < newPos)
+ ++newRow;
+ }
+ if (newRow != oldRow)
+ {
+ const int destination = newRow > oldRow ? newRow + 1 : newRow;
+ beginMoveRows(QModelIndex(), oldRow, oldRow, QModelIndex(), destination);
+ m_values.removeAt(oldRow);
+ m_values.insert(newRow, newPos);
+ endMoveRows();
+ }
+ else
+ m_values[oldRow] = newPos;
+ if (pending)
+ m_pendingRow = -1;
+ const QModelIndex changed = this->index(newRow, 0);
+ emit dataChanged(changed, changed);
+ }
+ if (pending)
+ {
+ if (!occupied)
+ emit guideAdded(newPos);
+ }
+ else
+ emit valueChanged(oldPos, newPos);
return true;
}
-Qt::ItemFlags GuidesModel::flags(const QModelIndex & /*index*/) const
+Qt::ItemFlags GuidesModel::flags(const QModelIndex &index) const
{
+ if (!index.isValid() || index.model() != this || index.column() != 0 ||
+ index.row() < 0 || index.row() >= m_values.count())
+ return Qt::NoItemFlags;
return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
}
@@ -84,42 +138,36 @@ QVariant GuidesModel::headerData(int /*section*/, Qt::Orientation orientation, i
void GuidesModel::removeValues(const Guides & guides)
{
+ if (guides.isEmpty())
+ return;
beginResetModel();
for (double d : guides)
m_values.removeAll(d);
+ m_pendingRow = -1;
endResetModel();
}
-// bool GuidesModel::removeRows(int row, int count, const QModelIndex & parent)
-// {
-// if (count <= 0 || row < 0 || (row + count - 1) > m_values.count())
-// return false;
-//
-// beginRemoveRows(parent, row, row + count - 1);
-// for (int i = 0; i < count; ++i)
-// m_values.removeAt(row);
-// endRemoveRows();
-// return true;
-// }
-
-// bool GuidesModel::insertRows( int row, int count, const QModelIndex & parent)
-// {
-// beginInsertRows(parent, row, row + count - 1);
-// for (int i = 0; i < count; ++i)
-// m_values.insert(row + count, 0.0);
-// endInsertRows();
-// return true;
-// }
-
-void GuidesModel::insertRow()
+int GuidesModel::insertRow()
{
-// insertRows(rowCount(), 1);
- beginResetModel();
- if (m_values.contains(0.0))
+ if (m_pendingRow >= 0)
+ return m_pendingRow;
+ // The temporary editor row is distinct from a committed guide at zero.
+ // Store ruler-relative zero as the initial value shown in the editor.
+ beginInsertRows(QModelIndex(), 0, 0);
+ m_values.prepend(m_rule);
+ m_pendingRow = 0;
+ endInsertRows();
+ return m_pendingRow;
+}
+
+void GuidesModel::discardPendingRow()
+{
+ if (m_pendingRow < 0)
return;
- m_values.append(0.0);
- std::sort(m_values.begin(), m_values.end());
- endResetModel();
+ beginRemoveRows(QModelIndex(), m_pendingRow, m_pendingRow);
+ m_values.removeAt(m_pendingRow);
+ m_pendingRow = -1;
+ endRemoveRows();
}
void GuidesModel::setValues(const Guides& values)
@@ -127,6 +175,7 @@ void GuidesModel::setValues(const Guides& values)
beginResetModel();
m_values = values;
std::sort(m_values.begin(), m_values.end());
+ m_pendingRow = -1;
endResetModel();
}
@@ -143,15 +192,3 @@ void GuidesModel::unitChange(int docUnitIndex, int docUnitDecimals,double offset
m_docUnitDecimals = docUnitDecimals;
endResetModel();
}
-
-#if 0
-// debug
-#include <QtDebug>
-void GuidesModel::printValues()
-{
- qDebug() << "GuidesModel dump start";
- for (int i = 0; i < m_values.count(); ++i)
- qDebug() << "GuidesModel dump: " << m_values[i];
- qDebug() << "GuidesModel end of dump";
-}
-#endif
diff --git a/scribus/guidesmodel.h b/scribus/guidesmodel.h
index 57c1a6610..f86561ea4 100644
--- a/scribus/guidesmodel.h
+++ b/scribus/guidesmodel.h
@@ -11,12 +11,8 @@ for which a new license (GPL+exception) is in place.
#include "scribusstructs.h"
-/*! \brief A model for guides lists.
-It holds guides as a double QList (it will be expanded later because of RFEs)
-and it handles its values editing too. The editor from GuidesDelegate
-is used.
-See Qt4 documentation for more info about its methods.
-FIXME: unit conversions for dipslay vs. internal
+/*! \brief A model for editing manual guide positions.
+Positions are stored in document points and displayed relative to the ruler.
\author Petr Vanek <petr@scribus.info>
*/
class GuidesModel : public QAbstractTableModel
@@ -38,11 +34,8 @@ class GuidesModel : public QAbstractTableModel
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void removeValues(const Guides & guides);
- // qt4 api is "wrokarounded" with insertRow() and removeValues()
- // these removeRows() and insertRows() does not handle margin items correctly
-// bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
-// bool insertRows( int row, int count, const QModelIndex & parent = QModelIndex());
- void insertRow();
+ int insertRow();
+ void discardPendingRow();
//! \brief Set new values into the model.
void setValues(const Guides& values);
@@ -50,18 +43,16 @@ class GuidesModel : public QAbstractTableModel
const Guides& values() const;
void unitChange(int docUnitIndex, int docUnitDecimals, double offset);
-#if 0
- //! debug only
- void printValues();
-#endif
signals:
/*! \brief Signal emitted when the user finishes editing one value.
*/
- void valueChanged();
+ void valueChanged(double oldPosition, double newPosition);
+ void guideAdded(double position);
private:
Guides m_values;
+ int m_pendingRow {-1};
int m_docUnitIndex {0};
int m_docUnitDecimals {0};
double m_rule {0.0};
diff --git a/scribus/guidesview.cpp b/scribus/guidesview.cpp
index 846ebd758..9329be1dc 100644
--- a/scribus/guidesview.cpp
+++ b/scribus/guidesview.cpp
@@ -20,5 +20,10 @@ void GuidesView::keyPressEvent(QKeyEvent * event)
emit deleteKeyPressed();
return;
}
+ if (event->key() == Qt::Key_Plus)
+ {
+ emit plusKeyPressed();
+ return;
+ }
QTableView::keyPressEvent(event);
}
diff --git a/scribus/guidesview.h b/scribus/guidesview.h
index 175aaabcb..da20e597b 100644
--- a/scribus/guidesview.h
+++ b/scribus/guidesview.h
@@ -22,6 +22,7 @@ class GuidesView : public QTableView
signals:
void deleteKeyPressed();
+ void plusKeyPressed();
protected:
void keyPressEvent(QKeyEvent * event) override;
diff --git a/scribus/plugins/fileloader/scribus171format/scribus171format.cpp b/scribus/plugins/fileloader/scribus171format/scribus171format.cpp
index 0401bbf7f..0b2cabd59 100644
--- a/scribus/plugins/fileloader/scribus171format/scribus171format.cpp
+++ b/scribus/plugins/fileloader/scribus171format/scribus171format.cpp
@@ -4897,8 +4897,8 @@ bool Scribus171Format::readPage(ScribusDoc* doc, ScXmlStreamReader& reader)
newPage->guides.setVerticalAutoGap(attrs.valueAsDouble("AGverticalAutoGap", 0.0));
newPage->guides.setHorizontalAutoCount(attrs.valueAsInt("AGhorizontalAutoCount", 0));
newPage->guides.setVerticalAutoCount(attrs.valueAsInt("AGverticalAutoCount", 0));
- newPage->guides.setHorizontalAutoRefer(attrs.valueAsInt("AGhorizontalAutoRefer", 0));
- newPage->guides.setVerticalAutoRefer(attrs.valueAsInt("AGverticalAutoRefer", 0));
+ newPage->guides.setHorizontalAutoRefer(attrs.valueAsInt("AGhorizontalAutoRefer", 1));
+ newPage->guides.setVerticalAutoRefer(attrs.valueAsInt("AGverticalAutoRefer", 1));
}
else
{
@@ -8413,8 +8413,8 @@ bool Scribus171Format::loadPage(const QString & fileName, int pageNumber, bool M
newPage->guides.setVerticalAutoGap(attrs.valueAsDouble("AGverticalAutoGap", 0.0));
newPage->guides.setHorizontalAutoCount(attrs.valueAsInt("AGhorizontalAutoCount", 0));
newPage->guides.setVerticalAutoCount(attrs.valueAsInt("AGverticalAutoCount", 0));
- newPage->guides.setHorizontalAutoRefer(attrs.valueAsInt("AGhorizontalAutoRefer", 0));
- newPage->guides.setVerticalAutoRefer(attrs.valueAsInt("AGverticalAutoRefer", 0));
+ newPage->guides.setHorizontalAutoRefer(attrs.valueAsInt("AGhorizontalAutoRefer", 1));
+ newPage->guides.setVerticalAutoRefer(attrs.valueAsInt("AGverticalAutoRefer", 1));
}
else
{
diff --git a/scribus/scpage.cpp b/scribus/scpage.cpp
index f231376bf..05e5a3f08 100644
--- a/scribus/scpage.cpp
+++ b/scribus/scpage.cpp
@@ -227,7 +227,7 @@ void ScPage::restore(UndoState* state, bool isUndo)
{
guides.setHorizontalAutoCount(0);
guides.setHorizontalAutoGap(0.0);
- guides.setHorizontalAutoRefer(0);
+ guides.setHorizontalAutoRefer(1);
}
m_Doc->scMW()->guidePalette->setupGui();
}
@@ -243,7 +243,7 @@ void ScPage::restore(UndoState* state, bool isUndo)
{
guides.setVerticalAutoCount(0);
guides.setVerticalAutoGap(0.0);
- guides.setVerticalAutoRefer(0);
+ guides.setVerticalAutoRefer(1);
}
m_Doc->scMW()->guidePalette->setupGui();
}
diff --git a/scribus/ui/guidemanager.cpp b/scribus/ui/guidemanager.cpp
index f7048e7a6..b2126f990 100644
--- a/scribus/ui/guidemanager.cpp
+++ b/scribus/ui/guidemanager.cpp
@@ -22,6 +22,8 @@ for which a new license (GPL+exception) is in place.
* *
***************************************************************************/
+#include <QEvent>
+#include <QMetaObject>
#include <QSignalBlocker>
#include "guidemanager.h"
@@ -36,14 +38,10 @@ for which a new license (GPL+exception) is in place.
#include "undomanager.h"
#include "units.h"
-
GuideManager::GuideManager(QWidget* parent) :
ScrPaletteBase(parent, "GuideManager")
{
setupUi(this);
- tabWidget->setEnabled(false);
- deletePageButton->setEnabled(false);
- deleteAllGuides->setEnabled(false);
horizontalAutoGapSpin->setMinimum(0.0);
horizontalAutoGapSpin->setMaximum(10000.0);
verticalAutoGapSpin->setMinimum(0.0);
@@ -51,69 +49,111 @@ GuideManager::GuideManager(QWidget* parent) :
horizontalAutoCountSpin->setDecimals(0);
verticalAutoCountSpin->setDecimals(0);
- IconManager& im = IconManager::instance();
- addHorButton->setIcon(im.loadIcon("list-add"));
- delHorButton->setIcon(im.loadIcon("edit-delete"));
- addVerButton->setIcon(im.loadIcon("list-add"));
- delVerButton->setIcon(im.loadIcon("edit-delete"));
- horizontalPageAutoButton->setIcon(im.loadIcon("align-to-page"));
- horizontalMarginsAutoButton->setIcon(im.loadIcon("align-to-margin"));
- horizontalSelectionAutoButton->setIcon(im.loadIcon("align-to-last-selection"));
- verticalPageAutoButton->setIcon(im.loadIcon("align-to-page"));
- verticalMarginsAutoButton->setIcon(im.loadIcon("align-to-margin"));
- verticalSelectionAutoButton->setIcon(im.loadIcon("align-to-last-selection"));
+ // Clicking the checkmark must not close the editor before the click handler.
+ // Tab still reaches these buttons through ordinary keyboard navigation.
+ addHorizontalButton->setFocusPolicy(Qt::TabFocus);
+ addVerticalButton->setFocusPolicy(Qt::TabFocus);
+ horizontalGroupBox->installEventFilter(this);
+ verticalGroupBox->installEventFilter(this);
// MVC
horizontalModel = new GuidesModel(this);
verticalModel = new GuidesModel(this);
- GuidesHDelegate * hdelegate = new GuidesHDelegate();
- GuidesVDelegate * vdelegate = new GuidesVDelegate();
+ GuidesHDelegate * hdelegate = new GuidesHDelegate(horizontalView);
+ GuidesVDelegate * vdelegate = new GuidesVDelegate(verticalView);
horizontalView->setItemDelegateForColumn(0, hdelegate);
verticalView->setItemDelegateForColumn(0, vdelegate);
horizontalView->setModel(horizontalModel);
verticalView->setModel(verticalModel);
- connect(addHorButton, SIGNAL(clicked()), this, SLOT(addHorButton_clicked()));
- connect(delHorButton, SIGNAL(clicked()), this, SLOT(delHorButton_clicked()));
- connect(horizontalView, SIGNAL(deleteKeyPressed()), this, SLOT(delHorButton_clicked()));
- connect(addVerButton, SIGNAL(clicked()), this, SLOT(addVerButton_clicked()));
- connect(delVerButton, SIGNAL(clicked()), this, SLOT(delVerButton_clicked()));
- connect(verticalView, SIGNAL(deleteKeyPressed()), this, SLOT(delVerButton_clicked()));
- connect(horizontalView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(forceDrawGuides(QItemSelection,QItemSelection)));
- connect(verticalView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(forceDrawGuides(QItemSelection,QItemSelection)));
-
- connect(applyToAllStdButton, SIGNAL(clicked()), this, SLOT(applyToAllStdButton_clicked()));
- connect(horizontalAutoCountSpin, SIGNAL(valueChanged(double)), this, SLOT(horizontalAutoCountSpin_valueChanged(double)));
- connect(verticalAutoCountSpin, SIGNAL(valueChanged(double)), this, SLOT(verticalAutoCountSpin_valueChanged(double)));
- connect(horizontalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(horizontalAutoGapCheck_stateChanged(int)));
- connect(verticalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(verticalAutoGapCheck_stateChanged(int)));
- connect(horizontalAutoGapSpin, SIGNAL(valueChanged(double)), this, SLOT(horizontalAutoGapSpin_valueChanged(double)));
- connect(verticalAutoGapSpin, SIGNAL(valueChanged(double)), this, SLOT(verticalAutoGapSpin_valueChanged(double)));
-
- connect(horizontalPageAutoButton, SIGNAL(toggled(bool)), this, SLOT(horizontalPageAutoButton_toggled(bool)));
- connect(horizontalMarginsAutoButton, SIGNAL(toggled(bool)), this, SLOT(horizontalMarginsAutoButton_toggled(bool)));
- connect(horizontalSelectionAutoButton, SIGNAL(toggled(bool)), this, SLOT(horizontalSelectionAutoButton_toggled(bool)));
- connect(verticalPageAutoButton, SIGNAL(toggled(bool)), this, SLOT(verticalPageAutoButton_toggled(bool)));
- connect(verticalMarginsAutoButton, SIGNAL(toggled(bool)), this, SLOT(verticalMarginsAutoButton_toggled(bool)));
- connect(verticalSelectionAutoButton, SIGNAL(toggled(bool)), this, SLOT(verticalSelectionAutoButton_toggled(bool)));
-
- connect(applyToAllAutoButton, SIGNAL(clicked()), this, SLOT(applyToAllAutoButton_clicked()));
- connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePageButton_clicked()));
- connect(deleteAllGuides, SIGNAL(clicked()), this, SLOT(deleteAllGuides_clicked()));
-
- connect(lockCheck, SIGNAL(stateChanged(int)), this, SLOT(lockCheck_stateChanged(int)));
-
- connect(horizontalModel, SIGNAL(valueChanged()), this, SLOT(horizontalModel_valueChanged()));
- connect(verticalModel, SIGNAL(valueChanged()), this, SLOT(verticalModel_valueChanged()));
-
- connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabWidget_currentChanged(int)));
-}
-
-GuideManager::~GuideManager()
-{
- delete horizontalView->itemDelegateForColumn(0);
- delete verticalView->itemDelegateForColumn(0);
-}
+ clearHorizontalButton->setEnabled(horizontalModel->rowCount() > 0);
+ clearVerticalButton->setEnabled(verticalModel->rowCount() > 0);
+
+ connect(hdelegate, &GuidesDelegate::editorOpened, this, [this](QWidget *editor) {
+ m_horizontalEditor = editor;
+ setAddButtonEditing(addHorizontalButton, true, true);
+ connect(editor, &QObject::destroyed, this, [this, editor]() {
+ if (m_horizontalEditor == editor)
+ {
+ m_horizontalEditor = nullptr;
+ setAddButtonEditing(addHorizontalButton, false, true);
+ }
+ });
+ });
+ connect(vdelegate, &GuidesDelegate::editorOpened, this, [this](QWidget *editor) {
+ m_verticalEditor = editor;
+ setAddButtonEditing(addVerticalButton, true, false);
+ connect(editor, &QObject::destroyed, this, [this, editor]() {
+ if (m_verticalEditor == editor)
+ {
+ m_verticalEditor = nullptr;
+ setAddButtonEditing(addVerticalButton, false, false);
+ }
+ });
+ });
+ connect(hdelegate, &QAbstractItemDelegate::closeEditor, this, [this](QWidget *editor) {
+ if (m_horizontalEditor == editor)
+ {
+ m_horizontalEditor = nullptr;
+ setAddButtonEditing(addHorizontalButton, false, true);
+ // Allow QTableView to finish closing the editor before removing its row.
+ ScPage* page = currentPage;
+ QMetaObject::invokeMethod(this, [this, page]() {
+ if (currentPage == page)
+ discardPendingGuide(true);
+ }, Qt::QueuedConnection);
+ }
+ });
+ connect(vdelegate, &QAbstractItemDelegate::closeEditor, this, [this](QWidget *editor) {
+ if (m_verticalEditor == editor)
+ {
+ m_verticalEditor = nullptr;
+ setAddButtonEditing(addVerticalButton, false, false);
+ ScPage* page = currentPage;
+ QMetaObject::invokeMethod(this, [this, page]() {
+ if (currentPage == page)
+ discardPendingGuide(false);
+ }, Qt::QueuedConnection);
+ }
+ });
+
+ connect(addHorizontalButton, &QToolButton::clicked, this, &GuideManager::addHorizontalButton_clicked);
+ connect(deleteHorizontalButton, &QToolButton::clicked, this, &GuideManager::deleteHorizontalButton_clicked);
+ connect(clearHorizontalButton, &QToolButton::clicked, this, &GuideManager::clearHorizontalButton_clicked);
+ connect(horizontalView, &GuidesView::deleteKeyPressed, this, &GuideManager::deleteHorizontalButton_clicked);
+ connect(horizontalView, &GuidesView::plusKeyPressed, this, &GuideManager::addHorizontalButton_clicked);
+ connect(addVerticalButton, &QToolButton::clicked, this, &GuideManager::addVerticalButton_clicked);
+ connect(deleteVerticalButton, &QToolButton::clicked, this, &GuideManager::deleteVerticalButton_clicked);
+ connect(clearVerticalButton, &QToolButton::clicked, this, &GuideManager::clearVerticalButton_clicked);
+ connect(verticalView, &GuidesView::deleteKeyPressed, this, &GuideManager::deleteVerticalButton_clicked);
+ connect(verticalView, &GuidesView::plusKeyPressed, this, &GuideManager::addVerticalButton_clicked);
+ connect(horizontalView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &GuideManager::forceDrawGuides);
+ connect(verticalView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &GuideManager::forceDrawGuides);
+
+ connect(applyToAllPagesButton, &QToolButton::clicked, this, &GuideManager::applyToAllPagesButton_clicked);
+ connect(applyAutoToAllPagesButton, &QToolButton::clicked, this, &GuideManager::applyAutoToAllPagesButton_clicked);
+ connect(horizontalAutoCountSpin, qOverload<double>(&ScrSpinBox::valueChanged), this, qOverload<double>(&GuideManager::horizontalAutoCountSpin_valueChanged));
+ connect(verticalAutoCountSpin, qOverload<double>(&ScrSpinBox::valueChanged), this, &GuideManager::verticalAutoCountSpin_valueChanged);
+ connect(horizontalAutoGapSpin, qOverload<double>(&ScrSpinBox::valueChanged), this, qOverload<double>(&GuideManager::horizontalAutoGapSpin_valueChanged));
+ connect(verticalAutoGapSpin, qOverload<double>(&ScrSpinBox::valueChanged), this, qOverload<double>(&GuideManager::verticalAutoGapSpin_valueChanged));
+
+ connect(horizontalPageAutoButton, &QToolButton::toggled, this, &GuideManager::horizontalPageAutoButton_toggled);
+ connect(horizontalMarginsAutoButton, &QToolButton::toggled, this, &GuideManager::horizontalMarginsAutoButton_toggled);
+ connect(horizontalSelectionAutoButton, &QToolButton::toggled, this, &GuideManager::horizontalSelectionAutoButton_toggled);
+ connect(verticalPageAutoButton, &QToolButton::toggled, this, &GuideManager::verticalPageAutoButton_toggled);
+ connect(verticalMarginsAutoButton, &QToolButton::toggled, this, &GuideManager::verticalMarginsAutoButton_toggled);
+ connect(verticalSelectionAutoButton, &QToolButton::toggled, this, &GuideManager::verticalSelectionAutoButton_toggled);
+
+
+ connect(lockGuidesButton, &QToolButton::clicked, this, &GuideManager::lockGuidesButton_clicked);
+
+ connect(horizontalModel, &GuidesModel::valueChanged, this, &GuideManager::horizontalModel_valueChanged);
+ connect(verticalModel, &GuidesModel::valueChanged, this, &GuideManager::verticalModel_valueChanged);
+ connect(horizontalModel, &GuidesModel::guideAdded, this, [this](double pos) { addGuide(true, pos); });
+ connect(verticalModel, &GuidesModel::guideAdded, this, [this](double pos) { addGuide(false, pos); });
+}
+
+GuideManager::~GuideManager() = default;
void GuideManager::setDoc(ScribusDoc* doc)
{
@@ -136,9 +176,6 @@ void GuideManager::setDoc(ScribusDoc* doc)
qobject_cast<GuidesVDelegate*>(verticalView->itemDelegateForColumn(0))->setDoc(doc);
if (!m_doc)
currentPage = nullptr;
- tabWidget->setEnabled(doc != nullptr);
- deletePageButton->setEnabled(doc != nullptr);
- deleteAllGuides->setEnabled(doc != nullptr);
}
void GuideManager::setVisible(bool visible)
@@ -164,55 +201,41 @@ void GuideManager::setupPage(bool storeValues)
void GuideManager::setupGui()
{
- disconnect(horizontalAutoGapCheck, SIGNAL(stateChanged(int)),
- this, SLOT(horizontalAutoGapCheck_stateChanged(int)));
- disconnect(verticalAutoGapCheck, SIGNAL(stateChanged(int)),
- this, SLOT(verticalAutoGapCheck_stateChanged(int)));
- disconnect(lockCheck, SIGNAL(stateChanged(int)),
- this, SLOT(lockCheck_stateChanged(int)));
-
- // restore values from new page
+ // Restore controls without treating a page change as a guide edit.
clearRestoreHorizontalList();
clearRestoreVerticalList();
- // restore: brand "auto guides into GUI restore algorithm"
- bool enable = currentPage->guides.horizontalAutoGap() > 0.0;
- horizontalAutoGapCheck->setChecked(enable);
- horizontalAutoGapSpin->setEnabled(enable);
- horizontalAutoGapSpin->setValue(currentPage->guides.horizontalAutoGap(), SC_PT);
+ QSignalBlocker horizontalCountBlock(horizontalAutoCountSpin);
+ QSignalBlocker horizontalGapBlock(horizontalAutoGapSpin);
+ QSignalBlocker verticalCountBlock(verticalAutoCountSpin);
+ QSignalBlocker verticalGapBlock(verticalAutoGapSpin);
+ QSignalBlocker horizontalPageBlock(horizontalPageAutoButton);
+ QSignalBlocker horizontalMarginsBlock(horizontalMarginsAutoButton);
+ QSignalBlocker horizontalSelectionBlock(horizontalSelectionAutoButton);
+ QSignalBlocker verticalPageBlock(verticalPageAutoButton);
+ QSignalBlocker verticalMarginsBlock(verticalMarginsAutoButton);
+ QSignalBlocker verticalSelectionBlock(verticalSelectionAutoButton);
+ QSignalBlocker lockBlock(lockGuidesButton);
horizontalAutoCountSpin->setValue(currentPage->guides.horizontalAutoCount());
- if (horizontalAutoCountSpin->value()==0)
- {
- horizontalAutoGapSpin->setEnabled(false);
- horizontalAutoGapCheck->setEnabled(false);
- }
- setHorizontalRefer(currentPage->guides.horizontalAutoRefer());
+ horizontalAutoGapSpin->setValue(currentPage->guides.horizontalAutoGap(), SC_PT);
+ horizontalAutoGapSpin->setEnabled(horizontalAutoCountSpin->value() > 0);
+ setHorizontalReference(currentPage->guides.horizontalAutoRefer());
// allow the selection radio button?
horizontalSelectionAutoButton->setEnabled(m_doc->m_Selection->isNotEmpty());
- // verticals
- enable = currentPage->guides.verticalAutoGap() > 0.0;
- verticalAutoGapCheck->setChecked(enable);
- verticalAutoGapSpin->setEnabled(enable);
- verticalAutoGapSpin->setValue(currentPage->guides.verticalAutoGap(), SC_PT);
verticalAutoCountSpin->setValue(currentPage->guides.verticalAutoCount());
- if (verticalAutoCountSpin->value()==0)
- {
- verticalAutoGapSpin->setEnabled(false);
- verticalAutoGapCheck->setEnabled(false);
- }
- setVerticalRefer(currentPage->guides.verticalAutoRefer());
+ verticalAutoGapSpin->setValue(currentPage->guides.verticalAutoGap(), SC_PT);
+ verticalAutoGapSpin->setEnabled(verticalAutoCountSpin->value() > 0);
+ setVerticalReference(currentPage->guides.verticalAutoRefer());
// allow the selection radio button?
verticalSelectionAutoButton->setEnabled(m_doc->m_Selection->isNotEmpty());
// restore guide locking
- lockCheck->setChecked(m_doc->GuideLock);
+ lockGuidesButton->setChecked(m_doc->GuideLock);
- connect(horizontalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(horizontalAutoGapCheck_stateChanged(int)));
- connect(verticalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(verticalAutoGapCheck_stateChanged(int)));
- connect(lockCheck, SIGNAL(stateChanged(int)), this, SLOT(lockCheck_stateChanged(int)));
+ iconSetChange();
+ languageChange();
m_drawGuides = true;
-// drawGuides(); let Canvas::DrawPageMarks take care of it and avoid a costly ScribusView::DrawNew()
}
void GuideManager::storePageValues(ScPage *page) const
@@ -220,20 +243,14 @@ void GuideManager::storePageValues(ScPage *page) const
if (!page || !m_doc)
return;
- double gapValue = 0.0;
- if (horizontalAutoGapCheck->isChecked())
- gapValue = horizontalAutoGapSpin->getValue(SC_PT);
- page->guides.setHorizontalAutoGap(gapValue);
+ page->guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
page->guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
- page->guides.setHorizontalAutoRefer(horizontalRefer());
+ page->guides.setHorizontalAutoRefer(horizontalReference());
page->guides.addHorizontals(getAutoHorizontals(page), GuideManagerCore::Auto);
- gapValue = 0.0;
- if (verticalAutoGapCheck->isChecked())
- gapValue = verticalAutoGapSpin->getValue(SC_PT);
- page->guides.setVerticalAutoGap(gapValue);
+ page->guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
page->guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
- page->guides.setVerticalAutoRefer(verticalRefer());
+ page->guides.setVerticalAutoRefer(verticalReference());
page->guides.addVerticals(getAutoVerticals(page), GuideManagerCore::Auto);
}
@@ -250,6 +267,67 @@ void GuideManager::changeEvent(QEvent *e)
void GuideManager::languageChange()
{
retranslateUi(this);
+ setAddButtonEditing(addHorizontalButton, m_horizontalEditor != nullptr, true);
+ setAddButtonEditing(addVerticalButton, m_verticalEditor != nullptr, false);
+}
+
+void GuideManager::discardPendingGuide(bool horizontal)
+{
+ if (!currentPage || (horizontal ? m_horizontalEditor : m_verticalEditor))
+ return;
+ (horizontal ? horizontalModel : verticalModel)->discardPendingRow();
+}
+
+void GuideManager::iconSetChange()
+{
+ IconManager& im = IconManager::instance();
+
+ addHorizontalButton->setIcon(im.loadIcon("list-add"));
+ deleteHorizontalButton->setIcon(im.loadIcon("list-remove"));
+ clearHorizontalButton->setIcon(im.loadIcon("list-clear"));
+ addVerticalButton->setIcon(im.loadIcon("list-add"));
+ deleteVerticalButton->setIcon(im.loadIcon("list-remove"));
+ clearVerticalButton->setIcon(im.loadIcon("list-clear"));
+
+ horizontalPageAutoButton->setIcon(im.loadIcon("align-to-page"));
+ horizontalMarginsAutoButton->setIcon(im.loadIcon("align-to-margin"));
+ horizontalSelectionAutoButton->setIcon(im.loadIcon("align-to-last-selection"));
+ verticalPageAutoButton->setIcon(im.loadIcon("align-to-page"));
+ verticalMarginsAutoButton->setIcon(im.loadIcon("align-to-margin"));
+ verticalSelectionAutoButton->setIcon(im.loadIcon("align-to-last-selection"));
+
+ // TODO: we might want a specific icon for an action applied to multiple pages
+ // or rename the icon used for the page-duplicate.
+ applyToAllPagesButton->setIcon(im.loadIcon("page-duplicate"));
+ applyAutoToAllPagesButton->setIcon(im.loadIcon("page-duplicate"));
+
+ QIcon lockIcon;
+ lockIcon.addPixmap(im.loadPixmap("lock"), QIcon::Normal, QIcon::On);
+ lockIcon.addPixmap(im.loadPixmap("lock-unlocked"), QIcon::Normal, QIcon::Off);
+ lockGuidesButton->setIcon(lockIcon);
+}
+
+void GuideManager::setAddButtonEditing(QToolButton *button, bool editing, bool horizontal)
+{
+ button->setIcon(IconManager::instance().loadIcon(editing ? "ok" : "list-add"));
+ button->setToolTip(editing ? tr("Finish editing")
+ : horizontal ? tr("Add a new horizontal guide")
+ : tr("Add a new vertical guide"));
+}
+
+bool GuideManager::eventFilter(QObject *watched, QEvent *event)
+{
+ if (event->type() == QEvent::MouseButtonPress &&
+ (watched == horizontalGroupBox || watched == verticalGroupBox))
+ {
+ // Guide-list blank space already finishes editing. Match it on the
+ // surrounding background without changing the selected guide.
+ if (m_horizontalEditor)
+ horizontalView->setFocus(Qt::MouseFocusReason);
+ else if (m_verticalEditor)
+ verticalView->setFocus(Qt::MouseFocusReason);
+ }
+ return ScrPaletteBase::eventFilter(watched, event);
}
void GuideManager::unitChange()
@@ -272,7 +350,7 @@ void GuideManager::unitChange()
qobject_cast<GuidesVDelegate*>(verticalView->itemDelegateForColumn(0))->setDoc(m_doc);
}
-void GuideManager::delHorButton_clicked()
+void GuideManager::deleteHorizontalButton_clicked()
{
const QModelIndexList indexes = horizontalView->selectionModel()->selectedRows(0);
Guides v;
@@ -288,9 +366,11 @@ void GuideManager::delHorButton_clicked()
currentPage->guides.addHorizontals(horizontalModel->values(), GuideManagerCore::Standard);
drawGuides();
m_doc->changed();
+
+ clearHorizontalButton->setEnabled(horizontalModel->rowCount() > 0);
}
-void GuideManager::delVerButton_clicked()
+void GuideManager::deleteVerticalButton_clicked()
{
const QModelIndexList indexes = verticalView->selectionModel()->selectedRows(0);
Guides v;
@@ -306,25 +386,97 @@ void GuideManager::delVerButton_clicked()
currentPage->guides.addVerticals(verticalModel->values(), GuideManagerCore::Standard);
drawGuides();
m_doc->changed();
+
+ clearVerticalButton->setEnabled(verticalModel->rowCount() > 0);
}
-void GuideManager::addHorButton_clicked()
+void GuideManager::clearHorizontalButton_clicked()
{
- horizontalModel->insertRow();
- horizontalView->setCurrentIndex(horizontalModel->index(0, 0, QModelIndex()));
- horizontalView->edit(horizontalView->currentIndex());
+ if (!currentPage->guides.horizontals(GuideManagerCore::Standard).empty())
+ {
+ UndoTransaction trans;
+ if(UndoManager::undoEnabled())
+ trans = UndoManager::instance()->beginTransaction(currentPage->getUName(),
+ currentPage->getUPixmap(),
+ Um::RemoveHorizontalGuides, "",
+ Um::IGuides);
+ currentPage->guides.clearHorizontals(GuideManagerCore::Standard);
+
+ if (trans)
+ trans.commit();
+
+ m_doc->changed();
+ }
+
+ clearRestoreHorizontalList();
+ drawGuides();
+
+ clearHorizontalButton->setEnabled(false);
+}
+
+void GuideManager::clearVerticalButton_clicked()
+{
+ if (!currentPage->guides.verticals(GuideManagerCore::Standard).empty())
+ {
+ UndoTransaction trans;
+ if(UndoManager::undoEnabled())
+ trans = UndoManager::instance()->beginTransaction(currentPage->getUName(),
+ currentPage->getUPixmap(),
+ Um::RemoveVerticalGuides, "",
+ Um::IGuides);
+ currentPage->guides.clearVerticals(GuideManagerCore::Standard);
+
+ if (trans)
+ trans.commit();
+
+ m_doc->changed();
+ }
+
+ drawGuides();
+ clearRestoreVerticalList();
+
+ clearVerticalButton->setEnabled(false);
+}
+
+void GuideManager::addHorizontalButton_clicked()
+{
+ if (m_verticalEditor)
+ qobject_cast<GuidesDelegate*>(verticalView->itemDelegateForColumn(0))->finishEditing(m_verticalEditor);
+ if (m_horizontalEditor)
+ {
+ qobject_cast<GuidesDelegate*>(horizontalView->itemDelegateForColumn(0))->finishEditing(m_horizontalEditor);
+ horizontalView->setFocus(Qt::OtherFocusReason);
+ clearHorizontalButton->setEnabled(true);
+ return;
+ }
+ horizontalView->clearSelection();
+ const int row = horizontalModel->insertRow();
+ horizontalView->setCurrentIndex(horizontalModel->index(row, 0));
+
+ clearHorizontalButton->setEnabled(true);
}
-void GuideManager::addVerButton_clicked()
+void GuideManager::addVerticalButton_clicked()
{
- verticalModel->insertRow();
- verticalView->setCurrentIndex(verticalModel->index(0, 0, QModelIndex()));
- verticalView->edit(verticalView->currentIndex());
+ if (m_horizontalEditor)
+ qobject_cast<GuidesDelegate*>(horizontalView->itemDelegateForColumn(0))->finishEditing(m_horizontalEditor);
+ if (m_verticalEditor)
+ {
+ qobject_cast<GuidesDelegate*>(verticalView->itemDelegateForColumn(0))->finishEditing(m_verticalEditor);
+ verticalView->setFocus(Qt::OtherFocusReason);
+ clearVerticalButton->setEnabled(true);
+ return;
+ }
+ verticalView->clearSelection();
+ const int row = verticalModel->insertRow();
+ verticalView->setCurrentIndex(verticalModel->index(row, 0));
+
+ clearVerticalButton->setEnabled(true);
}
-void GuideManager::lockCheck_stateChanged( int )
+void GuideManager::lockGuidesButton_clicked()
{
- m_doc->lockGuides(lockCheck->isChecked());
+ m_doc->lockGuides(lockGuidesButton->isChecked());
}
void GuideManager::copyGuidesToAllPages(GuideManagerCore::GuideType t)
@@ -352,24 +504,19 @@ void GuideManager::copyGuidesToAllPages(GuideManagerCore::GuideType t)
m_doc->changed();
}
-void GuideManager::applyToAllStdButton_clicked()
+void GuideManager::applyToAllPagesButton_clicked()
{
copyGuidesToAllPages(GuideManagerCore::Standard);
}
-void GuideManager::applyToAllAutoButton_clicked()
+void GuideManager::applyAutoToAllPagesButton_clicked()
{
copyGuidesToAllPages(GuideManagerCore::Auto);
}
void GuideManager::horizontalAutoCountSpin_valueChanged(double val)
{
- bool enable = val != 0;
- horizontalAutoGapCheck->setEnabled(enable);
- if (enable && horizontalAutoGapCheck->isChecked())
- horizontalAutoGapSpin->setEnabled(true);
- else
- horizontalAutoGapSpin->setEnabled(false);
+ horizontalAutoGapSpin->setEnabled(val > 0);
currentPage->guides.setHorizontalAutoCount(static_cast<int>(val));
drawGuides();
m_doc->changed();
@@ -382,25 +529,9 @@ void GuideManager::horizontalAutoGapSpin_valueChanged(double)
m_doc->changed();
}
-void GuideManager::horizontalAutoGapCheck_stateChanged( int )
-{
- horizontalAutoGapSpin->setEnabled(horizontalAutoGapCheck->isChecked());
- if (horizontalAutoGapCheck->isChecked())
- currentPage->guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
- else
- currentPage->guides.setHorizontalAutoGap(0.0);
- drawGuides();
- m_doc->changed();
-}
-
void GuideManager::verticalAutoCountSpin_valueChanged(double val)
{
- bool enable = val != 0;
- verticalAutoGapCheck->setEnabled(enable);
- if (enable && verticalAutoGapCheck->isChecked())
- verticalAutoGapSpin->setEnabled(true);
- else
- verticalAutoGapSpin->setEnabled(false);
+ verticalAutoGapSpin->setEnabled(val > 0);
currentPage->guides.setVerticalAutoCount(static_cast<int>(val));
drawGuides();
m_doc->changed();
@@ -413,27 +544,6 @@ void GuideManager::verticalAutoGapSpin_valueChanged(double)
m_doc->changed();
}
-void GuideManager::verticalAutoGapCheck_stateChanged( int )
-{
- verticalAutoGapSpin->setEnabled(verticalAutoGapCheck->isChecked());
- if (verticalAutoGapCheck->isChecked())
- currentPage->guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
- else
- currentPage->guides.setVerticalAutoGap(0.0);
- drawGuides();
- m_doc->changed();
-}
-
-void GuideManager::tabWidget_currentChanged(int)
-{
- drawGuides();
- if (tabWidget->currentIndex() == 1)
- {
- horizontalAutoGapSpin->setEnabled(horizontalAutoGapCheck->isChecked());
- verticalAutoGapSpin->setEnabled(verticalAutoGapCheck->isChecked());
- }
-}
-
Guides GuideManager::selectedHorizontals() const
{
const QModelIndexList selectedIndexes = horizontalView->selectionModel()->selectedIndexes();
@@ -460,9 +570,8 @@ Guides GuideManager::selectedVerticals() const
void GuideManager::setGuideLock(bool guidesLocked)
{
- bool b = lockCheck->blockSignals(true);
- lockCheck->setChecked(guidesLocked);
- lockCheck->blockSignals(b);
+ QSignalBlocker blocker(lockGuidesButton);
+ lockGuidesButton->setChecked(guidesLocked);
}
void GuideManager::forceDrawGuides(const QItemSelection &, const QItemSelection &)
@@ -472,7 +581,7 @@ void GuideManager::forceDrawGuides(const QItemSelection &, const QItemSelection
void GuideManager::drawGuides()
{
- if (!m_doc || !m_drawGuides)
+ if (!m_doc || !currentPage || !m_drawGuides)
return;
currentPage->guides.addHorizontals(getAutoHorizontals(currentPage), GuideManagerCore::Auto);
@@ -492,89 +601,17 @@ void GuideManager::clearRestoreVerticalList()
drawGuides();
}
-void GuideManager::deletePageButton_clicked()
-{
- if (!currentPage->guides.hasGuides())
- return;
-
- UndoTransaction trans;
- if(UndoManager::undoEnabled())
- trans = UndoManager::instance()->beginTransaction(currentPage->getUName(),
- currentPage->getUPixmap(),
- Um::RemoveAllPageGuides, "",
- Um::IGuides);
- currentPage->guides.clearHorizontals(GuideManagerCore::Standard);
- currentPage->guides.clearVerticals(GuideManagerCore::Standard);
- currentPage->guides.clearHorizontals(GuideManagerCore::Auto);
- currentPage->guides.clearVerticals(GuideManagerCore::Auto);
- clearRestoreHorizontalList();
- clearRestoreVerticalList();
-
- currentPage->guides.setHorizontalAutoCount(0);
- currentPage->guides.setVerticalAutoCount(0);
- currentPage->guides.setHorizontalAutoGap(0.0);
- currentPage->guides.setVerticalAutoGap(0.0);
- currentPage->guides.setHorizontalAutoRefer(0);
- currentPage->guides.setVerticalAutoRefer(0);
- horizontalAutoCountSpin->setValue(0);
- verticalAutoCountSpin->setValue(0);
-
- if (trans)
- trans.commit();
-
- drawGuides();
- m_doc->changed();
-}
-
-void GuideManager::deleteAllGuides_clicked()
-{
- bool hasGuides = false;
- for (const ScPage* page : *m_doc->Pages)
- {
- if (page->guides.hasGuides())
- {
- hasGuides = true;
- break;
- }
- }
- if (!hasGuides)
- return;
-
-
- UndoTransaction trans;
- if (UndoManager::undoEnabled())
- trans = UndoManager::instance()->beginTransaction(m_doc->getUName(),
- m_doc->getUPixmap(),
- Um::RemoveAllGuides, "",
- Um::IGuides);
- m_drawGuides = false;
- deletePageButton_clicked();
- copyGuidesToAllPages(GuideManagerCore::Standard);
- copyGuidesToAllPages(GuideManagerCore::Auto);
- m_drawGuides = true;
- if (trans)
- trans.commit();
- drawGuides();
- m_doc->changed();
-}
-
Guides GuideManager::getAutoVerticals(const ScPage * page) const
{
GuideManagerCore guides;
- double gapValue = 0.0;
- if (horizontalAutoGapCheck->isChecked())
- gapValue = horizontalAutoGapSpin->getValue(SC_PT);
- guides.setHorizontalAutoGap(gapValue);
+ guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
- guides.setHorizontalAutoRefer(horizontalRefer());
+ guides.setHorizontalAutoRefer(horizontalReference());
- gapValue = 0.0;
- if (verticalAutoGapCheck->isChecked())
- gapValue = verticalAutoGapSpin->getValue(SC_PT);
- guides.setVerticalAutoGap(gapValue);
+ guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
- guides.setVerticalAutoRefer(verticalRefer());
+ guides.setVerticalAutoRefer(verticalReference());
return guides.getAutoVerticals(page);
}
@@ -583,40 +620,60 @@ Guides GuideManager::getAutoHorizontals(const ScPage * page) const
{
GuideManagerCore guides;
- double gapValue = 0.0;
- if (horizontalAutoGapCheck->isChecked())
- gapValue = horizontalAutoGapSpin->getValue(SC_PT);
- guides.setHorizontalAutoGap(gapValue);
+ guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
- guides.setHorizontalAutoRefer(horizontalRefer());
+ guides.setHorizontalAutoRefer(horizontalReference());
- gapValue = 0.0;
- if (verticalAutoGapCheck->isChecked())
- gapValue = verticalAutoGapSpin->getValue(SC_PT);
- guides.setVerticalAutoGap(gapValue);
+ guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
- guides.setVerticalAutoRefer(verticalRefer());
+ guides.setVerticalAutoRefer(verticalReference());
return guides.getAutoHorizontals(page);
}
-void GuideManager::verticalModel_valueChanged()
+void GuideManager::addGuide(bool horizontal, double position)
{
- currentPage->guides.clearVerticals(GuideManagerCore::Standard);
- currentPage->guides.addVerticals(verticalModel->values(), GuideManagerCore::Standard);
+ if (!currentPage)
+ return;
+ const Guides existing = horizontal ? currentPage->guides.horizontals(GuideManagerCore::Standard)
+ : currentPage->guides.verticals(GuideManagerCore::Standard);
+ if (existing.contains(position))
+ return;
+ if (horizontal)
+ currentPage->guides.addHorizontal(position, GuideManagerCore::Standard);
+ else
+ currentPage->guides.addVertical(position, GuideManagerCore::Standard);
drawGuides();
m_doc->changed();
}
-void GuideManager::horizontalModel_valueChanged()
+void GuideManager::guideValueChanged(bool horizontal, double oldPosition, double newPosition)
{
- currentPage->guides.clearHorizontals(GuideManagerCore::Standard);
- currentPage->guides.addHorizontals(horizontalModel->values(), GuideManagerCore::Standard);
+ if (!currentPage || oldPosition == newPosition)
+ return;
+ const Guides existing = horizontal ? currentPage->guides.horizontals(GuideManagerCore::Standard)
+ : currentPage->guides.verticals(GuideManagerCore::Standard);
+ if (!existing.contains(oldPosition))
+ return;
+ if (horizontal)
+ currentPage->guides.moveHorizontal(oldPosition, newPosition, GuideManagerCore::Standard);
+ else
+ currentPage->guides.moveVertical(oldPosition, newPosition, GuideManagerCore::Standard);
drawGuides();
m_doc->changed();
}
-void GuideManager::setHorizontalRefer(int button)
+void GuideManager::verticalModel_valueChanged(double oldPosition, double newPosition)
+{
+ guideValueChanged(false, oldPosition, newPosition);
+}
+
+void GuideManager::horizontalModel_valueChanged(double oldPosition, double newPosition)
+{
+ guideValueChanged(true, oldPosition, newPosition);
+}
+
+void GuideManager::setHorizontalReference(int button)
{
switch (button)
{
@@ -633,7 +690,7 @@ void GuideManager::setHorizontalRefer(int button)
}
}
-int GuideManager::horizontalRefer() const
+int GuideManager::horizontalReference() const
{
if (horizontalPageAutoButton->isChecked())
return 0;
@@ -644,7 +701,7 @@ int GuideManager::horizontalRefer() const
return 0;
}
-void GuideManager::setVerticalRefer(int button)
+void GuideManager::setVerticalReference(int button)
{
switch (button)
{
@@ -661,7 +718,7 @@ void GuideManager::setVerticalRefer(int button)
}
}
-int GuideManager::verticalRefer() const
+int GuideManager::verticalReference() const
{
if (verticalPageAutoButton->isChecked())
return 0;
@@ -678,6 +735,8 @@ void GuideManager::horizontalPageAutoButton_toggled(bool state)
return;
currentPage->guides.setHorizontalAutoRefer(0);
drawGuides();
+ if (currentPage->guides.horizontalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::horizontalMarginsAutoButton_toggled(bool state)
@@ -686,6 +745,8 @@ void GuideManager::horizontalMarginsAutoButton_toggled(bool state)
return;
currentPage->guides.setHorizontalAutoRefer(1);
drawGuides();
+ if (currentPage->guides.horizontalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::horizontalSelectionAutoButton_toggled(bool state)
@@ -696,6 +757,8 @@ void GuideManager::horizontalSelectionAutoButton_toggled(bool state)
if (horizontalSelectionAutoButton->isEnabled())
currentPage->guides.resetSelectionForPage(currentPage);
drawGuides();
+ if (currentPage->guides.horizontalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::verticalPageAutoButton_toggled(bool state)
@@ -704,7 +767,8 @@ void GuideManager::verticalPageAutoButton_toggled(bool state)
return;
currentPage->guides.setVerticalAutoRefer(0);
drawGuides();
- m_doc->changed();
+ if (currentPage->guides.verticalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::verticalMarginsAutoButton_toggled(bool state)
@@ -713,7 +777,8 @@ void GuideManager::verticalMarginsAutoButton_toggled(bool state)
return;
currentPage->guides.setVerticalAutoRefer(1);
drawGuides();
- m_doc->changed();
+ if (currentPage->guides.verticalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::verticalSelectionAutoButton_toggled(bool state)
@@ -724,5 +789,6 @@ void GuideManager::verticalSelectionAutoButton_toggled(bool state)
if (verticalSelectionAutoButton->isEnabled())
currentPage->guides.resetSelectionForPage(currentPage);
drawGuides();
- m_doc->changed();
+ if (currentPage->guides.verticalAutoCount() > 0)
+ m_doc->changed();
}
diff --git a/scribus/ui/guidemanager.h b/scribus/ui/guidemanager.h
index b5330f5c3..edc406a6f 100644
--- a/scribus/ui/guidemanager.h
+++ b/scribus/ui/guidemanager.h
@@ -17,6 +17,7 @@ for which a new license (GPL+exception) is in place.
class GuidesModel;
class ScribusDoc;
+class QToolButton;
@@ -67,17 +68,16 @@ public:
\retval int page no */
int pageNr() const { return ((currentPage) ? currentPage->pageNr() : -1); }
- int currentIndex() const { return tabWidget->currentIndex(); }
-
void setGuideLock(bool guidesLocked);
protected:
void changeEvent(QEvent *e) override;
+ bool eventFilter(QObject *watched, QEvent *event) override;
private:
- //! \brief Store the guide values in the Qt4 model
+ //! \brief Model for horizontal manual guides
GuidesModel * horizontalModel { nullptr };
- //! \brief Store the guide values in the Qt4 model
+ //! \brief Model for vertical manual guides
GuidesModel * verticalModel { nullptr };
ScribusDoc* m_doc { nullptr };
@@ -85,6 +85,8 @@ private:
ScPage * currentPage { nullptr };
//! \brief A flag to prevent guides drawing when it's not needed
bool m_drawGuides { true };
+ QWidget *m_horizontalEditor { nullptr };
+ QWidget *m_verticalEditor { nullptr };
//! \brief Initialise the units. Spin boxes gets pt/mm/etc. extensions here.
void unitChange();
@@ -116,30 +118,35 @@ private:
/*! \brief Draw guides into painter */
void drawGuides();
+ void guideValueChanged(bool horizontal, double oldPosition, double newPosition);
+ void addGuide(bool horizontal, double position);
+ void setAddButtonEditing(QToolButton *button, bool editing, bool horizontal);
+ void discardPendingGuide(bool horizontal);
/*! \brief These methods simulate old button group behaviour.
Is there a better way to do it? QButtonGroup? It's more code...
*/
- void setHorizontalRefer(int button);
- int horizontalRefer() const;
- void setVerticalRefer(int button);
- int verticalRefer() const;
+ void setHorizontalReference(int button);
+ int horizontalReference() const;
+ void setVerticalReference(int button);
+ int verticalReference() const;
void languageChange();
+ void iconSetChange();
private slots:
//! Wrapper slot for drawGuides()
void forceDrawGuides(const QItemSelection &, const QItemSelection &);
- void verticalModel_valueChanged();
- void horizontalModel_valueChanged();
- void addHorButton_clicked();
- void delHorButton_clicked();
- void addVerButton_clicked();
- void delVerButton_clicked();
- void applyToAllStdButton_clicked();
- void lockCheck_stateChanged( int );
- void horizontalAutoGapCheck_stateChanged( int );
- void verticalAutoGapCheck_stateChanged( int );
- void applyToAllAutoButton_clicked();
+ void verticalModel_valueChanged(double oldPosition, double newPosition);
+ void horizontalModel_valueChanged(double oldPosition, double newPosition);
+ void addHorizontalButton_clicked();
+ void deleteHorizontalButton_clicked();
+ void addVerticalButton_clicked();
+ void deleteVerticalButton_clicked();
+ void clearHorizontalButton_clicked();
+ void clearVerticalButton_clicked();
+ void applyToAllPagesButton_clicked();
+ void applyAutoToAllPagesButton_clicked();
+ void lockGuidesButton_clicked();
void horizontalAutoCountSpin_valueChanged( double );
void verticalAutoCountSpin_valueChanged( double );
void horizontalAutoGapSpin_valueChanged(double);
@@ -150,9 +157,6 @@ private slots:
void verticalPageAutoButton_toggled(bool);
void verticalMarginsAutoButton_toggled(bool);
void verticalSelectionAutoButton_toggled(bool);
- void tabWidget_currentChanged(int);
- void deletePageButton_clicked();
- void deleteAllGuides_clicked();
};
#endif // GUIDEMANAGER_H
diff --git a/scribus/ui/guidemanager.ui b/scribus/ui/guidemanager.ui
index 2ff49b6ef..d1b8e2acc 100644
--- a/scribus/ui/guidemanager.ui
+++ b/scribus/ui/guidemanager.ui
@@ -8,10 +8,16 @@
<rect>
<x>0</x>
<y>0</y>
- <width>534</width>
- <height>364</height>
+ <width>425</width>
+ <height>481</height>
</rect>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>350</width>
+ <height>300</height>
+ </size>
+ </property>
<property name="windowTitle">
<string>Guide Manager</string>
</property>
@@ -28,229 +34,27 @@
<property name="bottomMargin">
<number>9</number>
</property>
- <item row="0" column="0">
- <widget class="QTabWidget" name="tabWidget">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="standardPage">
- <attribute name="title">
- <string>&Manual Guides</string>
- </attribute>
- <layout class="QGridLayout">
- <property name="leftMargin">
- <number>9</number>
- </property>
- <property name="topMargin">
- <number>9</number>
- </property>
- <property name="rightMargin">
- <number>9</number>
- </property>
- <property name="bottomMargin">
- <number>9</number>
- </property>
- <item row="0" column="0" colspan="2">
- <layout class="QHBoxLayout">
- <item>
- <widget class="QGroupBox" name="horizontalGroupBox">
- <property name="title">
- <string>&Horizontal Guides</string>
- </property>
- <layout class="QGridLayout">
- <property name="horizontalSpacing">
- <number>5</number>
- </property>
- <item row="0" column="0">
- <widget class="GuidesView" name="horizontalView">
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
- </property>
- <attribute name="horizontalHeaderStretchLastSection">
- <bool>true</bool>
- </attribute>
- </widget>
- </item>
- <item row="0" column="1">
- <layout class="QVBoxLayout" name="horizontalGuideActionsLayout">
- <item>
- <widget class="QToolButton" name="addHorButton">
- <property name="toolTip">
- <string>Add a new horizontal guide</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="delHorButton">
- <property name="toolTip">
- <string>Delete the selected horizontal guide</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Orientation::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="verticalGroupBox">
- <property name="title">
- <string>&Vertical Guides</string>
- </property>
- <layout class="QGridLayout">
- <property name="horizontalSpacing">
- <number>5</number>
- </property>
- <item row="0" column="0">
- <widget class="GuidesView" name="verticalView">
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
- </property>
- <attribute name="horizontalHeaderStretchLastSection">
- <bool>true</bool>
- </attribute>
- </widget>
- </item>
- <item row="0" column="1">
- <layout class="QVBoxLayout" name="verticalGuideActionsLayout">
- <item>
- <widget class="QToolButton" name="addVerButton">
- <property name="toolTip">
- <string>Add a new vertical guide</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="delVerButton">
- <property name="toolTip">
- <string>Delete the selected vertical guide</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Orientation::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0" colspan="2">
- <layout class="QHBoxLayout" name="applyStdLayout">
- <item>
- <widget class="QCheckBox" name="lockCheck">
- <property name="toolTip">
- <string>Lock the guides</string>
- </property>
- <property name="text">
- <string>Lock Guides</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacerCopyLeft">
- <property name="orientation">
- <enum>Qt::Orientation::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Policy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>10</width>
- <height>10</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="applyToAllStdButton">
- <property name="toolTip">
- <string>Replace the manual guides on all other pages with the manual guides from the current page</string>
- </property>
- <property name="text">
- <string>Copy Guides to All Pages</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="autoPage">
- <attribute name="title">
- <string>&Rows && Columns</string>
- </attribute>
- <layout class="QGridLayout">
- <property name="leftMargin">
- <number>9</number>
- </property>
- <property name="topMargin">
- <number>9</number>
- </property>
- <property name="rightMargin">
- <number>9</number>
+ <item row="1" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="verticalAutoGroup">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="bottomMargin">
- <number>9</number>
+ <property name="title">
+ <string>Rows && Columns</string>
</property>
- <item row="0" column="0">
- <widget class="QGroupBox" name="horizontalAutoGroup">
- <property name="title">
- <string>&Horizontal Guides</string>
- </property>
- <layout class="QGridLayout">
- <property name="horizontalSpacing">
- <number>20</number>
- </property>
- <property name="verticalSpacing">
- <number>8</number>
- </property>
- <item row="0" column="0">
- <widget class="FormWidget" name="horizontalRelativeForm" native="true">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="spacing">
+ <number>16</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="FormWidget" name="horizontalRelativeForm">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
@@ -288,7 +92,7 @@
<bool>true</bool>
</property>
<property name="checked">
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
@@ -306,6 +110,9 @@
<property name="checkable">
<bool>true</bool>
</property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
<property name="autoExclusive">
<bool>true</bool>
</property>
@@ -330,10 +137,16 @@
</layout>
</widget>
</item>
- <item row="0" column="1">
- <widget class="FormWidget" name="horizontalNumberForm" native="true">
+ <item>
+ <widget class="FormWidget" name="horizontalNumberForm">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="label" stdset="0">
- <string>Number</string>
+ <string>&Rows</string>
</property>
<layout class="QHBoxLayout" name="horizontalNumberLayout">
<property name="leftMargin">
@@ -379,52 +192,74 @@
</layout>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="horizontalAutoGapCheck">
- <property name="toolTip">
- <string>Set the gap between adjacent generated rows</string>
+ <item>
+ <widget class="FormWidget" name="horizontalGapForm">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="text">
- <string>Gap:</string>
+ <property name="label" stdset="0">
+ <string>Gap</string>
</property>
+ <layout class="QHBoxLayout" name="horizontalGapLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="ScrSpinBox" name="horizontalAutoGapSpin">
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Set the gap between adjacent generated rows</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</widget>
</item>
- <item row="1" column="1">
- <widget class="ScrSpinBox" name="horizontalAutoGapSpin">
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
+ <item>
+ <spacer name="horizontalAutoControlsSpacer">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
</property>
- <property name="maximumSize">
+ <property name="sizeType">
+ <enum>QSizePolicy::Policy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
<size>
- <width>100</width>
- <height>16777215</height>
+ <width>10</width>
+ <height>10</height>
</size>
</property>
- <property name="toolTip">
- <string>Set the gap between adjacent generated rows</string>
- </property>
- </widget>
+ </spacer>
</item>
</layout>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QGroupBox" name="verticalAutoGroup">
- <property name="title">
- <string>&Vertical Guides</string>
- </property>
- <layout class="QGridLayout">
- <property name="horizontalSpacing">
- <number>20</number>
- </property>
- <property name="verticalSpacing">
- <number>8</number>
- </property>
- <item row="0" column="0">
- <widget class="FormWidget" name="verticalRelativeForm" native="true">
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="FormWidget" name="verticalRelativeForm">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
@@ -462,7 +297,7 @@
<bool>true</bool>
</property>
<property name="checked">
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
@@ -480,6 +315,9 @@
<property name="checkable">
<bool>true</bool>
</property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
<property name="autoExclusive">
<bool>true</bool>
</property>
@@ -504,10 +342,16 @@
</layout>
</widget>
</item>
- <item row="0" column="1">
- <widget class="FormWidget" name="verticalNumberForm" native="true">
+ <item>
+ <widget class="FormWidget" name="verticalNumberForm">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="label" stdset="0">
- <string>Number</string>
+ <string>&Columns</string>
</property>
<layout class="QHBoxLayout" name="verticalNumberLayout">
<property name="leftMargin">
@@ -553,125 +397,335 @@
</layout>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="verticalAutoGapCheck">
- <property name="toolTip">
- <string>Set the gap between adjacent generated columns</string>
+ <item>
+ <widget class="FormWidget" name="verticalGapForm">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="label" stdset="0">
+ <string>Gap</string>
+ </property>
+ <layout class="QHBoxLayout" name="verticalGapLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="ScrSpinBox" name="verticalAutoGapSpin">
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Set the gap between adjacent generated columns</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QToolButton" name="applyAutoToAllPagesButton">
+ <property name="text">
+ <string/>
</property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="applyAutoToAllPagesLabel">
<property name="text">
- <string>Gap:</string>
+ <string>Apply to all pages</string>
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="ScrSpinBox" name="verticalAutoGapSpin">
- <property name="minimumSize">
+ <item>
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
<size>
- <width>100</width>
- <height>0</height>
+ <width>40</width>
+ <height>20</height>
</size>
</property>
- <property name="maximumSize">
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QGroupBox" name="horizontalGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>&Horizontal guides</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="horizontalSpacing">
+ <number>5</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="GuidesView" name="horizontalView">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
+ </property>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <layout class="QVBoxLayout" name="horizontalGuideActionsLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QToolButton" name="addHorizontalButton">
+ <property name="toolTip">
+ <string>Add a new horizontal guide</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="deleteHorizontalButton">
+ <property name="toolTip">
+ <string>Delete the selected horizontal guide</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Orientation::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="clearHorizontalButton">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="verticalGroupBox">
+ <property name="title">
+ <string>&Vertical guides</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="horizontalSpacing">
+ <number>5</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="GuidesView" name="verticalView">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
+ </property>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <layout class="QVBoxLayout" name="verticalGuideActionsLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QToolButton" name="addVerticalButton">
+ <property name="toolTip">
+ <string>Add a new vertical guide</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="deleteVerticalButton">
+ <property name="toolTip">
+ <string>Delete the selected vertical guide</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Orientation::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="clearVerticalButton">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QGridLayout" name="gridLayout3">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QToolButton" name="applyToAllPagesButton">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="applyAllPagesLabel">
+ <property name="text">
+ <string>Apply to all pages</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
<size>
- <width>100</width>
- <height>16777215</height>
+ <width>40</width>
+ <height>20</height>
</size>
</property>
- <property name="toolTip">
- <string>Set the gap between adjacent generated columns</string>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QToolButton" name="lockGuidesButton">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
</property>
</widget>
</item>
+ <item>
+ <widget class="QLabel" name="lockGuidesLabel">
+ <property name="text">
+ <string>Lock guides</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <layout class="QHBoxLayout" name="applyAutoLayout">
- <item>
- <spacer name="horizontalSpacerApplyLeft">
- <property name="orientation">
- <enum>Qt::Orientation::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Policy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>10</width>
- <height>10</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="applyToAllAutoButton">
- <property name="toolTip">
- <string>Apply the current row and column guide settings to all pages in the document</string>
- </property>
- <property name="text">
- <string>Apply Settings to All Pages</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="2" column="0" colspan="2">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Orientation::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>10</width>
- <height>10</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
</widget>
</item>
- <item row="1" column="0">
- <layout class="QHBoxLayout" name="globalGuideControlsLayout">
- <item>
- <spacer name="horizontalSpacerGlobal">
- <property name="orientation">
- <enum>Qt::Orientation::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Policy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>10</width>
- <height>10</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="deletePageButton">
- <property name="toolTip">
- <string>Delete all guides from the current page</string>
- </property>
- <property name="text">
- <string>Clear Page Guides</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="deleteAllGuides">
- <property name="toolTip">
- <string>Delete all guides from the current document</string>
- </property>
- <property name="text">
- <string>Clear All Guides</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
</layout>
</widget>
<customwidgets>
diff --git a/scribus/undomanager.cpp b/scribus/undomanager.cpp
index ca16b194c..97e1440d3 100644
--- a/scribus/undomanager.cpp
+++ b/scribus/undomanager.cpp
@@ -830,8 +830,8 @@ void UndoManager::languageChange()
UndoManager::ImageEffects = tr("Apply image effects");
UndoManager::InsertFrame = tr("Insert frame");
UndoManager::AdjustFrameToImage = tr("Adjust frame to the image size");
- UndoManager::RemoveAllGuides = tr("Remove all guides");
- UndoManager::RemoveAllPageGuides= tr("Remove page guides");
+ UndoManager::RemoveHorizontalGuides = tr("Remove the horizontal guides");
+ UndoManager::RemoveVerticalGuides = tr("Remove the vertical guides");
UndoManager::Copy = tr("Copy");
UndoManager::CopyPage = tr("Copy page");
UndoManager::MovePage = tr("Move page");
@@ -1182,8 +1182,8 @@ QString UndoManager::ResetControlPoints = "";
QString UndoManager::ImageEffects = "";
QString UndoManager::InsertFrame = "";
QString UndoManager::AdjustFrameToImage = "";
-QString UndoManager::RemoveAllGuides = "";
-QString UndoManager::RemoveAllPageGuides= "";
+QString UndoManager::RemoveHorizontalGuides = "";
+QString UndoManager::RemoveVerticalGuides= "";
QString UndoManager::Copy = "";
QString UndoManager::CopyPage = "";
QString UndoManager::ImportPage = "";
diff --git a/scribus/undomanager.h b/scribus/undomanager.h
index 48ec96056..1bf352970 100644
--- a/scribus/undomanager.h
+++ b/scribus/undomanager.h
@@ -366,8 +366,8 @@ public:
static QString BlendMode;
static QString ActionPDF;
static QString SplitItem;
- static QString RemoveAllGuides;
- static QString RemoveAllPageGuides;
+ static QString RemoveHorizontalGuides;
+ static QString RemoveVerticalGuides;
static QString LockGuides;
static QString UnlockGuides;
static QString Move;
|
|
|
@ale, I compared, and was suggested some improvements (keeping the UI same as yours). There is only 1 patch now for this ticket (earlier 2) as you just did. ## Changes from guides-manager.diff → GMR1 v1.04 - Baseline: r27915 - Immediate editing: Pressing + opens the spinbox directly, without requiring another click. - Dialog sizing: Changes the default size to 450 × 475 and replaces the hardcoded minimum with Qt-managed sizing. - Clear-button states: Correctly updates enabled/disabled states after guide changes and page switching. - Editor hardening: Safely finishes active edits during page/document switching and prevents stale deferred callbacks. - Pending rows: Preserves unfinished guide rows correctly when other rows are removed. - Apply controls: Disables both Apply-to-all-pages buttons when the document has fewer than two pages. - Canvas feedback: Keeps automatic guides in their normal colour rather than turning all of them red whenever the palette is visible. - Code cleanup: Reuses existing icons, removes unrelated changes to guide-reference defaults and tightens comments/documentation. - This is otherwise a series, and this is the first patch, the next patch in order is in 0018026 gmr1-unified-guide-manager-v1.04.patch (94,587 bytes)
Index: scribus/guidemanagercore.cpp
===================================================================
--- scribus/guidemanagercore.cpp (revision 27915)
+++ scribus/guidemanagercore.cpp (working copy)
@@ -471,8 +471,7 @@
p->drawLine(FPoint(horizontalFrom, guide), FPoint(horizontalTo, guide));
// highlight selected standards
- if (guideManager->currentIndex() == 0
- && m_page->pageNr() == guideManager->pageNr())
+ if (guideManager->isVisible() && m_page->pageNr() == guideManager->pageNr())
{
p->setPen(Qt::red, lineWidth, Qt::DashDotLine, Qt::FlatCap, Qt::MiterJoin);
Guides highlight = guideManager->selectedVerticals();
@@ -484,11 +483,7 @@
}
// all auto
- if (guideManager->currentIndex() == 1 && guideManager->isVisible())
- color = Qt::red;
- else
- color = doc->guidesPrefs().guideColor;
- p->setPen(color, lineWidth, Qt::DashDotLine, Qt::FlatCap, Qt::MiterJoin);
+ p->setPen(color, lineWidth, Qt::DashDotLine, Qt::FlatCap, Qt::MiterJoin);
for (auto guide : m_verticalAutoG)
p->drawLine(FPoint(guide, verticalFrom), FPoint(guide, verticalTo));
Index: scribus/guidesdelegate.cpp
===================================================================
--- scribus/guidesdelegate.cpp (revision 27915)
+++ scribus/guidesdelegate.cpp (working copy)
@@ -5,6 +5,7 @@
for which a new license (GPL+exception) is in place.
*/
#include <QModelIndex>
+#include <QPointer>
#include "ui/scrspinbox.h"
#include "scribusdoc.h"
@@ -16,17 +17,6 @@
: QItemDelegate(parent)
{
}
-
-// QWidget * GuidesDelegate::createEditor(QWidget *parent,
-// const QStyleOptionViewItem &/* option */,
-// const QModelIndex &/* index */) const
-// {
-// Q_ASSERT_X(m_doc != 0, "GuidesDelegate::createEditor",
-// "No reference to the doc");
-// ScrSpinBox *editor = new ScrSpinBox(0, m_doc->currentPage()->height(),
-// parent, m_doc->unitIndex());
-// return editor;
-// }
void GuidesDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
@@ -54,6 +44,14 @@
m_doc = doc;
}
+void GuidesDelegate::finishEditing(QWidget *editor)
+{
+ QPointer<QWidget> guard(editor);
+ emit commitData(editor);
+ if (guard)
+ emit closeEditor(editor);
+}
+
// horizontals
@@ -70,6 +68,7 @@
double max = (m_doc->currentPage()->height() * uix) + (m_doc->bleeds()->bottom() * uix);
ScrSpinBox *editor = new ScrSpinBox(min, max, parent, m_doc->unitIndex());
editor->setConstants(&m_doc->constants());
+ emit editorOpened(editor);
return editor;
}
@@ -88,5 +87,6 @@
double max = (m_doc->currentPage()->width() * uix) + (m_doc->bleeds()->right() * uix);
ScrSpinBox *editor = new ScrSpinBox(min, max, parent, m_doc->unitIndex());
editor->setConstants(&m_doc->constants());
+ emit editorOpened(editor);
return editor;
}
Index: scribus/guidesdelegate.h
===================================================================
--- scribus/guidesdelegate.h (revision 27915)
+++ scribus/guidesdelegate.h (working copy)
@@ -24,11 +24,6 @@
public:
GuidesDelegate(QObject *parent = nullptr);
-// implemented in inheritance
-// QWidget *createEditor(QWidget *parent,
-// const QStyleOptionViewItem &option,
-// const QModelIndex &index) const;
-
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor,
@@ -39,8 +34,11 @@
const QStyleOptionViewItem &option,
const QModelIndex &index) const;
- void unitChange(int docUnitDecimals);
void setDoc(ScribusDoc * doc);
+ void finishEditing(QWidget *editor);
+
+ signals:
+ void editorOpened(QWidget *editor) const;
// protected due const in createEditor
protected:
Index: scribus/guidesmodel.cpp
===================================================================
--- scribus/guidesmodel.cpp (revision 27915)
+++ scribus/guidesmodel.cpp (working copy)
@@ -12,31 +12,29 @@
#include "units.h"
-GuidesModel::GuidesModel(QObject * /*parent*/)
+GuidesModel::GuidesModel(QObject *parent)
+ : QAbstractTableModel(parent)
{
}
GuidesModel::~GuidesModel() = default;
-int GuidesModel::rowCount(const QModelIndex & /*parent*/) const
+int GuidesModel::rowCount(const QModelIndex &parent) const
{
- return m_values.count();
+ return parent.isValid() ? 0 : m_values.count();
}
-int GuidesModel::columnCount(const QModelIndex & /*parent*/) const
+int GuidesModel::columnCount(const QModelIndex &parent) const
{
- // for future RFEs - color per guide etc.
- return 1;
+ return parent.isValid() ? 0 : 1;
}
QVariant GuidesModel::data(const QModelIndex & index, int role) const
{
- if (!index.isValid())
+ if (!index.isValid() || index.model() != this || index.column() != 0 ||
+ index.row() < 0 || index.row() >= m_values.count())
return QVariant();
- // DisplayRole and EditRole *must* be split. There is rounding
- // in pts2value(), toString() sequence. It disallows to compare
- // these values with m_data list.
- // Call it with EditRole when you need exact value.
+ // Display is rounded to the document's precision; editing uses the value.
if (role == Qt::DisplayRole)
{
QLocale l;
@@ -50,28 +48,82 @@
if (role == Qt::UserRole)
return m_values.at(index.row());
- if (role == Qt::BackgroundRole && m_values.at(index.row()) == 0.0)
- return QVariant(QColor(Qt::red));
return QVariant();
}
bool GuidesModel::setData(const QModelIndex & index, const QVariant & value, int role)
{
- if (role != Qt::EditRole || !index.isValid())
+ if (role != Qt::EditRole || !index.isValid() || index.model() != this ||
+ index.column() != 0 || index.row() < 0 || index.row() >= m_values.count())
return false;
bool ok;
double newVal = value.toDouble(&ok);
if (!ok)
return false;
- m_values[index.row()] = value2pts(newVal, m_docUnitIndex) + m_rule;
- std::sort(m_values.begin(), m_values.end());
- emit dataChanged(index, index);
- emit valueChanged();
+
+ const int oldRow = index.row();
+ const double oldPos = m_values.at(oldRow);
+ const double newPos = value2pts(newVal, m_docUnitIndex) + m_rule;
+ const bool pending = (oldRow == m_pendingRow);
+ // Commit a new row even at zero; unchanged existing guides must be no-ops.
+ if (!pending)
+ {
+ QLocale locale;
+ const double shownValue = locale.toDouble(locale.toString(pts2value(oldPos - m_rule, m_docUnitIndex),
+ 'f', m_docUnitDecimals));
+ if (oldPos == newPos || shownValue == newVal)
+ return true;
+ }
+
+ // Ignore the pending row itself when checking for duplicate positions.
+ const bool occupied = m_values.contains(newPos) &&
+ (!pending || newPos != oldPos || m_values.count(newPos) > 1);
+ if (occupied)
+ {
+ beginRemoveRows(QModelIndex(), oldRow, oldRow);
+ m_values.removeAt(oldRow);
+ if (pending)
+ m_pendingRow = -1;
+ endRemoveRows();
+ }
+ else
+ {
+ int newRow = 0;
+ for (int i = 0; i < m_values.count(); ++i)
+ {
+ if (i != oldRow && m_values.at(i) < newPos)
+ ++newRow;
+ }
+ if (newRow != oldRow)
+ {
+ const int destination = newRow > oldRow ? newRow + 1 : newRow;
+ beginMoveRows(QModelIndex(), oldRow, oldRow, QModelIndex(), destination);
+ m_values.removeAt(oldRow);
+ m_values.insert(newRow, newPos);
+ endMoveRows();
+ }
+ else
+ m_values[oldRow] = newPos;
+ if (pending)
+ m_pendingRow = -1;
+ const QModelIndex changed = this->index(newRow, 0);
+ emit dataChanged(changed, changed);
+ }
+ if (pending)
+ {
+ if (!occupied)
+ emit guideAdded(newPos);
+ }
+ else
+ emit valueChanged(oldPos, newPos);
return true;
}
-Qt::ItemFlags GuidesModel::flags(const QModelIndex & /*index*/) const
+Qt::ItemFlags GuidesModel::flags(const QModelIndex &index) const
{
+ if (!index.isValid() || index.model() != this || index.column() != 0 ||
+ index.row() < 0 || index.row() >= m_values.count())
+ return Qt::NoItemFlags;
return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
}
@@ -84,42 +136,41 @@
void GuidesModel::removeValues(const Guides & guides)
{
- beginResetModel();
- for (double d : guides)
- m_values.removeAll(d);
- endResetModel();
+ if (guides.isEmpty())
+ return;
+ // Keep an unfinished editor row (and its index) when removing other guides.
+ for (int row = m_values.count() - 1; row >= 0; --row)
+ {
+ if (row == m_pendingRow || !guides.contains(m_values.at(row)))
+ continue;
+ beginRemoveRows(QModelIndex(), row, row);
+ m_values.removeAt(row);
+ if (m_pendingRow > row)
+ --m_pendingRow;
+ endRemoveRows();
+ }
}
-// bool GuidesModel::removeRows(int row, int count, const QModelIndex & parent)
-// {
-// if (count <= 0 || row < 0 || (row + count - 1) > m_values.count())
-// return false;
-//
-// beginRemoveRows(parent, row, row + count - 1);
-// for (int i = 0; i < count; ++i)
-// m_values.removeAt(row);
-// endRemoveRows();
-// return true;
-// }
+int GuidesModel::insertRow()
+{
+ if (m_pendingRow >= 0)
+ return m_pendingRow;
+ // A temporary editor row starts at ruler-relative zero, not a committed guide.
+ beginInsertRows(QModelIndex(), 0, 0);
+ m_values.prepend(m_rule);
+ m_pendingRow = 0;
+ endInsertRows();
+ return m_pendingRow;
+}
-// bool GuidesModel::insertRows( int row, int count, const QModelIndex & parent)
-// {
-// beginInsertRows(parent, row, row + count - 1);
-// for (int i = 0; i < count; ++i)
-// m_values.insert(row + count, 0.0);
-// endInsertRows();
-// return true;
-// }
-
-void GuidesModel::insertRow()
+void GuidesModel::discardPendingRow()
{
-// insertRows(rowCount(), 1);
- beginResetModel();
- if (m_values.contains(0.0))
+ if (m_pendingRow < 0)
return;
- m_values.append(0.0);
- std::sort(m_values.begin(), m_values.end());
- endResetModel();
+ beginRemoveRows(QModelIndex(), m_pendingRow, m_pendingRow);
+ m_values.removeAt(m_pendingRow);
+ m_pendingRow = -1;
+ endRemoveRows();
}
void GuidesModel::setValues(const Guides& values)
@@ -127,6 +178,7 @@
beginResetModel();
m_values = values;
std::sort(m_values.begin(), m_values.end());
+ m_pendingRow = -1;
endResetModel();
}
@@ -143,15 +195,3 @@
m_docUnitDecimals = docUnitDecimals;
endResetModel();
}
-
-#if 0
-// debug
-#include <QtDebug>
-void GuidesModel::printValues()
-{
- qDebug() << "GuidesModel dump start";
- for (int i = 0; i < m_values.count(); ++i)
- qDebug() << "GuidesModel dump: " << m_values[i];
- qDebug() << "GuidesModel end of dump";
-}
-#endif
Index: scribus/guidesmodel.h
===================================================================
--- scribus/guidesmodel.h (revision 27915)
+++ scribus/guidesmodel.h (working copy)
@@ -11,12 +11,8 @@
#include "scribusstructs.h"
-/*! \brief A model for guides lists.
-It holds guides as a double QList (it will be expanded later because of RFEs)
-and it handles its values editing too. The editor from GuidesDelegate
-is used.
-See Qt4 documentation for more info about its methods.
-FIXME: unit conversions for dipslay vs. internal
+/*! \brief A model for editing manual guide positions.
+Positions are stored in document points and displayed relative to the ruler.
\author Petr Vanek <petr@scribus.info>
*/
class GuidesModel : public QAbstractTableModel
@@ -38,11 +34,8 @@
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
void removeValues(const Guides & guides);
- // qt4 api is "wrokarounded" with insertRow() and removeValues()
- // these removeRows() and insertRows() does not handle margin items correctly
-// bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex());
-// bool insertRows( int row, int count, const QModelIndex & parent = QModelIndex());
- void insertRow();
+ int insertRow();
+ void discardPendingRow();
//! \brief Set new values into the model.
void setValues(const Guides& values);
@@ -50,18 +43,16 @@
const Guides& values() const;
void unitChange(int docUnitIndex, int docUnitDecimals, double offset);
-#if 0
- //! debug only
- void printValues();
-#endif
signals:
/*! \brief Signal emitted when the user finishes editing one value.
*/
- void valueChanged();
+ void valueChanged(double oldPosition, double newPosition);
+ void guideAdded(double position);
private:
Guides m_values;
+ int m_pendingRow {-1};
int m_docUnitIndex {0};
int m_docUnitDecimals {0};
double m_rule {0.0};
Index: scribus/guidesview.cpp
===================================================================
--- scribus/guidesview.cpp (revision 27915)
+++ scribus/guidesview.cpp (working copy)
@@ -20,5 +20,10 @@
emit deleteKeyPressed();
return;
}
+ if (event->key() == Qt::Key_Plus)
+ {
+ emit plusKeyPressed();
+ return;
+ }
QTableView::keyPressEvent(event);
}
Index: scribus/guidesview.h
===================================================================
--- scribus/guidesview.h (revision 27915)
+++ scribus/guidesview.h (working copy)
@@ -22,6 +22,7 @@
signals:
void deleteKeyPressed();
+ void plusKeyPressed();
protected:
void keyPressEvent(QKeyEvent * event) override;
Index: scribus/ui/guidemanager.cpp
===================================================================
--- scribus/ui/guidemanager.cpp (revision 27915)
+++ scribus/ui/guidemanager.cpp (working copy)
@@ -22,11 +22,14 @@
* *
***************************************************************************/
+#include <QEvent>
+#include <QMetaObject>
#include <QSignalBlocker>
#include "guidemanager.h"
#include "guidesdelegate.h"
#include "guidesmodel.h"
+#include "guidesview.h"
#include "iconmanager.h"
#include "scpage.h"
#include "scribuscore.h"
@@ -36,14 +39,10 @@
#include "undomanager.h"
#include "units.h"
-
GuideManager::GuideManager(QWidget* parent) :
ScrPaletteBase(parent, "GuideManager")
{
setupUi(this);
- tabWidget->setEnabled(false);
- deletePageButton->setEnabled(false);
- deleteAllGuides->setEnabled(false);
horizontalAutoGapSpin->setMinimum(0.0);
horizontalAutoGapSpin->setMaximum(10000.0);
verticalAutoGapSpin->setMinimum(0.0);
@@ -51,11 +50,270 @@
horizontalAutoCountSpin->setDecimals(0);
verticalAutoCountSpin->setDecimals(0);
+ // Clicking the checkmark must not close the editor before the click handler.
+ // Tab still reaches these buttons through ordinary keyboard navigation.
+ addHorizontalButton->setFocusPolicy(Qt::TabFocus);
+ addVerticalButton->setFocusPolicy(Qt::TabFocus);
+ horizontalGroupBox->installEventFilter(this);
+ verticalGroupBox->installEventFilter(this);
+
+ horizontalModel = new GuidesModel(this);
+ verticalModel = new GuidesModel(this);
+ GuidesHDelegate* hdelegate = new GuidesHDelegate(horizontalView);
+ GuidesVDelegate* vdelegate = new GuidesVDelegate(verticalView);
+ horizontalView->setItemDelegateForColumn(0, hdelegate);
+ verticalView->setItemDelegateForColumn(0, vdelegate);
+ horizontalView->setModel(horizontalModel);
+ verticalView->setModel(verticalModel);
+
+ updateClearButtons();
+
+ connect(hdelegate, &GuidesDelegate::editorOpened, this, [this](QWidget *editor) {
+ m_horizontalEditor = editor;
+ setAddButtonEditing(addHorizontalButton, true, true);
+ connect(editor, &QObject::destroyed, this, [this, editor]() {
+ if (m_horizontalEditor == editor)
+ {
+ m_horizontalEditor = nullptr;
+ setAddButtonEditing(addHorizontalButton, false, true);
+ }
+ });
+ });
+ connect(vdelegate, &GuidesDelegate::editorOpened, this, [this](QWidget *editor) {
+ m_verticalEditor = editor;
+ setAddButtonEditing(addVerticalButton, true, false);
+ connect(editor, &QObject::destroyed, this, [this, editor]() {
+ if (m_verticalEditor == editor)
+ {
+ m_verticalEditor = nullptr;
+ setAddButtonEditing(addVerticalButton, false, false);
+ }
+ });
+ });
+ connect(hdelegate, &QAbstractItemDelegate::closeEditor, this, [this](QWidget *editor) {
+ if (m_horizontalEditor == editor)
+ {
+ m_horizontalEditor = nullptr;
+ setAddButtonEditing(addHorizontalButton, false, true);
+ // Allow QTableView to finish closing the editor before removing its row.
+ const auto generation = m_pageGeneration;
+ QMetaObject::invokeMethod(this, [this, generation]() {
+ if (m_pageGeneration == generation)
+ discardPendingGuide(true);
+ }, Qt::QueuedConnection);
+ }
+ });
+ connect(vdelegate, &QAbstractItemDelegate::closeEditor, this, [this](QWidget *editor) {
+ if (m_verticalEditor == editor)
+ {
+ m_verticalEditor = nullptr;
+ setAddButtonEditing(addVerticalButton, false, false);
+ const auto generation = m_pageGeneration;
+ QMetaObject::invokeMethod(this, [this, generation]() {
+ if (m_pageGeneration == generation)
+ discardPendingGuide(false);
+ }, Qt::QueuedConnection);
+ }
+ });
+
+ connect(addHorizontalButton, &QToolButton::clicked, this, &GuideManager::addHorizontalButton_clicked);
+ connect(deleteHorizontalButton, &QToolButton::clicked, this, &GuideManager::deleteHorizontalButton_clicked);
+ connect(clearHorizontalButton, &QToolButton::clicked, this, &GuideManager::clearHorizontalButton_clicked);
+ connect(horizontalView, &GuidesView::deleteKeyPressed, this, &GuideManager::deleteHorizontalButton_clicked);
+ connect(horizontalView, &GuidesView::plusKeyPressed, this, &GuideManager::addHorizontalButton_clicked);
+ connect(addVerticalButton, &QToolButton::clicked, this, &GuideManager::addVerticalButton_clicked);
+ connect(deleteVerticalButton, &QToolButton::clicked, this, &GuideManager::deleteVerticalButton_clicked);
+ connect(clearVerticalButton, &QToolButton::clicked, this, &GuideManager::clearVerticalButton_clicked);
+ connect(verticalView, &GuidesView::deleteKeyPressed, this, &GuideManager::deleteVerticalButton_clicked);
+ connect(verticalView, &GuidesView::plusKeyPressed, this, &GuideManager::addVerticalButton_clicked);
+ connect(horizontalView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &GuideManager::forceDrawGuides);
+ connect(verticalView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &GuideManager::forceDrawGuides);
+
+ connect(applyToAllPagesButton, &QToolButton::clicked, this, &GuideManager::applyToAllPagesButton_clicked);
+ connect(applyAutoToAllPagesButton, &QToolButton::clicked, this, &GuideManager::applyAutoToAllPagesButton_clicked);
+ connect(horizontalAutoCountSpin, qOverload<double>(&ScrSpinBox::valueChanged), this, qOverload<double>(&GuideManager::horizontalAutoCountSpin_valueChanged));
+ connect(verticalAutoCountSpin, qOverload<double>(&ScrSpinBox::valueChanged), this, &GuideManager::verticalAutoCountSpin_valueChanged);
+ connect(horizontalAutoGapSpin, qOverload<double>(&ScrSpinBox::valueChanged), this, qOverload<double>(&GuideManager::horizontalAutoGapSpin_valueChanged));
+ connect(verticalAutoGapSpin, qOverload<double>(&ScrSpinBox::valueChanged), this, qOverload<double>(&GuideManager::verticalAutoGapSpin_valueChanged));
+
+ connect(horizontalPageAutoButton, &QToolButton::toggled, this, &GuideManager::horizontalPageAutoButton_toggled);
+ connect(horizontalMarginsAutoButton, &QToolButton::toggled, this, &GuideManager::horizontalMarginsAutoButton_toggled);
+ connect(horizontalSelectionAutoButton, &QToolButton::toggled, this, &GuideManager::horizontalSelectionAutoButton_toggled);
+ connect(verticalPageAutoButton, &QToolButton::toggled, this, &GuideManager::verticalPageAutoButton_toggled);
+ connect(verticalMarginsAutoButton, &QToolButton::toggled, this, &GuideManager::verticalMarginsAutoButton_toggled);
+ connect(verticalSelectionAutoButton, &QToolButton::toggled, this, &GuideManager::verticalSelectionAutoButton_toggled);
+
+ connect(lockGuidesButton, &QToolButton::clicked, this, &GuideManager::lockGuidesButton_clicked);
+
+ connect(horizontalModel, &GuidesModel::valueChanged, this, &GuideManager::horizontalModel_valueChanged);
+ connect(verticalModel, &GuidesModel::valueChanged, this, &GuideManager::verticalModel_valueChanged);
+ connect(horizontalModel, &GuidesModel::guideAdded, this, [this](double pos) { addGuide(true, pos); });
+ connect(verticalModel, &GuidesModel::guideAdded, this, [this](double pos) { addGuide(false, pos); });
+}
+
+GuideManager::~GuideManager() = default;
+
+void GuideManager::setDoc(ScribusDoc* doc)
+{
+ finishGuideEditors();
+ ++m_pageGeneration;
+ if (m_doc && (m_doc != doc))
+ {
+ if (currentPage && (currentPage->doc() == m_doc))
+ storePageValues(currentPage);
+ currentPage = nullptr;
+ }
+
+ m_doc = doc;
+ if (m_doc)
+ {
+ int oldUnitIndex = docUnitIndex;
+ if (oldUnitIndex != m_doc->unitIndex())
+ unitChange();
+ }
+
+ qobject_cast<GuidesHDelegate*>(horizontalView->itemDelegateForColumn(0))->setDoc(doc);
+ qobject_cast<GuidesVDelegate*>(verticalView->itemDelegateForColumn(0))->setDoc(doc);
+ if (!m_doc)
+ currentPage = nullptr;
+ setEnabled(m_doc != nullptr);
+ updateClearButtons();
+ const bool multiplePages = m_doc && m_doc->Pages->count() > 1;
+ applyToAllPagesButton->setEnabled(multiplePages);
+ applyAutoToAllPagesButton->setEnabled(multiplePages);
+}
+
+void GuideManager::setVisible(bool visible)
+{
+ ScrPaletteBase::setVisible(visible);
+ drawGuides();
+}
+
+void GuideManager::setupPage(bool storeValues)
+{
+ if (!m_doc)
+ return;
+ finishGuideEditors();
+ ++m_pageGeneration;
+ m_drawGuides = false;
+ setEnabled(true);
+ if (currentPage && storeValues)
+ storePageValues(currentPage);
+
+ currentPage = m_doc->currentPage();
+ unitChange();
+ setupGui();
+ const bool multiplePages = m_doc->Pages->count() > 1;
+ applyToAllPagesButton->setEnabled(multiplePages);
+ applyAutoToAllPagesButton->setEnabled(multiplePages);
+}
+
+void GuideManager::setupGui()
+{
+ if (!m_doc || !currentPage)
+ return;
+ // Restore controls without treating a page change as a guide edit.
+ clearRestoreHorizontalList();
+ clearRestoreVerticalList();
+ updateClearButtons();
+ QSignalBlocker horizontalCountBlock(horizontalAutoCountSpin);
+ QSignalBlocker horizontalGapBlock(horizontalAutoGapSpin);
+ QSignalBlocker verticalCountBlock(verticalAutoCountSpin);
+ QSignalBlocker verticalGapBlock(verticalAutoGapSpin);
+ QSignalBlocker horizontalPageBlock(horizontalPageAutoButton);
+ QSignalBlocker horizontalMarginsBlock(horizontalMarginsAutoButton);
+ QSignalBlocker horizontalSelectionBlock(horizontalSelectionAutoButton);
+ QSignalBlocker verticalPageBlock(verticalPageAutoButton);
+ QSignalBlocker verticalMarginsBlock(verticalMarginsAutoButton);
+ QSignalBlocker verticalSelectionBlock(verticalSelectionAutoButton);
+ QSignalBlocker lockBlock(lockGuidesButton);
+ horizontalAutoCountSpin->setValue(currentPage->guides.horizontalAutoCount());
+ horizontalAutoGapSpin->setValue(currentPage->guides.horizontalAutoGap(), SC_PT);
+ horizontalAutoGapSpin->setEnabled(horizontalAutoCountSpin->value() > 0);
+ setHorizontalReference(currentPage->guides.horizontalAutoRefer());
+ horizontalSelectionAutoButton->setEnabled(m_doc->m_Selection->isNotEmpty());
+
+ verticalAutoCountSpin->setValue(currentPage->guides.verticalAutoCount());
+ verticalAutoGapSpin->setValue(currentPage->guides.verticalAutoGap(), SC_PT);
+ verticalAutoGapSpin->setEnabled(verticalAutoCountSpin->value() > 0);
+ setVerticalReference(currentPage->guides.verticalAutoRefer());
+ verticalSelectionAutoButton->setEnabled(m_doc->m_Selection->isNotEmpty());
+
+ lockGuidesButton->setChecked(m_doc->GuideLock);
+
+ iconSetChange();
+ languageChange();
+
+ m_drawGuides = true;
+}
+
+void GuideManager::storePageValues(ScPage* page) const
+{
+ if (!page || !m_doc)
+ return;
+
+ page->guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
+ page->guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
+ page->guides.setHorizontalAutoRefer(horizontalReference());
+ page->guides.addHorizontals(getAutoHorizontals(page), GuideManagerCore::Auto);
+
+ page->guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
+ page->guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
+ page->guides.setVerticalAutoRefer(verticalReference());
+ page->guides.addVerticals(getAutoVerticals(page), GuideManagerCore::Auto);
+}
+
+void GuideManager::changeEvent(QEvent *e)
+{
+ if (e->type() == QEvent::LanguageChange)
+ {
+ languageChange();
+ }
+ else
+ QWidget::changeEvent(e);
+}
+
+void GuideManager::languageChange()
+{
+ retranslateUi(this);
+ setAddButtonEditing(addHorizontalButton, m_horizontalEditor != nullptr, true);
+ setAddButtonEditing(addVerticalButton, m_verticalEditor != nullptr, false);
+}
+
+void GuideManager::discardPendingGuide(bool horizontal)
+{
+ if (!currentPage || (horizontal ? m_horizontalEditor : m_verticalEditor))
+ return;
+ (horizontal ? horizontalModel : verticalModel)->discardPendingRow();
+ updateClearButtons();
+}
+
+void GuideManager::finishGuideEditors()
+{
+ if (m_horizontalEditor)
+ qobject_cast<GuidesDelegate*>(horizontalView->itemDelegateForColumn(0))->finishEditing(m_horizontalEditor);
+ if (m_verticalEditor)
+ qobject_cast<GuidesDelegate*>(verticalView->itemDelegateForColumn(0))->finishEditing(m_verticalEditor);
+}
+
+void GuideManager::updateClearButtons()
+{
+ const bool hasPage = m_doc && currentPage;
+ clearHorizontalButton->setEnabled(hasPage && !currentPage->guides.horizontals(GuideManagerCore::Standard).isEmpty());
+ clearVerticalButton->setEnabled(hasPage && !currentPage->guides.verticals(GuideManagerCore::Standard).isEmpty());
+}
+
+void GuideManager::iconSetChange()
+{
IconManager& im = IconManager::instance();
- addHorButton->setIcon(im.loadIcon("list-add"));
- delHorButton->setIcon(im.loadIcon("edit-delete"));
- addVerButton->setIcon(im.loadIcon("list-add"));
- delVerButton->setIcon(im.loadIcon("edit-delete"));
+
+ addHorizontalButton->setIcon(im.loadIcon("list-add"));
+ deleteHorizontalButton->setIcon(im.loadIcon("list-remove"));
+ clearHorizontalButton->setIcon(im.loadIcon("trashcan"));
+ addVerticalButton->setIcon(im.loadIcon("list-add"));
+ deleteVerticalButton->setIcon(im.loadIcon("list-remove"));
+ clearVerticalButton->setIcon(im.loadIcon("trashcan"));
+
horizontalPageAutoButton->setIcon(im.loadIcon("align-to-page"));
horizontalMarginsAutoButton->setIcon(im.loadIcon("align-to-margin"));
horizontalSelectionAutoButton->setIcon(im.loadIcon("align-to-last-selection"));
@@ -63,193 +321,36 @@
verticalMarginsAutoButton->setIcon(im.loadIcon("align-to-margin"));
verticalSelectionAutoButton->setIcon(im.loadIcon("align-to-last-selection"));
- // MVC
- horizontalModel = new GuidesModel(this);
- verticalModel = new GuidesModel(this);
- GuidesHDelegate * hdelegate = new GuidesHDelegate();
- GuidesVDelegate * vdelegate = new GuidesVDelegate();
- horizontalView->setItemDelegateForColumn(0, hdelegate);
- verticalView->setItemDelegateForColumn(0, vdelegate);
- horizontalView->setModel(horizontalModel);
- verticalView->setModel(verticalModel);
-
- connect(addHorButton, SIGNAL(clicked()), this, SLOT(addHorButton_clicked()));
- connect(delHorButton, SIGNAL(clicked()), this, SLOT(delHorButton_clicked()));
- connect(horizontalView, SIGNAL(deleteKeyPressed()), this, SLOT(delHorButton_clicked()));
- connect(addVerButton, SIGNAL(clicked()), this, SLOT(addVerButton_clicked()));
- connect(delVerButton, SIGNAL(clicked()), this, SLOT(delVerButton_clicked()));
- connect(verticalView, SIGNAL(deleteKeyPressed()), this, SLOT(delVerButton_clicked()));
- connect(horizontalView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(forceDrawGuides(QItemSelection,QItemSelection)));
- connect(verticalView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(forceDrawGuides(QItemSelection,QItemSelection)));
-
- connect(applyToAllStdButton, SIGNAL(clicked()), this, SLOT(applyToAllStdButton_clicked()));
- connect(horizontalAutoCountSpin, SIGNAL(valueChanged(double)), this, SLOT(horizontalAutoCountSpin_valueChanged(double)));
- connect(verticalAutoCountSpin, SIGNAL(valueChanged(double)), this, SLOT(verticalAutoCountSpin_valueChanged(double)));
- connect(horizontalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(horizontalAutoGapCheck_stateChanged(int)));
- connect(verticalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(verticalAutoGapCheck_stateChanged(int)));
- connect(horizontalAutoGapSpin, SIGNAL(valueChanged(double)), this, SLOT(horizontalAutoGapSpin_valueChanged(double)));
- connect(verticalAutoGapSpin, SIGNAL(valueChanged(double)), this, SLOT(verticalAutoGapSpin_valueChanged(double)));
-
- connect(horizontalPageAutoButton, SIGNAL(toggled(bool)), this, SLOT(horizontalPageAutoButton_toggled(bool)));
- connect(horizontalMarginsAutoButton, SIGNAL(toggled(bool)), this, SLOT(horizontalMarginsAutoButton_toggled(bool)));
- connect(horizontalSelectionAutoButton, SIGNAL(toggled(bool)), this, SLOT(horizontalSelectionAutoButton_toggled(bool)));
- connect(verticalPageAutoButton, SIGNAL(toggled(bool)), this, SLOT(verticalPageAutoButton_toggled(bool)));
- connect(verticalMarginsAutoButton, SIGNAL(toggled(bool)), this, SLOT(verticalMarginsAutoButton_toggled(bool)));
- connect(verticalSelectionAutoButton, SIGNAL(toggled(bool)), this, SLOT(verticalSelectionAutoButton_toggled(bool)));
-
- connect(applyToAllAutoButton, SIGNAL(clicked()), this, SLOT(applyToAllAutoButton_clicked()));
- connect(deletePageButton, SIGNAL(clicked()), this, SLOT(deletePageButton_clicked()));
- connect(deleteAllGuides, SIGNAL(clicked()), this, SLOT(deleteAllGuides_clicked()));
-
- connect(lockCheck, SIGNAL(stateChanged(int)), this, SLOT(lockCheck_stateChanged(int)));
-
- connect(horizontalModel, SIGNAL(valueChanged()), this, SLOT(horizontalModel_valueChanged()));
- connect(verticalModel, SIGNAL(valueChanged()), this, SLOT(verticalModel_valueChanged()));
-
- connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabWidget_currentChanged(int)));
-}
-
-GuideManager::~GuideManager()
-{
- delete horizontalView->itemDelegateForColumn(0);
- delete verticalView->itemDelegateForColumn(0);
-}
-
-void GuideManager::setDoc(ScribusDoc* doc)
-{
- if (m_doc && (m_doc != doc))
- {
- if (currentPage && (currentPage->doc() == m_doc))
- storePageValues(currentPage);
- currentPage = nullptr;
- }
-
- m_doc = doc;
- if (m_doc)
- {
- int oldUnitIndex = docUnitIndex;
- if (oldUnitIndex != m_doc->unitIndex())
- unitChange();
- }
-
- qobject_cast<GuidesHDelegate*>(horizontalView->itemDelegateForColumn(0))->setDoc(doc);
- qobject_cast<GuidesVDelegate*>(verticalView->itemDelegateForColumn(0))->setDoc(doc);
- if (!m_doc)
- currentPage = nullptr;
- tabWidget->setEnabled(doc != nullptr);
- deletePageButton->setEnabled(doc != nullptr);
- deleteAllGuides->setEnabled(doc != nullptr);
-}
-
-void GuideManager::setVisible(bool visible)
-{
- ScrPaletteBase::setVisible(visible);
- drawGuides();
-}
-
-void GuideManager::setupPage(bool storeValues)
-{
- if (!m_doc)
- return;
- m_drawGuides = false;
- setEnabled(true);
- // store old values for current page (= page to leave)
- if (currentPage && storeValues)
- storePageValues(currentPage);
-
- currentPage = m_doc->currentPage();
- unitChange();
- setupGui();
-}
-
-void GuideManager::setupGui()
-{
- disconnect(horizontalAutoGapCheck, SIGNAL(stateChanged(int)),
- this, SLOT(horizontalAutoGapCheck_stateChanged(int)));
- disconnect(verticalAutoGapCheck, SIGNAL(stateChanged(int)),
- this, SLOT(verticalAutoGapCheck_stateChanged(int)));
- disconnect(lockCheck, SIGNAL(stateChanged(int)),
- this, SLOT(lockCheck_stateChanged(int)));
-
- // restore values from new page
- clearRestoreHorizontalList();
- clearRestoreVerticalList();
- // restore: brand "auto guides into GUI restore algorithm"
- bool enable = currentPage->guides.horizontalAutoGap() > 0.0;
- horizontalAutoGapCheck->setChecked(enable);
- horizontalAutoGapSpin->setEnabled(enable);
- horizontalAutoGapSpin->setValue(currentPage->guides.horizontalAutoGap(), SC_PT);
- horizontalAutoCountSpin->setValue(currentPage->guides.horizontalAutoCount());
- if (horizontalAutoCountSpin->value()==0)
- {
- horizontalAutoGapSpin->setEnabled(false);
- horizontalAutoGapCheck->setEnabled(false);
- }
- setHorizontalRefer(currentPage->guides.horizontalAutoRefer());
- // allow the selection radio button?
- horizontalSelectionAutoButton->setEnabled(m_doc->m_Selection->isNotEmpty());
-
- // verticals
- enable = currentPage->guides.verticalAutoGap() > 0.0;
- verticalAutoGapCheck->setChecked(enable);
- verticalAutoGapSpin->setEnabled(enable);
- verticalAutoGapSpin->setValue(currentPage->guides.verticalAutoGap(), SC_PT);
- verticalAutoCountSpin->setValue(currentPage->guides.verticalAutoCount());
- if (verticalAutoCountSpin->value()==0)
- {
- verticalAutoGapSpin->setEnabled(false);
- verticalAutoGapCheck->setEnabled(false);
- }
- setVerticalRefer(currentPage->guides.verticalAutoRefer());
- // allow the selection radio button?
- verticalSelectionAutoButton->setEnabled(m_doc->m_Selection->isNotEmpty());
-
- // restore guide locking
- lockCheck->setChecked(m_doc->GuideLock);
-
- connect(horizontalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(horizontalAutoGapCheck_stateChanged(int)));
- connect(verticalAutoGapCheck, SIGNAL(stateChanged(int)), this, SLOT(verticalAutoGapCheck_stateChanged(int)));
- connect(lockCheck, SIGNAL(stateChanged(int)), this, SLOT(lockCheck_stateChanged(int)));
-
- m_drawGuides = true;
-// drawGuides(); let Canvas::DrawPageMarks take care of it and avoid a costly ScribusView::DrawNew()
-}
-
-void GuideManager::storePageValues(ScPage *page) const
-{
- if (!page || !m_doc)
- return;
-
- double gapValue = 0.0;
- if (horizontalAutoGapCheck->isChecked())
- gapValue = horizontalAutoGapSpin->getValue(SC_PT);
- page->guides.setHorizontalAutoGap(gapValue);
- page->guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
- page->guides.setHorizontalAutoRefer(horizontalRefer());
- page->guides.addHorizontals(getAutoHorizontals(page), GuideManagerCore::Auto);
-
- gapValue = 0.0;
- if (verticalAutoGapCheck->isChecked())
- gapValue = verticalAutoGapSpin->getValue(SC_PT);
- page->guides.setVerticalAutoGap(gapValue);
- page->guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
- page->guides.setVerticalAutoRefer(verticalRefer());
- page->guides.addVerticals(getAutoVerticals(page), GuideManagerCore::Auto);
-}
-
-void GuideManager::changeEvent(QEvent *e)
-{
- if (e->type() == QEvent::LanguageChange)
- {
- languageChange();
- }
- else
- QWidget::changeEvent(e);
-}
-
-void GuideManager::languageChange()
-{
- retranslateUi(this);
+ applyToAllPagesButton->setIcon(im.loadIcon("page-duplicate"));
+ applyAutoToAllPagesButton->setIcon(im.loadIcon("page-duplicate"));
+
+ QIcon lockIcon;
+ lockIcon.addPixmap(im.loadPixmap("lock"), QIcon::Normal, QIcon::On);
+ lockIcon.addPixmap(im.loadPixmap("lock-unlocked"), QIcon::Normal, QIcon::Off);
+ lockGuidesButton->setIcon(lockIcon);
+}
+
+void GuideManager::setAddButtonEditing(QToolButton* button, bool editing, bool horizontal)
+{
+ button->setIcon(IconManager::instance().loadIcon(editing ? "ok" : "list-add"));
+ button->setToolTip(editing ? tr("Finish editing")
+ : horizontal ? tr("Add a new horizontal guide")
+ : tr("Add a new vertical guide"));
+}
+
+bool GuideManager::eventFilter(QObject *watched, QEvent *event)
+{
+ if (event->type() == QEvent::MouseButtonPress &&
+ (watched == horizontalGroupBox || watched == verticalGroupBox))
+ {
+ // Guide-list blank space already finishes editing. Match it on the
+ // surrounding background without changing the selected guide.
+ if (m_horizontalEditor)
+ horizontalView->setFocus(Qt::MouseFocusReason);
+ else if (m_verticalEditor)
+ verticalView->setFocus(Qt::MouseFocusReason);
+ }
+ return ScrPaletteBase::eventFilter(watched, event);
}
void GuideManager::unitChange()
@@ -265,18 +366,25 @@
horizontalAutoGapSpin->setNewUnit(docUnitIndex);
verticalAutoGapSpin->setNewUnit(docUnitIndex);
- // models display
horizontalModel->unitChange(docUnitIndex, docUnitDecimals, m_doc->rulerYoffset);
verticalModel->unitChange(docUnitIndex, docUnitDecimals, m_doc->rulerXoffset);
qobject_cast<GuidesHDelegate*>(horizontalView->itemDelegateForColumn(0))->setDoc(m_doc);
qobject_cast<GuidesVDelegate*>(verticalView->itemDelegateForColumn(0))->setDoc(m_doc);
}
-void GuideManager::delHorButton_clicked()
-{
+
+
+void GuideManager::deleteHorizontalButton_clicked()
+{
+ if (!currentPage)
+ return;
+ finishGuideEditors();
+ discardPendingGuide(true);
const QModelIndexList indexes = horizontalView->selectionModel()->selectedRows(0);
Guides v;
+ if (indexes.isEmpty())
+ return;
for (const QModelIndex& ix : indexes)
// here *must* go EditRole due truncations in DisplayRole
// see GuidesModel::data()
@@ -288,13 +396,21 @@
currentPage->guides.addHorizontals(horizontalModel->values(), GuideManagerCore::Standard);
drawGuides();
m_doc->changed();
-}
-
-void GuideManager::delVerButton_clicked()
-{
+
+ updateClearButtons();
+}
+
+void GuideManager::deleteVerticalButton_clicked()
+{
+ if (!currentPage)
+ return;
+ finishGuideEditors();
+ discardPendingGuide(false);
const QModelIndexList indexes = verticalView->selectionModel()->selectedRows(0);
Guides v;
+ if (indexes.isEmpty())
+ return;
for (const QModelIndex& ix : indexes)
// here *must* go EditRole due truncations in DisplayRole
// see GuidesModel::data()
@@ -306,25 +422,99 @@
currentPage->guides.addVerticals(verticalModel->values(), GuideManagerCore::Standard);
drawGuides();
m_doc->changed();
-}
-
-void GuideManager::addHorButton_clicked()
-{
- horizontalModel->insertRow();
- horizontalView->setCurrentIndex(horizontalModel->index(0, 0, QModelIndex()));
+
+ updateClearButtons();
+}
+
+void GuideManager::clearHorizontalButton_clicked()
+{
+ if (!currentPage->guides.horizontals(GuideManagerCore::Standard).empty())
+ {
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ trans = UndoManager::instance()->beginTransaction(currentPage->getUName(),
+ currentPage->getUPixmap(),
+ QObject::tr("Remove horizontal guides"), "",
+ Um::IGuides);
+ currentPage->guides.clearHorizontals(GuideManagerCore::Standard);
+
+ if (trans)
+ trans.commit();
+
+ m_doc->changed();
+ }
+
+ clearRestoreHorizontalList();
+ drawGuides();
+
+ updateClearButtons();
+}
+
+void GuideManager::clearVerticalButton_clicked()
+{
+ if (!currentPage->guides.verticals(GuideManagerCore::Standard).empty())
+ {
+ UndoTransaction trans;
+ if (UndoManager::undoEnabled())
+ trans = UndoManager::instance()->beginTransaction(currentPage->getUName(),
+ currentPage->getUPixmap(),
+ QObject::tr("Remove vertical guides"), "",
+ Um::IGuides);
+ currentPage->guides.clearVerticals(GuideManagerCore::Standard);
+
+ if (trans)
+ trans.commit();
+
+ m_doc->changed();
+ }
+
+ drawGuides();
+ clearRestoreVerticalList();
+
+ updateClearButtons();
+}
+
+void GuideManager::addHorizontalButton_clicked()
+{
+ if (m_verticalEditor)
+ qobject_cast<GuidesDelegate*>(verticalView->itemDelegateForColumn(0))->finishEditing(m_verticalEditor);
+ if (m_horizontalEditor)
+ {
+ qobject_cast<GuidesDelegate*>(horizontalView->itemDelegateForColumn(0))->finishEditing(m_horizontalEditor);
+ horizontalView->setFocus(Qt::OtherFocusReason);
+ updateClearButtons();
+ return;
+ }
+ horizontalView->clearSelection();
+ const int row = horizontalModel->insertRow();
+ horizontalView->setCurrentIndex(horizontalModel->index(row, 0));
horizontalView->edit(horizontalView->currentIndex());
-}
-
-void GuideManager::addVerButton_clicked()
-{
- verticalModel->insertRow();
- verticalView->setCurrentIndex(verticalModel->index(0, 0, QModelIndex()));
+
+ updateClearButtons();
+}
+
+void GuideManager::addVerticalButton_clicked()
+{
+ if (m_horizontalEditor)
+ qobject_cast<GuidesDelegate*>(horizontalView->itemDelegateForColumn(0))->finishEditing(m_horizontalEditor);
+ if (m_verticalEditor)
+ {
+ qobject_cast<GuidesDelegate*>(verticalView->itemDelegateForColumn(0))->finishEditing(m_verticalEditor);
+ verticalView->setFocus(Qt::OtherFocusReason);
+ updateClearButtons();
+ return;
+ }
+ verticalView->clearSelection();
+ const int row = verticalModel->insertRow();
+ verticalView->setCurrentIndex(verticalModel->index(row, 0));
verticalView->edit(verticalView->currentIndex());
-}
-
-void GuideManager::lockCheck_stateChanged( int )
-{
- m_doc->lockGuides(lockCheck->isChecked());
+
+ updateClearButtons();
+}
+
+void GuideManager::lockGuidesButton_clicked()
+{
+ m_doc->lockGuides(lockGuidesButton->isChecked());
}
void GuideManager::copyGuidesToAllPages(GuideManagerCore::GuideType t)
@@ -352,24 +542,19 @@
m_doc->changed();
}
-void GuideManager::applyToAllStdButton_clicked()
+void GuideManager::applyToAllPagesButton_clicked()
{
copyGuidesToAllPages(GuideManagerCore::Standard);
}
-void GuideManager::applyToAllAutoButton_clicked()
+void GuideManager::applyAutoToAllPagesButton_clicked()
{
copyGuidesToAllPages(GuideManagerCore::Auto);
}
void GuideManager::horizontalAutoCountSpin_valueChanged(double val)
{
- bool enable = val != 0;
- horizontalAutoGapCheck->setEnabled(enable);
- if (enable && horizontalAutoGapCheck->isChecked())
- horizontalAutoGapSpin->setEnabled(true);
- else
- horizontalAutoGapSpin->setEnabled(false);
+ horizontalAutoGapSpin->setEnabled(val > 0);
currentPage->guides.setHorizontalAutoCount(static_cast<int>(val));
drawGuides();
m_doc->changed();
@@ -382,56 +567,19 @@
m_doc->changed();
}
-void GuideManager::horizontalAutoGapCheck_stateChanged( int )
-{
- horizontalAutoGapSpin->setEnabled(horizontalAutoGapCheck->isChecked());
- if (horizontalAutoGapCheck->isChecked())
- currentPage->guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
- else
- currentPage->guides.setHorizontalAutoGap(0.0);
+void GuideManager::verticalAutoCountSpin_valueChanged(double val)
+{
+ verticalAutoGapSpin->setEnabled(val > 0);
+ currentPage->guides.setVerticalAutoCount(static_cast<int>(val));
drawGuides();
m_doc->changed();
}
-void GuideManager::verticalAutoCountSpin_valueChanged(double val)
-{
- bool enable = val != 0;
- verticalAutoGapCheck->setEnabled(enable);
- if (enable && verticalAutoGapCheck->isChecked())
- verticalAutoGapSpin->setEnabled(true);
- else
- verticalAutoGapSpin->setEnabled(false);
- currentPage->guides.setVerticalAutoCount(static_cast<int>(val));
+void GuideManager::verticalAutoGapSpin_valueChanged(double)
+{
+ currentPage->guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
drawGuides();
m_doc->changed();
-}
-
-void GuideManager::verticalAutoGapSpin_valueChanged(double)
-{
- currentPage->guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
- drawGuides();
- m_doc->changed();
-}
-
-void GuideManager::verticalAutoGapCheck_stateChanged( int )
-{
- verticalAutoGapSpin->setEnabled(verticalAutoGapCheck->isChecked());
- if (verticalAutoGapCheck->isChecked())
- currentPage->guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
- else
- currentPage->guides.setVerticalAutoGap(0.0);
- drawGuides();
- m_doc->changed();
-}
-
-void GuideManager::tabWidget_currentChanged(int)
-{
- drawGuides();
- if (tabWidget->currentIndex() == 1)
- {
- horizontalAutoGapSpin->setEnabled(horizontalAutoGapCheck->isChecked());
- verticalAutoGapSpin->setEnabled(verticalAutoGapCheck->isChecked());
- }
}
Guides GuideManager::selectedHorizontals() const
@@ -460,9 +608,8 @@
void GuideManager::setGuideLock(bool guidesLocked)
{
- bool b = lockCheck->blockSignals(true);
- lockCheck->setChecked(guidesLocked);
- lockCheck->blockSignals(b);
+ QSignalBlocker blocker(lockGuidesButton);
+ lockGuidesButton->setChecked(guidesLocked);
}
void GuideManager::forceDrawGuides(const QItemSelection &, const QItemSelection &)
@@ -472,7 +619,7 @@
void GuideManager::drawGuides()
{
- if (!m_doc || !m_drawGuides)
+ if (!m_doc || !currentPage || !m_drawGuides)
return;
currentPage->guides.addHorizontals(getAutoHorizontals(currentPage), GuideManagerCore::Auto);
@@ -483,140 +630,88 @@
void GuideManager::clearRestoreHorizontalList()
{
horizontalModel->setValues(currentPage->guides.horizontals(GuideManagerCore::Standard));
- drawGuides();
}
void GuideManager::clearRestoreVerticalList()
{
verticalModel->setValues(currentPage->guides.verticals(GuideManagerCore::Standard));
- drawGuides();
-}
-
-void GuideManager::deletePageButton_clicked()
-{
- if (!currentPage->guides.hasGuides())
- return;
-
- UndoTransaction trans;
- if(UndoManager::undoEnabled())
- trans = UndoManager::instance()->beginTransaction(currentPage->getUName(),
- currentPage->getUPixmap(),
- Um::RemoveAllPageGuides, "",
- Um::IGuides);
- currentPage->guides.clearHorizontals(GuideManagerCore::Standard);
- currentPage->guides.clearVerticals(GuideManagerCore::Standard);
- currentPage->guides.clearHorizontals(GuideManagerCore::Auto);
- currentPage->guides.clearVerticals(GuideManagerCore::Auto);
- clearRestoreHorizontalList();
- clearRestoreVerticalList();
-
- currentPage->guides.setHorizontalAutoCount(0);
- currentPage->guides.setVerticalAutoCount(0);
- currentPage->guides.setHorizontalAutoGap(0.0);
- currentPage->guides.setVerticalAutoGap(0.0);
- currentPage->guides.setHorizontalAutoRefer(0);
- currentPage->guides.setVerticalAutoRefer(0);
- horizontalAutoCountSpin->setValue(0);
- verticalAutoCountSpin->setValue(0);
-
- if (trans)
- trans.commit();
-
+}
+
+Guides GuideManager::getAutoVerticals(const ScPage * page) const
+{
+ GuideManagerCore guides;
+
+ guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
+ guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
+ guides.setHorizontalAutoRefer(horizontalReference());
+
+ guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
+ guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
+ guides.setVerticalAutoRefer(verticalReference());
+
+ return guides.getAutoVerticals(page);
+}
+
+Guides GuideManager::getAutoHorizontals(const ScPage * page) const
+{
+ GuideManagerCore guides;
+
+ guides.setHorizontalAutoGap(horizontalAutoGapSpin->getValue(SC_PT));
+ guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
+ guides.setHorizontalAutoRefer(horizontalReference());
+
+ guides.setVerticalAutoGap(verticalAutoGapSpin->getValue(SC_PT));
+ guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
+ guides.setVerticalAutoRefer(verticalReference());
+
+ return guides.getAutoHorizontals(page);
+}
+
+void GuideManager::addGuide(bool horizontal, double position)
+{
+ if (!currentPage)
+ return;
+ const Guides existing = horizontal ? currentPage->guides.horizontals(GuideManagerCore::Standard)
+ : currentPage->guides.verticals(GuideManagerCore::Standard);
+ if (existing.contains(position))
+ return;
+ if (horizontal)
+ currentPage->guides.addHorizontal(position, GuideManagerCore::Standard);
+ else
+ currentPage->guides.addVertical(position, GuideManagerCore::Standard);
+ updateClearButtons();
drawGuides();
m_doc->changed();
}
-void GuideManager::deleteAllGuides_clicked()
-{
- bool hasGuides = false;
- for (const ScPage* page : *m_doc->Pages)
- {
- if (page->guides.hasGuides())
- {
- hasGuides = true;
- break;
- }
- }
- if (!hasGuides)
- return;
-
-
- UndoTransaction trans;
- if (UndoManager::undoEnabled())
- trans = UndoManager::instance()->beginTransaction(m_doc->getUName(),
- m_doc->getUPixmap(),
- Um::RemoveAllGuides, "",
- Um::IGuides);
- m_drawGuides = false;
- deletePageButton_clicked();
- copyGuidesToAllPages(GuideManagerCore::Standard);
- copyGuidesToAllPages(GuideManagerCore::Auto);
- m_drawGuides = true;
- if (trans)
- trans.commit();
+void GuideManager::guideValueChanged(bool horizontal, double oldPosition, double newPosition)
+{
+ if (!currentPage || oldPosition == newPosition)
+ return;
+ const Guides existing = horizontal ? currentPage->guides.horizontals(GuideManagerCore::Standard)
+ : currentPage->guides.verticals(GuideManagerCore::Standard);
+ if (!existing.contains(oldPosition))
+ return;
+ if (horizontal)
+ currentPage->guides.moveHorizontal(oldPosition, newPosition, GuideManagerCore::Standard);
+ else
+ currentPage->guides.moveVertical(oldPosition, newPosition, GuideManagerCore::Standard);
+ updateClearButtons();
drawGuides();
m_doc->changed();
}
-Guides GuideManager::getAutoVerticals(const ScPage * page) const
-{
- GuideManagerCore guides;
-
- double gapValue = 0.0;
- if (horizontalAutoGapCheck->isChecked())
- gapValue = horizontalAutoGapSpin->getValue(SC_PT);
- guides.setHorizontalAutoGap(gapValue);
- guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
- guides.setHorizontalAutoRefer(horizontalRefer());
-
- gapValue = 0.0;
- if (verticalAutoGapCheck->isChecked())
- gapValue = verticalAutoGapSpin->getValue(SC_PT);
- guides.setVerticalAutoGap(gapValue);
- guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
- guides.setVerticalAutoRefer(verticalRefer());
-
- return guides.getAutoVerticals(page);
-}
-
-Guides GuideManager::getAutoHorizontals(const ScPage * page) const
-{
- GuideManagerCore guides;
-
- double gapValue = 0.0;
- if (horizontalAutoGapCheck->isChecked())
- gapValue = horizontalAutoGapSpin->getValue(SC_PT);
- guides.setHorizontalAutoGap(gapValue);
- guides.setHorizontalAutoCount(static_cast<int>(horizontalAutoCountSpin->value()));
- guides.setHorizontalAutoRefer(horizontalRefer());
-
- gapValue = 0.0;
- if (verticalAutoGapCheck->isChecked())
- gapValue = verticalAutoGapSpin->getValue(SC_PT);
- guides.setVerticalAutoGap(gapValue);
- guides.setVerticalAutoCount(static_cast<int>(verticalAutoCountSpin->value()));
- guides.setVerticalAutoRefer(verticalRefer());
-
- return guides.getAutoHorizontals(page);
-}
-
-void GuideManager::verticalModel_valueChanged()
-{
- currentPage->guides.clearVerticals(GuideManagerCore::Standard);
- currentPage->guides.addVerticals(verticalModel->values(), GuideManagerCore::Standard);
- drawGuides();
- m_doc->changed();
-}
-
-void GuideManager::horizontalModel_valueChanged()
-{
- currentPage->guides.clearHorizontals(GuideManagerCore::Standard);
- currentPage->guides.addHorizontals(horizontalModel->values(), GuideManagerCore::Standard);
- drawGuides();
- m_doc->changed();
-}
-
-void GuideManager::setHorizontalRefer(int button)
+void GuideManager::verticalModel_valueChanged(double oldPosition, double newPosition)
+{
+ guideValueChanged(false, oldPosition, newPosition);
+}
+
+void GuideManager::horizontalModel_valueChanged(double oldPosition, double newPosition)
+{
+ guideValueChanged(true, oldPosition, newPosition);
+}
+
+void GuideManager::setHorizontalReference(int button)
{
switch (button)
{
@@ -633,7 +728,7 @@
}
}
-int GuideManager::horizontalRefer() const
+int GuideManager::horizontalReference() const
{
if (horizontalPageAutoButton->isChecked())
return 0;
@@ -644,7 +739,7 @@
return 0;
}
-void GuideManager::setVerticalRefer(int button)
+void GuideManager::setVerticalReference(int button)
{
switch (button)
{
@@ -661,7 +756,7 @@
}
}
-int GuideManager::verticalRefer() const
+int GuideManager::verticalReference() const
{
if (verticalPageAutoButton->isChecked())
return 0;
@@ -678,6 +773,8 @@
return;
currentPage->guides.setHorizontalAutoRefer(0);
drawGuides();
+ if (currentPage->guides.horizontalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::horizontalMarginsAutoButton_toggled(bool state)
@@ -686,6 +783,8 @@
return;
currentPage->guides.setHorizontalAutoRefer(1);
drawGuides();
+ if (currentPage->guides.horizontalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::horizontalSelectionAutoButton_toggled(bool state)
@@ -696,6 +795,8 @@
if (horizontalSelectionAutoButton->isEnabled())
currentPage->guides.resetSelectionForPage(currentPage);
drawGuides();
+ if (currentPage->guides.horizontalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::verticalPageAutoButton_toggled(bool state)
@@ -704,7 +805,8 @@
return;
currentPage->guides.setVerticalAutoRefer(0);
drawGuides();
- m_doc->changed();
+ if (currentPage->guides.verticalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::verticalMarginsAutoButton_toggled(bool state)
@@ -713,7 +815,8 @@
return;
currentPage->guides.setVerticalAutoRefer(1);
drawGuides();
- m_doc->changed();
+ if (currentPage->guides.verticalAutoCount() > 0)
+ m_doc->changed();
}
void GuideManager::verticalSelectionAutoButton_toggled(bool state)
@@ -724,5 +827,6 @@
if (verticalSelectionAutoButton->isEnabled())
currentPage->guides.resetSelectionForPage(currentPage);
drawGuides();
- m_doc->changed();
-}
+ if (currentPage->guides.verticalAutoCount() > 0)
+ m_doc->changed();
+}
Index: scribus/ui/guidemanager.h
===================================================================
--- scribus/ui/guidemanager.h (revision 27915)
+++ scribus/ui/guidemanager.h (working copy)
@@ -17,13 +17,12 @@
class GuidesModel;
class ScribusDoc;
+class QToolButton;
-/*! \brief GuideManager is the dialog for guides managing ;).
-It's scribus non-modal palette now.
-\warning Be careful with UI file guidemanagerbase.ui it uses ScrPaletteBase
-as base class instead of QDialog. It should provide correct header file too.
+/*! \brief Non-modal palette for managing manual and automatic page guides.
+The guidemanager.ui form uses ScrPaletteBase as its base class.
\author Petr vanek <petr@scribus.info>
\author Alessandro Rimoldi
@@ -37,20 +36,19 @@
GuideManager(QWidget* parent);
~GuideManager();
- /*! \brief Set the doc fo the guidemanager to work on. */
+ /*! \brief Set the document managed by this palette. */
void setDoc(ScribusDoc* doc);
- /*! \brief Reimplement ScrPaletteBase::setVisible() */
+ /*! \brief Override ScrPaletteBase::setVisible(). */
void setVisible(bool visible) override;
- /*! \brief Set the widgets on the page change.
- It has to be called on every page to page transition */
+ /*! \brief Update the palette when the current page changes. */
void setupPage(bool storeValues = true);
void setupGui();
- /*! \brief Clear and reset the GUI horizontal list widget. */
+ /*! \brief Reload the horizontal manual-guide model. */
void clearRestoreHorizontalList();
- /*! \brief Clear and reset the GUI vertical list widget. */
+ /*! \brief Reload the vertical manual-guide model. */
void clearRestoreVerticalList();
/*! \brief Get selected standard guides from GUI list.
@@ -62,29 +60,27 @@
\retval Guides a list with double values */
Guides selectedVerticals() const;
- /*! \brief check the current page number to prevent drawing
- marks on the others pages. See GuideManagerCore::drawPage.
- \retval int page no */
+ /*! \brief Current page number, or -1 when no page is set. */
int pageNr() const { return ((currentPage) ? currentPage->pageNr() : -1); }
-
- int currentIndex() const { return tabWidget->currentIndex(); }
void setGuideLock(bool guidesLocked);
protected:
void changeEvent(QEvent *e) override;
+ bool eventFilter(QObject *watched, QEvent *event) override;
private:
- //! \brief Store the guide values in the Qt4 model
- GuidesModel * horizontalModel { nullptr };
- //! \brief Store the guide values in the Qt4 model
- GuidesModel * verticalModel { nullptr };
+ GuidesModel* horizontalModel { nullptr };
+ GuidesModel* verticalModel { nullptr };
ScribusDoc* m_doc { nullptr };
//! \brief a reference to the current pages
- ScPage * currentPage { nullptr };
+ ScPage* currentPage { nullptr };
//! \brief A flag to prevent guides drawing when it's not needed
bool m_drawGuides { true };
+ QWidget* m_horizontalEditor { nullptr };
+ QWidget* m_verticalEditor { nullptr };
+ unsigned int m_pageGeneration { 0 };
//! \brief Initialise the units. Spin boxes gets pt/mm/etc. extensions here.
void unitChange();
@@ -92,15 +88,11 @@
//! \brief Document measurements and metrics
int docUnitIndex { 0 };
- /*! \brief Copy guides from currentPage to all remaining.
- All gudes are deleted before copying.
- \param t a type to clear and copy.*/
+ /*! \brief Apply one guide category to the other pages without changing the other category. */
void copyGuidesToAllPages(GuideManagerCore::GuideType t);
- /*! \brief Save needed (Auto) values into GuideManagerCore.
- To be restored on the page return.
- \param page A reference to the page to store values. */
- void storePageValues(ScPage * page) const;
+ /*! \brief Store automatic-guide settings and positions for the given page. */
+ void storePageValues(ScPage* page) const;
/*! \brief Create automatic horizontal guides.
Calculates positions of the guides.
@@ -114,32 +106,37 @@
*/
Guides getAutoVerticals(const ScPage * p) const;
- /*! \brief Draw guides into painter */
+ /*! \brief Refresh the canvas guides. */
void drawGuides();
+ void guideValueChanged(bool horizontal, double oldPosition, double newPosition);
+ void addGuide(bool horizontal, double position);
+ void setAddButtonEditing(QToolButton* button, bool editing, bool horizontal);
+ void discardPendingGuide(bool horizontal);
+ void finishGuideEditors();
+ void updateClearButtons();
- /*! \brief These methods simulate old button group behaviour.
- Is there a better way to do it? QButtonGroup? It's more code...
- */
- void setHorizontalRefer(int button);
- int horizontalRefer() const;
- void setVerticalRefer(int button);
- int verticalRefer() const;
+ /*! \brief Map the mutually exclusive reference buttons to stored indices. */
+ void setHorizontalReference(int button);
+ int horizontalReference() const;
+ void setVerticalReference(int button);
+ int verticalReference() const;
void languageChange();
+ void iconSetChange();
private slots:
//! Wrapper slot for drawGuides()
void forceDrawGuides(const QItemSelection &, const QItemSelection &);
- void verticalModel_valueChanged();
- void horizontalModel_valueChanged();
- void addHorButton_clicked();
- void delHorButton_clicked();
- void addVerButton_clicked();
- void delVerButton_clicked();
- void applyToAllStdButton_clicked();
- void lockCheck_stateChanged( int );
- void horizontalAutoGapCheck_stateChanged( int );
- void verticalAutoGapCheck_stateChanged( int );
- void applyToAllAutoButton_clicked();
+ void verticalModel_valueChanged(double oldPosition, double newPosition);
+ void horizontalModel_valueChanged(double oldPosition, double newPosition);
+ void addHorizontalButton_clicked();
+ void deleteHorizontalButton_clicked();
+ void addVerticalButton_clicked();
+ void deleteVerticalButton_clicked();
+ void clearHorizontalButton_clicked();
+ void clearVerticalButton_clicked();
+ void applyToAllPagesButton_clicked();
+ void applyAutoToAllPagesButton_clicked();
+ void lockGuidesButton_clicked();
void horizontalAutoCountSpin_valueChanged( double );
void verticalAutoCountSpin_valueChanged( double );
void horizontalAutoGapSpin_valueChanged(double);
@@ -150,9 +147,6 @@
void verticalPageAutoButton_toggled(bool);
void verticalMarginsAutoButton_toggled(bool);
void verticalSelectionAutoButton_toggled(bool);
- void tabWidget_currentChanged(int);
- void deletePageButton_clicked();
- void deleteAllGuides_clicked();
};
#endif // GUIDEMANAGER_H
Index: scribus/ui/guidemanager.ui
===================================================================
--- scribus/ui/guidemanager.ui (revision 27915)
+++ scribus/ui/guidemanager.ui (working copy)
@@ -8,14 +8,17 @@
<rect>
<x>0</x>
<y>0</y>
- <width>534</width>
- <height>364</height>
+ <width>450</width>
+ <height>475</height>
</rect>
</property>
<property name="windowTitle">
<string>Guide Manager</string>
</property>
<layout class="QGridLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinimumSize</enum>
+ </property>
<property name="leftMargin">
<number>9</number>
</property>
@@ -28,229 +31,27 @@
<property name="bottomMargin">
<number>9</number>
</property>
- <item row="0" column="0">
- <widget class="QTabWidget" name="tabWidget">
- <property name="currentIndex">
- <number>0</number>
- </property>
- <widget class="QWidget" name="standardPage">
- <attribute name="title">
- <string>&Manual Guides</string>
- </attribute>
- <layout class="QGridLayout">
- <property name="leftMargin">
- <number>9</number>
+ <item row="1" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QGroupBox" name="verticalAutoGroup">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="topMargin">
- <number>9</number>
+ <property name="title">
+ <string>Rows && Columns</string>
</property>
- <property name="rightMargin">
- <number>9</number>
- </property>
- <property name="bottomMargin">
- <number>9</number>
- </property>
- <item row="0" column="0" colspan="2">
- <layout class="QHBoxLayout">
- <item>
- <widget class="QGroupBox" name="horizontalGroupBox">
- <property name="title">
- <string>&Horizontal Guides</string>
- </property>
- <layout class="QGridLayout">
- <property name="horizontalSpacing">
- <number>5</number>
- </property>
- <item row="0" column="0">
- <widget class="GuidesView" name="horizontalView">
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
- </property>
- <attribute name="horizontalHeaderStretchLastSection">
- <bool>true</bool>
- </attribute>
- </widget>
- </item>
- <item row="0" column="1">
- <layout class="QVBoxLayout" name="horizontalGuideActionsLayout">
- <item>
- <widget class="QToolButton" name="addHorButton">
- <property name="toolTip">
- <string>Add a new horizontal guide</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="delHorButton">
- <property name="toolTip">
- <string>Delete the selected horizontal guide</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Orientation::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="verticalGroupBox">
- <property name="title">
- <string>&Vertical Guides</string>
- </property>
- <layout class="QGridLayout">
- <property name="horizontalSpacing">
- <number>5</number>
- </property>
- <item row="0" column="0">
- <widget class="GuidesView" name="verticalView">
- <property name="alternatingRowColors">
- <bool>true</bool>
- </property>
- <property name="selectionBehavior">
- <enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
- </property>
- <attribute name="horizontalHeaderStretchLastSection">
- <bool>true</bool>
- </attribute>
- </widget>
- </item>
- <item row="0" column="1">
- <layout class="QVBoxLayout" name="verticalGuideActionsLayout">
- <item>
- <widget class="QToolButton" name="addVerButton">
- <property name="toolTip">
- <string>Add a new vertical guide</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="delVerButton">
- <property name="toolTip">
- <string>Delete the selected vertical guide</string>
- </property>
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Orientation::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0" colspan="2">
- <layout class="QHBoxLayout" name="applyStdLayout">
- <item>
- <widget class="QCheckBox" name="lockCheck">
- <property name="toolTip">
- <string>Lock the guides</string>
- </property>
- <property name="text">
- <string>Lock Guides</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacerCopyLeft">
- <property name="orientation">
- <enum>Qt::Orientation::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Policy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>10</width>
- <height>10</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="applyToAllStdButton">
- <property name="toolTip">
- <string>Replace the manual guides on all other pages with the manual guides from the current page</string>
- </property>
- <property name="text">
- <string>Copy Guides to All Pages</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="autoPage">
- <attribute name="title">
- <string>&Rows && Columns</string>
- </attribute>
- <layout class="QGridLayout">
- <property name="leftMargin">
- <number>9</number>
- </property>
- <property name="topMargin">
- <number>9</number>
- </property>
- <property name="rightMargin">
- <number>9</number>
- </property>
- <property name="bottomMargin">
- <number>9</number>
- </property>
- <item row="0" column="0">
- <widget class="QGroupBox" name="horizontalAutoGroup">
- <property name="title">
- <string>&Horizontal Guides</string>
- </property>
- <layout class="QGridLayout">
- <property name="horizontalSpacing">
- <number>20</number>
- </property>
- <property name="verticalSpacing">
- <number>8</number>
- </property>
- <item row="0" column="0">
- <widget class="FormWidget" name="horizontalRelativeForm" native="true">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="spacing">
+ <number>16</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="FormWidget" name="horizontalRelativeForm">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
@@ -288,7 +89,7 @@
<bool>true</bool>
</property>
<property name="checked">
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
@@ -306,6 +107,9 @@
<property name="checkable">
<bool>true</bool>
</property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
<property name="autoExclusive">
<bool>true</bool>
</property>
@@ -330,101 +134,8 @@
</layout>
</widget>
</item>
- <item row="0" column="1">
- <widget class="FormWidget" name="horizontalNumberForm" native="true">
- <property name="label" stdset="0">
- <string>Number</string>
- </property>
- <layout class="QHBoxLayout" name="horizontalNumberLayout">
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <widget class="ScrSpinBox" name="horizontalAutoCountSpin">
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Number of horizontal guides to create</string>
- </property>
- <property name="suffix">
- <string/>
- </property>
- <property name="minimum">
- <double>0.000000000000000</double>
- </property>
- <property name="value">
- <double>0.000000000000000</double>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="horizontalAutoGapCheck">
- <property name="toolTip">
- <string>Set the gap between adjacent generated rows</string>
- </property>
- <property name="text">
- <string>Gap:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="ScrSpinBox" name="horizontalAutoGapSpin">
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Set the gap between adjacent generated rows</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QGroupBox" name="verticalAutoGroup">
- <property name="title">
- <string>&Vertical Guides</string>
- </property>
- <layout class="QGridLayout">
- <property name="horizontalSpacing">
- <number>20</number>
- </property>
- <property name="verticalSpacing">
- <number>8</number>
- </property>
- <item row="0" column="0">
- <widget class="FormWidget" name="verticalRelativeForm" native="true">
+ <item>
+ <widget class="FormWidget" name="horizontalNumberForm">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
@@ -432,6 +143,127 @@
</sizepolicy>
</property>
<property name="label" stdset="0">
+ <string>&Rows</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalNumberLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="ScrSpinBox" name="horizontalAutoCountSpin">
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Number of horizontal guides to create</string>
+ </property>
+ <property name="suffix">
+ <string/>
+ </property>
+ <property name="minimum">
+ <double>0.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>0.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="FormWidget" name="horizontalGapForm">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="label" stdset="0">
+ <string>Gap</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalGapLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="ScrSpinBox" name="horizontalAutoGapSpin">
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Set the gap between adjacent generated rows</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalAutoControlsSpacer">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Policy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>10</width>
+ <height>10</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="FormWidget" name="verticalRelativeForm">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="label" stdset="0">
<string>Relative to</string>
</property>
<layout class="QHBoxLayout" name="verticalRelativeButtonsLayout">
@@ -462,7 +294,7 @@
<bool>true</bool>
</property>
<property name="checked">
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property name="autoExclusive">
<bool>true</bool>
@@ -480,6 +312,9 @@
<property name="checkable">
<bool>true</bool>
</property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
<property name="autoExclusive">
<bool>true</bool>
</property>
@@ -504,10 +339,16 @@
</layout>
</widget>
</item>
- <item row="0" column="1">
- <widget class="FormWidget" name="verticalNumberForm" native="true">
+ <item>
+ <widget class="FormWidget" name="verticalNumberForm">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="label" stdset="0">
- <string>Number</string>
+ <string>&Columns</string>
</property>
<layout class="QHBoxLayout" name="verticalNumberLayout">
<property name="leftMargin">
@@ -553,124 +394,334 @@
</layout>
</widget>
</item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="verticalAutoGapCheck">
- <property name="toolTip">
- <string>Set the gap between adjacent generated columns</string>
- </property>
+ <item>
+ <widget class="FormWidget" name="verticalGapForm">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="label" stdset="0">
+ <string>Gap</string>
+ </property>
+ <layout class="QHBoxLayout" name="verticalGapLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="ScrSpinBox" name="verticalAutoGapSpin">
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Set the gap between adjacent generated columns</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_6">
+ <item>
+ <widget class="QToolButton" name="applyAutoToAllPagesButton">
<property name="text">
- <string>Gap:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="ScrSpinBox" name="verticalAutoGapSpin">
- <property name="minimumSize">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="applyAutoToAllPagesLabel">
+ <property name="text">
+ <string>Apply to all pages</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_4">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
<size>
- <width>100</width>
- <height>0</height>
+ <width>40</width>
+ <height>20</height>
</size>
</property>
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Set the gap between adjacent generated columns</string>
- </property>
- </widget>
+ </spacer>
</item>
</layout>
- </widget>
- </item>
- <item row="1" column="0" colspan="2">
- <layout class="QHBoxLayout" name="applyAutoLayout">
- <item>
- <spacer name="horizontalSpacerApplyLeft">
- <property name="orientation">
- <enum>Qt::Orientation::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Policy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>10</width>
- <height>10</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="applyToAllAutoButton">
- <property name="toolTip">
- <string>Apply the current row and column guide settings to all pages in the document</string>
- </property>
- <property name="text">
- <string>Apply Settings to All Pages</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="2" column="0" colspan="2">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Orientation::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>10</width>
- <height>10</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- </widget>
- </item>
- <item row="1" column="0">
- <layout class="QHBoxLayout" name="globalGuideControlsLayout">
- <item>
- <spacer name="horizontalSpacerGlobal">
- <property name="orientation">
- <enum>Qt::Orientation::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Policy::Expanding</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>10</width>
- <height>10</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="deletePageButton">
- <property name="toolTip">
- <string>Delete all guides from the current page</string>
- </property>
- <property name="text">
- <string>Clear Page Guides</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="deleteAllGuides">
- <property name="toolTip">
- <string>Delete all guides from the current document</string>
- </property>
- <property name="text">
- <string>Clear All Guides</string>
- </property>
+ </item>
+ </layout>
</widget>
</item>
</layout>
+ </item>
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QGroupBox" name="horizontalGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>&Horizontal guides</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="horizontalSpacing">
+ <number>5</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="GuidesView" name="horizontalView">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
+ </property>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <layout class="QVBoxLayout" name="horizontalGuideActionsLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QToolButton" name="addHorizontalButton">
+ <property name="toolTip">
+ <string>Add a new horizontal guide</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="deleteHorizontalButton">
+ <property name="toolTip">
+ <string>Delete the selected horizontal guide</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Orientation::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="clearHorizontalButton">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="verticalGroupBox">
+ <property name="title">
+ <string>&Vertical guides</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="horizontalSpacing">
+ <number>5</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="GuidesView" name="verticalView">
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
+ </property>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <layout class="QVBoxLayout" name="verticalGuideActionsLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QToolButton" name="addVerticalButton">
+ <property name="toolTip">
+ <string>Add a new vertical guide</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="deleteVerticalButton">
+ <property name="toolTip">
+ <string>Delete the selected vertical guide</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Orientation::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="clearVerticalButton">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QGridLayout" name="gridLayout3">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QToolButton" name="applyToAllPagesButton">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="applyAllPagesLabel">
+ <property name="text">
+ <string>Apply to all pages</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QToolButton" name="lockGuidesButton">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="lockGuidesLabel">
+ <property name="text">
+ <string>Lock guides</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
</item>
</layout>
</widget>
|
|
|
From the UI perspective, the patch can be applied as is. There is some further work that can (in my eyes) be done, but it can be done in a further step: - The new default for rows and columns to use the margins instead of the page as a reference got lost. We can fix it later. - The visual selection in the lists is a bit funky, but the results are more than OK (and for sure way better as the current state) - The tabbing order is not always correct. It can also be fixed later by editing the .ui file. |
|
|
Committed, with tab order fixed, with defaults to margins referenced. I maintained the page/all clear buttons as I believe they are required. |
|
|
Thanks for committing. A "huge" progress for people like me who only open the Guide Manager to set the rows and columns! From my understanding, "Clear Page Guides" is not really needed. You can do the same with a few clicks: - clear horizontal and vertical = 2 clicks, and - put the rows and columns to 0 = 2 small edits Yes, it's more clicks, but clearing all clicks is not something you will do often. For applying to all pages, you need to additional clicks on the two "Apply to all pages" buttons. Not sure that those are tasks performed often enough to require dedicated buttons (and a dedicated section). This having been said, the dialog is now much cleaner and readable, and the additional section at the bottom does not disturb me much. (Before, the two buttons were there where Cancel and OK normally are, which can perturb some UI reflexes.) Still, I would remove them and let the users apply "nothing" to the target rather than having two dedicated buttons for actions that are almost never performed. (And have a good enough workaround) |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-10-20 11:04 | buttar | New Issue | |
| 2026-10-20 11:04 | buttar | File Added: gmu1-guide-manager-layout-v1.00.patch | |
| 2026-10-20 11:04 | buttar | File Added: gmu2-manual-guide-editing-ux-v1.00.patch | |
| 2026-10-20 11:04 | buttar | File Added: 1st tab-PROPOSED.png | |
| 2026-10-20 11:04 | buttar | File Added: 2nd tab-PROPOSED.png | |
| 2026-10-20 12:37 | utnik | Note Added: 0054575 | |
| 2026-10-20 17:15 | ale | Note Added: 0054578 | |
| 2026-10-20 17:39 | buttar | Note Added: 0054579 | |
| 2026-10-20 18:28 | ale | Note Added: 0054580 | |
| 2026-10-22 15:02 | ale | Note Added: 0054593 | |
| 2026-10-22 15:02 | ale | File Added: guidemanager.ui | |
| 2026-10-22 15:02 | ale | File Added: guides-manager-one-tab.png | |
| 2026-10-23 11:39 | buttar | Note Added: 0054606 | |
| 2026-10-24 06:07 | ale | Relationship added | related to 0018026 |
| 2026-10-24 06:08 | ale | Relationship added | related to 0018035 |
| 2026-10-25 18:47 | ale | Note Added: 0054611 | |
| 2026-10-25 18:47 | ale | File Added: guides-manager.diff | |
| 2026-10-25 18:47 | ale | File Added: guides-manager-one-tab-2.png | |
| 2026-10-26 12:55 | buttar | Note Added: 0054616 | |
| 2026-10-26 12:55 | buttar | File Added: gmr1-unified-guide-manager-v1.04.patch | |
| 2026-11-09 17:03 | ale | Note Added: 0054691 | |
| 2026-11-09 17:03 | ale | Tag Attached: #patch_is_ready | |
| 2026-11-12 16:12 | ale | Relationship added | related to 0008999 |
| 2026-11-14 22:25 | cbradney | Assigned To | => cbradney |
| 2026-11-14 22:25 | cbradney | Status | new => resolved |
| 2026-11-14 22:25 | cbradney | Resolution | open => fixed |
| 2026-11-14 22:25 | cbradney | Fixed in Version | => 1.7.5.svn |
| 2026-11-14 22:25 | cbradney | Note Added: 0054722 | |
| 2026-11-15 08:18 | ale | Note Added: 0054724 |