added bold and italic formatting helpers

This commit is contained in:
Patrizio Bekerle 2016-03-15 17:50:59 +01:00
parent 99caedb5c0
commit eda89868bf
8 changed files with 333 additions and 4 deletions

View file

@ -2,6 +2,9 @@
## 1.2.0
- added more German translation
- added bold and italic formatting helpers
- <kbd>Ctrl</kbd> + <kbd>B</kbd> formats the selected text bold
- <kbd>Ctrl</kbd> + <kbd>I</kbd> formats the selected text italic
## 1.1.9
- fixed a problem with continuous list editing where text from the previous

View file

@ -44,8 +44,10 @@ Important Shortcuts
- <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Down</kbd> does the same
- <kbd>Ctrl</kbd> + <kbd>L</kbd> opens a dialog to add a link to an other note or an URL (also works on selected text)
- <kbd>Ctrl</kbd> + <kbd>T</kbd> inserts the current date in ISO 8601 format
- <kbd>Ctrl</kbd> + <kbd>I</kbd> inserts an image (the image will be copied to the `media` folder in the current notes folder)
- <kbd>Ctrl</kbd> + <kbd></kbd> + <kbd>I</kbd> inserts an image (the image will be copied to the `media` folder in the current notes folder)
- <kbd>Ctrl</kbd> + <kbd></kbd> + <kbd>C</kbd> inserts a code block at the current position
- <kbd>Ctrl</kbd> + <kbd>B</kbd> formats the selected text bold
- <kbd>Ctrl</kbd> + <kbd>I</kbd> formats the selected text italic
- <kbd>Tab</kbd> indents the selected text (also works on multiple lines)
- <kbd></kbd> + <kbd>Tab</kbd> un-indents the selected text
- <kbd>Tab</kbd> after an unordered list character indents the list item
@ -106,8 +108,10 @@ Important Shortcuts
- <kbd></kbd> + <kbd>Opt</kbd> + <kbd>Down</kbd> does the same
- <kbd></kbd> + <kbd>L</kbd> opens a dialog to add a link to an other note or an URL (also works on selected text)
- <kbd></kbd> + <kbd>T</kbd> inserts the current date in ISO 8601 format
- <kbd></kbd> + <kbd>I</kbd> inserts an image (the image will be copied to the `media` folder in the current notes folder)
- <kbd></kbd> + <kbd></kbd> + <kbd>I</kbd> inserts an image (the image will be copied to the `media` folder in the current notes folder)
- <kbd></kbd> + <kbd></kbd> + <kbd>C</kbd> inserts a code block at the current position
- <kbd></kbd> + <kbd>B</kbd> formats the selected text bold
- <kbd></kbd> + <kbd>I</kbd> formats the selected text italic
- <kbd>Tab</kbd> indents the selected text (also works on multiple lines)
- <kbd></kbd> + <kbd>Tab</kbd> un-indents the selected text
- <kbd>Tab</kbd> after an unordered list character indents the list item

View file

@ -56,5 +56,7 @@
<file alias="16x16/document-open.svg">icons/breeze-qownnotes/16x16/document-open.svg</file>
<file alias="16x16/code-context.svg">icons/breeze-qownnotes/16x16/code-context.svg</file>
<file alias="16x16/zoom-original.svg">icons/breeze-qownnotes/16x16/zoom-original.svg</file>
<file alias="16x16/format-text-bold.svg">icons/breeze-qownnotes/16x16/format-text-bold.svg</file>
<file alias="16x16/format-text-italic.svg">icons/breeze-qownnotes/16x16/format-text-italic.svg</file>
</qresource>
</RCC>

View file

