[kde-doc-english] [kde-runtime] kurifilter-plugins/ikws: Add insert query placeholder button to search provider dialog

Maarten De Meyer de.meyer.maarten at gmail.com
Wed May 29 14:41:22 UTC 2013


Git commit 1c0621835f5670f722db9d8f6cf579ee7098e93e by Maarten De Meyer.
Committed on 29/05/2013 at 16:29.
Pushed by demeyer into branch 'master'.

Add insert query placeholder button to search provider dialog

Add a 'Insert query placeholder' button to the add/modify web shortcut
dialog. Clicking this button inserts \{@} in the shortcut URL lineEdit.

This makes it easy to add new web shortcuts.
Users don't have to remember and type the query placeholder.
BUG: 146879
FIXED-IN: 4.11
REVIEW: 110423
GUI: Button added to the add web shortcuts dialog.

M  +8    -2    kurifilter-plugins/ikws/searchproviderdlg.cpp
M  +1    -0    kurifilter-plugins/ikws/searchproviderdlg.h
M  +74   -41   kurifilter-plugins/ikws/searchproviderdlg_ui.ui

http://commits.kde.org/kde-runtime/1c0621835f5670f722db9d8f6cf579ee7098e93e

diff --git a/kurifilter-plugins/ikws/searchproviderdlg.cpp b/kurifilter-plugins/ikws/searchproviderdlg.cpp
index 5f40f5f..3c50d50 100644
--- a/kurifilter-plugins/ikws/searchproviderdlg.cpp
+++ b/kurifilter-plugins/ikws/searchproviderdlg.cpp
@@ -42,6 +42,7 @@ SearchProviderDialog::SearchProviderDialog(SearchProvider *provider, QList<Searc
     connect(m_dlg.leQuery,     SIGNAL(textChanged(QString)), SLOT(slotChanged()));
     connect(m_dlg.leShortcut,  SIGNAL(textChanged(QString)), SLOT(slotChanged()));
     connect(m_dlg.leShortcut,  SIGNAL(textChanged(QString)), SLOT(shortcutsChanged(QString)));
+    connect(m_dlg.pbPaste,     SIGNAL(clicked()),            SLOT(pastePlaceholder()));
 
     // Data init
     m_providers = providers;
@@ -151,10 +152,10 @@ void SearchProviderDialog::slotButtonClicked(int button) {
         const QString charset = (m_dlg.cbCharset->currentIndex() ? m_dlg.cbCharset->currentText().trimmed() : QString());
 
         m_provider->setDirty((name != m_provider->name() || query != m_provider->query() ||
-                              keys != m_provider->keys() || charset != m_provider->charset()));        
+                              keys != m_provider->keys() || charset != m_provider->charset()));
         m_provider->setName(name);
         m_provider->setQuery(query);
-        m_provider->setKeys(keys); 
+        m_provider->setKeys(keys);
         m_provider->setCharset(charset);
         KDialog::accept();
     } else {
@@ -162,4 +163,9 @@ void SearchProviderDialog::slotButtonClicked(int button) {
     }
 }
 
+void SearchProviderDialog::pastePlaceholder() {
+    m_dlg.leQuery->insert("\\{@}");
+    m_dlg.leQuery->setFocus();
+}
+
 #include "searchproviderdlg.moc"
diff --git a/kurifilter-plugins/ikws/searchproviderdlg.h b/kurifilter-plugins/ikws/searchproviderdlg.h
index e931e11..562ea41 100644
--- a/kurifilter-plugins/ikws/searchproviderdlg.h
+++ b/kurifilter-plugins/ikws/searchproviderdlg.h
@@ -37,6 +37,7 @@ public:
 protected Q_SLOTS:
     void slotChanged();
     void shortcutsChanged(const QString& newShorthands);
+    void pastePlaceholder();
     virtual void slotButtonClicked(int button);
 
 private:
diff --git a/kurifilter-plugins/ikws/searchproviderdlg_ui.ui b/kurifilter-plugins/ikws/searchproviderdlg_ui.ui
index d75ac5b..7592909 100644
--- a/kurifilter-plugins/ikws/searchproviderdlg_ui.ui
+++ b/kurifilter-plugins/ikws/searchproviderdlg_ui.ui
@@ -10,15 +10,21 @@
     <height>143</height>
    </rect>
   </property>
-  <layout class="QFormLayout" name="formLayout">
-   <item row="0" column="0">
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="1">
     <widget class="QLabel" name="lbName">
      <property name="whatsThis">
       <string>Enter the human-readable name of the search provider here.</string>
      </property>
+     <property name="layoutDirection">
+      <enum>Qt::LeftToRight</enum>
+     </property>
      <property name="text">
       <string>Shortcut &name:</string>
      </property>
+     <property name="alignment">
+      <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+     </property>
      <property name="wordWrap">
       <bool>false</bool>
      </property>
@@ -27,17 +33,7 @@
      </property>
     </widget>
    </item>
-   <item row="0" column="1">
-    <widget class="KLineEdit" name="leName">
-     <property name="toolTip">
-      <string><html><head/><body><p>Enter the human-readable name of the web shortcut here.</p></body></html></string>
-     </property>
-     <property name="whatsThis">
-      <string><html><head/><body><p>Enter the human-readable name of the web shortcut here.</p></body></html></string>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="0">
+   <item row="2" column="1" alignment="Qt::AlignRight">
     <widget class="QLabel" name="lbQuery">
      <property name="whatsThis">
       <string><qt>
