forked from qt-creator/qt-creator
		
	FindToolBar: Add support for "lightcolored" panels
The labels need to be polished so that they get the right palette, and the icon needs to be switched from light to dark. Change-Id: I3e37947e741c3d92f3c1ac3bb02e631aa7803f59 Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
		@@ -93,7 +93,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
 | 
			
		||||
 | 
			
		||||
    connect(m_ui.findEdit, SIGNAL(editingFinished()), this, SLOT(invokeResetIncrementalSearch()));
 | 
			
		||||
 | 
			
		||||
    m_ui.close->setIcon(QIcon(QLatin1String(Core::Constants::ICON_BUTTON_CLOSE)));
 | 
			
		||||
    setLightColoredIcon(false);
 | 
			
		||||
    connect(m_ui.close, SIGNAL(clicked()), this, SLOT(hideAndResetFocus()));
 | 
			
		||||
 | 
			
		||||
    m_findCompleter->setModel(m_plugin->findCompletionModel());
 | 
			
		||||
@@ -821,6 +821,12 @@ void FindToolBar::setBackward(bool backward)
 | 
			
		||||
    setFindFlag(FindBackward, backward);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FindToolBar::setLightColoredIcon(bool lightColored)
 | 
			
		||||
{
 | 
			
		||||
    m_ui.close->setIcon(lightColored ? QIcon(QLatin1String(Core::Constants::ICON_DARK_CLOSE))
 | 
			
		||||
                                     : QIcon(QLatin1String(Core::Constants::ICON_BUTTON_CLOSE)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
OptionsPopup::OptionsPopup(QWidget *parent)
 | 
			
		||||
    : QWidget(parent, Qt::Popup)
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -83,6 +83,7 @@ public:
 | 
			
		||||
    void openFindToolBar(bool focus = true);
 | 
			
		||||
    void setUseFakeVim(bool on);
 | 
			
		||||
 | 
			
		||||
    void setLightColoredIcon(bool lightColored);
 | 
			
		||||
public slots:
 | 
			
		||||
    void setBackward(bool backward);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -132,7 +132,7 @@ IFindSupport::Result ItemViewFind::findStep(const QString &txt, FindFlags findFl
 | 
			
		||||
    return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QFrame *ItemViewFind::createSearchableWrapper(QAbstractItemView *treeView, FetchOption option)
 | 
			
		||||
QFrame *ItemViewFind::createSearchableWrapper(QAbstractItemView *treeView, ColorOption lightColored, FetchOption option)
 | 
			
		||||
{
 | 
			
		||||
    QFrame *widget = new QFrame;
 | 
			
		||||
    widget->setFrameStyle(QFrame::NoFrame);
 | 
			
		||||
@@ -140,7 +140,9 @@ QFrame *ItemViewFind::createSearchableWrapper(QAbstractItemView *treeView, Fetch
 | 
			
		||||
    vbox->setMargin(0);
 | 
			
		||||
    vbox->setSpacing(0);
 | 
			
		||||
    vbox->addWidget(treeView);
 | 
			
		||||
    vbox->addWidget(new Core::FindToolBarPlaceHolder(widget));
 | 
			
		||||
    auto placeHolder = new Core::FindToolBarPlaceHolder(widget);
 | 
			
		||||
    placeHolder->setLightColored(lightColored);
 | 
			
		||||
    vbox->addWidget(placeHolder);
 | 
			
		||||
 | 
			
		||||
    Aggregation::Aggregate *agg = new Aggregation::Aggregate;
 | 
			
		||||
    agg->add(treeView);
 | 
			
		||||
 
 | 
			
		||||
@@ -50,6 +50,11 @@ public:
 | 
			
		||||
        FetchMoreWhileSearching
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    enum ColorOption {
 | 
			
		||||
        DarkColored = 0,
 | 
			
		||||
        LightColored = 1
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    explicit ItemViewFind(QAbstractItemView *view, int role = Qt::DisplayRole,
 | 
			
		||||
            FetchOption option = DoNotFetchMoreWhileSearching);
 | 
			
		||||
    virtual ~ItemViewFind();
 | 
			
		||||
@@ -65,9 +70,8 @@ public:
 | 
			
		||||
    Result findIncremental(const QString &txt, FindFlags findFlags);
 | 
			
		||||
    Result findStep(const QString &txt, FindFlags findFlags);
 | 
			
		||||
 | 
			
		||||
    static QFrame *createSearchableWrapper(QAbstractItemView *treeView,
 | 
			
		||||
            FetchOption option = DoNotFetchMoreWhileSearching);
 | 
			
		||||
 | 
			
		||||
    static QFrame *createSearchableWrapper(QAbstractItemView *treeView, ColorOption lightColored = DarkColored,
 | 
			
		||||
                                           FetchOption option = DoNotFetchMoreWhileSearching);
 | 
			
		||||
private:
 | 
			
		||||
    Result find(const QString &txt, FindFlags findFlags,
 | 
			
		||||
                bool startFromCurrentIndex, bool *wrapped);
 | 
			
		||||
 
 | 
			
		||||
@@ -28,18 +28,18 @@
 | 
			
		||||
****************************************************************************/
 | 
			
		||||
 | 
			
		||||
#include "findplaceholder.h"
 | 
			
		||||
#include "find/findtoolbar.h"
 | 
			
		||||
 | 
			
		||||
#include <extensionsystem/pluginmanager.h>
 | 
			
		||||
 | 
			
		||||
#include <QVBoxLayout>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
using namespace Core;
 | 
			
		||||
 | 
			
		||||
FindToolBarPlaceHolder *FindToolBarPlaceHolder::m_current = 0;
 | 
			
		||||
 | 
			
		||||
FindToolBarPlaceHolder::FindToolBarPlaceHolder(QWidget *owner, QWidget *parent)
 | 
			
		||||
    : QWidget(parent), m_owner(owner), m_subWidget(0)
 | 
			
		||||
    : QWidget(parent), m_owner(owner), m_subWidget(0), m_lightColored(false)
 | 
			
		||||
{
 | 
			
		||||
    setLayout(new QVBoxLayout);
 | 
			
		||||
    setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
 | 
			
		||||
@@ -77,15 +77,18 @@ bool FindToolBarPlaceHolder::isUsedByWidget(QWidget *widget)
 | 
			
		||||
    return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FindToolBarPlaceHolder::setWidget(QWidget *widget)
 | 
			
		||||
void FindToolBarPlaceHolder::setWidget(Internal::FindToolBar *widget)
 | 
			
		||||
{
 | 
			
		||||
    if (m_subWidget) {
 | 
			
		||||
        m_subWidget->setVisible(false);
 | 
			
		||||
        m_subWidget->setParent(0);
 | 
			
		||||
    }
 | 
			
		||||
    m_subWidget = widget;
 | 
			
		||||
    if (m_subWidget)
 | 
			
		||||
    if (m_subWidget) {
 | 
			
		||||
        m_subWidget->setLightColored(m_lightColored);
 | 
			
		||||
        m_subWidget->setLightColoredIcon(m_lightColored);
 | 
			
		||||
        layout()->addWidget(m_subWidget);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
FindToolBarPlaceHolder *FindToolBarPlaceHolder::getCurrent()
 | 
			
		||||
@@ -97,3 +100,13 @@ void FindToolBarPlaceHolder::setCurrent(FindToolBarPlaceHolder *placeHolder)
 | 
			
		||||
{
 | 
			
		||||
    m_current = placeHolder;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void FindToolBarPlaceHolder::setLightColored(bool lightColored)
 | 
			
		||||
{
 | 
			
		||||
    m_lightColored = lightColored;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool FindToolBarPlaceHolder::isLightColored() const
 | 
			
		||||
{
 | 
			
		||||
    return m_lightColored;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,7 @@
 | 
			
		||||
#include <QWidget>
 | 
			
		||||
 | 
			
		||||
namespace Core {
 | 
			
		||||
namespace Internal { class FindToolBar; }
 | 
			
		||||
 | 
			
		||||
class CORE_EXPORT FindToolBarPlaceHolder : public QWidget
 | 
			
		||||
{
 | 
			
		||||
@@ -46,14 +47,18 @@ public:
 | 
			
		||||
    QWidget *owner() const;
 | 
			
		||||
    bool isUsedByWidget(QWidget *widget);
 | 
			
		||||
 | 
			
		||||
    void setWidget(QWidget *widget);
 | 
			
		||||
    void setWidget(Internal::FindToolBar *widget);
 | 
			
		||||
 | 
			
		||||
    static FindToolBarPlaceHolder *getCurrent();
 | 
			
		||||
    static void setCurrent(FindToolBarPlaceHolder *placeHolder);
 | 
			
		||||
 | 
			
		||||
    void setLightColored(bool lightColored);
 | 
			
		||||
    bool isLightColored() const;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    QWidget *m_owner;
 | 
			
		||||
    QPointer<QWidget> m_subWidget;
 | 
			
		||||
    QPointer<Internal::FindToolBar> m_subWidget;
 | 
			
		||||
    bool m_lightColored;
 | 
			
		||||
    static FindToolBarPlaceHolder *m_current;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user