From cff850993565778ef5d0aa01969e87251eb8ef2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20O=2E=20Cordero=20P=C3=A9rez?= Date: Tue, 1 Feb 2022 15:57:26 -0400 Subject: [PATCH] Fixed issue #50: cannot set same color attribute with text color and text highlight twice in a row. Fixed issue #47: HTML anchors created externally and HTML anchors created in QPrompt didn't share the same formatting. Enhanced: Hid unnecessary alpha channel slider on mobile QML color ColorDialog. --- src/kirigami_ui/EditorToolbar.qml | 17 +++++++++++++---- src/kirigami_ui/PrompterPage.qml | 6 +++--- src/prompter/Prompter.qml | 4 ++-- src/prompter/PrompterBackground.qml | 1 + src/prompter/TimerClock.qml | 1 + src/prompter/documenthandler.cpp | 2 +- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/kirigami_ui/EditorToolbar.qml b/src/kirigami_ui/EditorToolbar.qml index 5e90fd38..d6156f16 100644 --- a/src/kirigami_ui/EditorToolbar.qml +++ b/src/kirigami_ui/EditorToolbar.qml @@ -541,8 +541,10 @@ ToolBar { font.family: iconFont.name font.pointSize: 13 focusPolicy: Qt.TabFocus - onClicked: colorDialog.open() - + onClicked: { + colorDialog.color = prompter.textColor; + colorDialog.open(); + } Rectangle { width: aFontMetrics.width + 3 height: 2 @@ -574,8 +576,15 @@ ToolBar { font.family: iconFont.name font.pointSize: 13 focusPolicy: Qt.TabFocus - onClicked: highlightDialog.open() - + onClicked: { + console.log(highlightDialog.color); + highlightDialog.color = Qt.rgba(0,0,0,0); + // if (Qt.colorEqual(highlightDialog.color, "#000000")) + // highlightDialog.color = Qt.rgba(0,0,0,0); + // else + // highlightDialog.color = prompter.textBackground; + highlightDialog.open(); + } Rectangle { width: bFontMetrics.width + 3 height: 2 diff --git a/src/kirigami_ui/PrompterPage.qml b/src/kirigami_ui/PrompterPage.qml index 53e939eb..ed60c0cd 100644 --- a/src/kirigami_ui/PrompterPage.qml +++ b/src/kirigami_ui/PrompterPage.qml @@ -640,12 +640,12 @@ Kirigami.Page { ColorDialog { id: colorDialog - currentColor: Kirigami.Theme.textColor + showAlphaChannel: false } - + ColorDialog { id: highlightDialog - currentColor: Kirigami.Settings.isMobile ? "#FFFF00" : Kirigami.Theme.backgroundColor + showAlphaChannel: false } // ShaderEffectSource { diff --git a/src/prompter/Prompter.qml b/src/prompter/Prompter.qml index e962c5c4..598a2c27 100644 --- a/src/prompter/Prompter.qml +++ b/src/prompter/Prompter.qml @@ -787,8 +787,8 @@ Flickable { cursorPosition: editor.cursorPosition selectionStart: editor.selectionStart selectionEnd: editor.selectionEnd - textColor: "#FFF" - textBackground: "#000" + //textColor: "#FFF" + //textBackground: "#000" onLoaded: { editor.textFormat = format diff --git a/src/prompter/PrompterBackground.qml b/src/prompter/PrompterBackground.qml index 32f4f018..0443d5e7 100644 --- a/src/prompter/PrompterBackground.qml +++ b/src/prompter/PrompterBackground.qml @@ -104,6 +104,7 @@ Rectangle { ColorDialog { id: backgroundColorDialog + showAlphaChannel: false currentColor: appTheme.__backgroundColor onAccepted: { console.log(color) diff --git a/src/prompter/TimerClock.qml b/src/prompter/TimerClock.qml index 97d3720b..dee1af0e 100644 --- a/src/prompter/TimerClock.qml +++ b/src/prompter/TimerClock.qml @@ -194,6 +194,7 @@ Item { ColorDialog { id: timerColorDialog + showAlphaChannel: false color: '#AAA' onAccepted: { timerSettings.color = currentColor diff --git a/src/prompter/documenthandler.cpp b/src/prompter/documenthandler.cpp index f7497c90..59227264 100644 --- a/src/prompter/documenthandler.cpp +++ b/src/prompter/documenthandler.cpp @@ -132,7 +132,7 @@ void DocumentHandler::setDocument(QQuickTextDocument *document) m_document->textDocument()->disconnect(this); m_document = document; if (m_document) { - m_document->textDocument()->setDefaultStyleSheet("body{margin:0;padding:0;}a:link,a:visited,a:hover,a:active{color:#5294e2;text-decoration:none;}p,html,body,div,span,blockquote,address,cite,code,pre,h1,h2,h3,h4,h5,h6,li,ol,ul,table,tbody,td,th,thead,tr,dl,dt,big,small,tt,font{white-space:pre-wrap;font-size:medium;text-align:center;line-height:100%;margin:0;padding:0;border-width:2px;border-collapse:collapse;border-style:solid;border-color:\"#404040\";font-weight:normal;}table,tbody,thead{width:100%;}table,tbody,thead,td,th,tr{border:1pt;align:center;valign:top;}img{margin:5pt;width:50vw;}h1,h2,h3,h4,h5,h6,big{font-size:medium;font-weight:normal;}"); + m_document->textDocument()->setDefaultStyleSheet("body{margin:0;padding:0;color:\"#FFFFFF\";}a:link,a:visited,a:hover,a:active,a:before,a:after{text-decoration:overline;color:\"#FFFFFF\";background-color:rgba(0,0,0,0.0);}p,html,body,div,span,blockquote,address,cite,code,pre,h1,h2,h3,h4,h5,h6,li,ol,ul,table,tbody,td,th,thead,tr,dl,dt,big,small,tt,font{white-space:pre-wrap;font-size:medium;text-align:center;line-height:100%;margin:0;padding:0;border-width:2px;border-collapse:collapse;border-style:solid;border-color:\"#404040\";background-color:rgba(0,0,0,0.0);font-weight:normal;}table,tbody,thead{width:100%;}table,tbody,thead,td,th,tr{border:1pt;align:center;valign:top;background-color:rgba(0,0,0,0.0);}img{margin:5pt;width:50vw;}h1,h2,h3,h4,h5,h6,big{font-size:medium;font-weight:normal;}"); connect(m_document->textDocument(), &QTextDocument::modificationChanged, this, &DocumentHandler::modifiedChanged); connect(m_document->textDocument(), &QTextDocument::contentsChanged, this, &DocumentHandler::setMarkersListDirty); }