@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24"
height="24"
id="svg3869"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="format-text-bold.svg">
<defs
id="defs3871">
<linearGradient
id="linearGradient3257">
<stop
offset="0"
style="stop-color:#a50000;stop-opacity:1"
id="stop3259" />
<stop
offset="1"
style="stop-color:#e73800;stop-opacity:1"
id="stop3261" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627416"
inkscape:cx="5.4926209"
inkscape:cy="10.264796"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1366"
inkscape:window-height="709"
inkscape:window-x="-4"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:showpageshadow="false"
inkscape:object-nodes="true"
inkscape:snap-bbox="true">
<inkscape:grid
type="xygrid"
id="grid4132" />
<sodipodi:guide
position="4,18"
orientation="18,0"
id="guide4138" />
<sodipodi:guide
position="5,3"
orientation="0,18"
id="guide4140" />
<sodipodi:guide
position="20,2.0000174"
orientation="-18,0"
id="guide4142" />
<sodipodi:guide
position="2,21"
orientation="0,-18"
id="guide4144" />
<sodipodi:guide
position="3,19.000017"
orientation="16,0"
id="guide4146" />
<sodipodi:guide
position="2,4"
orientation="0,16"
id="guide4148" />
<sodipodi:guide
position="21,20"
orientation="-16,0"
id="guide4150" />
<sodipodi:guide
position="2,20"
orientation="0,-16"
id="guide4152" />
</sodipodi:namedview>
<metadata
id="metadata3874">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Capa 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-326,-532.3622)">
<g
transform="translate(327,-497)"
id="layer1-9"
inkscape:label="Capa 1">
<path
id="rect4164"
d="m 3.5,1033.362 c -0.1713731,0 -0.3353491,0.025 -0.5,0.049 l 0,1.9512 c 1.108,0 2,0.892 2,2 l 0,3 0,5 c 0,1.108 -0.892,2 -2,2 l 0,1.9512 c 0.1646509,0.024 0.3286269,0.049 0.5,0.049 l 1.5,0 4,0 5,0 c 2.769995,0 5,-2.23 5,-5 0,-2.2049 -1.422883,-4.0466 -3.396484,-4.7148 C 16.447639,1039.0093 17,1038.0063 17,1036.862 c 0,-1.939 -1.561,-3.5 -3.5,-3.5 l -4.5,0 -4,0 -1.5,0 z m 5.5,2 2,0 c 1.108,0 2,0.892 2,2 0,1.108 -0.892,2 -2,2 l -2,0 0,-4 z m 0,6 3,0 c 1.662,0 3,1.338 3,3 0,1.662 -1.338,3 -3,3 l -3,0 0,-6 z"
style="opacity:1;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24"
height="24"
id="svg3869"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="format-text-italic.svg">
<defs
id="defs3871">
<linearGradient
id="linearGradient3257">
<stop
offset="0"
style="stop-color:#a50000;stop-opacity:1"
id="stop3259" />
<stop
offset="1"
style="stop-color:#e73800;stop-opacity:1"
id="stop3261" />
</linearGradient>
<clipPath
clipPathUnits="userSpaceOnUse"
id="clipPath4210">
<rect
y="1024.3622"
x="-7"
height="34"
width="34"
id="rect4212"
style="opacity:1;fill:#0000ff;fill-opacity:0.51376145;stroke:none;stroke-opacity:1" />
</clipPath>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="22.627416"
inkscape:cx="5.4926209"
inkscape:cy="10.264796"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-width="1366"
inkscape:window-height="709"
inkscape:window-x="-4"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:showpageshadow="false"
inkscape:object-nodes="true"
inkscape:snap-bbox="true">
<inkscape:grid
type="xygrid"
id="grid4132" />
<sodipodi:guide
position="4,18"
orientation="18,0"
id="guide4138" />
<sodipodi:guide
position="5,3"
orientation="0,18"
id="guide4140" />
<sodipodi:guide
position="20,2.0000174"
orientation="-18,0"
id="guide4142" />
<sodipodi:guide
position="2,21"
orientation="0,-18"
id="guide4144" />
<sodipodi:guide
position="3,19.000017"
orientation="16,0"
id="guide4146" />
<sodipodi:guide
position="2,4"
orientation="0,16"
id="guide4148" />
<sodipodi:guide
position="21,20"
orientation="-16,0"
id="guide4150" />
<sodipodi:guide
position="2,20"
orientation="0,-16"
id="guide4152" />
</sodipodi:namedview>
<metadata
id="metadata3874">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Capa 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-326,-532.3622)">
<g
transform="translate(327,-497)"
id="layer1-7"
inkscape:label="Capa 1">
<path
id="rect4252"
d="m 8,1033.3622 0,1 5,0 -6,14 -3,0 0,1 10,0 0,-1 -5,0 6,-14 3,0 0,-1 -10,0 z"
style="opacity:1;fill:#4d4d4d;fill-opacity:1;stroke:none;stroke-opacity:1"
inkscape:connector-curvature="0" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

