From 2a7780246aa519a685a43df9f34d012df329e44f Mon Sep 17 00:00:00 2001 From: gee12 Date: Mon, 6 Jan 2025 14:48:51 +0300 Subject: [PATCH 1/3] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=B8=D0=B7=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9=20=D0=B2=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B5=20=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=B4=D0=B0=D1=80=D1=82=D0=BD=D0=BE=D0=B9=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D0=BE=D0=B9=20?= =?UTF-8?q?=D0=9E=D0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/bin/resource/translations/mytetra_ru.ts | 7 +- app/src/libraries/wyedit/Editor.cpp | 8 ++ .../libraries/wyedit/EditorContextMenu.cpp | 17 ++++ app/src/libraries/wyedit/EditorContextMenu.h | 3 + app/src/libraries/wyedit/EditorTextArea.cpp | 81 +++++++++++++++++-- app/src/libraries/wyedit/EditorTextArea.h | 4 + .../wyedit/formatters/ImageFormatter.cpp | 59 +++++++++++++- .../wyedit/formatters/ImageFormatter.h | 3 + 8 files changed, 175 insertions(+), 7 deletions(-) diff --git a/app/bin/resource/translations/mytetra_ru.ts b/app/bin/resource/translations/mytetra_ru.ts index 2fb37aed5..53fe7efc6 100644 --- a/app/bin/resource/translations/mytetra_ru.ts +++ b/app/bin/resource/translations/mytetra_ru.ts @@ -1366,11 +1366,16 @@ enable «Decrypt to a temporary file» option in Settings. + Open image + Открыть изображение + + + Edit image properties Свойства картинки - + Edit math expression Редактировать формулу diff --git a/app/src/libraries/wyedit/Editor.cpp b/app/src/libraries/wyedit/Editor.cpp index 723cf996c..7b8a46756 100644 --- a/app/src/libraries/wyedit/Editor.cpp +++ b/app/src/libraries/wyedit/Editor.cpp @@ -367,6 +367,11 @@ void Editor::setupSignals(void) referenceFormatter, &ReferenceFormatter::onClickedGotoReference, Qt::DirectConnection); + // Клик по картинке, для ImageFormatter + connect(textArea, &EditorTextArea::clickOnImage, + imageFormatter, &ImageFormatter::onClickOnImage, + Qt::DirectConnection); + // Двойной клик по картинке, для ImageFormatter connect(textArea, &EditorTextArea::doubleClickOnImage, imageFormatter, &ImageFormatter::onDoubleClickOnImage, @@ -422,6 +427,9 @@ void Editor::setupSignals(void) connect(editorContextMenu, &EditorContextMenu::selectAll, this, &Editor::onSelectAll, Qt::DirectConnection); + connect(editorContextMenu, &EditorContextMenu::contextMenuOpenImageProperties, + imageFormatter, &ImageFormatter::onContextMenuOpenImageProperties, + Qt::DirectConnection); connect(editorContextMenu, &EditorContextMenu::contextMenuEditImageProperties, imageFormatter, &ImageFormatter::onContextMenuEditImageProperties, Qt::DirectConnection); diff --git a/app/src/libraries/wyedit/EditorContextMenu.cpp b/app/src/libraries/wyedit/EditorContextMenu.cpp index 1bf22e4b5..ee91b6aeb 100644 --- a/app/src/libraries/wyedit/EditorContextMenu.cpp +++ b/app/src/libraries/wyedit/EditorContextMenu.cpp @@ -41,6 +41,7 @@ void EditorContextMenu::setupActions(void) actionPasteAsPlainText=new QAction(this); actionSelectAll=new QAction(this); + actionOpenImageProperties=new QAction(this); actionEditImageProperties=new QAction(this); actionEditMathExpression=new QAction(this); actionGotoReference=new QAction(this); @@ -62,6 +63,9 @@ void EditorContextMenu::setupShortcuts(void) shortcutManager.initAction("editor-pasteAsPlainText", actionPasteAsPlainText ); shortcutManager.initAction("editor-selectAll", actionSelectAll ); + // "Умное" действие Открыть изображение + actionOpenImageProperties->setText(tr("Open image")); + // "Умное" действие Вставить изображение / Редактировать свойства изображения shortcutManager.initAction("editor-insertImageFromFile", actionEditImageProperties ); actionEditImageProperties->setText(tr("Edit image properties")); // В контекстном меню это редактирование свойств изображения @@ -146,6 +150,9 @@ void EditorContextMenu::setImageProperties(bool flag) { qDebug() << "In EditorContextMenu::setImageProperties() " << flag; + actionOpenImageProperties->setVisible(flag); + actionOpenImageProperties->setEnabled(flag); + actionEditImageProperties->setVisible(flag); actionEditImageProperties->setEnabled(flag); } @@ -204,6 +211,7 @@ void EditorContextMenu::setupSignals(void) connect(actionPasteAsPlainText,&QAction::triggered, this, &EditorContextMenu::onActionPasteAsPlainText); connect(actionSelectAll, &QAction::triggered, this, &EditorContextMenu::onActionSelectAll); + connect(actionOpenImageProperties,&QAction::triggered, this, &EditorContextMenu::onActionContextMenuOpenImageProperties); connect(actionEditImageProperties,&QAction::triggered, this, &EditorContextMenu::onActionContextMenuEditImageProperties); connect(actionEditMathExpression, &QAction::triggered, this, &EditorContextMenu::onActionContextMenuEditMathExpression); connect(actionGotoReference, &QAction::triggered, this, &EditorContextMenu::onActionContextMenuGotoReference); @@ -236,6 +244,7 @@ void EditorContextMenu::setupMenu(void) this->addSeparator(); this->addAction(actionSelectAll); + this->addAction(actionOpenImageProperties); this->addAction(actionEditImageProperties); this->addAction(actionEditMathExpression); this->addAction(actionGotoReference); @@ -298,6 +307,14 @@ void EditorContextMenu::onActionSelectAll() } } +void EditorContextMenu::onActionContextMenuOpenImageProperties() +{ + update(); + if(actionOpenImageProperties->isEnabled()) { + emit contextMenuOpenImageProperties(); + } +} + void EditorContextMenu::onActionContextMenuEditImageProperties() { update(); diff --git a/app/src/libraries/wyedit/EditorContextMenu.h b/app/src/libraries/wyedit/EditorContextMenu.h index 6710c6942..036f6a33a 100644 --- a/app/src/libraries/wyedit/EditorContextMenu.h +++ b/app/src/libraries/wyedit/EditorContextMenu.h @@ -34,6 +34,7 @@ class EditorContextMenu : public QMenu void paste(void); void pasteAsPlainText(void); void selectAll(void); + void contextMenuOpenImageProperties(void); void contextMenuEditImageProperties(void); void contextMenuEditMathExpression(void); void contextMenuGotoReference(void); @@ -56,6 +57,7 @@ protected slots: QAction *actionLowercase; // строчный QAction *actionUppercase; // ПРОПИСНЫЕ + QAction *actionOpenImageProperties; QAction *actionEditImageProperties; QAction *actionEditMathExpression; QAction *actionGotoReference; @@ -73,6 +75,7 @@ protected slots: void onActionPaste(void); void onActionPasteAsPlainText(void); void onActionSelectAll(void); + void onActionContextMenuOpenImageProperties(); void onActionContextMenuEditImageProperties(void); void onActionContextMenuEditMathExpression(void); void onActionContextMenuGotoReference(void); diff --git a/app/src/libraries/wyedit/EditorTextArea.cpp b/app/src/libraries/wyedit/EditorTextArea.cpp index f46cb675d..203c4bad5 100644 --- a/app/src/libraries/wyedit/EditorTextArea.cpp +++ b/app/src/libraries/wyedit/EditorTextArea.cpp @@ -163,11 +163,24 @@ void EditorTextArea::switchReferenceClickMode(bool flag) globalParameters.getStatusBar()->showMessage(href); qDebug() << "Cursor href in key event: " << href; } + else + { + // Сразу нужно проверить, не наведен ли курсор на изображение, и если наведен, то поменять его вид + QString imageName = imageAt(currentMousePosition); + + if(!imageName.isEmpty()) + { + qApp->setOverrideCursor(QCursor(Qt::PointingHandCursor)); // Меняется форма курсора на указатель клика по ссылке + mouseCursorOverriden = true; + globalParameters.getStatusBar()->showMessage(imageName); // Имя изображения отображается в строке статуса + qDebug() << "Cursor image in mouse event: " << imageName; + } + } } else { // Вид курсора сбрасывается на основной. Нужно для того, чтобы курсор поменялся, - // если мышка в момент отжатия клавиши была наведена на ссылку и курсор был с указательным пальцем + // если мышка в момент отжатия клавиши была наведена на ссылку или изображение и курсор был с указательным пальцем qApp->restoreOverrideCursor(); mouseCursorOverriden = false; @@ -201,11 +214,26 @@ void EditorTextArea::mouseMoveEvent(QMouseEvent *event) } else { - if(mouseCursorOverriden) + QString imageName = imageAt(currentMousePosition); + + if(!imageName.isEmpty()) + { + if(!mouseCursorOverriden) + { + qApp->setOverrideCursor(QCursor(Qt::PointingHandCursor)); // Меняется форма курсора на указатель клика по ссылке + mouseCursorOverriden = true; + globalParameters.getStatusBar()->showMessage(imageName); // Имя изображения отображается в строке статуса + qDebug() << "Cursor image in mouse event: " << imageName; + } + } + else { - qApp->restoreOverrideCursor(); // Воостанавливается обычный курсор - mouseCursorOverriden = false; - globalParameters.getStatusBar()->showMessage(""); + if(mouseCursorOverriden) + { + qApp->restoreOverrideCursor(); // Воостанавливается обычный курсор + mouseCursorOverriden = false; + globalParameters.getStatusBar()->showMessage(""); + } } } } @@ -222,7 +250,22 @@ void EditorTextArea::mousePressEvent(QMouseEvent *event) if( event->type()==QEvent::MouseButtonPress && (QApplication::keyboardModifiers() & Qt::ControlModifier) ) { QString href = this->anchorAt(event->pos()); if(!href.isEmpty()) + { emit clickedOnReference(href); + } + else + { + QString imageName = imageAt(currentMousePosition); + + if(!imageName.isEmpty()) + { + // Устанавливаем курсор на изображение, по которому кликнули + setTextCursorFromPoint(currentMousePosition); + + // Открываем изображение + emit clickOnImage(); + } + } } else { qApp->restoreOverrideCursor(); } @@ -676,3 +719,31 @@ void EditorTextArea::onChangeFontPointSize(int n) setFontPointSize(n); } +QString EditorTextArea::imageAt(const QPoint& point) +{ + int scrollY = verticalScrollBar()->value(); + int scrollX = horizontalScrollBar()->value(); + QPoint mousePositionWithScroll = QPoint(point.x()+scrollX, point.y()+scrollY); + return document()->documentLayout()->imageAt(mousePositionWithScroll); +} + +int EditorTextArea::hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) +{ + int scrollY = verticalScrollBar()->value(); + int scrollX = horizontalScrollBar()->value(); + QPoint mousePositionWithScroll = QPoint(point.x()+scrollX, point.y()+scrollY); + return document()->documentLayout()->hitTest(mousePositionWithScroll, accuracy); +} + +void EditorTextArea::setTextCursorFromPoint(const QPointF &point) +{ + int pos = hitTest(point, Qt::ExactHit); + if (pos < 0) + return; + QTextCursor cursor(textCursor()); + if (!cursor.atEnd()) + pos+=1; + cursor.setPosition(pos); + setTextCursor(cursor); +} + diff --git a/app/src/libraries/wyedit/EditorTextArea.h b/app/src/libraries/wyedit/EditorTextArea.h index 438189983..bb3e7441d 100644 --- a/app/src/libraries/wyedit/EditorTextArea.h +++ b/app/src/libraries/wyedit/EditorTextArea.h @@ -43,6 +43,7 @@ class EditorTextArea : public QTextEdit void downloadImages(const QString href); + void clickOnImage(); void doubleClickOnImage(); public slots: @@ -90,6 +91,9 @@ class EditorTextArea : public QTextEdit void mouseDoubleClickEvent(QMouseEvent *event); void switchReferenceClickMode(bool flag); + QString imageAt(const QPoint& point); + int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy); + void setTextCursorFromPoint(const QPointF &point); }; #endif // _EDITORTEXTAREA_H_ diff --git a/app/src/libraries/wyedit/formatters/ImageFormatter.cpp b/app/src/libraries/wyedit/formatters/ImageFormatter.cpp index 3c268a40f..4652fd1e3 100644 --- a/app/src/libraries/wyedit/formatters/ImageFormatter.cpp +++ b/app/src/libraries/wyedit/formatters/ImageFormatter.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include "main.h" #include "libraries//Downloader.h" #include "libraries/helpers/UniqueIdHelper.h" +#include "libraries/helpers/MessageHelper.h" ImageFormatter::ImageFormatter() @@ -55,6 +57,35 @@ QTextImageFormat ImageFormatter::imageFormatOnCursor(void) } +void ImageFormatter::openImage() +{ + // Данные обрабатываемой картинки + QTextImageFormat imageFormat; + + // Если выбрано изображение + if(editor->cursorPositionDetector->isImageSelect()) { + imageFormat=imageFormatOnSelect(); + } + else if(editor->cursorPositionDetector->isCursorOnImage()) { + // Если изображение не выбрано, но курсор находится в позиции изображения + imageFormat=imageFormatOnCursor(); + } + + // Имя картинки в ресурсах документа + QString imageName=imageFormat.name(); + + // Выясняется путь к файлу + QString fullDir = editor->getWorkDirectory(); + QString fullFileName = fullDir+"/"+imageName; + + qDebug() << "Open image file: "+fullFileName; + + // Открытие файла средствами операционной системы + QUrl urlFileName("file:"+fullFileName); + QDesktopServices::openUrl(urlFileName); +} + + void ImageFormatter::editImageProperties(void) { // Для картинки с формулой свойства изображения редактироваться не должны @@ -259,6 +290,26 @@ void ImageFormatter::onInsertImageFromFileClicked(void) } +// Вызов открытия изображения +void ImageFormatter::onContextMenuOpenImageProperties() +{ + // Для картинки с формулой свойства изображения редактироваться не должны + if(editor->cursorPositionDetector->isMathExpressionSelect() || + editor->cursorPositionDetector->isCursorOnMathExpression()) { + return; + } + + // Если выделена картинка + if(editor->cursorPositionDetector->isImageSelect() || + editor->cursorPositionDetector->isCursorOnImage()) + { + qDebug() << "Open image selected"; + + openImage(); + } +} + + // Вызов окна настройки свойств изображения void ImageFormatter::onContextMenuEditImageProperties() { @@ -272,13 +323,19 @@ void ImageFormatter::onContextMenuEditImageProperties() if(editor->cursorPositionDetector->isImageSelect() || editor->cursorPositionDetector->isCursorOnImage()) { - qDebug() << "Image selected"; + qDebug() << "Edit image selected"; editImageProperties(); } } +void ImageFormatter::onClickOnImage(void) +{ + openImage(); +} + + void ImageFormatter::onDoubleClickOnImage(void) { onContextMenuEditImageProperties(); diff --git a/app/src/libraries/wyedit/formatters/ImageFormatter.h b/app/src/libraries/wyedit/formatters/ImageFormatter.h index b60f52d84..a58013bfc 100644 --- a/app/src/libraries/wyedit/formatters/ImageFormatter.h +++ b/app/src/libraries/wyedit/formatters/ImageFormatter.h @@ -20,6 +20,7 @@ class ImageFormatter : public Formatter QTextImageFormat imageFormatOnSelect(void); QTextImageFormat imageFormatOnCursor(void); + void openImage(); void editImageProperties(void); signals: @@ -31,10 +32,12 @@ class ImageFormatter : public Formatter public slots: void onInsertImageFromFileClicked(void); + void onContextMenuOpenImageProperties(); void onContextMenuEditImageProperties(void); void onDownloadImages(const QString html); + void onClickOnImage(); void onDoubleClickOnImage(void); }; From 2c716d771c238a49f999e298fcd072d471fc2031 Mon Sep 17 00:00:00 2001 From: gee12 Date: Mon, 6 Jan 2025 14:49:50 +0300 Subject: [PATCH 2/3] =?UTF-8?q?=D0=9F=D1=83=D0=BD=D0=BA=D1=82=20=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D1=8E=20"=D0=A1=D0=B2=D0=BE=D0=B9=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=B0=20=D0=BA=D0=B0=D1=80=D1=82=D0=B8=D0=BD=D0=BA=D0=B8?= =?UTF-8?q?"=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B8=D0=BC=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=20=D0=B2=20"=D0=A1=D0=B2=D0=BE=D0=B9=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B0=20=D0=B8=D0=B7=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/bin/resource/translations/mytetra_ru.ts | 2 +- app/src/libraries/wyedit/EditorContextMenu.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/bin/resource/translations/mytetra_ru.ts b/app/bin/resource/translations/mytetra_ru.ts index 53fe7efc6..b2a726273 100644 --- a/app/bin/resource/translations/mytetra_ru.ts +++ b/app/bin/resource/translations/mytetra_ru.ts @@ -1372,7 +1372,7 @@ enable «Decrypt to a temporary file» option in Settings. Edit image properties - Свойства картинки + Свойства изображения diff --git a/app/src/libraries/wyedit/EditorContextMenu.h b/app/src/libraries/wyedit/EditorContextMenu.h index 036f6a33a..49a590e3a 100644 --- a/app/src/libraries/wyedit/EditorContextMenu.h +++ b/app/src/libraries/wyedit/EditorContextMenu.h @@ -15,7 +15,7 @@ class EditorContextMenu : public QMenu QList getActionsList(void); - void setImageProperties(bool flag); // Активирование добавочного пункта меню "Свойства картинки") + void setImageProperties(bool flag); // Активирование добавочного пункта меню "Свойства изображения") void setEditMathExpression(bool flag); // Активирование добавочного пункта меню "Редактирование формулы") void setGotoReference(bool flag); // Активирование добавочного пункта меню "Перейти по ссылке") void setPasteAsPlainText(bool flag); From 891284820f821369370001e1972393c3a1d27612 Mon Sep 17 00:00:00 2001 From: gee12 Date: Tue, 7 Jan 2025 15:25:30 +0300 Subject: [PATCH 3/3] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20shortcut=20=D0=B8=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D1=83=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BF=D0=B0=D0=BD=D0=B5=D0=BB=D1=8C=20=D0=B8?= =?UTF-8?q?=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=B4=D0=BB=D1=8F=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D1=8B=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=B8=D0=B7=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/bin/mytetra.qrc | 1 + app/bin/resource/pic/open_image.svg | 43 +++ app/bin/resource/translations/mytetra_fr.ts | 272 ++++++++--------- app/bin/resource/translations/mytetra_ru.ts | 278 +++++++++--------- app/src/libraries/ShortcutManager.cpp | 1 + app/src/libraries/wyedit/Editor.cpp | 7 +- .../libraries/wyedit/EditorContextMenu.cpp | 20 +- app/src/libraries/wyedit/EditorContextMenu.h | 6 +- app/src/libraries/wyedit/EditorToolBar.cpp | 9 +- app/src/libraries/wyedit/EditorToolBar.h | 1 + .../wyedit/formatters/ImageFormatter.cpp | 2 +- .../wyedit/formatters/ImageFormatter.h | 2 +- 12 files changed, 360 insertions(+), 282 deletions(-) create mode 100644 app/bin/resource/pic/open_image.svg diff --git a/app/bin/mytetra.qrc b/app/bin/mytetra.qrc index 60c0e471c..c6c9841cf 100644 --- a/app/bin/mytetra.qrc +++ b/app/bin/mytetra.qrc @@ -125,5 +125,6 @@ resource/pic/move_right.svg resource/pic/edit_zoom-in.svg resource/pic/edit_zoom-out.svg + resource/pic/open_image.svg diff --git a/app/bin/resource/pic/open_image.svg b/app/bin/resource/pic/open_image.svg new file mode 100644 index 000000000..a76369da1 --- /dev/null +++ b/app/bin/resource/pic/open_image.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/bin/resource/translations/mytetra_fr.ts b/app/bin/resource/translations/mytetra_fr.ts index ddaf58451..ba14928dc 100644 --- a/app/bin/resource/translations/mytetra_fr.ts +++ b/app/bin/resource/translations/mytetra_fr.ts @@ -2399,657 +2399,667 @@ MyTetra will try to create a blank entry to fix it. ShortcutManager - + Add a new note - + Add a note before - + Add a note before current selected note - + Add a note after - + Add a note after current selected note - + Edit properties - + Edit note properties (name, author, tags...) - + Block/Unblock note - + Block or unblock current selected note - + Delete note(s) - + Cut notes(s) - + Cut notes(s) to clipboard - + Copy note(s) - + Copy note(s) to clipboard - + Paste note(s) - + Paste note(s) from clipboard - + Move up - + Move up current note - + Move down - + Move down current note - + Previous note - + Previous note has been viewing - + Next note - + Next note has been viewing - + Expand all sub items - + Collapse all sub items - + Move item up - + Move item down - + Insert a new sub item - + Insert a new sub item into selected - + Insert a new sibling item - + Insert a new sibling item after selected - + Edit item name - + Edit name of selected item - + Delete item - + Delete selected item and all sub items - + Cut item - + Cut item including sub items - + Copy item - + Copy item including sub items - + Paste item - + Paste sibling item after selected - + Paste as sub item - + Paste item as sub item for selected - + Encrypt item - + Encrypt item and all subitem - + Decrypt item - + Decrypt item and all subitem - + Set icon - + Set item icon - + Select all - + Copy - + Paste - + Paste plain text - + Cut - + Undo - + Redo - + Bold - + Italic - + Underline - + Strike out - + Superscript - + Subscript - + Monospace - + Code - + Select a whole paragraphs to format text as code - + Lowercase - + Uppercase - + Clear format - + When selected whole paragraph both text and paragraph format is reset to default or just text format in other case - + Text only - + Return type replace - + Replace soft carriage return to standard carriage return - + Numeric list - + Marked list - + Increase indent - + Decrease indent - + Align left - + Align center - + Align right - + Align width - + Text color - + Background color - + Select font - + Select font size - + Find text - + Find text in current note - + Editor settings - + Edit reference URL - + Edit HTML code - + Show special chars - + Create a new table - + Remove row(s) - + Remove column(s) - + Add row(s) - + Add column(s) - + Merge cells - + Split cell - + Table properties - + + Open image + + + + + Open selected image in external viewer + + + + Insert/edit image - + Insert image from file or edit selected image properties - + Insert horizontal line - + Insert a horizontal line into the empty paragraph from cursor - + Insert/edit math expression - + Expand edit area - + Expand tools - + Forse save note - + Show detached window - + Attach files - + Go to URL or reference - + Copy selected rows - + Attach file - + Attach file from URL - + Add link - + Add link without file copying - + Edit file name - + Delete file - + Preview file - + Save as... - + Attach info - + Return to editor - + Set focus to items tree - + Set focus to notes table - + Set focus to editor - + Find in base - + Synchronization - + Run synchronization - + Ok - + Print - + Export PDF - + Quit diff --git a/app/bin/resource/translations/mytetra_ru.ts b/app/bin/resource/translations/mytetra_ru.ts index b2a726273..67aec5255 100644 --- a/app/bin/resource/translations/mytetra_ru.ts +++ b/app/bin/resource/translations/mytetra_ru.ts @@ -1365,17 +1365,17 @@ enable «Decrypt to a temporary file» option in Settings. Выбрать всё - + Open image Открыть изображение - + Edit image properties Свойства изображения - + Edit math expression Редактировать формулу @@ -3630,7 +3630,7 @@ MyTetra will try to create a blank entry to fix it. ShortcutManager - + Add a new note Добавить новую запись @@ -3639,502 +3639,512 @@ MyTetra will try to create a blank entry to fix it. Нобавить новую запись - + Add a note before Добавить перед - + Add a note before current selected note Добавить новую запись перед выбранной записью - + Add a note after Добавить после - + Add a note after current selected note Добавить новую запись после выбранной записи - + Edit properties Редактировать свойства - + Edit note properties (name, author, tags...) Редактировать свойства записи (название, автор, текстовые метки...) - + Block/Unblock note Блокировать/Разблокировать запись - + Block or unblock current selected note Блокировать/Разблокировать возможность изменения записи - + Delete note(s) Удалить - + Cut notes(s) Вырезать - + Cut notes(s) to clipboard Вырезать запись (записи) в буфер обмена - + Copy note(s) Копировать - + Copy note(s) to clipboard Копировать запись (записи) в буфер обмена - + Paste note(s) Вставить - + Paste note(s) from clipboard Вставить запись (записи) из буфера обмена - + Move up Передвинуть вверх - + Move up current note Передвинуть вверх текущую запись - + Move down Передвинуть вниз - + Move down current note Передвинуть вниз текущую запись - + Previous note Предыдущая запись - + Previous note has been viewing Предыдущая запись, которая была просмотрена - + Next note Следующая запись - + Next note has been viewing Следующая запись, которая была просмотрена - + Expand all sub items Развернуть все подветки - + Collapse all sub items Свернуть все подветки - + Move item up Переместить ветку вверх - + Move item down Переместить ветку вниз - + Insert a new sub item Добавить подветку - + Insert a new sub item into selected Добавить подветку к выделенной ветке - + Insert a new sibling item Добавить ветку такого же уровня - + Insert a new sibling item after selected Добавить ветку такого же уровня вложения после выделенной ветки - + Edit item name Редактировать название ветки - + Edit name of selected item Редактировать название выделенной ветки - + Delete item Удалить ветку - + Delete selected item and all sub items Удалить выделенную ветку и все её подветки - + Cut item Вырезать ветку - + Cut item including sub items Вырезать выделенную ветку и все её подветки - + Copy item Копировать ветку - + Copy item including sub items Скопировать ветку и все её подветки в буфер обмена - + Paste item Вставить ветку - + Paste sibling item after selected Вставить ветку из буфера обмена после выделенной на том же уровне - + Paste as sub item Вставить ветку как подветку - + Paste item as sub item for selected Вставить ветку из буфера обмена как подветку для выбранной ветки - + Encrypt item Зашифровать ветку - + Encrypt item and all subitem Зашифровать ветку и все подветки - + Decrypt item Расшифровать ветку - + Decrypt item and all subitem Расшифровать ветку и все подветки - + Set icon Задать иконку - + Set item icon Задать иконку для ветки - + Select all Выбрать всё - + Copy Копировать - + Paste Вставить - + Paste plain text Вставить только текст - + Cut Вырезать - + Undo Отмена - + Redo Повтор - + Bold Жирный - + Italic Курсив - + Underline Подчёркнутый - + Strike out Зачеркнутый - + Superscript Верхний индекс - + Subscript Нижний индекс - + Monospace Моноширинный - + Code Код - + Select a whole paragraphs to format text as code Требуется целиком выделить абзац(ы) для полного форматирования в код - + Lowercase Нижний регистр - + Uppercase Верхний регистр - + Clear format Очистка форматирования - + When selected whole paragraph both text and paragraph format is reset to default or just text format in other case Сброс форматирования к стандартному. Если выбрана часть строки, очищается начертание. Если выбран абзац, очищается всё форматирование - + Text only Только текст - + Return type replace Замена символов перевода строк - + Replace soft carriage return to standard carriage return Заменить "мягкий" перевод строки на стандартный перевод строки - + Numeric list Нумерованный список - + Marked list Маркированный список - + Increase indent Увеличить отступ - + Decrease indent Уменьшить отступ - + Align left По левому краю - + Align center По центру - + Align right По правому краю - + Align width По ширине - + Text color Цвет текста - + Background color Цвет фона - + Select font Выбор шрифта - + Select font size Выбор размера шрифта - + Find text Поиск текста - + Find text in current note Поиск текста в текущей записи - + Editor settings Настройки редактора - + Edit reference URL Редактировать ссылку - + Edit HTML code Редактирование HTML кода - + Show special chars Показать символы форматирования - + Create a new table Создать новую таблицу - + Remove row(s) Удалить строку - + Remove column(s) Удалить столбец - + Add row(s) Добавить строки - + Add column(s) Добавить столбец - + Merge cells Объединить ячейки - + Split cell Разделить ячейку - + Table properties Свойства таблицы - + + Open image + Открыть изображение + + + + Open selected image in external viewer + Открыть выбранное изображение в сторонней программе + + + Insert/edit image Вставка изображения - + Insert image from file or edit selected image properties Вставка картинки из файла / Редактирование свойств картинки @@ -4143,152 +4153,152 @@ MyTetra will try to create a blank entry to fix it. Вставка картинки из файла / Редактирование свойств картинки - + Insert horizontal line Вставка горизонтальной линии - + Insert a horizontal line into the empty paragraph from cursor Вставка горизонтальной линии для разграничения параграфов - + Insert/edit math expression Вставить формулу / редактировать формулу - + Expand edit area Распахнуть область редактирования - + Expand tools Развернуть панель инструментов - + Forse save note Быстрое сохранение записи - + Show detached window Показать открепляемое окно - + Attach files Прикрепить файл - + Go to URL or reference Перейти по URL или по ссылке - + Copy selected rows Копировать выделенные строки - + Attach file Прикрепить файл - + Attach file from URL Прикрепить файл по URL - + Add link Добавить линк - + Add link without file copying Добавить линк на файл без копирования самого файла - + Edit file name Изменить имя файла - + Delete file Удалить файл - + Preview file Предпросмотр файла - + Save as... Сохранить как... - + Attach info Информация о прикрепленном файле - + Return to editor Вернуться в редактор - + Set focus to items tree Устновить фокус на дереве - + Set focus to notes table Устновить фокус на списке записей - + Set focus to editor Устновить фокус на редакторе - + Find in base Найти в базе - + Synchronization Синхронизация - + Run synchronization Запуск синхронизации - + Ok ОК - + Print Печать - + Export PDF Экспорт в PDF - + Quit Выход diff --git a/app/src/libraries/ShortcutManager.cpp b/app/src/libraries/ShortcutManager.cpp index 7351df10c..e2d45e6cb 100644 --- a/app/src/libraries/ShortcutManager.cpp +++ b/app/src/libraries/ShortcutManager.cpp @@ -145,6 +145,7 @@ void ShortcutManager::initDefaultKeyTable() defaultKeyTable.insert("editor-tableMergeCells", Data{ QKeySequence(""), tr("Merge cells"), tr("") }); defaultKeyTable.insert("editor-tableSplitCell", Data{ QKeySequence(""), tr("Split cell"), tr("") }); defaultKeyTable.insert("editor-tableProperties", Data{ QKeySequence(""), tr("Table properties"), tr("") }); + defaultKeyTable.insert("editor-openImage", Data{ QKeySequence("Ctrl+Shift+Y"), tr("Open image"), tr("Open selected image in external viewer") }); defaultKeyTable.insert("editor-insertImageFromFile", Data{ QKeySequence("Ctrl+Shift+I"), tr("Insert/edit image"), tr("Insert image from file or edit selected image properties") }); defaultKeyTable.insert("editor-insertHorizontalLine",Data{ QKeySequence("Ctrl+H"), tr("Insert horizontal line"), tr("Insert a horizontal line into the empty paragraph from cursor") }); defaultKeyTable.insert("editor-mathExpression", Data{ QKeySequence("Ctrl+Shift+M"), tr("Insert/edit math expression"), tr("") }); diff --git a/app/src/libraries/wyedit/Editor.cpp b/app/src/libraries/wyedit/Editor.cpp index 7b8a46756..88d4437b7 100644 --- a/app/src/libraries/wyedit/Editor.cpp +++ b/app/src/libraries/wyedit/Editor.cpp @@ -427,8 +427,8 @@ void Editor::setupSignals(void) connect(editorContextMenu, &EditorContextMenu::selectAll, this, &Editor::onSelectAll, Qt::DirectConnection); - connect(editorContextMenu, &EditorContextMenu::contextMenuOpenImageProperties, - imageFormatter, &ImageFormatter::onContextMenuOpenImageProperties, + connect(editorContextMenu, &EditorContextMenu::contextMenuOpenImage, + imageFormatter, &ImageFormatter::onContextMenuOpenImage, Qt::DirectConnection); connect(editorContextMenu, &EditorContextMenu::contextMenuEditImageProperties, imageFormatter, &ImageFormatter::onContextMenuEditImageProperties, @@ -589,6 +589,9 @@ void Editor::setupToolsSignals(void) // Прочие кнопки + connect(editorToolBarAssistant->openImage, &QAction::triggered, + imageFormatter, &ImageFormatter::openImage); + connect(editorToolBarAssistant->insertImageFromFile, &QAction::triggered, imageFormatter, &ImageFormatter::onInsertImageFromFileClicked); diff --git a/app/src/libraries/wyedit/EditorContextMenu.cpp b/app/src/libraries/wyedit/EditorContextMenu.cpp index ee91b6aeb..b2f062428 100644 --- a/app/src/libraries/wyedit/EditorContextMenu.cpp +++ b/app/src/libraries/wyedit/EditorContextMenu.cpp @@ -41,7 +41,7 @@ void EditorContextMenu::setupActions(void) actionPasteAsPlainText=new QAction(this); actionSelectAll=new QAction(this); - actionOpenImageProperties=new QAction(this); + actionOpenImage=new QAction(this); actionEditImageProperties=new QAction(this); actionEditMathExpression=new QAction(this); actionGotoReference=new QAction(this); @@ -64,7 +64,8 @@ void EditorContextMenu::setupShortcuts(void) shortcutManager.initAction("editor-selectAll", actionSelectAll ); // "Умное" действие Открыть изображение - actionOpenImageProperties->setText(tr("Open image")); + shortcutManager.initAction("editor-openImage", actionOpenImage); + actionOpenImage->setText(tr("Open image")); // "Умное" действие Вставить изображение / Редактировать свойства изображения shortcutManager.initAction("editor-insertImageFromFile", actionEditImageProperties ); @@ -150,8 +151,8 @@ void EditorContextMenu::setImageProperties(bool flag) { qDebug() << "In EditorContextMenu::setImageProperties() " << flag; - actionOpenImageProperties->setVisible(flag); - actionOpenImageProperties->setEnabled(flag); + actionOpenImage->setVisible(flag); + actionOpenImage->setEnabled(flag); actionEditImageProperties->setVisible(flag); actionEditImageProperties->setEnabled(flag); @@ -211,7 +212,7 @@ void EditorContextMenu::setupSignals(void) connect(actionPasteAsPlainText,&QAction::triggered, this, &EditorContextMenu::onActionPasteAsPlainText); connect(actionSelectAll, &QAction::triggered, this, &EditorContextMenu::onActionSelectAll); - connect(actionOpenImageProperties,&QAction::triggered, this, &EditorContextMenu::onActionContextMenuOpenImageProperties); + connect(actionOpenImage, &QAction::triggered, this, &EditorContextMenu::onActionContextMenuOpenImage); connect(actionEditImageProperties,&QAction::triggered, this, &EditorContextMenu::onActionContextMenuEditImageProperties); connect(actionEditMathExpression, &QAction::triggered, this, &EditorContextMenu::onActionContextMenuEditMathExpression); connect(actionGotoReference, &QAction::triggered, this, &EditorContextMenu::onActionContextMenuGotoReference); @@ -244,7 +245,7 @@ void EditorContextMenu::setupMenu(void) this->addSeparator(); this->addAction(actionSelectAll); - this->addAction(actionOpenImageProperties); + this->addAction(actionOpenImage); this->addAction(actionEditImageProperties); this->addAction(actionEditMathExpression); this->addAction(actionGotoReference); @@ -307,11 +308,12 @@ void EditorContextMenu::onActionSelectAll() } } -void EditorContextMenu::onActionContextMenuOpenImageProperties() +void EditorContextMenu::onActionContextMenuOpenImage() { update(); - if(actionOpenImageProperties->isEnabled()) { - emit contextMenuOpenImageProperties(); + if(actionOpenImage->isEnabled()) + { + emit contextMenuOpenImage(); } } diff --git a/app/src/libraries/wyedit/EditorContextMenu.h b/app/src/libraries/wyedit/EditorContextMenu.h index 49a590e3a..069f96754 100644 --- a/app/src/libraries/wyedit/EditorContextMenu.h +++ b/app/src/libraries/wyedit/EditorContextMenu.h @@ -34,7 +34,7 @@ class EditorContextMenu : public QMenu void paste(void); void pasteAsPlainText(void); void selectAll(void); - void contextMenuOpenImageProperties(void); + void contextMenuOpenImage(void); void contextMenuEditImageProperties(void); void contextMenuEditMathExpression(void); void contextMenuGotoReference(void); @@ -57,7 +57,7 @@ protected slots: QAction *actionLowercase; // строчный QAction *actionUppercase; // ПРОПИСНЫЕ - QAction *actionOpenImageProperties; + QAction *actionOpenImage; QAction *actionEditImageProperties; QAction *actionEditMathExpression; QAction *actionGotoReference; @@ -75,7 +75,7 @@ protected slots: void onActionPaste(void); void onActionPasteAsPlainText(void); void onActionSelectAll(void); - void onActionContextMenuOpenImageProperties(); + void onActionContextMenuOpenImage(); void onActionContextMenuEditImageProperties(void); void onActionContextMenuEditMathExpression(void); void onActionContextMenuGotoReference(void); diff --git a/app/src/libraries/wyedit/EditorToolBar.cpp b/app/src/libraries/wyedit/EditorToolBar.cpp index bb55d30d5..96481891e 100644 --- a/app/src/libraries/wyedit/EditorToolBar.cpp +++ b/app/src/libraries/wyedit/EditorToolBar.cpp @@ -293,6 +293,12 @@ void EditorToolBar::setupToolBarTools(void) tableProperties->setIcon(QIcon(":/resource/pic/edit_table_properties.svg")); tableProperties->setObjectName("editor_tb_tableProperties"); + // Кнопка открытия изображения + openImage=new QAction(this); + openImage->setIcon(QIcon(":/resource/pic/open_image.svg")); + openImage->setObjectName("editor_tb_openImage"); + + // Кнопка вставки / редактирования свойств изображения insertImageFromFile=new QAction(this); insertImageFromFile->setIcon(QIcon(":/resource/pic/edit_insert_image_from_file.svg")); insertImageFromFile->setObjectName("editor_tb_insertImageFromFile"); @@ -378,7 +384,7 @@ void EditorToolBar::setupShortcuts(void) shortcutManager.initAction("editor-backgroundColor", backgroundColor); // Настраиваются скрытые кнопки действия, а надписи настраиваются для самого виджета - // Скрытые кнопки нужны чтобы работал выбор виджета по грячим кнопкам + // Скрытые кнопки нужны чтобы работал выбор виджета по горячим кнопкам shortcutManager.initAction("editor-fontSelect", fontSelect->toolFocus.getSelectAction() ); fontSelect->setStatusTip( shortcutManager.getFullDescription("editor-fontSelect") ); fontSelect->setToolTip( shortcutManager.getDescriptionWithShortcut("editor-fontSelect") ); @@ -400,6 +406,7 @@ void EditorToolBar::setupShortcuts(void) shortcutManager.initAction("editor-tableMergeCells", tableMergeCells); shortcutManager.initAction("editor-tableSplitCell", tableSplitCell); shortcutManager.initAction("editor-tableProperties", tableProperties); + shortcutManager.initAction("editor-openImage", openImage); shortcutManager.initAction("editor-insertImageFromFile", insertImageFromFile); shortcutManager.initAction("editor-insertHorizontalLine", insertHorizontalLine); shortcutManager.initAction("editor-mathExpression", mathExpression); diff --git a/app/src/libraries/wyedit/EditorToolBar.h b/app/src/libraries/wyedit/EditorToolBar.h index b6865459b..dbd23f48b 100644 --- a/app/src/libraries/wyedit/EditorToolBar.h +++ b/app/src/libraries/wyedit/EditorToolBar.h @@ -82,6 +82,7 @@ class EditorToolBar : public QWidget QAction *tableSplitCell; QAction *tableProperties; + QAction *openImage; QAction *insertImageFromFile; QAction *insertHorizontalLine; QAction *mathExpression; diff --git a/app/src/libraries/wyedit/formatters/ImageFormatter.cpp b/app/src/libraries/wyedit/formatters/ImageFormatter.cpp index 4652fd1e3..b2f483c5a 100644 --- a/app/src/libraries/wyedit/formatters/ImageFormatter.cpp +++ b/app/src/libraries/wyedit/formatters/ImageFormatter.cpp @@ -291,7 +291,7 @@ void ImageFormatter::onInsertImageFromFileClicked(void) // Вызов открытия изображения -void ImageFormatter::onContextMenuOpenImageProperties() +void ImageFormatter::onContextMenuOpenImage() { // Для картинки с формулой свойства изображения редактироваться не должны if(editor->cursorPositionDetector->isMathExpressionSelect() || diff --git a/app/src/libraries/wyedit/formatters/ImageFormatter.h b/app/src/libraries/wyedit/formatters/ImageFormatter.h index a58013bfc..5435bf4f3 100644 --- a/app/src/libraries/wyedit/formatters/ImageFormatter.h +++ b/app/src/libraries/wyedit/formatters/ImageFormatter.h @@ -32,7 +32,7 @@ class ImageFormatter : public Formatter public slots: void onInsertImageFromFileClicked(void); - void onContextMenuOpenImageProperties(); + void onContextMenuOpenImage(); void onContextMenuEditImageProperties(void); void onDownloadImages(const QString html);