Commit d5818417 authored by Jens Bache-Wiig's avatar Jens Bache-Wiig

Clean up layouts and use minisplitter everywhere

This patch replaces all uses of QSplitter with thin 1-pixel
splitters. I also fixed dock widget layouts in main windows
to do the same. Additionally I had to tweak the tabbars so
they look good in mini splitter layouts to avoid a double
left-border.

Reviewed-by: thorbjorn
parent 0146926f
......@@ -33,7 +33,6 @@
#include <QtGui/QDockWidget>
#include <QtCore/QSettings>
using namespace Utils;
FancyMainWindow::FancyMainWindow(QWidget *parent)
......@@ -41,6 +40,7 @@ FancyMainWindow::FancyMainWindow(QWidget *parent)
m_locked(true),
m_handleDockVisibilityChanges(true)
{
setProperty("panelwidget", true);
}
QDockWidget *FancyMainWindow::addDockForWidget(QWidget *widget)
......
......@@ -55,6 +55,7 @@
#include <QtGui/QStyleFactory>
#include <QtGui/QStyleOption>
#include <QtGui/QToolBar>
#include <QtGui/QTreeView>
#include <QtGui/QToolButton>
#include <QtGui/QAbstractItemView>
......@@ -88,10 +89,9 @@ bool panelWidget(const QWidget *widget)
while (p) {
if (qobject_cast<const QToolBar *>(p) ||
qobject_cast<const QStatusBar *>(p) ||
qobject_cast<const QMenuBar *>(p))
qobject_cast<const QMenuBar *>(p) ||
p->property("panelwidget").toBool())
return styleEnabled(widget);
if (p->property("panelwidget").toBool())
return true;
p = p->parentWidget();
}
return false;
......@@ -197,6 +197,8 @@ int ManhattanStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
if (panelWidget(widget))
retval = 16;
break;
case PM_DockWidgetSeparatorExtent:
return 1;
case PM_MenuPanelWidth:
case PM_MenuBarHMargin:
case PM_MenuBarVMargin:
......@@ -260,6 +262,7 @@ void ManhattanStyle::polish(QWidget *widget)
if (qobject_cast<QToolBar*>(widget))
widget->removeEventFilter(baseStyle());
}
if (panelWidget(widget)) {
widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
if (qobject_cast<QToolButton*>(widget)) {
......@@ -594,6 +597,27 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
return QProxyStyle::drawControl(element, option, painter, widget);
switch (element) {
case CE_Splitter:
painter->fillRect(option->rect, Utils::StyleHelper::borderColor());
break;
case CE_TabBarTabShape:
// Most styles draw a single dark outline. This looks rather ugly when combined with our
// single pixel dark separator so we adjust the first tab to compensate for this
if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) {
QStyleOptionTabV3 adjustedTab = *tab;
if (tab->position == QStyleOptionTab::Beginning) {
if (option->direction == Qt::LeftToRight)
adjustedTab.rect = adjustedTab.rect.adjusted(-1, 0, 0, 0);
else
adjustedTab.rect = adjustedTab.rect.adjusted(0, 0, 1 ,0);
}
QProxyStyle::drawControl(element, &adjustedTab, painter, widget);
return;
}
break;
case CE_MenuBarItem:
painter->save();
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
......
......@@ -83,6 +83,7 @@ BreakWindow::BreakWindow(Debugger::DebuggerManager *manager)
: m_manager(manager), m_alwaysResizeColumnsToContents(false)
{
QAction *act = theDebuggerAction(UseAlternatingRowColors);
setFrameStyle(QFrame::NoFrame);
setWindowTitle(tr("Breakpoints"));
setWindowIcon(QIcon(":/debugger/images/debugger_breakpoints.png"));
setAlternatingRowColors(act->isChecked());
......
......@@ -64,6 +64,7 @@
#endif
#include <coreplugin/icore.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/editormanager/editormanager.h>
#include <utils/qtcassert.h>
#include <projectexplorer/toolchain.h>
......@@ -585,7 +586,7 @@ void DebuggerManager::init()
d->m_threadsDock = uiSwitcher->createDockWidget(LANG_CPP, d->m_threadsWindow);
QSplitter *localsAndWatchers = new QSplitter(Qt::Vertical);
QSplitter *localsAndWatchers = new Core::MiniSplitter(Qt::Vertical);
localsAndWatchers->setWindowTitle(d->m_localsWindow->windowTitle());
localsAndWatchers->addWidget(d->m_localsWindow);
localsAndWatchers->addWidget(d->m_watchersWindow);
......
......@@ -47,6 +47,7 @@
#include <aggregation/aggregate.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/minisplitter.h>
#include <find/basetextfind.h>
using namespace Debugger;
......@@ -329,7 +330,8 @@ DebuggerOutputWindow::DebuggerOutputWindow(QWidget *parent)
{
setWindowTitle(tr("Debugger"));
QSplitter *m_splitter = new QSplitter(Qt::Horizontal, this);
QSplitter *m_splitter = new Core::MiniSplitter(Qt::Horizontal);
m_splitter->setParent(this);
// mixed input/output
m_combinedText = new CombinedPane(this);
m_combinedText->setReadOnly(true);
......
......@@ -74,6 +74,7 @@ SnapshotWindow::SnapshotWindow(DebuggerManager *manager, QWidget *parent)
QAction *act = theDebuggerAction(UseAlternatingRowColors);
setWindowTitle(tr("Snapshots"));
setFrameStyle(QFrame::NoFrame);
setAlternatingRowColors(act->isChecked());
setRootIsDecorated(false);
setIconSize(QSize(10, 10));
......
......@@ -169,6 +169,7 @@ SourceFilesWindow::SourceFilesWindow(QWidget *parent)
proxyModel->setSourceModel(m_model);
setModel(proxyModel);
setFrameStyle(QFrame::NoFrame);
setWindowTitle(tr("Source Files"));
setSortingEnabled(true);
setAlternatingRowColors(act->isChecked());
......
......@@ -54,6 +54,7 @@ namespace Internal {
StackWindow::StackWindow(DebuggerManager *manager, QWidget *parent)
: QTreeView(parent), m_manager(manager), m_alwaysResizeColumnsToContents(false)
{
setFrameStyle(QFrame::NoFrame);
m_disassemblerAgent = new DisassemblerViewAgent(manager);
QAction *act = theDebuggerAction(UseAlternatingRowColors);
......
......@@ -43,6 +43,7 @@ ThreadsWindow::ThreadsWindow(QWidget *parent)
{
QAction *act = theDebuggerAction(UseAlternatingRowColors);
setFrameStyle(QFrame::NoFrame);
setWindowTitle(tr("Thread"));
setAlternatingRowColors(act->isChecked());
setRootIsDecorated(false);
......
......@@ -125,6 +125,7 @@ WatchWindow::WatchWindow(Type type, DebuggerManager *manager, QWidget *parent)
m_grabbing = false;
QAction *act = theDebuggerAction(UseAlternatingRowColors);
setFrameStyle(QFrame::NoFrame);
setWindowTitle(tr("Locals and Watchers"));
setAlternatingRowColors(act->isChecked());
setIndentation(indentation() * 9/10);
......
......@@ -35,6 +35,7 @@
#include <QtGui/QVBoxLayout>
#include <QtGui/QDockWidget>
#include <QtGui/QAbstractItemView>
using namespace Designer::Constants;
......@@ -59,6 +60,13 @@ EditorWidget::EditorWidget(FormEditorW *few, QWidget *parent) :
QWidget *subWindow = subs[i];
subWindow->setWindowTitle(subs[i]->windowTitle());
m_designerDockWidgets[i] = addDockForWidget(subWindow);
// Since we have 1-pixel splitters, we generally want to remove
// frames around item views. So we apply this hack for now.
QList<QAbstractItemView*> frames = subWindow->findChildren<QAbstractItemView*>();
for (int i = 0 ; i< frames.count(); ++i)
frames[i]->setFrameStyle(QFrame::NoFrame);
}
resetToDefaultLayout();
}
......
......@@ -80,6 +80,11 @@ void FormEditorStack::add(const EditorData &data)
if (Designer::Constants::Internal::debug)
qDebug() << "FormEditorStack::add" << data.widgetHost;
// Since we have 1 pixel splitters we enforce no frame
// on the content widget
if (QFrame *frame = qobject_cast<QFrame*>(data.widgetHost))
frame->setFrameStyle(QFrame::NoFrame);
}
int FormEditorStack::indexOf(const QDesignerFormWindowInterface *fw) const
......
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