summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/NetPlay/NetPlayBrowser.h
blob: dcadd036a7d7cf6fad377c3361921593155aa6fe (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2019 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <map>
#include <mutex>
#include <optional>
#include <thread>
#include <vector>

#include <QDialog>

#include "Common/Event.h"
#include "Common/Flag.h"
#include "UICommon/NetPlayIndex.h"

class QCheckBox;
class QComboBox;
class QDialogButtonBox;
class QLabel;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QTableWidget;

class NetPlayBrowser : public QDialog
{
  Q_OBJECT
public:
  explicit NetPlayBrowser(QWidget* parent = nullptr);
  ~NetPlayBrowser() override;

  void accept() override;
signals:
  void Join();
  void UpdateStatusRequested(const QString& status);
  void UpdateListRequested(std::vector<NetPlaySession> sessions);

private:
  void CreateWidgets();
  void ConnectWidgets();

  void Refresh();
  void RefreshLoop();
  void UpdateList();

  void OnSelectionChanged();

  void OnUpdateStatusRequested(const QString& status);
  void OnUpdateListRequested(std::vector<NetPlaySession> sessions);

  void SaveSettings() const;
  void RestoreSettings();

  QComboBox* m_region_combo;
  QLabel* m_status_label;
  QPushButton* m_button_refresh;
  QTableWidget* m_table_widget;
  QDialogButtonBox* m_button_box;
  QLineEdit* m_edit_name;
  QLineEdit* m_edit_game_id;
  QCheckBox* m_check_hide_incompatible;
  QCheckBox* m_check_hide_ingame;

  QRadioButton* m_radio_all;
  QRadioButton* m_radio_private;
  QRadioButton* m_radio_public;

  std::vector<NetPlaySession> m_sessions;

  std::thread m_refresh_thread;
  std::optional<std::map<std::string, std::string>> m_refresh_filters;
  std::mutex m_refresh_filters_mutex;
  Common::Flag m_refresh_run;
  Common::Event m_refresh_event;
};

Q_DECLARE_METATYPE(std::vector<NetPlaySession>)