View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0018020 | Scribus | Fonts | public | 2026-10-18 13:54 | 2026-10-29 17:09 |
| Reporter | utnik | Assigned To | ale | ||
| Priority | low | Severity | feature | Reproducibility | have not tried |
| Status | assigned | Resolution | open | ||
| Platform | all | OS | all | ||
| Target Version | 1.7.5.svn | ||||
| Summary | 0018020: [PATCH] move 'fonts preview' from the 'story editor' to the 'style manager' | ||||
| Description | the 'fonts preview' (accessible in the 'edit' menu of the 'story editor') might be useful when creating a character style. as the 'story editor' is a bit outdated and not much in use these days, it would make sense to move the 'fonts preview' to the 'style manager'. | ||||
| Tags | No tags attached. | ||||
| Patch | Yes | ||||
|
|
What about: - The Font Preview is already in the main Extras menu. - We should make the dialog non modal (that means that one can work on other things while the dialog is open). - Possibly make it dockable (we might need to change a few things to make it readable while it's docked and slim...) Then you can open both the Styles Manager and the Font Preview and interact with both in parallel. |
|
|
sounds good. |
|
|
Can 0017922 be useful, @ale, @utnik ? |
|
|
i tend to use a separate app for font previews. some fonts would not be readable any more when scribus tries to write their names as in 0017922. (not every special font contains glyphs for the normal latin letters…) …and it's a cleaner ui without this change. (but i can see that many users might like it…) |
|
|
Yes, it was a light attempt like the word processors have. I think it might not be very useful in Scribus. Shared just in case you might find it is. |
|
|
The patch attached makes the Font Preview dialog non modal and updates the current document when it changes. font-preview.diff (6,734 bytes)
diff --git a/scribus/fontlistmodel.cpp b/scribus/fontlistmodel.cpp
index 75f6e6413..eb435377a 100644
--- a/scribus/fontlistmodel.cpp
+++ b/scribus/fontlistmodel.cpp
@@ -35,6 +35,12 @@ void FontListModel::iconSetChange()
substFont = iconManager.loadPixmap("font-substitute");
}
+void FontListModel::setDocument(ScribusDoc* doc)
+{
+ m_doc = doc;
+ setFonts(m_fonts.keys());
+}
+
void FontListModel::setFonts(QList<QString> f)
{
beginResetModel();
diff --git a/scribus/fontlistmodel.h b/scribus/fontlistmodel.h
index 4560d1f15..67b170082 100644
--- a/scribus/fontlistmodel.h
+++ b/scribus/fontlistmodel.h
@@ -68,6 +68,8 @@ class SCRIBUS_API FontListModel : public QAbstractTableModel
are able to be edited by user. */
Qt::ItemFlags flags(const QModelIndex &index) const;
+ void setDocument(ScribusDoc* doc);
+
//! Returns the font list
QList<QString> fonts() { return m_font_names; }
//! Sets font list and refresh the model. This will detach the model from the main Scribus font list!
diff --git a/scribus/plugins/fontpreview/fontpreview.cpp b/scribus/plugins/fontpreview/fontpreview.cpp
index d2b839652..da83ab8e6 100644
--- a/scribus/plugins/fontpreview/fontpreview.cpp
+++ b/scribus/plugins/fontpreview/fontpreview.cpp
@@ -19,12 +19,12 @@ for which a new license (GPL+exception) is in place.
#include "iconmanager.h"
-FontPreview::FontPreview(const QString& fontName, QWidget* parent, ScribusDoc* doc)
- : QDialog(parent, Qt::WindowFlags()),
+FontPreview::FontPreview(const QString& fontName, ScribusDoc* doc)
+ : QDialog(nullptr, Qt::WindowFlags()),
m_Doc(doc)
{
setupUi(this);
- setModal(true);
+ setModal(false);
setWindowIcon(IconManager::instance().loadIcon("app-icon"));
m_sampleItem = new SampleItem();
@@ -129,6 +129,17 @@ void FontPreview::resizeEvent(QResizeEvent * event)
QDialog::resizeEvent(event);
}
+void FontPreview::changedDocument(ScribusDoc* doc)
+{
+ m_Doc = doc;
+ m_fontModel->setDocument(m_Doc);
+}
+
+void FontPreview::closedDocument()
+{
+ m_fontModel->setDocument(nullptr);
+}
+
bool FontPreview::allowSample()
{
if (m_fontModel->rowCount() != 0)
diff --git a/scribus/plugins/fontpreview/fontpreview.h b/scribus/plugins/fontpreview/fontpreview.h
index bd194bbf3..d9284dcb6 100644
--- a/scribus/plugins/fontpreview/fontpreview.h
+++ b/scribus/plugins/fontpreview/fontpreview.h
@@ -30,9 +30,12 @@ public:
/*! \brief Create Font Preview window,
\param fontName Optional name of the font to init/select on start.
*/
- FontPreview(const QString& fontName = QString(), QWidget* parent = nullptr, ScribusDoc* doc = nullptr);
+ FontPreview(const QString& fontName = QString(), ScribusDoc* doc = nullptr);
~FontPreview();
+ void changedDocument(ScribusDoc* doc);
+ void closedDocument();
+
/*! \brief Get the current selected font name.
\retval QString the font name. */
QString getCurrentFont();
diff --git a/scribus/plugins/fontpreview/fontpreviewplugin.cpp b/scribus/plugins/fontpreview/fontpreviewplugin.cpp
index ecc57dde1..cb3436299 100644
--- a/scribus/plugins/fontpreview/fontpreviewplugin.cpp
+++ b/scribus/plugins/fontpreview/fontpreviewplugin.cpp
@@ -64,11 +64,8 @@ const ScActionPlugin::AboutData* FontPreviewPlugin::getAboutData() const
AboutData* about = new AboutData;
Q_CHECK_PTR(about);
about->authors = QString::fromUtf8("Petr Van\xc4\x9bk <petr@scribus.info>");
- about->shortDescription = tr("Font Preview dialog");
- about->description = tr("Sorting, searching and browsing available fonts.");
- // about->version
- // about->releaseDate
- // about->copyright
+ about->shortDescription = tr("Fonts Preview dialog");
+ about->description = tr("Browse available fonts.");
about->license = "GPL";
return about;
}
@@ -79,31 +76,50 @@ void FontPreviewPlugin::deleteAboutData(const AboutData* about) const
delete about;
}
-/**
-Create dialog and insert font into Style menu when user accepts.
-*/
bool FontPreviewPlugin::run(ScribusDoc* doc, const QString& target)
-{
- ScribusMainWindow* scmw = (doc == nullptr) ? ScCore->primaryMainWindow() : doc->scMW();
- return run(scmw, doc, target);
-}
-
-bool FontPreviewPlugin::run(QWidget* parent, ScribusDoc* doc, const QString& target)
{
if (doc == nullptr)
+ {
return false;
+ }
+
// I don't know how many fonts user has...
qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
- FontPreview *dlg = new FontPreview(target, parent, doc);
- qApp->changeOverrideCursor(Qt::ArrowCursor);
- // run it and wait for user's reaction
- if (dlg->exec() == QDialog::Accepted)
+ if (dialog == nullptr)
{
- if (target.isEmpty())
- doc->itemSelection_SetFont(dlg->getCurrentFont());
- else
- m_runResult = dlg->getCurrentFont();
+ dialog = new FontPreview(target, doc);
+ if (dialog == nullptr)
+ {
+ return false;
+ }
+ connect(dialog, &FontPreview::destroyed, this, &FontPreviewPlugin::dialogClosed);
}
- delete dlg;
+ Q_CHECK_PTR(dialog);
+
+ dialog->setAttribute ( Qt::WA_DeleteOnClose );
+ //show, get on top and activate window
+ dialog->show();
+ dialog->raise();
+ dialog->activateWindow();
+
+ qApp->changeOverrideCursor(Qt::ArrowCursor);
+
return true;
}
+
+void FontPreviewPlugin::setDoc(ScribusDoc* doc)
+{
+ if (dialog)
+ dialog->changedDocument(doc);
+}
+
+void FontPreviewPlugin::unsetDoc()
+{
+ if (dialog)
+ dialog->closedDocument();
+}
+
+void FontPreviewPlugin::dialogClosed()
+{
+ dialog = nullptr;
+}
diff --git a/scribus/plugins/fontpreview/fontpreviewplugin.h b/scribus/plugins/fontpreview/fontpreviewplugin.h
index 1dde890cd..bedbadb89 100644
--- a/scribus/plugins/fontpreview/fontpreviewplugin.h
+++ b/scribus/plugins/fontpreview/fontpreviewplugin.h
@@ -11,6 +11,7 @@ for which a new license (GPL+exception) is in place.
#include "scplugin.h"
class ScribusDoc;
+class FontPreview;
class PLUGIN_API FontPreviewPlugin : public ScActionPlugin
{
@@ -21,14 +22,20 @@ class PLUGIN_API FontPreviewPlugin : public ScActionPlugin
FontPreviewPlugin();
virtual ~FontPreviewPlugin();
bool run(ScribusDoc* doc, const QString& target = QString()) override;
- bool run(QWidget *parent, ScribusDoc* doc, const QString& target = QString()) override;
QString fullTrName() const override;
const AboutData* getAboutData() const override;
void deleteAboutData(const AboutData* about) const override;
void languageChange() override;
void addToMainWindowMenu(ScribusMainWindow *) override {};
+ void setDoc ( ScribusDoc* doc ) override;
+ void unsetDoc() override;
- // Special features (none)
+ private:
+ FontPreview *dialog{nullptr};
+
+ private slots:
+ //only called on auto delete on close, resets ptr
+ void dialogClosed();
};
extern "C" PLUGIN_API int fontpreview_getPluginAPIVersion();
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2026-10-18 13:54 | utnik | New Issue | |
| 2026-10-18 14:25 | utnik | Severity | minor => feature |
| 2026-10-18 14:56 | ale | Note Added: 0054555 | |
| 2026-10-18 15:22 | utnik | Note Added: 0054557 | |
| 2026-10-18 15:33 | ale | Assigned To | => ale |
| 2026-10-18 15:33 | ale | Status | new => assigned |
| 2026-10-18 20:15 | cbradney | Target Version | => 1.8 Milestone |
| 2026-10-19 09:48 | buttar | Note Added: 0054560 | |
| 2026-10-19 11:05 | utnik | Note Added: 0054561 | |
| 2026-10-19 11:20 | buttar | Note Added: 0054562 | |
| 2026-10-22 18:02 | ale | Note Added: 0054594 | |
| 2026-10-22 18:02 | ale | File Added: font-preview.diff | |
| 2026-10-22 18:08 | ale | Summary | move 'fonts preview' from the 'story editor' to the 'style manager' => [PATCH] move 'fonts preview' from the 'story editor' to the 'style manager' |
| 2026-10-22 18:08 | ale | Patch | No => Yes |
| 2026-10-29 17:09 | cbradney | Target Version | 1.8 Milestone => 1.7.5.svn |