Commit baaf7b1d authored by con's avatar con

Less QToolBars in editor tool bar.

parent 5e1a24f7
......@@ -12,6 +12,17 @@ StyledBar::StyledBar(QWidget *parent)
: QWidget(parent)
{
setProperty("panelwidget", true);
setProperty("panelwidget_singlerow", true);
}
void StyledBar::setSingleRow(bool singleRow)
{
setProperty("panelwidget_singlerow", singleRow);
}
bool StyledBar::isSingleRow() const
{
return property("panelwidget_singlerow").toBool();
}
void StyledBar::paintEvent(QPaintEvent *event)
......
......@@ -12,7 +12,8 @@ class QTCREATOR_UTILS_EXPORT StyledBar : public QWidget
{
public:
StyledBar(QWidget *parent = 0);
void setSingleRow(bool singleRow);
bool isSingleRow() const;
protected:
void paintEvent(QPaintEvent *event);
};
......
......@@ -287,7 +287,7 @@ public:
QByteArray saveState() const { return QByteArray(); } // TODO
bool restoreState(const QByteArray & /* state */) { return false; } // TODO
QToolBar *toolBar() { return m_toolBar; }
QWidget *toolBar() { return m_toolBar; }
bool isTemporary() const { return false; }
......
......@@ -34,6 +34,7 @@
#include "openeditorsmodel.h"
#include <utils/qtcassert.h>
#include <utils/styledbar.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>
......@@ -49,7 +50,6 @@
#include <QtGui/QStackedWidget>
#include <QtGui/QStyle>
#include <QtGui/QStyleOption>
#include <QtGui/QToolBar>
#include <QtGui/QToolButton>
#include <QtGui/QMenu>
#include <QtGui/QClipboard>
......@@ -74,7 +74,7 @@ EditorView::EditorView(OpenEditorsModel *model, QWidget *parent) :
m_editorList(new QComboBox),
m_closeButton(new QToolButton),
m_lockButton(new QToolButton),
m_defaultToolBar(new QToolBar(this)),
m_defaultToolBar(new QWidget(this)),
m_infoWidget(new QFrame(this)),
m_editorForInfoWidget(0),
m_statusHLine(new QFrame(this)),
......@@ -94,12 +94,7 @@ EditorView::EditorView(OpenEditorsModel *model, QWidget *parent) :
m_editorList->setMaxVisibleItems(40);
m_editorList->setContextMenuPolicy(Qt::CustomContextMenu);
QToolBar *editorListToolBar = new QToolBar;
editorListToolBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
editorListToolBar->addWidget(m_editorList);
m_defaultToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
m_defaultToolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
m_activeToolBar = m_defaultToolBar;
QHBoxLayout *toolBarLayout = new QHBoxLayout;
......@@ -107,6 +102,7 @@ EditorView::EditorView(OpenEditorsModel *model, QWidget *parent) :
toolBarLayout->setSpacing(0);
toolBarLayout->addWidget(m_defaultToolBar);
m_toolBar->setLayout(toolBarLayout);
m_toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
m_lockButton->setAutoRaise(true);
m_lockButton->setProperty("type", QLatin1String("dockbutton"));
......@@ -115,23 +111,16 @@ EditorView::EditorView(OpenEditorsModel *model, QWidget *parent) :
m_closeButton->setIcon(QIcon(":/core/images/closebutton.png"));
m_closeButton->setProperty("type", QLatin1String("dockbutton"));
QToolBar *rightToolBar = new QToolBar;
rightToolBar->setLayoutDirection(Qt::RightToLeft);
rightToolBar->addWidget(m_closeButton);
rightToolBar->addWidget(m_lockButton);
QHBoxLayout *toplayout = new QHBoxLayout;
toplayout->setSpacing(0);
toplayout->setMargin(0);
toplayout->addWidget(editorListToolBar);
toplayout->addWidget(m_editorList);
toplayout->addWidget(m_toolBar, 1); // Custom toolbar stretches
toplayout->addWidget(rightToolBar);
toplayout->addWidget(m_lockButton);
toplayout->addWidget(m_closeButton);
QWidget *top = new QWidget;
QVBoxLayout *vlayout = new QVBoxLayout(top);
vlayout->setSpacing(0);
vlayout->setMargin(0);
vlayout->addLayout(toplayout);
Core::Utils::StyledBar *top = new Core::Utils::StyledBar;
top->setLayout(toplayout);
tl->addWidget(top);
connect(m_editorList, SIGNAL(activated(int)), this, SLOT(listSelectionActivated(int)));
......@@ -258,7 +247,7 @@ void EditorView::addEditor(IEditor *editor)
m_container->addWidget(editor->widget());
m_widgetEditorMap.insert(editor->widget(), editor);
QToolBar *toolBar = editor->toolBar();
QWidget *toolBar = editor->toolBar();
if (toolBar) {
toolBar->setVisible(false); // will be made visible in setCurrentEditor
m_toolBar->layout()->addWidget(toolBar);
......@@ -297,7 +286,7 @@ void EditorView::removeEditor(IEditor *editor)
m_widgetEditorMap.remove(editor->widget());
editor->widget()->setParent(0);
disconnect(editor, SIGNAL(changed()), this, SLOT(checkEditorStatus()));
QToolBar *toolBar = editor->toolBar();
QWidget *toolBar = editor->toolBar();
if (toolBar != 0) {
if (m_activeToolBar == toolBar) {
m_activeToolBar = m_defaultToolBar;
......@@ -375,7 +364,7 @@ void EditorView::updateEditorStatus(IEditor *editor)
void EditorView::updateToolBar(IEditor *editor)
{
QToolBar *toolBar = editor->toolBar();
QWidget *toolBar = editor->toolBar();
if (!toolBar)
toolBar = m_defaultToolBar;
if (m_activeToolBar == toolBar)
......
......@@ -105,12 +105,12 @@ private:
OpenEditorsModel *m_model;
QWidget *m_toolBar;
QToolBar *m_activeToolBar;
QWidget *m_activeToolBar;
QStackedWidget *m_container;
QComboBox *m_editorList;
QToolButton *m_closeButton;
QToolButton *m_lockButton;
QToolBar *m_defaultToolBar;
QWidget *m_defaultToolBar;
QString m_infoWidgetKind;
QFrame *m_infoWidget;
QLabel *m_infoWidgetLabel;
......
......@@ -65,7 +65,7 @@ public:
virtual bool isTemporary() const = 0;
virtual QToolBar *toolBar() = 0;
virtual QWidget *toolBar() = 0;
signals:
void changed();
......
......@@ -314,10 +314,10 @@ void ManhattanStyle::polish(QWidget *widget)
widget->removeEventFilter(d->style);
}
if (panelWidget(widget)) {
widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
if (qobject_cast<QToolButton*>(widget)) {
widget->setAttribute(Qt::WA_Hover);
widget->setMaximumHeight(StyleHelper::navigationWidgetHeight() - 2);
widget->setAttribute(Qt::WA_Hover);
}
else if (qobject_cast<QLineEdit*>(widget)) {
widget->setAttribute(Qt::WA_Hover);
......@@ -325,8 +325,8 @@ void ManhattanStyle::polish(QWidget *widget)
}
else if (qobject_cast<QLabel*>(widget))
widget->setPalette(panelPalette(widget->palette()));
else if (qobject_cast<QToolBar*>(widget))
widget->setMinimumHeight(StyleHelper::navigationWidgetHeight());
else if (qobject_cast<QToolBar*>(widget) || widget->property("panelwidget_singlerow").toBool())
widget->setFixedHeight(StyleHelper::navigationWidgetHeight());
else if (qobject_cast<QStatusBar*>(widget))
widget->setFixedHeight(StyleHelper::navigationWidgetHeight() + 2);
else if (qobject_cast<QComboBox*>(widget)) {
......@@ -340,6 +340,7 @@ void ManhattanStyle::unpolish(QWidget *widget)
{
d->style->unpolish(widget);
if (panelWidget(widget)) {
widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, false);
if (qobject_cast<QTabBar*>(widget))
widget->setAttribute(Qt::WA_Hover, false);
else if (qobject_cast<QToolBar*>(widget))
......
......@@ -346,7 +346,7 @@ Core::IFile *EditorPrototype::file() const
return callee()->file();
}
QToolBar* EditorPrototype::toolBar() const
QWidget* EditorPrototype::toolBar() const
{
return callee()->toolBar();
}
......
......@@ -198,7 +198,7 @@ class EditorPrototype : public QObject, public QScriptable
Q_PROPERTY(QString kind READ kind DESIGNABLE false SCRIPTABLE true STORED false)
Q_PROPERTY(bool duplicateSupported READ duplicateSupported DESIGNABLE false SCRIPTABLE true STORED false)
Q_PROPERTY(Core::IFile* file READ file DESIGNABLE false SCRIPTABLE true STORED false)
Q_PROPERTY(QToolBar* toolBar READ toolBar DESIGNABLE false SCRIPTABLE true STORED false)
Q_PROPERTY(QWidget* toolBar READ toolBar DESIGNABLE false SCRIPTABLE true STORED false)
public:
EditorPrototype(QObject *parent = 0);
......@@ -210,7 +210,7 @@ public:
bool duplicateSupported() const;
Core::IFile *file() const;
QToolBar* toolBar() const;
QWidget* toolBar() const;
public slots:
bool createNew(const QString &contents);
......
......@@ -640,7 +640,7 @@ void CPPEditor::createToolBar(CPPEditorEditable *editable)
connect(m_semanticHighlighter, SIGNAL(changed(SemanticInfo)),
this, SLOT(updateSemanticInfo(SemanticInfo)));
QToolBar *toolBar = editable->toolBar();
QToolBar *toolBar = static_cast<QToolBar*>(editable->toolBar());
QList<QAction*> actions = toolBar->actions();
QWidget *w = toolBar->widgetForAction(actions.first());
static_cast<QHBoxLayout*>(w->layout())->insertWidget(0, m_methodCombo, 1);
......
......@@ -467,8 +467,8 @@ void FormEditorW::setupActions()
QToolBar *FormEditorW::createEditorToolBar() const
{
QToolBar *rc = new QToolBar;
rc->addSeparator();
QToolBar *toolBar = new QToolBar;
toolBar->addSeparator();
Core::ActionManager *am = m_core->actionManager();
const QStringList::const_iterator cend = m_toolActionIds.constEnd();
for (QStringList::const_iterator it = m_toolActionIds.constBegin(); it != cend; ++it) {
......@@ -476,11 +476,12 @@ QToolBar *FormEditorW::createEditorToolBar() const
QTC_ASSERT(cmd, continue);
QAction *action = cmd->action();
if (!action->icon().isNull()) // Simplify grid has no action yet
rc->addAction(action);
toolBar->addAction(action);
}
int size = rc->style()->pixelMetric(QStyle::PM_SmallIconSize);
rc->setIconSize(QSize(size, size));
return rc;
int size = toolBar->style()->pixelMetric(QStyle::PM_SmallIconSize);
toolBar->setIconSize(QSize(size, size));
toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
return toolBar;
}
Core::ActionContainer *FormEditorW::createPreviewStyleMenu(Core::ActionManager *am,
......
......@@ -274,7 +274,7 @@ void FormWindowEditor::setDisplayName(const QString &title)
m_displayName = title;
}
QToolBar *FormWindowEditor::toolBar()
QWidget *FormWindowEditor::toolBar()
{
if (!m_toolBar)
m_toolBar = FormEditorW::instance()->createEditorToolBar();
......
......@@ -76,7 +76,7 @@ public:
const char *kind() const;
QString displayName() const;
void setDisplayName(const QString &title);
QToolBar *toolBar();
QWidget *toolBar();
QByteArray saveState() const;
bool restoreState(const QByteArray &state);
virtual bool isTemporary() const { return false; }
......
......@@ -677,7 +677,7 @@ void ScriptEditor::createToolBar(ScriptEditorEditable *editable)
connect(file(), SIGNAL(changed()), this, SLOT(updateFileName()));
QToolBar *toolBar = editable->toolBar();
QToolBar *toolBar = static_cast<QToolBar*>(editable->toolBar());
QList<QAction*> actions = toolBar->actions();
toolBar->insertWidget(actions.first(), m_methodCombo);
......
......@@ -76,6 +76,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
m_ui.setupUi(this);
setFocusProxy(m_ui.findEdit);
setProperty("topBorder", true);
setSingleRow(false);
m_ui.findEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
m_ui.replaceEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
......
......@@ -384,7 +384,7 @@ void ScriptEditor::createToolBar(ScriptEditorEditable *editable)
connect(file(), SIGNAL(changed()), this, SLOT(updateFileName()));
QToolBar *toolBar = editable->toolBar();
QToolBar *toolBar = static_cast<QToolBar*>(editable->toolBar());
QList<QAction*> actions = toolBar->actions();
QWidget *w = toolBar->widgetForAction(actions.first());
......
......@@ -96,7 +96,7 @@ public:
const char *kind() const;
QString displayName() const { return m_displayName; }
void setDisplayName(const QString &title) { m_displayName = title; }
QToolBar *toolBar() { return 0; }
QWidget *toolBar() { return 0; }
QByteArray saveState() const { return QByteArray(); }
bool restoreState(const QByteArray &/*state*/) { return true; }
......
......@@ -4143,7 +4143,7 @@ BaseTextEditorEditable::~BaseTextEditorEditable()
delete e;
}
QToolBar *BaseTextEditorEditable::toolBar()
QWidget *BaseTextEditorEditable::toolBar()
{
return m_toolBar;
}
......
......@@ -573,7 +573,7 @@ public:
inline QByteArray saveState() const { return e->saveState(); }
inline bool restoreState(const QByteArray &state) { return e->restoreState(state); }
QToolBar *toolBar();
QWidget *toolBar();
// ITextEditor
int find(const QString &string) const;
......
......@@ -104,7 +104,7 @@ public:
VCSBaseDiffEditorEditable(VCSBaseEditor *, const VCSBaseEditorParameters *type);
~VCSBaseDiffEditorEditable();
virtual QToolBar *toolBar() { return m_toolBar; }
virtual QWidget *toolBar() { return m_toolBar; }
QComboBox *diffFileBrowseComboBox() const { return m_diffFileBrowseComboBox; }
bool isTemporary() const { return true; }
......
......@@ -343,7 +343,7 @@ static QToolBar *createToolBar(const QWidget *someWidget, QAction *submitAction,
return toolBar;
}
QToolBar *VCSBaseSubmitEditor::toolBar()
QWidget *VCSBaseSubmitEditor::toolBar()
{
if (!wantToolBar)
return 0;
......
......@@ -142,7 +142,7 @@ public:
virtual Core::IEditor *duplicate(QWidget * parent);
virtual const char *kind() const;
virtual QToolBar *toolBar();
virtual QWidget *toolBar();
virtual QList<int> context() const;
virtual QWidget *widget();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment