blob: f6ba8036ca09580d6bd0a6d9d4c5d475d27ecc33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright 2024 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <string_view>
#include <QStyle>
class QDateTimeEdit;
class QLabel;
class QWidget;
namespace QtUtils
{
void ShowFourDigitYear(QDateTimeEdit* widget);
QWidget* CreateIconWarning(QWidget* parent, QStyle::StandardPixmap standard_pixmap, QLabel* label);
// Similar to QWidget::adjustSize except maximum size is 9/10 of screen rather than 2/3.
void AdjustSizeWithinScreen(QWidget* widget);
// Centers the widget on its parent. It should be called after any adjustments to the widget's size
// has been applied.
void CenterOnParentWindow(QWidget* widget);
// A QWidget that returns the minimumSizeHint as the primary sizeHint.
// Useful for QListWidget which hints a fairly large height even when entirely empty.
// Usage: QtUtils::MinimumSizeHintWidget<QListWidget>
template <typename Widget>
class MinimumSizeHintWidget : public Widget
{
public:
using Widget::Widget;
// Note: Some widget (e.g. QPushButton) minimumSizeHint implementations themselves use sizeHint,
// which would cause this to stack overflow.
QSize sizeHint() const override { return Widget::minimumSizeHint(); }
};
// Opens the folder of the given file (and also selects the file on supported platforms).
void ShowFileInFolder(std::string_view file_path);
} // namespace QtUtils
|