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