qt_profile_select.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <vector>
  5. #include <QDialog>
  6. #include <QList>
  7. #include "core/frontend/applets/profile_select.h"
  8. class ControllerNavigation;
  9. class GMainWindow;
  10. class QDialogButtonBox;
  11. class QGraphicsScene;
  12. class QLabel;
  13. class QScrollArea;
  14. class QStandardItem;
  15. class QStandardItemModel;
  16. class QTreeView;
  17. class QVBoxLayout;
  18. namespace Core {
  19. class System;
  20. }
  21. namespace Service::Account {
  22. class ProfileManager;
  23. }
  24. class QtProfileSelectionDialog final : public QDialog {
  25. Q_OBJECT
  26. public:
  27. explicit QtProfileSelectionDialog(Core::System& system, QWidget* parent,
  28. const Core::Frontend::ProfileSelectParameters& parameters);
  29. ~QtProfileSelectionDialog() override;
  30. int exec() override;
  31. void accept() override;
  32. void reject() override;
  33. int GetIndex() const;
  34. private:
  35. void SelectUser(const QModelIndex& index);
  36. void SetWindowTitle(const Core::Frontend::ProfileSelectParameters& parameters);
  37. void SetDialogPurpose(const Core::Frontend::ProfileSelectParameters& parameters);
  38. int user_index = 0;
  39. QVBoxLayout* layout;
  40. QTreeView* tree_view;
  41. QStandardItemModel* item_model;
  42. QGraphicsScene* scene;
  43. std::vector<QList<QStandardItem*>> list_items;
  44. QVBoxLayout* outer_layout;
  45. QLabel* instruction_label;
  46. QScrollArea* scroll_area;
  47. QDialogButtonBox* buttons;
  48. Service::Account::ProfileManager& profile_manager;
  49. ControllerNavigation* controller_navigation = nullptr;
  50. };
  51. class QtProfileSelector final : public QObject, public Core::Frontend::ProfileSelectApplet {
  52. Q_OBJECT
  53. public:
  54. explicit QtProfileSelector(GMainWindow& parent);
  55. ~QtProfileSelector() override;
  56. void Close() const override;
  57. void SelectProfile(SelectProfileCallback callback_,
  58. const Core::Frontend::ProfileSelectParameters& parameters) const override;
  59. signals:
  60. void MainWindowSelectProfile(const Core::Frontend::ProfileSelectParameters& parameters) const;
  61. void MainWindowRequestExit() const;
  62. private:
  63. void MainWindowFinishedSelection(std::optional<Common::UUID> uuid);
  64. mutable SelectProfileCallback callback;
  65. };