Debian Codegraph @

Source/Core/DolphinQt/QtUtils/QtUtils.h

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