Debian Codegraph @

xbmc/input/joysticks/dialogs/GUIDialogNewJoystick.cpp

raw
1 /*
2 * Copyright (C) 2016-2024 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #include "GUIDialogNewJoystick.h"
10
11 #include "ServiceBroker.h"
12 #include "guilib/GUIComponent.h"
13 #include "guilib/GUIWindowManager.h"
14 #include "guilib/WindowIDs.h"
15 #include "messaging/helpers/DialogHelper.h"
16 #include "settings/Settings.h"
17 #include "settings/SettingsComponent.h"
18
19 using namespace KODI;
20 using namespace JOYSTICK;
21
22 CGUIDialogNewJoystick::CGUIDialogNewJoystick() : CThread("NewJoystickDlg")
23 {
24 }
25
26 void CGUIDialogNewJoystick::ShowAsync()
27 {
28 bool bShow = true;
29
30 if (IsRunning())
31 bShow = false;
32 else if (!CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(
33 CSettings::SETTING_INPUT_ASKNEWCONTROLLERS))
34 bShow = false;
35 else if (CServiceBroker::GetGUI()->GetWindowManager().IsWindowActive(
36 WINDOW_DIALOG_GAME_CONTROLLERS, false))
37 bShow = false;
38
39 if (bShow)
40 Create();
41 }
42
43 void CGUIDialogNewJoystick::Process()
44 {
45 using namespace MESSAGING::HELPERS;
46
47 // "New controller detected"
48 // "A new controller has been detected. Configuration can be done at any time in "Settings ->
49 // System Settings -> Input". Would you like to configure it now?"
50 if (ShowYesNoDialogText(CVariant{35011}, CVariant{35012}) == DialogResponse::CHOICE_YES)
51 {
52 CServiceBroker::GetGUI()->GetWindowManager().ActivateWindow(WINDOW_DIALOG_GAME_CONTROLLERS);
53 }
54 else
55 {
56 CServiceBroker::GetSettingsComponent()->GetSettings()->SetBool(
57 CSettings::SETTING_INPUT_ASKNEWCONTROLLERS, false);
58 }
59 }