View file

@ -3346,3 +3346,39 @@ void MainWindow::on_actionShow_note_in_file_manager_triggered()
{
Utils::Misc::openFolderSelect(currentNote.fullNoteFilePath());
}
/**
* Inserts a bold block at the current cursor position
*/
void MainWindow::on_actionFormat_text_bold_triggered()
{
QMarkdownTextEdit* textEdit = activeNoteTextEdit();
QTextCursor c = textEdit->textCursor();
QString selectedText = textEdit->textCursor().selectedText();
if (selectedText.isEmpty()) {
c.insertText("****");
c.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 2);
textEdit->setTextCursor(c);
} else {
c.insertText("**" + selectedText + "**");
}
}
/**
* Inserts a italic block at the current cursor position
*/
void MainWindow::on_actionFormat_text_italic_triggered()
{
QMarkdownTextEdit* textEdit = activeNoteTextEdit();
QTextCursor c = textEdit->textCursor();
QString selectedText = textEdit->textCursor().selectedText();
if (selectedText.isEmpty()) {
c.insertText("**");
c.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor);
textEdit->setTextCursor(c);
} else {
c.insertText("*" + selectedText + "*");
}
}

View file

@ -203,6 +203,10 @@ private slots:
void on_actionShow_note_in_file_manager_triggered();
void on_actionFormat_text_bold_triggered();
void on_actionFormat_text_italic_triggered();
private:
Ui::MainWindow *ui;
QSplitter *mainSplitter;

View file

@ -333,6 +333,9 @@ p, li { white-space: pre-wrap; }
<addaction name="actionInsert_current_time"/>
<addaction name="actionInset_code_block"/>
<addaction name="separator"/>
<addaction name="actionFormat_text_bold"/>
<addaction name="actionFormat_text_italic"/>
<addaction name="separator"/>
<addaction name="actionPaste_image"/>
<addaction name="separator"/>
<addaction name="action_Remove_note"/>
@ -757,7 +760,7 @@ p, li { white-space: pre-wrap; }
<string>Insert image (the image will be copied to the `media` folder in the current notes folder)</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+I</string>
<string>Ctrl+Shift+I</string>
</property>
</action>
<action name="actionShow_changelog">
@ -962,6 +965,30 @@ p, li { white-space: pre-wrap; }
<string notr="true">Alt+Shift+F</string>
</property>
</action>
<action name="actionFormat_text_bold">
<property name="icon">
<iconset theme="format-text-bold" resource="breeze-qownnotes.qrc">
<normaloff>:/icons/breeze-qownnotes/16x16/format-text-bold.svg</normaloff>:/icons/breeze-qownnotes/16x16/format-text-bold.svg</iconset>
</property>
<property name="text">
<string>Format text &amp;bold</string>
</property>
<property name="shortcut">
<string>Ctrl+B</string>
</property>
</action>
<action name="actionFormat_text_italic">
<property name="icon">
<iconset theme="format-text-italic" resource="breeze-qownnotes.qrc">
<normaloff>:/icons/breeze-qownnotes/16x16/format-text-italic.svg</normaloff>:/icons/breeze-qownnotes/16x16/format-text-italic.svg</iconset>
</property>
<property name="text">
<string>Format text &amp;italic</string>
</property>
<property name="shortcut">
<string>Ctrl+I</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
@ -972,8 +999,8 @@ p, li { white-space: pre-wrap; }
</customwidget>
</customwidgets>
<resources>
<include location="images.qrc"/>
<include location="breeze-qownnotes.qrc"/>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>