@@ -45,6 +41,9 @@ Enter the URI that is used to perform a search on the search engine here.<br/
 Recommended is \{@}, since it removes all query variables (name=value) from the resulting string, whereas \{0} will be substituted with the unmodified query string.<br/>You can use \{1} ... \{n} to specify certain words from the query and \{name} to specify a value given by 'name=value' in the user query.<br/>In addition it is possible to specify multiple references (names, numbers and strings) at once (\{name1,name2,...,"string"}).<br/>The first matching value (from the left) will be used as the substitution value for the resulting URI.<br/>A quoted string can be used as the default value if nothing matches from the left of the reference list.
 </qt></string>
      </property>
+     <property name="layoutDirection">
+      <enum>Qt::LeftToRight</enum>
+     </property>
      <property name="text">
       <string>Shortcut &URL:</string>
      </property>
@@ -56,7 +55,7 @@ Recommended is \{@}, since it removes all query variables (name=value) from the
      </property>
     </widget>
    </item>
-   <item row="1" column="1">
+   <item row="2" column="2">
     <widget class="KLineEdit" name="leQuery">
      <property name="toolTip">
       <string><qt>
@@ -75,25 +74,20 @@ Recommended is \{@}, since it removes all query variables (name=value) from the
      </property>
     </widget>
    </item>
-   <item row="2" column="0">
-    <widget class="QLabel" name="lbShortcut">
-     <property name="whatsThis">
-      <string><qt>
-The shortcuts entered here can be used as a pseudo-URI scheme in KDE. For example, the shortcut <b>av</b> can be used as in <b>av</b>:<b>my search</b>
-</qt></string>
-     </property>
-     <property name="text">
-      <string>&Shortcuts:</string>
-     </property>
-     <property name="wordWrap">
-      <bool>true</bool>
+   <item row="5" column="2" colspan="2">
+    <widget class="KComboBox" name="cbCharset">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
      </property>
-     <property name="buddy">
-      <cstring>leShortcut</cstring>
+     <property name="whatsThis">
+      <string>Select the character set that will be used to encode your search query.</string>
      </property>
     </widget>
    </item>
-   <item row="2" column="1">
+   <item row="3" column="2" colspan="2">
     <widget class="KLineEdit" name="leShortcut">
      <property name="toolTip">
       <string><qt>
@@ -110,7 +104,35 @@ The shortcuts entered here can be used as a pseudo-URI scheme in KDE. For exampl
      </property>
     </widget>
    </item>
-   <item row="3" column="0">
+   <item row="0" column="2" colspan="2">
+    <widget class="KLineEdit" name="leName">
+     <property name="toolTip">
+      <string><html><head/><body><p>Enter the human-readable name of the web shortcut here.</p></body></html></string>
+     </property>
+     <property name="whatsThis">
+      <string><html><head/><body><p>Enter the human-readable name of the web shortcut here.</p></body></html></string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="1" alignment="Qt::AlignRight">
+    <widget class="QLabel" name="lbShortcut">
+     <property name="whatsThis">
+      <string><qt>
+The shortcuts entered here can be used as a pseudo-URI scheme in KDE. For example, the shortcut <b>av</b> can be used as in <b>av</b>:<b>my search</b>
+</qt></string>
+     </property>
+     <property name="text">
+      <string>&Shortcuts:</string>
+     </property>
+     <property name="wordWrap">
+      <bool>true</bool>
+     </property>
+     <property name="buddy">
+      <cstring>leShortcut</cstring>
+     </property>
+    </widget>
+   </item>
+   <item row="5" column="1" alignment="Qt::AlignRight">
     <widget class="QLabel" name="lbCharset">
      <property name="whatsThis">
       <string>Select the character set that will be used to encode your search query</string>
@@ -126,24 +148,29 @@ The shortcuts entered here can be used as a pseudo-URI scheme in KDE. For exampl
      </property>
     </widget>
    </item>
-   <item row="3" column="1">
-    <widget class="KComboBox" name="cbCharset">
-     <property name="sizePolicy">
-      <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
-       <horstretch>0</horstretch>
-       <verstretch>0</verstretch>
-      </sizepolicy>
+   <item row="6" column="1" colspan="3">
+    <widget class="QLabel" name="noteLabel">
+     <property name="toolTip">
+      <string>Insert query placeholder</string>
      </property>
-     <property name="whatsThis">
-      <string>Select the character set that will be used to encode your search query.</string>
+     <property name="text">
+      <string/>
      </property>
     </widget>
    </item>
-   <item row="4" column="0" colspan="2">
-    <widget class="QLabel" name="noteLabel">
+   <item row="2" column="3">
+    <widget class="QPushButton" name="pbPaste">
+     <property name="toolTip">
+      <string>Insert query placeholder</string>
+     </property>
      <property name="text">
       <string/>
      </property>
+     <property name="icon">
+      <iconset theme="edit-paste">
+       <normaloff/>
+      </iconset>
+     </property>
     </widget>
    </item>
   </layout>
@@ -160,6 +187,12 @@ The shortcuts entered here can be used as a pseudo-URI scheme in KDE. For exampl
    <header>klineedit.h</header>
   </customwidget>
  </customwidgets>
+ <tabstops>
+  <tabstop>leName</tabstop>
+  <tabstop>leQuery</tabstop>
+  <tabstop>leShortcut</tabstop>
+  <tabstop>cbCharset</tabstop>
+ </tabstops>
  <includes>
   <include location="local">klineedit.h</include>
   <include location="local">kcombobox.h</include>


More information about the kde-doc-english mailing list