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
|
|
|
*/
|
2021-12-12 18:19:44 +02: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
|
2021-12-12 18:19:44 +02:00
|
|
|
{
|
|
|
|
|
/* Disable using menu with alt key */
|
|
|
|
|
if (hint == QStyle::SH_MenuBar_AltKeyNavigation)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return QProxyStyle::styleHint(hint, option, widget, returnData);
|
2022-02-05 22:56:43 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-19 08:49:04 -05:00
|
|
|
void
|
|
|
|
|
StyleOverride::polish(QWidget *widget)
|
2022-02-05 22:56:43 +02:00
|
|
|
{
|
2022-02-08 15:50:56 +06:00
|
|
|
QProxyStyle::polish(widget);
|
2022-02-05 22:56:43 +02:00
|
|
|
/* Disable title bar context help buttons globally as they are unused. */
|
2022-02-09 00:29:19 +06:00
|
|
|
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()
|
2022-02-10 13:22:12 +06:00
|
|
|
|| 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);
|
|
|
|
|
}
|
2022-02-09 00:29:19 +06:00
|
|
|
widget->setWindowFlag(Qt::MSWindowsFixedSizeDialogHint, true);
|
|
|
|
|
}
|
2022-02-05 22:56:43 +02:00
|
|
|
widget->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
2022-02-09 00:29:19 +06:00
|
|
|
}
|
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
|
|
|
}
|