MythTV master
setupwizard_general.cpp
Go to the documentation of this file.
1// Qt
2#include <QString>
3#include <QVariant>
4
5// MythTV
12
13// MythFrontend
15#include "setupwizard_general.h"
16#include "setupwizard_audio.h"
17
18// ---------------------------------------------------
19
21 : MythScreenType(parent, name),
22 m_hardwareProfile(new HardwareProfile())
23{
24 m_popupStack = GetMythMainWindow()->GetStack("popup stack");
25}
26
28{
29 // Load the theme for this screen
30 bool foundtheme = LoadWindowFromXML("config-ui.xml", "generalwizard", this);
31 if (!foundtheme)
32 return false;
33
34 m_submitButton = dynamic_cast<MythUIButton *> (GetChild("submit"));
35 m_viewButton = dynamic_cast<MythUIButton *> (GetChild("view"));
36 m_deleteButton = dynamic_cast<MythUIButton *> (GetChild("delete"));
37
38 m_nextButton = dynamic_cast<MythUIButton *> (GetChild("next"));
39 m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
40
41 m_profileLocation = dynamic_cast<MythUIText *> (GetChild("profiletext"));
42 m_adminPassword = dynamic_cast<MythUIText *> (GetChild("profilepassword"));
43
46 {
47 LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
48 return false;
49 }
50
51 m_submitButton->SetHelpText( tr("Anonymously submit a profile of your hardware. "
52 "This helps the developers to determine where "
53 "to focus their efforts.") );
54 m_viewButton->SetHelpText( tr("Visit your online hardware profile. (This requires "
55 "that you have the MythBrowser plugin installed)") );
56 m_deleteButton->SetHelpText( tr("Delete your online hardware profile.") );
57
58 m_nextButton->SetHelpText( tr("Save these changes and move on to the "
59 "next configuration step.") );
60 m_cancelButton->SetHelpText( tr("Exit this wizard, save no changes.") );
61
65
68
70 loadData();
71
72#ifndef __linux__
73#ifndef CONFIG_BINDINGS_PYTHON
74 // The hardware profiler only works on linux.
75 // Make the widgets invisible on other platforms.
76
80
83
86#endif
87#endif
88
89 return true;
90}
91
93{
95 return;
96
98
101
102 if (m_adminPassword)
104}
105
107{
108 save();
109
111 auto *sw = new AudioSetupWizard(mainStack, this, "audiosetupwizard");
112
113 if (sw->Create())
114 {
115 mainStack->AddScreen(sw);
116 }
117 else
118 {
119 delete sw;
120 }
121}
122
124{
125 QString message = tr("Would you like to share your "
126 "hardware profile with the MythTV developers? "
127 "Profiles are anonymous and are a great way to "
128 "help with future development.");
129 auto *confirmdialog = new MythConfirmationDialog(m_popupStack,message);
130
131 if (confirmdialog->Create())
132 m_popupStack->AddScreen(confirmdialog);
133
134 connect(confirmdialog, &MythConfirmationDialog::haveResult,
136}
137
139{
140 if (submit)
141 {
142 CreateBusyDialog(tr("Submitting your hardware profile..."));
144 {
145 if (m_busyPopup)
146 {
148 m_busyPopup = nullptr;
149 }
150 ShowOkPopup(tr("Hardware profile submitted. Thank you for supporting "
151 "MythTV!"));
154 if (m_adminPassword)
156 }
157 else
158 {
159 if (m_busyPopup)
160 {
162 m_busyPopup = nullptr;
163 }
164 ShowOkPopup(tr("Encountered a problem while submitting your profile."));
165 }
166 }
167}
168
170{
171 if (gCoreContext->GetSetting("HardwareProfilePublicUUID").isEmpty())
172 {
173 ShowOkPopup(tr("You haven't submitted your hardware profile yet! "
174 "Please submit your profile to visit it online."));
175 return;
176 }
177
178 QString url = m_hardwareProfile->GetProfileURL();
179
180 LOG(VB_GENERAL, LOG_DEBUG, QString("Profile URL = %1").arg(url));
181
182 if (url.isEmpty())
183 return;
184
185 QString browser = gCoreContext->GetSetting("WebBrowserCommand", "");
186 QString zoom = gCoreContext->GetSetting("WebBrowserZoomLevel", "1.0");
187
188 if (browser.isEmpty())
189 {
190 ShowOkPopup(tr("No browser command set! MythTV needs a browser "
191 "installed and configure to display your hardware "
192 "profile."));
193 return;
194 }
195
196 if (browser.toLower() == "internal")
197 {
198 GetMythMainWindow()->HandleMedia("WebBrowser", url);
199 return;
200 }
201
202 QString cmd = browser;
203 cmd.replace("%ZOOM%", zoom);
204 cmd.replace("%URL%", url);
205 cmd.replace('\'', "%27");
206 cmd.replace("&","\\&");
207 cmd.replace(";","\\;");
208
212}
213
215{
216 if (gCoreContext->GetSetting("HardwareProfileUUID").isEmpty())
217 {
218 ShowOkPopup(tr("You haven't submitted your hardware profile yet!"));
219 return;
220 }
221
222 QString message = tr("Are you sure you want to delete "
223 "your online profile? Your information "
224 "is anonymous and helps the developers "
225 "to know what hardware the majority of users "
226 "prefer.");
227 auto *confirmdialog = new MythConfirmationDialog(m_popupStack,message);
228
229 if (confirmdialog->Create())
230 m_popupStack->AddScreen(confirmdialog);
231
232 connect(confirmdialog, &MythConfirmationDialog::haveResult,
234}
235
237{
238 if (submit)
239 {
240 CreateBusyDialog(tr("Deleting your hardware profile..."));
242 {
243 if (m_busyPopup)
244 {
246 m_busyPopup = nullptr;
247 }
248 ShowOkPopup(tr("Hardware profile deleted."));
251 if (m_adminPassword)
253 }
254 else
255 {
256 if (m_busyPopup)
257 {
259 m_busyPopup = nullptr;
260 }
261 ShowOkPopup(tr("Encountered a problem while deleting your profile."));
262 }
263 }
264}
265
267{
268}
269
271{
272 if (GetFocusWidget()->keyPressEvent(event))
273 return true;
274
275 bool handled = false;
276
278 handled = true;
279
280 return handled;
281}
282
283void GeneralSetupWizard::CreateBusyDialog(const QString& message)
284{
285 if (m_busyPopup)
286 return;
287
289 "setupwizardbusydialog");
290
291 if (m_busyPopup->Create())
293}
void CreateBusyDialog(const QString &message)
MythUIBusyDialog * m_busyPopup
MythUIButton * m_deleteButton
MythUIButton * m_submitButton
MythUIText * m_profileLocation
GeneralSetupWizard(MythScreenStack *parent, const char *name=nullptr)
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
MythUIButton * m_nextButton
HardwareProfile * m_hardwareProfile
bool Create(void) override
MythUIButton * m_viewButton
void OnDeletePromptReturn(bool submit)
MythUIText * m_adminPassword
MythUIButton * m_cancelButton
MythScreenStack * m_popupStack
void OnSubmitPromptReturn(bool submit)
void GenerateUUIDs(void)
QString GetProfileURL(void) const
bool DeleteProfile(void)
static QString GetAdminPasswordFromFile(void)
bool SubmitProfile(bool updateTime=true)
Dialog asking for user confirmation.
QString GetSetting(const QString &key, const QString &defaultval="")
MythScreenStack * GetMainStack()
MythScreenStack * GetStack(const QString &Stackname)
bool HandleMedia(const QString &Handler, const QString &Mrl, const QString &Plot="", const QString &Title="", const QString &Subtitle="", const QString &Director="", int Season=0, int Episode=0, const QString &Inetref="", std::chrono::minutes LenMins=2h, const QString &Year="1895", const QString &Id="", bool UseBookmarks=false)
void AllowInput(bool Allow)
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Screen in which all other widgets are contained and rendered.
void BuildFocusList(void)
MythUIType * GetFocusWidget(void) const
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
virtual void Close()
bool Create(void) override
A single button widget.
Definition: mythuibutton.h:22
void Clicked()
All purpose text widget, displays a text string.
Definition: mythuitext.h:29
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:115
void SetHelpText(const QString &text)
Definition: mythuitype.h:177
void Hide(void)
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:138
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythMainWindow * GetMythMainWindow(void)
@ kMSDontDisableDrawing
avoid disabling UI drawing
Definition: mythsystem.h:37
uint myth_system(const QString &command, uint flags, std::chrono::seconds timeout)