Debian Codegraph @

Source/Core/DolphinQt/Settings/USBDevicePicker.h

raw symbols SCIP
1 // Copyright 2017 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #include <optional>
7 #include <vector>
8
9 #include <QDialog>
10
11 #include "Core/USBUtils.h"
12
13 class QTimer;
14 class QDialog;
15 class QHeaderView;
16 class QLabel;
17 class QLineEdit;
18 class QDialogButtonBox;
19 class QVBoxLayout;
20 class QHBoxLayout;
21 class QListView;
22 class QPushButton;
23 class QListWidget;
24 class QPushButton;
25 class QErrorMessage;
26 class QMessageBox;
27
28 class USBDevicePicker final : public QDialog
29 {
30 Q_OBJECT
31 public:
32 using FilterFunctionType = std::function<bool(const USBUtils::DeviceInfo&)>;
33 explicit USBDevicePicker(QWidget* parent, FilterFunctionType filter);
34
35 static std::optional<USBUtils::DeviceInfo> Run(
36 QWidget* parent, const QString& title,
37 const FilterFunctionType filter = [](const USBUtils::DeviceInfo&) { return true; });
38
39 private:
40 static constexpr int DEVICE_REFRESH_INTERVAL_MS = 100;
41 QTimer* m_refresh_devices_timer;
42 QDialogButtonBox* m_picker_buttonbox;
43 QVBoxLayout* main_layout;
44 QLabel* enter_device_id_label;
45 QHBoxLayout* entry_hbox_layout;
46 QLineEdit* device_vid_textbox;
47 QLineEdit* device_pid_textbox;
48 QLabel* select_label;
49 QListWidget* usb_inserted_devices_list;
50
51 FilterFunctionType m_filter;
52
53 std::optional<USBUtils::DeviceInfo> GetSelectedDevice() const;
54
55 void InitControls();
56 void RefreshDeviceList();
57
58 void OnDeviceSelection();
59
60 std::vector<USBUtils::DeviceInfo> m_shown_devices;
61 };