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