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:
Daniel Teske
2014-08-11 17:31:27 +02:00
parent b7f1c93495
commit 7d5d9b4d0f
13 changed files with 58 additions and 18 deletions

View File

@@ -54,7 +54,11 @@ bool StyledBar::isSingleRow() const
void StyledBar::setLightColored(bool lightColored) void StyledBar::setLightColored(bool lightColored)
{ {
if (isLightColored() == lightColored)
return;
setProperty("lightColored", lightColored); setProperty("lightColored", lightColored);
foreach (QWidget *childWidget, findChildren<QWidget *>())
childWidget->style()->polish(childWidget);
} }
bool StyledBar::isLightColored() const bool StyledBar::isLightColored() const

View File

@@ -99,7 +99,8 @@ NavigationWidget::NavigationWidget(QWidget *parent) :
treeView = new ::Utils::NavigationTreeView(this); treeView = new ::Utils::NavigationTreeView(this);
treeView->setEditTriggers(QAbstractItemView::NoEditTriggers); treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
verticalLayout->addWidget(Core::ItemViewFind::createSearchableWrapper( verticalLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(
treeView, Core::ItemViewFind::FetchMoreWhileSearching)); treeView, Core::ItemViewFind::DarkColored,
Core::ItemViewFind::FetchMoreWhileSearching));
// tree model // tree model
treeModel = new TreeItemModel(this); treeModel = new TreeItemModel(this);

View File

@@ -346,7 +346,8 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
frame->setFrameStyle(QFrame::StyledPanel); frame->setFrameStyle(QFrame::StyledPanel);
QVBoxLayout *frameLayout = new QVBoxLayout(frame); QVBoxLayout *frameLayout = new QVBoxLayout(frame);
frameLayout->setMargin(0); frameLayout->setMargin(0);
frameLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_buildTargetsList)); frameLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(m_buildTargetsList,
Core::ItemViewFind::LightColored));
fl->addRow(tr("Targets:"), frame); fl->addRow(tr("Targets:"), frame);

View File

@@ -93,7 +93,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
connect(m_ui.findEdit, SIGNAL(editingFinished()), this, SLOT(invokeResetIncrementalSearch())); 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())); connect(m_ui.close, SIGNAL(clicked()), this, SLOT(hideAndResetFocus()));
m_findCompleter->setModel(m_plugin->findCompletionModel()); m_findCompleter->setModel(m_plugin->findCompletionModel());
@@ -821,6 +821,12 @@ void FindToolBar::setBackward(bool backward)
setFindFlag(FindBackward, 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) OptionsPopup::OptionsPopup(QWidget *parent)
: QWidget(parent, Qt::Popup) : QWidget(parent, Qt::Popup)
{ {

View File

@@ -83,6 +83,7 @@ public:
void openFindToolBar(bool focus = true); void openFindToolBar(bool focus = true);
void setUseFakeVim(bool on); void setUseFakeVim(bool on);
void setLightColoredIcon(bool lightColored);
public slots: public slots:
void setBackward(bool backward); void setBackward(bool backward);

View File

@@ -132,7 +132,7 @@ IFindSupport::Result ItemViewFind::findStep(const QString &txt, FindFlags findFl
return result; return result;
} }
QFrame *ItemViewFind::createSearchableWrapper(QAbstractItemView *treeView, FetchOption option) QFrame *ItemViewFind::createSearchableWrapper(QAbstractItemView *treeView, ColorOption lightColored, FetchOption option)
{ {
QFrame *widget = new QFrame; QFrame *widget = new QFrame;
widget->setFrameStyle(QFrame::NoFrame); widget->setFrameStyle(QFrame::NoFrame);
@@ -140,7 +140,9 @@ QFrame *ItemViewFind::createSearchableWrapper(QAbstractItemView *treeView, Fetch
vbox->setMargin(0); vbox->setMargin(0);
vbox->setSpacing(0); vbox->setSpacing(0);
vbox->addWidget(treeView); 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; Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(treeView); agg->add(treeView);

View File

@@ -50,6 +50,11 @@ public:
FetchMoreWhileSearching FetchMoreWhileSearching
}; };
enum ColorOption {
DarkColored = 0,
LightColored = 1
};
explicit ItemViewFind(QAbstractItemView *view, int role = Qt::DisplayRole, explicit ItemViewFind(QAbstractItemView *view, int role = Qt::DisplayRole,
FetchOption option = DoNotFetchMoreWhileSearching); FetchOption option = DoNotFetchMoreWhileSearching);
virtual ~ItemViewFind(); virtual ~ItemViewFind();
@@ -65,9 +70,8 @@ public:
Result findIncremental(const QString &txt, FindFlags findFlags); Result findIncremental(const QString &txt, FindFlags findFlags);
Result findStep(const QString &txt, FindFlags findFlags); Result findStep(const QString &txt, FindFlags findFlags);
static QFrame *createSearchableWrapper(QAbstractItemView *treeView, static QFrame *createSearchableWrapper(QAbstractItemView *treeView, ColorOption lightColored = DarkColored,
FetchOption option = DoNotFetchMoreWhileSearching); FetchOption option = DoNotFetchMoreWhileSearching);
private: private:
Result find(const QString &txt, FindFlags findFlags, Result find(const QString &txt, FindFlags findFlags,
bool startFromCurrentIndex, bool *wrapped); bool startFromCurrentIndex, bool *wrapped);

View File

@@ -28,18 +28,18 @@
****************************************************************************/ ****************************************************************************/
#include "findplaceholder.h" #include "findplaceholder.h"
#include "find/findtoolbar.h"
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <QVBoxLayout> #include <QVBoxLayout>
using namespace Core; using namespace Core;
FindToolBarPlaceHolder *FindToolBarPlaceHolder::m_current = 0; FindToolBarPlaceHolder *FindToolBarPlaceHolder::m_current = 0;
FindToolBarPlaceHolder::FindToolBarPlaceHolder(QWidget *owner, QWidget *parent) 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); setLayout(new QVBoxLayout);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
@@ -77,15 +77,18 @@ bool FindToolBarPlaceHolder::isUsedByWidget(QWidget *widget)
return false; return false;
} }
void FindToolBarPlaceHolder::setWidget(QWidget *widget) void FindToolBarPlaceHolder::setWidget(Internal::FindToolBar *widget)
{ {
if (m_subWidget) { if (m_subWidget) {
m_subWidget->setVisible(false); m_subWidget->setVisible(false);
m_subWidget->setParent(0); m_subWidget->setParent(0);
} }
m_subWidget = widget; m_subWidget = widget;
if (m_subWidget) if (m_subWidget) {
m_subWidget->setLightColored(m_lightColored);
m_subWidget->setLightColoredIcon(m_lightColored);
layout()->addWidget(m_subWidget); layout()->addWidget(m_subWidget);
}
} }
FindToolBarPlaceHolder *FindToolBarPlaceHolder::getCurrent() FindToolBarPlaceHolder *FindToolBarPlaceHolder::getCurrent()
@@ -97,3 +100,13 @@ void FindToolBarPlaceHolder::setCurrent(FindToolBarPlaceHolder *placeHolder)
{ {
m_current = placeHolder; m_current = placeHolder;
} }
void FindToolBarPlaceHolder::setLightColored(bool lightColored)
{
m_lightColored = lightColored;
}
bool FindToolBarPlaceHolder::isLightColored() const
{
return m_lightColored;
}

