View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0017497 | Scribus | User Interface | public | 2025-04-12 09:13 | 2025-04-27 19:14 |
| Reporter | ale | Assigned To | ale | ||
| Priority | normal | Severity | feature | Reproducibility | N/A |
| Status | closed | Resolution | fixed | ||
| Product Version | 1.7.1.svn | ||||
| Fixed in Version | 1.7.1.svn | ||||
| Summary | 0017497: Hyphenation exceptions and ignore lists: allow to add and remove multiple entries at once | ||||
| Description | As a user, I want to be able to add and remove multiple entries in one go... | ||||
| Tags | No tags attached. | ||||
| Patch | Yes | ||||
|
|
- allow multiple selection in both lists (for deleting) - allow adding multiple items at once (and copy paste them from a text file) - editing in place by double clicking on the item in the list hyphenation-exceptions-and-ignores.diff (7,637 bytes)
From 1489fd222b8d0aae6a848b05174b3a5f8495af51 Mon Sep 17 00:00:00 2001
From: ale rimoldi <ale@graphicslab.org>
Date: Sat, 12 Apr 2025 11:15:44 +0200
Subject: hyphenation exceptions and ignores: add and remove multiple items at
once; edit items "in place"
diff --git a/scribus/ui/prefs_hyphenator.cpp b/scribus/ui/prefs_hyphenator.cpp
index aefc623c8..9b34ffdb6 100644
--- a/scribus/ui/prefs_hyphenator.cpp
+++ b/scribus/ui/prefs_hyphenator.cpp
@@ -10,6 +10,7 @@ for which a new license (GPL+exception) is in place.
#include <QListWidget>
#include <QTableWidgetItem>
#include <QTextStream>
+#include <QtAlgorithms>
#include "iconmanager.h"
#include "prefs_hyphenator.h"
@@ -26,21 +27,21 @@ Prefs_Hyphenator::Prefs_Hyphenator(QWidget* parent, ScribusDoc* /*doc*/)
m_icon = "pref-hyphenator";
exceptionAddButton->setIcon(IconManager::instance().loadIcon("list-add"));
- exceptionEditButton->setEnabled(false);
exceptionRemoveButton->setIcon(IconManager::instance().loadIcon("list-remove"));
exceptionRemoveButton->setEnabled(false);
ignoreAddButton->setIcon(IconManager::instance().loadIcon("list-add"));
- ignoreEditButton->setEnabled(false);
ignoreRemoveButton->setIcon(IconManager::instance().loadIcon("list-remove"));
ignoreRemoveButton->setEnabled(false);
connect(ignoreAddButton, SIGNAL(clicked()), this, SLOT(addToIgnoreList()));
- connect(ignoreEditButton, SIGNAL(clicked()), this, SLOT(editIgnoreListEntry()));
- connect(ignoreRemoveButton, SIGNAL(clicked()), this, SLOT(removeIgnoreListEntry()));
+ connect(ignoreListWidget, &QListWidget::itemDoubleClicked, this, &Prefs_Hyphenator::editIgnoreListItem);
+ connect(ignoreListWidget, &QListWidget::itemChanged, this, &Prefs_Hyphenator::ignoreListItemChanged);
+ connect(ignoreRemoveButton, SIGNAL(clicked()), this, SLOT(removeFromIgnoreList()));
connect(ignoreListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(enableIgnoreButtons()));
- connect(exceptionAddButton, SIGNAL(clicked()), this, SLOT(addToExceptList()));
- connect(exceptionEditButton, SIGNAL(clicked()), this, SLOT(editExceptListEntry()));
- connect(exceptionRemoveButton, SIGNAL(clicked()), this, SLOT(removeExceptListEntry()));
- connect(exceptionListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(enableExceptButtons()));
+ connect(exceptionAddButton, SIGNAL(clicked()), this, SLOT(addToExceptionList()));
+ connect(exceptionListWidget, &QListWidget::itemDoubleClicked, this, &Prefs_Hyphenator::editExceptionListItem);
+ connect(exceptionListWidget, &QListWidget::itemChanged, this, &Prefs_Hyphenator::exceptionListItemChanged);
+ connect(exceptionRemoveButton, SIGNAL(clicked()), this, SLOT(removeFromExceptionList()));
+ connect(exceptionListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(enableExceptionButtons()));
}
void Prefs_Hyphenator::languageChange()
@@ -79,13 +80,19 @@ void Prefs_Hyphenator::saveGuiToPrefs(struct ApplicationPrefs *prefsData) const
void Prefs_Hyphenator::addToIgnoreList()
{
bool ok;
- QString text = QInputDialog::getText(this, tr("Ignore List"), tr("Add a new Entry"), QLineEdit::Normal, "", &ok);
- if (ok && !text.isEmpty())
+ QString text = QInputDialog::getMultiLineText(this, tr("Ignore List"), tr("Add new Entries"), "", &ok);
+ text = text.trimmed();
+ if (!ok || text.isEmpty())
{
- if (ignoreListWidget->findItems(text, Qt::MatchExactly).count() == 0)
- ignoreListWidget->addItem(text);
- ignoreListWidget->sortItems();
+ return;
+ }
+ for (QString& word: text.split("\n"))
+ {
+ word = word.trimmed();
+ if (ignoreListWidget->findItems(word, Qt::MatchExactly).count() == 0)
+ ignoreListWidget->addItem(word);
}
+ ignoreListWidget->sortItems();
}
void Prefs_Hyphenator::editIgnoreListEntry()
@@ -100,36 +107,47 @@ void Prefs_Hyphenator::editIgnoreListEntry()
}
}
-void Prefs_Hyphenator::removeIgnoreListEntry()
+void Prefs_Hyphenator::editIgnoreListItem(QListWidgetItem* item)
{
- QListWidgetItem *item = ignoreListWidget->takeItem(ignoreListWidget->row(ignoreListWidget->currentItem()));
- delete item;
- if (ignoreListWidget->count() == 0)
- {
- ignoreEditButton->setEnabled(false);
- ignoreRemoveButton->setEnabled(false);
- }
+ item->setFlags(item->flags() | Qt::ItemIsEditable);
+ ignoreListWidget->editItem(item);
+}
+
+
+void Prefs_Hyphenator::ignoreListItemChanged(QListWidgetItem*)
+{
+ ignoreListWidget->sortItems();
+}
+
+void Prefs_Hyphenator::removeFromIgnoreList()
+{
+ qDeleteAll(ignoreListWidget->selectedItems());
}
void Prefs_Hyphenator::enableIgnoreButtons()
{
- ignoreEditButton->setEnabled(true);
ignoreRemoveButton->setEnabled(true);
}
-void Prefs_Hyphenator::addToExceptList()
+void Prefs_Hyphenator::addToExceptionList()
{
bool ok;
- QString text = QInputDialog::getText(this, tr("Exception List"), tr("Add a new Entry"), QLineEdit::Normal, "", &ok);
- if (ok && !text.isEmpty())
+ QString text = QInputDialog::getMultiLineText(this, tr("Exception List"), tr("Add new Entries"), "", &ok);
+ text = text.trimmed();
+ if (!ok || text.isEmpty())
{
- if (exceptionListWidget->findItems(text, Qt::MatchExactly).count() == 0)
- exceptionListWidget->addItem(text);
- exceptionListWidget->sortItems();
+ return;
+ }
+ for (QString& word: text.split("\n"))
+ {
+ word = word.trimmed();
+ if (exceptionListWidget->findItems(word, Qt::MatchExactly).count() == 0)
+ exceptionListWidget->addItem(word);
}
+ exceptionListWidget->sortItems();
}
-void Prefs_Hyphenator::editExceptListEntry()
+void Prefs_Hyphenator::editExceptionListEntry()
{
bool ok;
QString text = QInputDialog::getText(this, tr("Exception List"), tr("Edit Entry"), QLineEdit::Normal, exceptionListWidget->currentItem()->text(), &ok);
@@ -141,19 +159,24 @@ void Prefs_Hyphenator::editExceptListEntry()
}
}
-void Prefs_Hyphenator::removeExceptListEntry()
+void Prefs_Hyphenator::editExceptionListItem(QListWidgetItem* item)
{
- QListWidgetItem *item = exceptionListWidget->takeItem(exceptionListWidget->row(exceptionListWidget->currentItem()));
- delete item;
- if (exceptionListWidget->count() == 0)
- {
- exceptionEditButton->setEnabled(false);
- exceptionRemoveButton->setEnabled(false);
- }
+ item->setFlags(item->flags() | Qt::ItemIsEditable);
+ exceptionListWidget->editItem(item);
+}
+
+
+void Prefs_Hyphenator::exceptionListItemChanged(QListWidgetItem*)
+{
+ exceptionListWidget->sortItems();
+}
+
+void Prefs_Hyphenator::removeFromExceptionList()
+{
+ qDeleteAll(exceptionListWidget->selectedItems());
}
-void Prefs_Hyphenator::enableExceptButtons()
+void Prefs_Hyphenator::enableExceptionButtons()
{
- exceptionEditButton->setEnabled(true);
exceptionRemoveButton->setEnabled(true);
}
diff --git a/scribus/ui/prefs_hyphenator.h b/scribus/ui/prefs_hyphenator.h
index 95f70838c..40626c816 100644
--- a/scribus/ui/prefs_hyphenator.h
+++ b/scribus/ui/prefs_hyphenator.h
@@ -32,12 +32,16 @@ class SCRIBUS_API Prefs_Hyphenator : public Prefs_Pane, Ui::Prefs_Hyphenator
protected slots:
void addToIgnoreList();
void editIgnoreListEntry();
- void removeIgnoreListEntry();
+ void editIgnoreListItem(QListWidgetItem* item);
+ void ignoreListItemChanged(QListWidgetItem* item);
+ void removeFromIgnoreList();
void enableIgnoreButtons();
- void addToExceptList();
- void editExceptListEntry();
- void removeExceptListEntry();
- void enableExceptButtons();
+ void addToExceptionList();
+ void editExceptionListEntry();
+ void editExceptionListItem(QListWidgetItem* item);
+ void exceptionListItemChanged(QListWidgetItem* item);
+ void removeFromExceptionList();
+ void enableExceptionButtons();
protected:
QString affixFileName(QStringList files);
|
|
|
oops, the changes to the .ui file are misssing hyphenation-ui-file.diff (8,155 bytes)
From 69f41a45c4cc6c878dc3b3f8292d0bd93a5f8159 Mon Sep 17 00:00:00 2001
From: ale rimoldi <ale@graphicslab.org>
Date: Sun, 13 Apr 2025 21:28:13 +0200
Subject: add the changes to the ui file
diff --git a/scribus/ui/prefs_hyphenatorbase.ui b/scribus/ui/prefs_hyphenatorbase.ui
index dba5fd3de..be70cef13 100644
--- a/scribus/ui/prefs_hyphenatorbase.ui
+++ b/scribus/ui/prefs_hyphenatorbase.ui
@@ -5,33 +5,32 @@
<property name="geometry">
<rect>
<x>0</x>
- <y>0</y>
- <width>711</width>
- <height>550</height>
- </rect>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <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="QLabel" name="label">
- <property name="font">
- <font>
- <pointsize>14</pointsize>
- <weight>75</weight>
- <bold>true</bold>
- </font>
- </property>
+ <y>0</y>
+ <width>711</width>
+ <height>550</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <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="QLabel" name="label">
+ <property name="font">
+ <font>
+ <pointsize>14</pointsize>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="text">
<string>Hyphenation</string>
</property>
@@ -40,7 +39,7 @@
<item>
<widget class="Line" name="line">
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
</item>
@@ -77,10 +76,10 @@
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
- <enum>Qt::Vertical</enum>
+ <enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeType">
- <enum>QSizePolicy::Expanding</enum>
+ <enum>QSizePolicy::Policy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -99,68 +98,68 @@
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QGroupBox" name="groupBox_2">
- <property name="title">
- <string>Exceptions</string>
- </property>
- <layout class="QGridLayout" name="_2">
- <item row="0" column="0" colspan="4">
- <widget class="QListWidget" name="exceptionListWidget"/>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="exceptionAddButton">
- <property name="text">
- <string/>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Exceptions</string>
+ </property>
+ <layout class="QGridLayout" name="_2">
+ <item row="1" column="2">
+ <spacer>
+ <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>
+ <item row="0" column="0" colspan="3">
+ <widget class="QListWidget" name="exceptionListWidget">
+ <property name="selectionMode">
+ <enum>QAbstractItemView::SelectionMode::ExtendedSelection</enum>
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QPushButton" name="exceptionEditButton">
+ <item row="1" column="0">
+ <widget class="QPushButton" name="exceptionAddButton">
<property name="text">
- <string>Edit</string>
+ <string/>
</property>
</widget>
</item>
- <item row="1" column="2">
+ <item row="1" column="1">
<widget class="QPushButton" name="exceptionRemoveButton">
<property name="text">
<string/>
</property>
</widget>
</item>
- <item row="1" column="3">
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Ignore List</string>
+ </property>
+ <layout class="QGridLayout" name="_3">
+ <item row="1" column="2">
<spacer>
<property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>40</width>
+ <width>21</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox_3">
- <property name="title">
- <string>Ignore List</string>
- </property>
- <layout class="QGridLayout" name="_3">
- <item row="0" column="0" colspan="4">
- <widget class="QListWidget" name="ignoreListWidget">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- </widget>
- </item>
<item row="1" column="0">
<widget class="QPushButton" name="ignoreAddButton">
<property name="text">
@@ -169,31 +168,24 @@
</widget>
</item>
<item row="1" column="1">
- <widget class="QPushButton" name="ignoreEditButton">
- <property name="text">
- <string>Edit</string>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
<widget class="QPushButton" name="ignoreRemoveButton">
<property name="text">
<string/>
</property>
</widget>
</item>
- <item row="1" column="3">
- <spacer>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
+ <item row="0" column="0" colspan="3">
+ <widget class="QListWidget" name="ignoreListWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>21</width>
- <height>20</height>
- </size>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::SelectionMode::ExtendedSelection</enum>
</property>
- </spacer>
+ </widget>
</item>
</layout>
</widget>
|
|
|
thanks! |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2025-04-12 09:13 | ale | New Issue | |
| 2025-04-12 09:16 | ale | Note Added: 0052426 | |
| 2025-04-12 09:16 | ale | File Added: hyphenation.gif | |
| 2025-04-12 09:16 | ale | File Added: hyphenation-exceptions-and-ignores.diff | |
| 2025-04-13 19:29 | ale | Note Added: 0052433 | |
| 2025-04-13 19:29 | ale | File Added: hyphenation-ui-file.diff | |
| 2025-04-15 19:45 | cbradney | Assigned To | => ale |
| 2025-04-15 19:45 | cbradney | Status | new => resolved |
| 2025-04-15 19:45 | cbradney | Resolution | open => fixed |
| 2025-04-15 19:45 | cbradney | Fixed in Version | => 1.7.1.svn |
| 2025-04-16 21:28 | jghali | Summary | [PATCH] Hyphenation exceptions and ignore lists: allow to add and remove multiple entries at once => Hyphenation exceptions and ignore lists: allow to add and remove multiple entries at once |
| 2025-04-17 06:45 | ale | Note Added: 0052456 | |
| 2025-04-27 19:14 | cbradney | Status | resolved => closed |