Files
86Box/src/qt/qt_styleoverride.cpp

57 lines
1.8 KiB
C++
Raw Normal View History

2022-02-07 15:00:02 +06:00
/*
2023-01-06 15:36:05 -05:00
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
2022-02-07 15:00:02 +06:00
*
2023-01-06 15:36:05 -05:00
* This file is part of the 86Box distribution.
2022-02-07 15:00:02 +06:00
*
2023-01-06 15:36:05 -05:00
* Style override class.
2022-02-07 15:00:02 +06:00
*
*
*
2023-01-06 15:36:05 -05:00
* Authors: Teemu Korhonen
2022-02-07 15:00:02 +06:00
*
2023-01-06 15:36:05 -05:00
* Copyright 2022 Teemu Korhonen
2022-02-07 15:00:02 +06:00
*/
#include "qt_styleoverride.hpp"
2022-02-10 01:37:41 +06:00
#include <QComboBox>
#include <QAbstractItemView>
2022-11-19 08:49:04 -05:00
int
StyleOverride::styleHint(
StyleHint hint,
const QStyleOption *option,
const QWidget *widget,
QStyleHintReturn *returnData) const
{
/* Disable using menu with alt key */
if (hint == QStyle::SH_MenuBar_AltKeyNavigation)
return 0;
return QProxyStyle::styleHint(hint, option, widget, returnData);
}
2022-11-19 08:49:04 -05:00
void
StyleOverride::polish(QWidget *widget)
{
2022-02-08 15:50:56 +06:00
QProxyStyle::polish(widget);
/* Disable title bar context help buttons globally as they are unused. */
if (widget->isWindow()) {
if (widget->layout() && widget->minimumSize() == widget->maximumSize()) {
2022-02-09 12:21:14 +06:00
if (widget->minimumSize().width() < widget->minimumSizeHint().width()
|| widget->minimumSize().height() < widget->minimumSizeHint().height()) {
2022-02-09 10:36:22 +06:00
widget->setFixedSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
widget->layout()->setSizeConstraint(QLayout::SetFixedSize);
}
widget->setWindowFlag(Qt::MSWindowsFixedSizeDialogHint, true);
}
widget->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
}
2022-02-10 01:37:41 +06:00
2022-11-19 08:49:04 -05:00
if (qobject_cast<QComboBox *>(widget)) {
qobject_cast<QComboBox *>(widget)->view()->setMinimumWidth(widget->minimumSizeHint().width());
2022-02-10 01:37:41 +06:00
}
2022-02-07 15:00:02 +06:00
}