View File

@@ -36,6 +36,7 @@
#include <QWidget> #include <QWidget>
namespace Core { namespace Core {
namespace Internal { class FindToolBar; }
class CORE_EXPORT FindToolBarPlaceHolder : public QWidget class CORE_EXPORT FindToolBarPlaceHolder : public QWidget
{ {
@@ -46,14 +47,18 @@ public:
QWidget *owner() const; QWidget *owner() const;
bool isUsedByWidget(QWidget *widget); bool isUsedByWidget(QWidget *widget);
void setWidget(QWidget *widget); void setWidget(Internal::FindToolBar *widget);
static FindToolBarPlaceHolder *getCurrent(); static FindToolBarPlaceHolder *getCurrent();
static void setCurrent(FindToolBarPlaceHolder *placeHolder); static void setCurrent(FindToolBarPlaceHolder *placeHolder);
void setLightColored(bool lightColored);
bool isLightColored() const;
private: private:
QWidget *m_owner; QWidget *m_owner;
QPointer<QWidget> m_subWidget; QPointer<Internal::FindToolBar> m_subWidget;
bool m_lightColored;
static FindToolBarPlaceHolder *m_current; static FindToolBarPlaceHolder *m_current;
}; };

View File

@@ -116,7 +116,9 @@ CppIncludeHierarchyWidget::CppIncludeHierarchyWidget() :
layout->setSpacing(0); layout->setSpacing(0);
layout->addWidget(m_inspectedFile); layout->addWidget(m_inspectedFile);
layout->addWidget(Core::ItemViewFind::createSearchableWrapper( layout->addWidget(Core::ItemViewFind::createSearchableWrapper(
m_treeView, Core::ItemViewFind::FetchMoreWhileSearching)); m_treeView,
Core::ItemViewFind::DarkColored,
Core::ItemViewFind::FetchMoreWhileSearching));
layout->addWidget(m_includeHierarchyInfoLabel); layout->addWidget(m_includeHierarchyInfoLabel);
setLayout(layout); setLayout(layout);

View File

@@ -102,7 +102,7 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
d->m_environmentView->setSelectionMode(QAbstractItemView::SingleSelection); d->m_environmentView->setSelectionMode(QAbstractItemView::SingleSelection);
d->m_environmentView->setSelectionBehavior(QAbstractItemView::SelectItems); d->m_environmentView->setSelectionBehavior(QAbstractItemView::SelectItems);
d->m_environmentView->setFrameShape(QFrame::NoFrame); d->m_environmentView->setFrameShape(QFrame::NoFrame);
QFrame *findWrapper = Core::ItemViewFind::createSearchableWrapper(d->m_environmentView); QFrame *findWrapper = Core::ItemViewFind::createSearchableWrapper(d->m_environmentView, Core::ItemViewFind::LightColored);
findWrapper->setFrameStyle(QFrame::StyledPanel); findWrapper->setFrameStyle(QFrame::StyledPanel);
horizontalLayout->addWidget(findWrapper); horizontalLayout->addWidget(findWrapper);

View File

@@ -136,7 +136,8 @@ ProjectTreeWidget::ProjectTreeWidget(QWidget *parent)
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(Core::ItemViewFind::createSearchableWrapper( layout->addWidget(Core::ItemViewFind::createSearchableWrapper(
m_view, ItemViewFind::FetchMoreWhileSearching)); m_view, ItemViewFind::DarkColored,
ItemViewFind::FetchMoreWhileSearching));
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
setLayout(layout); setLayout(layout);