On Freitag, 19. Oktober 2012 03:38:36 CEST, Jan Kundrát wrote:
> Anyway, there's supposed to 
> be an ExLineEdit class in Qt4's demo browser application; this 
> class should support embedding icons (or buttons?) in a 
> QLineEdit. That would look better, in my opinion. Would you like 
> to try to use it?
Icons, I'd say.
This is not hard to do, but unfortunately the AutoRaise buttons do not look 
that great in oxygen & qtcurve, ahve a look.

Cheers,
Thomas
diff --git a/src/Gui/MessageListWidget.cpp b/src/Gui/MessageListWidget.cpp
index ad76bd5..7ff1bc8 100644
--- a/src/Gui/MessageListWidget.cpp
+++ b/src/Gui/MessageListWidget.cpp
@@ -21,6 +21,7 @@
 
 #include "MessageListWidget.h"
 #include <QAction>
+#include <QApplication>
 #include <QCheckBox>
 #include <QFrame>
 #include <QLineEdit>
@@ -50,6 +51,7 @@ MessageListWidget::MessageListWidget(QWidget *parent) :
     connect(m_quickSearchText, SIGNAL(cursorPositionChanged(int, int)), this, SLOT(slotUpdateSearchCursor()));
 
     m_searchOptions = new QToolButton(this);
+    m_searchOptions->setAutoRaise(true);
     m_searchOptions->setPopupMode(QToolButton::InstantPopup);
     m_searchOptions->setText("*");
     m_searchOptions->setIcon(loadIcon(QLatin1String("edit-find")));
@@ -91,13 +93,20 @@ MessageListWidget::MessageListWidget(QWidget *parent) :
     m_searchOptions->setMenu(optionsMenu);
     connect (optionsMenu, SIGNAL(aboutToShow()), SLOT(slotDeActivateSimpleSearch()));
 
-    QHBoxLayout *hlayout = new QHBoxLayout;
-    hlayout->addWidget(m_quickSearchText);
+    QHBoxLayout *hlayout = new QHBoxLayout(m_quickSearchText);
+    hlayout->setContentsMargins(0, 0, 0, 0);
     hlayout->addWidget(m_searchOptions);
+    hlayout->addStretch();
+    hlayout->activate(); // this processes the layout and ensures the toolbutton has it's final dimensions
+    if (qApp->keyboardInputDirection() == Qt::LeftToRight)
+        m_quickSearchText->setTextMargins(m_searchOptions->width(), 0, 0, 0);
+    else // ppl. in N Africa and the middle east write the wrong direction...
+        m_quickSearchText->setTextMargins(0, 0, m_searchOptions->width(), 0);
+    m_searchOptions->setCursor(Qt::ArrowCursor); // inherits I-Beam from lineedit otherwise
 
     QVBoxLayout *layout = new QVBoxLayout(this);
     layout->setSpacing(0);
-    layout->addLayout(hlayout);
+    layout->addWidget(m_quickSearchText);
     layout->addWidget(tree);
 
     m_searchResetTimer = new QTimer(this);

Reply via email to