Reduce height of RunningScripts so titlebar is inside main window

This commit is contained in:
Ryan Huffman 2014-09-02 13:12:52 -07:00
parent a95b670716
commit 67cefc8d54
3 changed files with 58 additions and 1 deletions

View file

@ -22,6 +22,7 @@
#include "Application.h"
#include "Menu.h"
#include "ScriptsModel.h"
#include "UIUtil.h"
RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
@ -154,7 +155,10 @@ void RunningScriptsWidget::showEvent(QShowEvent* event) {
}
const QRect parentGeometry = parentWidget()->geometry();
setGeometry(parentGeometry.topLeft().x(), parentGeometry.topLeft().y(), size().width(), parentWidget()->height());
int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
setGeometry(parentGeometry.topLeft().x(), parentGeometry.topLeft().y() + titleBarHeight,
size().width(), parentWidget()->height() - titleBarHeight);
QWidget::showEvent(event);
}

View file

@ -0,0 +1,29 @@
//
// UIUtil.cpp
// library/shared/src
//
// Created by Ryan Huffman on 09/02/2014.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include <QStyle>
#include <QStyleOptionTitleBar>
#include "UIUtil.h"
int UIUtil::getWindowTitleBarHeight(QWidget *window) {
QStyleOptionTitleBar options;
options.titleBarState = 1;
options.titleBarFlags = Qt::Window;
int titleBarHeight = window->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, window);
#if defined(Q_OS_MAC)
// The height on OSX is 4 pixels too tall
titleBarHeight -= 4;
#endif
return titleBarHeight;
}

View file

@ -0,0 +1,24 @@
//
// UIUtil.h
// library/shared/src
//
// Created by Ryan Huffman on 09/02/2014.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_UIUtil_h
#define hifi_UIUtil_h
#include <QWidget>
class UIUtil {
public:
static int getWindowTitleBarHeight(QWidget *window);
};
#endif // hifi_UIUtil_h