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:
@@ -54,7 +54,11 @@ bool StyledBar::isSingleRow() const
|
||||
|
||||
void StyledBar::setLightColored(bool lightColored)
|
||||
{
|
||||
if (isLightColored() == lightColored)
|
||||
return;
|
||||
setProperty("lightColored", lightColored);
|
||||
foreach (QWidget *childWidget, findChildren<QWidget *>())
|
||||
childWidget->style()->polish(childWidget);
|
||||
}
|
||||
|
||||
bool StyledBar::isLightColored() const
|
||||
|
||||
@@ -99,7 +99,8 @@ NavigationWidget::NavigationWidget(QWidget *parent) :
|
||||
treeView = new ::Utils::NavigationTreeView(this);
|
||||
treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
verticalLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(
|
||||
treeView, Core::ItemViewFind::FetchMoreWhileSearching));
|
||||
treeView, Core::ItemViewFind::DarkColored,
|
||||
Core::ItemViewFind::FetchMoreWhileSearching));
|
||||
|
||||
// tree model
|
||||
treeModel = new TreeItemModel(this);
|
||||
|
||||
@@ -346,7 +346,8 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
|
||||
frame->setFrameStyle(QFrame::StyledPanel);
|
||||
QVBoxLayout *frameLayout = new QVBoxLayout(frame);
|
||||
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);
|
||||
|
||||
|
||||
@@ -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,
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
@@ -116,7 +116,9 @@ CppIncludeHierarchyWidget::CppIncludeHierarchyWidget() :
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(m_inspectedFile);
|
||||
layout->addWidget(Core::ItemViewFind::createSearchableWrapper(
|
||||
m_treeView, Core::ItemViewFind::FetchMoreWhileSearching));
|
||||
m_treeView,
|
||||
Core::ItemViewFind::DarkColored,
|
||||
Core::ItemViewFind::FetchMoreWhileSearching));
|
||||
layout->addWidget(m_includeHierarchyInfoLabel);
|
||||
setLayout(layout);
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ EnvironmentWidget::EnvironmentWidget(QWidget *parent, QWidget *additionalDetails
|
||||
d->m_environmentView->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
d->m_environmentView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||
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);
|
||||
horizontalLayout->addWidget(findWrapper);
|
||||
|
||||
|
||||
@@ -136,7 +136,8 @@ ProjectTreeWidget::ProjectTreeWidget(QWidget *parent)
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout();
|
||||
layout->addWidget(Core::ItemViewFind::createSearchableWrapper(
|
||||
m_view, ItemViewFind::FetchMoreWhileSearching));
|
||||
m_view, ItemViewFind::DarkColored,
|
||||
ItemViewFind::FetchMoreWhileSearching));
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
setLayout(layout);
|
||||
|
||||
|
||||
Submodule src/shared/qbs updated: 48225ceaa6...657a4ccf4c
Reference in New Issue
Block a user