Commit 580fbb1a authored by Kai Koehne's avatar Kai Koehne
Browse files

QmlObserver: Remove toolbar and make crumblepath an overlay

Try to make the observer mode less intrusive by removing the toolbar,
and making the crumblepath only when mode is active / an overlay.
parent 5f1d93c3
......@@ -528,6 +528,32 @@ QNetworkAccessManager *NetworkAccessManagerFactory::create(QObject *parent)
return manager;
}
//
// Event filter that ensures the crumble path width is always the canvas width
//
class CrumblePathResizer : public QObject
{
Q_OBJECT
public:
CrumblePathResizer(Utils::CrumblePath *crumblePathWidget, QObject *parent = 0) :
QObject(parent),
m_crumblePathWidget(crumblePathWidget)
{
}
bool eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::Resize) {
QResizeEvent *resizeEvent = static_cast<QResizeEvent *>(event);
m_crumblePathWidget->resize(resizeEvent->size().width(), m_crumblePathWidget->height());
}
return QObject::eventFilter(obj, event);
}
private:
QWidget *m_crumblePathWidget;
};
QString QDeclarativeViewer::getVideoFileName()
{
QString title = convertAvailable || ffmpegAvailable ? tr("Save Video File") : tr("Save PNG Frames");
......@@ -587,27 +613,22 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
canvas = new QmlViewer::QDeclarativeDesignView(this);
if (!(flags & Qt::FramelessWindowHint)) {
addToolBar(Qt::TopToolBarArea, canvas->toolbar());
canvas->toolbar()->setFloatable(false);
canvas->toolbar()->setMovable(false);
m_crumblePathWidget = new Utils::CrumblePath(this);
m_crumblePathWidget = new Utils::CrumblePath(canvas);
#ifndef Q_WS_MAC
QFile file(":/toolbarstyle.css");
file.open(QFile::ReadOnly);
QString toolbarStylesheet = QLatin1String(file.readAll());
canvas->toolbar()->setStyleSheet(toolbarStylesheet);
m_crumblePathWidget->setStyleSheet("QWidget { border-bottom: 1px solid black; }");
#endif
}
m_crumblePathWidget->setVisible(canvas->designModeBehavior());
// CrumblePath is not in a layout, so that it overlays the central widget
// The event filter ensures that its width stays in sync nevertheless
CrumblePathResizer *resizer = new CrumblePathResizer(m_crumblePathWidget, m_crumblePathWidget);
canvas->installEventFilter(resizer);
}
m_centralWidget = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(m_centralWidget);
layout->setMargin(0);
layout->setSpacing(0);
if (m_crumblePathWidget)
layout->addWidget(m_crumblePathWidget);
layout->addWidget(canvas);
......@@ -626,6 +647,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
QObject::connect(canvas, SIGNAL(inspectorContextPushed(QString)), m_crumblePathWidget, SLOT(pushElement(QString)));
QObject::connect(canvas, SIGNAL(inspectorContextPopped()), m_crumblePathWidget, SLOT(popElement()));
QObject::connect(m_crumblePathWidget, SIGNAL(elementClicked(int)), canvas, SLOT(setInspectorContext(int)));
QObject::connect(canvas, SIGNAL(designModeBehaviorChanged(bool)), m_crumblePathWidget, SLOT(setVisible(bool)));
}
QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit()));
......
......@@ -5,6 +5,5 @@
<file>content/images/folder.png</file>
<file>content/images/titlebar.sci</file>
<file>content/images/titlebar.png</file>
<file>toolbarstyle.css</file>
</qresource>
</RCC>
QToolBar {
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(85, 85, 85, 255), stop:0.3 rgba(79, 79, 79, 255), stop:0.301 rgba(70, 70, 70, 255), stop:1 rgba(57, 57, 57, 255));
color: #EEEEEE;
}
QToolBar::separator {
width: 1px;
border-right: 1px solid #6d6d6d;
background: #414141;
}
QToolButton {
border: none;
padding-left:4px;
padding-right:4px;
padding-top:5px;
padding-bottom:5px;
}
QToolButton:checked {
border: none;
padding-left:4px;
padding-right:4px;
padding-top:5px;
padding-bottom:5px;
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(65, 65, 65, 255), stop:0.3 rgba(59, 59, 59, 255), stop:0.301 rgba(50, 50, 50, 255), stop:1 rgba(37, 37, 37, 255));
}
QToolButton:hover {
border: none;
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(105, 105, 105, 255), stop:0.3 rgba(99, 99, 99, 255), stop:0.301 rgba(90, 90, 90, 255), stop:1 rgba(77, 77, 77, 255));
}
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