mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 01:53:10 +02:00
Reduce height of RunningScripts so titlebar is inside main window
This commit is contained in:
parent
a95b670716
commit
67cefc8d54
3 changed files with 58 additions and 1 deletions
|
@ -22,6 +22,7 @@
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "ScriptsModel.h"
|
#include "ScriptsModel.h"
|
||||||
|
#include "UIUtil.h"
|
||||||
|
|
||||||
RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
|
RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
|
||||||
QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
|
QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
|
||||||
|
@ -154,7 +155,10 @@ void RunningScriptsWidget::showEvent(QShowEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const QRect parentGeometry = parentWidget()->geometry();
|
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);
|
QWidget::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
29
libraries/shared/src/UIUtil.cpp
Normal file
29
libraries/shared/src/UIUtil.cpp
Normal 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;
|
||||||
|
}
|
24
libraries/shared/src/UIUtil.h
Normal file
24
libraries/shared/src/UIUtil.h
Normal 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
|
Loading…
Reference in a new issue