Skip to content

Commit

Permalink
Fixed text zooming with Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
tsujan committed Nov 26, 2022
1 parent 1ef1f6d commit 0f45109
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
V1.0.1
V1.1.0
---------
* Fixed crash on pasting with empty clipboard.
* Fixed a bug in updating widget states after deleting a node.
* Fixed text zooming for documents that are saved by the Qt6 version.
* Added a workaround for a Qt bug related to the current character format.
* Added a real Unix signal handler.
* Removed "Embed Image" from the toolbar to make it uncluttered.
Expand Down
2 changes: 1 addition & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Latest version:

26 Nov 2022, V1.0.1
26 Nov 2022, V1.1.0

See "ChangeLog" for changes.
6 changes: 3 additions & 3 deletions feathernotes/fn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,7 @@ void FN::selChanged (const QItemSelection &selected, const QItemSelection &desel
DomItem *item = static_cast<DomItem*>(index.internalPointer());
QDomNodeList list = item->node().childNodes();
text = list.item (0).nodeValue();
/* this is needed for text zooming */
/* NOTE: This is needed for text zooming. */
static const QString htmlStr ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
Expand All @@ -2341,7 +2341,7 @@ void FN::selChanged (const QItemSelection &selected, const QItemSelection &desel
bool defaultDocColor (bgColor_ == QColor (Qt::white) && fgColor_ == QColor (Qt::black));
if (defaultDocColor)
{
static const QRegularExpression htmlRegex (R"(^<!DOCTYPE[A-Za-z0-9/<>,;.:\-={}\s"]+</style></head><body\sstyle=[A-Za-z0-9/<>;:\-\s"']+>)");
static const QRegularExpression htmlRegex (R"(^<!DOCTYPE[A-Za-z0-9/<>,;.:\-={}\s"\\]+</style></head><body\sstyle=[A-Za-z0-9/<>;:\-\s"']+>)");
if (text.indexOf (htmlRegex, 0, &match) > -1)
text.replace (0, match.capturedLength(), htmlStr);
}
Expand All @@ -2352,7 +2352,7 @@ void FN::selChanged (const QItemSelection &selected, const QItemSelection &desel
/* To enable the default stylesheet, we should set the HTML text of the document.
Setting the HTML text of the editor above is needed for empty nodes. */
QString str = textEdit->document()->toHtml();
static const QRegularExpression htmlRegex1 (R"(^<!DOCTYPE[A-Za-z0-9/<>,;.:\-={}\s"]+</style></head><body\sstyle=[A-Za-z0-9/;:\-\s"'#=]+>(<br\s*/>(</p>)?)?)");
static const QRegularExpression htmlRegex1 (R"(^<!DOCTYPE[A-Za-z0-9/<>,;.:\-={}\s"\\]+</style></head><body\sstyle=[A-Za-z0-9/;:\-\s"'#=]+>(<br\s*/>(</p>)?)?)");
if (str.indexOf (htmlRegex1, 0, &match) > -1)
str.replace (0, match.capturedLength(), htmlStr);
textEdit->document()->setHtml (str);
Expand Down
2 changes: 1 addition & 1 deletion feathernotes/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
int main(int argc, char *argv[])
{
const QString name = "FeatherNotes";
const QString version = "1.0.1";
const QString version = "1.1.0";
const QString option = QString::fromUtf8 (argv[1]);
if (option == "--help" || option == "-h")
{
Expand Down

0 comments on commit 0f45109

Please sign in to comment.