- add label and remove subclassed SearchLineEdit

- put ShortcutLineEdit in namespace lyx::frontend
- additional dialog layout tweaks

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21254 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Edwin Leuven 2007-10-29 08:56:30 +00:00
parent cff2f03285
commit 608236c0db
6 changed files with 131 additions and 159 deletions

View File

@ -36,6 +36,9 @@ using lyx::KeySequence;
using lyx::KeyModifier;
using lyx::toqstr;
namespace lyx {
namespace frontend {
ShortcutLineEdit::ShortcutLineEdit(QWidget * parent)
: QLineEdit(parent), keysequence_()
{
@ -128,25 +131,7 @@ void ShortcutLineEdit::appendToSequence(QKeyEvent * e)
keysequence_.addkey(sym, mod, lyx::NoModifier);
}
QString const SearchLineEdit::hintMessage() const
{
return toqstr("Search ...");
}
void SearchLineEdit::focusInEvent(QFocusEvent * e)
{
if (text() == hintMessage())
clear();
}
void SearchLineEdit::focusOutEvent(QFocusEvent * e)
{
if (text().isEmpty())
setText(hintMessage());
}
} // namespace frontend
} // namespace lyx
#include "CustomizedWidgets_moc.cpp"

View File

@ -19,6 +19,9 @@
class QEvent;
class QKeyEvent;
namespace lyx {
namespace frontend {
/**
* A lineedit for inputting shortcuts
*/
@ -38,20 +41,7 @@ private:
bool has_cursor_;
};
/**
* A lineedit that displays a hint message when there is no
* text and not under focus.
*/
class SearchLineEdit : public QLineEdit {
Q_OBJECT
public:
QString const hintMessage() const;
SearchLineEdit(QWidget * parent) : QLineEdit(parent) {}
protected Q_SLOTS:
void focusInEvent(QFocusEvent * e);
void focusOutEvent(QFocusEvent * e);
};
} // namespace frontend
} // namespace lyx
#endif // CUSTOMIZEDWIDGETS_H

View File

@ -2021,10 +2021,8 @@ void PrefShortcuts::on_removePB_pressed()
}
void PrefShortcuts::on_searchLE_textChanged()
void PrefShortcuts::on_searchLE_textEdited()
{
if (searchLE->text() == searchLE->hintMessage())
return;
if (searchLE->text().isEmpty()) {
// show all hidden items
QTreeWidgetItemIterator it(shortcutsTW, QTreeWidgetItemIterator::Hidden);

View File

@ -382,7 +382,7 @@ public Q_SLOTS:
void select_bind();
void on_newPB_pressed();
void on_removePB_pressed();
void on_searchLE_textChanged();
void on_searchLE_textEdited();
///
void on_shortcutsTW_itemSelectionChanged();
void shortcut_okPB_pressed();

View File

@ -1,4 +1,7 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>PrefShortcuts</class>
<widget class="QWidget" name="PrefShortcuts" >
<property name="geometry" >
@ -6,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>409</width>
<height>418</height>
<height>494</height>
</rect>
</property>
<property name="sizePolicy" >
@ -27,58 +30,79 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="6" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<item row="1" column="0" colspan="2" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
<property name="spacing" >
<number>6</number>
</property>
<property name="sizeHint" >
<size>
<width>51</width>
<height>83</height>
</size>
</property>
</spacer>
<item>
<widget class="QLabel" name="shortcutsLBL" >
<property name="text" >
<string>Show commands containing:</string>
</property>
<property name="buddy" >
<cstring>searchLE</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="searchLE" />
</item>
</layout>
</item>
<item row="4" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<item row="1" column="2" >
<widget class="QPushButton" name="pushButton" >
<property name="text" >
<string>&lt;- Clea&amp;r</string>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</widget>
</item>
<item row="3" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="sizeHint" >
<size>
<width>51</width>
<height>83</height>
</size>
<property name="spacing" >
<number>6</number>
</property>
</spacer>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="removePB" >
<property name="text" >
<string>&amp;Remove</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="newPB" >
<property name="text" >
<string>New</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="0" colspan="3" >
<widget class="QTreeWidget" name="shortcutsTW" />
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="bindFileED" />
</item>
<item rowspan="5" row="2" column="0" colspan="2" >
<widget class="QTreeWidget" name="shortcutsTW" />
</item>
<item row="3" column="2" >
<widget class="QPushButton" name="removePB" >
<property name="text" >
<string>Remove</string>
</property>
</widget>
</item>
<item row="2" column="2" >
<widget class="QPushButton" name="newPB" >
<property name="text" >
<string>New</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QPushButton" name="bindFilePB" >
<property name="text" >
@ -96,44 +120,37 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="QLabel" name="shortcutsLBL" >
<property name="text" >
<string>Shortcuts:</string>
</property>
</widget>
</item>
<item row="5" column="2" >
<widget class="SearchLineEdit" name="searchLE" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>Search ...</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>SearchLineEdit</class>
<extends>QLineEdit</extends>
<header>CustomizedWidgets.h</header>
</customwidget>
</customwidgets>
<pixmapfunction></pixmapfunction>
<tabstops>
<tabstop>bindFileED</tabstop>
<tabstop>bindFilePB</tabstop>
<tabstop>searchLE</tabstop>
<tabstop>shortcutsTW</tabstop>
<tabstop>removePB</tabstop>
<tabstop>newPB</tabstop>
</tabstops>
<includes>
<include location="local" >qt_helpers.h</include>
</includes>
<resources/>
<connections/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>searchLE</receiver>
<slot>clear()</slot>
<hints>
<hint type="sourcelabel" >
<x>349</x>
<y>52</y>
</hint>
<hint type="destinationlabel" >
<x>265</x>
<y>52</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -1,22 +1,17 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>shortcutUi</class>
<widget class="QDialog" name="shortcutUi" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>277</width>
<height>147</height>
<width>348</width>
<height>106</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle" >
<string>Edit shortcut</string>
</property>
@ -30,16 +25,21 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="1" >
<widget class="lyx::frontend::ShortcutLineEdit" name="shortcutLE" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="toolTip" >
<string>Enter BibTeX database name</string>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QLineEdit" name="lfunLE" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>7</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Enter BibTeX database name</string>
</property>
@ -55,13 +55,6 @@
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="shortcutLBL" >
<property name="text" >
<string>Shortcut</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="lfunLBL" >
<property name="text" >
@ -69,6 +62,13 @@
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="shortcutLBL" >
<property name="text" >
<string>Shortcut</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
@ -118,34 +118,16 @@
</item>
</layout>
</item>
<item row="1" column="1" >
<widget class="ShortcutLineEdit" name="shortcutLE" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>13</hsizetype>
<vsizetype>13</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip" >
<string>Enter BibTeX database name</string>
</property>
<property name="text" >
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<customwidgets>
<customwidget>
<class>ShortcutLineEdit</class>
<class>lyx::frontend::ShortcutLineEdit</class>
<extends>QLineEdit</extends>
<header>CustomizedWidgets.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
</customwidgets>
<tabstops>