浏览代码

MarkdownEditor: fix

1. Fix issue that duplicated images would not be processed when copied;
2. Add suffix `*.nasm` to Intel ASM syntax.
Le Tan 3 年之前
父节点
当前提交
2d4d4609da

+ 1 - 1
libs/vtextedit

@@ -1 +1 @@
-Subproject commit 08b440d3045c944a8a6d7f8945a197ff56dcec82
+Subproject commit 6d924bef99de572016c34311063b50482b5851c6

+ 1 - 1
src/data/extra/syntax-highlighting/syntax/nasm.xml

@@ -40,7 +40,7 @@ You should have received a copy of the GNU General Public License along
 with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 -->
-<language name="Intel x86 (NASM)" section="Assembler" version="3" kateversion="2.3" extensions="*.asm" mimetype="" author="Nicola Gigante ([email protected])" license="GPLv2+">
+<language name="Intel x86 (NASM)" section="Assembler" version="3" kateversion="2.3" extensions="*.asm;*.nasm" mimetype="" author="Nicola Gigante ([email protected])" license="GPLv2+">
   <highlighting>
     <list name="registers">
       <!-- General purpose registers -->

+ 2 - 2
src/utils/fileutils.cpp

@@ -254,7 +254,8 @@ bool FileUtils::isText(const QString &p_filePath)
 {
     QMimeDatabase mimeDatabase;
     auto mimeType = mimeDatabase.mimeTypeForFile(p_filePath);
-    if (mimeType.name().startsWith(QStringLiteral("text/"))) {
+    const auto name = mimeType.name();
+    if (name.startsWith(QStringLiteral("text/")) || name == QStringLiteral("application/x-zerosize")) {
         return true;
     }
 
@@ -345,7 +346,6 @@ QString FileUtils::generateFileNameWithSequence(const QString &p_folderPath,
 void FileUtils::removeEmptyDir(const QString &p_dirPath)
 {
     QDir dir(p_dirPath);
-    qDebug() << "removeEmptyDir" << p_dirPath << dir.isEmpty();
     if (dir.isEmpty()) {
         return;
     }

+ 12 - 0
src/widgets/editors/markdowneditor.cpp

@@ -16,6 +16,7 @@
 #include <QTimer>
 #include <QBuffer>
 #include <QPainter>
+#include <QHash>
 
 #include <vtextedit/markdowneditorconfig.h>
 #include <vtextedit/previewmgr.h>
@@ -1396,12 +1397,22 @@ void MarkdownEditor::uploadImagesToImageHost()
     proDlg.setWindowModality(Qt::WindowModal);
     proDlg.setWindowTitle(tr("Upload Images To Image Host"));
 
+    QHash<QString, QString> uploadedImages;
+
     int cnt = 0;
     auto cursor = m_textEdit->textCursor();
     cursor.beginEditBlock();
     for (int i = 0; i < images.size(); ++i) {
         const auto &link = images[i];
 
+        auto it = uploadedImages.find(link.m_path);
+        if (it != uploadedImages.end()) {
+            cursor.setPosition(link.m_urlInLinkPos);
+            cursor.setPosition(link.m_urlInLinkPos + link.m_urlInLink.size(), QTextCursor::KeepAnchor);
+            cursor.insertText(it.value());
+            continue;
+        }
+
         proDlg.setValue(i + 1);
         if (proDlg.wasCanceled()) {
             break;
@@ -1444,6 +1455,7 @@ void MarkdownEditor::uploadImagesToImageHost()
         cursor.setPosition(link.m_urlInLinkPos);
         cursor.setPosition(link.m_urlInLinkPos + link.m_urlInLink.size(), QTextCursor::KeepAnchor);
         cursor.insertText(targetUrl);
+        uploadedImages.insert(link.m_path, targetUrl);
         ++cnt;
     }
     cursor.endEditBlock();

+ 1 - 0
src/widgets/findandreplacewidget.cpp

@@ -77,6 +77,7 @@ void FindAndReplaceWidget::setupUI()
 
         m_findLineEdit = WidgetsFactory::createLineEdit(this);
         m_findLineEdit->setPlaceholderText(tr("Search"));
+        m_findLineEdit->setClearButtonEnabled(true);
         connect(m_findLineEdit, &QLineEdit::textChanged,
                 m_findTextTimer, QOverload<>::of(&QTimer::start));
 

+ 1 - 0
src/widgets/searchpanel.cpp

@@ -78,6 +78,7 @@ void SearchPanel::setupUI()
     m_keywordComboBox->setEditable(true);
     m_keywordComboBox->setLineEdit(WidgetsFactory::createLineEdit(mainWidget));
     m_keywordComboBox->lineEdit()->setProperty(PropertyDefs::c_embeddedLineEdit, true);
+    m_keywordComboBox->lineEdit()->setClearButtonEnabled(true);
     m_keywordComboBox->completer()->setCaseSensitivity(Qt::CaseSensitive);
     connect(m_keywordComboBox->lineEdit(), &QLineEdit::returnPressed,
             this, [this]() {

+ 6 - 2
src/widgets/viewwindow.cpp

@@ -1162,9 +1162,13 @@ void ViewWindow::replaceAll(const QString &p_text, FindOptions p_options, const
 
 void ViewWindow::showFindResult(const QStringList &p_texts, int p_totalMatches, int p_currentMatchIndex)
 {
+    if (p_texts.isEmpty() || p_texts[0].isEmpty()) {
+        showMessage(QString());
+        return;
+    }
+
     if (p_totalMatches == 0) {
-        showMessage(tr("Pattern not found: %1%2").arg(p_texts.isEmpty() ? QString() : p_texts[0],
-                                                      p_texts.size() > 1 ? tr(" [+]"): QString()));
+        showMessage(tr("Pattern not found: %1").arg(p_texts.join(QStringLiteral("; "))));
     } else {
         showMessage(tr("Match found: %1/%2").arg(p_currentMatchIndex + 1).arg(p_totalMatches));
     }