MythTV master
setupwizard_general.cpp
Go to the documentation of this file.
1// Qt
2#include <QtGlobal>
3#include <QString>
4#include <QVariant>
5
6// MythTV
7#include "libmythbase/mythconfig.h"
14
15// MythFrontend
17#include "setupwizard_general.h"
18#include "setupwizard_audio.h"
19
20// ---------------------------------------------------
21
23 : MythScreenType(parent, name),
24 m_hardwareProfile(new HardwareProfile())
25{
26 m_popupStack = GetMythMainWindow()->GetStack("popup stack");
27}
28
30{
31 // Load the theme for this screen
32 bool foundtheme = LoadWindowFromXML("config-ui.xml", "generalwizard", this);
33 if (!foundtheme)
34 return false;
35
36 m_submitButton = dynamic_cast<MythUIButton *> (GetChild("submit"));
37 m_viewButton = dynamic_cast<MythUIButton *> (GetChild("view"));
38 m_deleteButton = dynamic_cast<MythUIButton *> (GetChild("delete"));
39
40 m_nextButton = dynamic_cast<MythUIButton *> (GetChild("next"));
41 m_cancelButton = dynamic_cast<MythUIButton *> (GetChild("cancel"));
42
43 m_profileLocation = dynamic_cast<MythUIText *> (GetChild("profiletext"));
44 m_adminPassword = dynamic_cast<MythUIText *> (GetChild("profilepassword"));
45
48 {
49 LOG(VB_GENERAL, LOG_ERR, "Theme is missing critical theme elements.");
50 return false;
51 }
52
53 m_submitButton->SetHelpText( tr("Anonymously submit a profile of your hardware. "
54 "This helps the developers to determine where "
55 "to focus their efforts.") );
56 m_viewButton->SetHelpText( tr("Visit your online hardware profile. (This requires "
57 "that you have the MythBrowser plugin installed)") );
58 m_deleteButton->SetHelpText( tr("Delete your online hardware profile.") );
59
60 m_nextButton->SetHelpText( tr("Save these changes and move on to the "
61 "next configuration step.") );
62 m_cancelButton->SetHelpText( tr("Exit this wizard, save no changes.") );
63
67
70
72 loadData();
73
74#ifndef Q_OS_LINUX
75#ifndef CONFIG_BINDINGS_PYTHON
76 // The hardware profiler only works on linux.
77 // Make the widgets invisible on other platforms.
78
82
85
88#endif
89#endif
90
91 return true;
92}
93
95{
97 return;
98
100
103
104 if (m_adminPassword)
106}
107
109{
110 save();
111
113 auto *sw = new AudioSetupWizard(mainStack, this, "audiosetupwizard");
114
115 if (sw->Create())
116 {
117 mainStack->AddScreen(sw);
118 }
119 else
120 {
121 delete sw;
122 }
123}
124
126{
127 QString message = tr("Would you like to share your "
128 "hardware profile with the MythTV developers? "
129 "Profiles are anonymous and are a great way to "
130 "help with future development.");
131 auto *confirmdialog = new MythConfirmationDialog(m_popupStack,message);
132
133 if (confirmdialog->Create())
134 m_popupStack->AddScreen(confirmdialog);
135
136 connect(confirmdialog, &MythConfirmationDialog::haveResult,
138}
139
141{
142 if (submit)
143 {
144 CreateBusyDialog(tr("Submitting your hardware profile..."));
146 {
147 if (m_busyPopup)
148 {
150 m_busyPopup = nullptr;
151 }
152 ShowOkPopup(tr("Hardware profile submitted. Thank you for supporting "
153 "MythTV!"));
156 if (m_adminPassword)
158 }
159 else
160 {
161 if (m_busyPopup)
162 {
164 m_busyPopup = nullptr;
165 }
166 ShowOkPopup(tr("Encountered a problem while submitting your profile."));
167 }
168 }
169}
170
172{
173 if (gCoreContext->GetSetting("HardwareProfilePublicUUID").isEmpty())
174 {
175 ShowOkPopup(tr("You haven't submitted your hardware profile yet! "
176 "Please submit your profile to visit it online."));
177 return;
178 }
179
180 QString url = m_hardwareProfile->GetProfileURL();
181
182 LOG(VB_GENERAL, LOG_DEBUG, QString("Profile URL = %1").arg(url));
183
184 if (url.isEmpty())
185 return;
186
187 QString browser = gCoreContext->GetSetting("WebBrowserCommand", "");
188 QString zoom = gCoreContext->GetSetting("WebBrowserZoomLevel", "1.0");
189
190 if (browser.isEmpty())
191 {
192 ShowOkPopup(tr("No browser command set! MythTV needs a browser "
193 "installed and configure to display your hardware "
194 "profile."));
195 return;
196 }
197
198 if (browser.toLower() == "internal")
199 {
200 GetMythMainWindow()->HandleMedia("WebBrowser", url);
201 return;
202 }
203
204 QString cmd = browser;
205 cmd.replace("%ZOOM%", zoom);
206 cmd.replace("%URL%", url);
207 cmd.replace('\'', "%27");
208 cmd.replace("&","\\&");
209 cmd.replace(";","\\;");
210
214}
215
217{
218 if (gCoreContext->GetSetting("HardwareProfileUUID").isEmpty())
219 {
220 ShowOkPopup(tr("You haven't submitted your hardware profile yet!"));
221 return;
222 }
223
224 QString message = tr("Are you sure you want to delete "
225 "your online profile? Your information "
226 "is anonymous and helps the developers "
227 "to know what hardware the majority of users "
228 "prefer.");
229 auto *confirmdialog = new MythConfirmationDialog(m_popupStack,message);
230
231 if (confirmdialog->Create())
232 m_popupStack->AddScreen(confirmdialog);
233
234 connect(confirmdialog, &MythConfirmationDialog::haveResult,
236}
237
239{
240 if (submit)
241 {
242 CreateBusyDialog(tr("Deleting your hardware profile..."));
244 {
245 if (m_busyPopup)
246 {
248 m_busyPopup = nullptr;
249 }
250 ShowOkPopup(tr("Hardware profile deleted."));
253 if (m_adminPassword)
255 }
256 else
257 {
258 if (m_busyPopup)
259 {
261 m_busyPopup = nullptr;
262 }
263 ShowOkPopup(tr("Encountered a problem while deleting your profile."));
264 }
265 }
266}
267
269{
270}
271
273{
274 if (GetFocusWidget()->keyPressEvent(event))
275 return true;
276
277 bool handled = false;
278
280 handled = true;
281
282 return handled;
283}
284
285void GeneralSetupWizard::CreateBusyDialog(const QString& message)
286{
287 if (m_busyPopup)
288 return;
289
291 "setupwizardbusydialog");
292
293 if (m_busyPopup->Create())
295}
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:188
void Hide(void)
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:130
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)