Browse Source

add tool bar button for Universal Entry

Le Tan 7 years ago
parent
commit
a6087d98a6
4 changed files with 28 additions and 10 deletions
  1. 11 0
      src/resources/icons/universal_entry_tb.svg
  2. 15 9
      src/vmainwindow.cpp
  3. 1 0
      src/vnote.qrc
  4. 1 1
      src/vuniversalentry.cpp

+ 11 - 0
src/resources/icons/universal_entry_tb.svg

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 width="512px" height="512px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
+<path style="fill:#000000" d="M256,32C132.3,32,32,132.3,32,256c0,123.7,100.3,224,224,224c123.7,0,224-100.3,224-224C480,132.3,379.7,32,256,32z
+	 M391.8,391.8c-32.5,32.5-74.6,51.9-119.8,55.6L264,384h-16l-7.9,63.3c-45.3-3.7-87.4-23.1-119.8-55.6
+	c-32.5-32.5-51.9-74.6-55.6-119.8L128,264v-16l-63.3-7.9c3.7-45.3,23.1-87.4,55.6-119.8c32.5-32.5,74.6-51.9,119.8-55.6L248,128h16
+	l7.9-63.3c45.3,3.7,87.4,23.1,119.8,55.6c32.5,32.5,51.9,74.6,55.6,119.8L384,248v16l63.3,7.9C443.6,317.2,424.2,359.3,391.8,391.8z
+	"/>
+</svg>

+ 15 - 9
src/vmainwindow.cpp

@@ -647,8 +647,23 @@ void VMainWindow::initNoteToolBar(QSize p_iconSize)
     connect(flashPageAct, &QAction::triggered,
             this, &VMainWindow::openFlashPage);
 
+    QAction *universalEntryAct = new QAction(VIconUtils::toolButtonIcon(":/resources/icons/universal_entry_tb.svg"),
+                                             tr("Universal Entry"),
+                                             this);
+    universalEntryAct->setStatusTip(tr("Activate Universal Entry"));
+    keySeq = g_config->getShortcutKeySequence("UniversalEntry");
+    seq = QKeySequence(keySeq);
+    if (!seq.isEmpty()) {
+        universalEntryAct->setText(tr("Universal Entry\t%1").arg(VUtils::getShortcutText(keySeq)));
+        universalEntryAct->setShortcut(seq);
+    }
+
+    connect(universalEntryAct, &QAction::triggered,
+            this, &VMainWindow::activateUniversalEntry);
+
     noteToolBar->addWidget(m_attachmentBtn);
     noteToolBar->addAction(flashPageAct);
+    noteToolBar->addAction(universalEntryAct);
 }
 
 void VMainWindow::initFileToolBar(QSize p_iconSize)
@@ -2849,15 +2864,6 @@ void VMainWindow::initShortcuts()
         connect(closeNoteShortcut, &QShortcut::activated,
                 this, &VMainWindow::closeCurrentFile);
     }
-
-    keySeq = g_config->getShortcutKeySequence("UniversalEntry");
-    qDebug() << "set UniversalEntry shortcut to" << keySeq;
-    if (!keySeq.isEmpty()) {
-        QShortcut *ueShortcut = new QShortcut(QKeySequence(keySeq), this);
-        ueShortcut->setContext(Qt::WidgetWithChildrenShortcut);
-        connect(ueShortcut, &QShortcut::activated,
-                this, &VMainWindow::activateUniversalEntry);
-    }
 }
 
 void VMainWindow::openFlashPage()

+ 1 - 0
src/vnote.qrc

@@ -209,5 +209,6 @@
         <file>resources/themes/v_moonlight/checkbox_unchecked_disabled.svg</file>
         <file>resources/themes/v_moonlight/radiobutton_checked_disabled.svg</file>
         <file>resources/themes/v_moonlight/radiobutton_unchecked_disabled.svg</file>
+        <file>resources/icons/universal_entry_tb.svg</file>
     </qresource>
 </RCC>

+ 1 - 1
src/vuniversalentry.cpp

@@ -103,7 +103,7 @@ VUniversalEntry::VUniversalEntry(QWidget *p_parent)
 void VUniversalEntry::setupUI()
 {
     m_cmdEdit = new VMetaWordLineEdit(this);
-    m_cmdEdit->setPlaceholderText(tr("Welcome to Universal Entry"));
+    m_cmdEdit->setPlaceholderText(tr("Universal Entry, reach anything by typing"));
     m_cmdEdit->setCtrlKEnabled(false);
     m_cmdEdit->setCtrlEEnabled(false);
     connect(m_cmdEdit, &VMetaWordLineEdit::textEdited,