MythTV  master
setupwizard_general.cpp
Go to the documentation of this file.
1 // qt
2 #include <QString>
3 #include <QVariant>
4 
5 // myth
6 #include "mythcontext.h"
7 #include "mythsystemlegacy.h"
8 #include "mythdbcon.h"
9 #include "mythdirs.h"
10 
11 #include "hardwareprofile.h"
12 
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 
61  connect(m_submitButton, SIGNAL(Clicked()), this, SLOT(slotSubmit()));
62  connect(m_viewButton, SIGNAL(Clicked()), this, SLOT(slotView()));
63  connect(m_deleteButton, SIGNAL(Clicked()), this, SLOT(slotDelete()));
64 
65  connect(m_nextButton, SIGNAL(Clicked()), this, SLOT(slotNext()));
66  connect(m_cancelButton, SIGNAL(Clicked()), this, SLOT(Close()));
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  AudioSetupWizard *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  MythConfirmationDialog *confirmdialog =
128 
129  if (confirmdialog->Create())
130  m_popupStack->AddScreen(confirmdialog);
131 
132  connect(confirmdialog, SIGNAL(haveResult(bool)),
133  SLOT(OnSubmitPromptReturn(bool)));
134 }
135 
137 {
138  if (submit)
139  {
140  CreateBusyDialog(tr("Submitting your hardware profile..."));
142  {
143  if (m_busyPopup)
144  {
145  m_busyPopup->Close();
146  m_busyPopup = nullptr;
147  }
148  ShowOkPopup(tr("Hardware profile submitted. Thank you for supporting "
149  "MythTV!"));
150  if (m_profileLocation)
152  if (m_adminPassword)
154  }
155  else
156  {
157  if (m_busyPopup)
158  {
159  m_busyPopup->Close();
160  m_busyPopup = nullptr;
161  }
162  ShowOkPopup(tr("Encountered a problem while submitting your profile."));
163  }
164  }
165 }
166 
168 {
169  if (gCoreContext->GetSetting("HardwareProfilePublicUUID").isEmpty())
170  {
171  ShowOkPopup(tr("You haven't submitted your hardware profile yet! "
172  "Please submit your profile to visit it online."));
173  return;
174  }
175 
176  QString url = m_hardwareProfile->GetProfileURL();
177 
178  LOG(VB_GENERAL, LOG_DEBUG, QString("Profile URL = %1").arg(url));
179 
180  if (url.isEmpty())
181  return;
182 
183  QString browser = gCoreContext->GetSetting("WebBrowserCommand", "");
184  QString zoom = gCoreContext->GetSetting("WebBrowserZoomLevel", "1.0");
185 
186  if (browser.isEmpty())
187  {
188  ShowOkPopup(tr("No browser command set! MythTV needs a browser "
189  "installed and configure to display your hardware "
190  "profile."));
191  return;
192  }
193 
194  if (browser.toLower() == "internal")
195  {
196  GetMythMainWindow()->HandleMedia("WebBrowser", url);
197  return;
198  }
199 
200  QString cmd = browser;
201  cmd.replace("%ZOOM%", zoom);
202  cmd.replace("%URL%", url);
203  cmd.replace('\'', "%27");
204  cmd.replace("&","\\&");
205  cmd.replace(";","\\;");
206 
207  GetMythMainWindow()->AllowInput(false);
209  GetMythMainWindow()->AllowInput(true);
210 }
211 
213 {
214  if (gCoreContext->GetSetting("HardwareProfileUUID").isEmpty())
215  {
216  ShowOkPopup(tr("You haven't submitted your hardware profile yet!"));
217  return;
218  }
219 
220  QString message = tr("Are you sure you want to delete "
221  "your online profile? Your information "
222  "is anonymous and helps the developers "
223  "to know what hardware the majority of users "
224  "prefer.");
225  MythConfirmationDialog *confirmdialog =
227 
228  if (confirmdialog->Create())
229  m_popupStack->AddScreen(confirmdialog);
230 
231  connect(confirmdialog, SIGNAL(haveResult(bool)),
232  SLOT(OnDeletePromptReturn(bool)));
233 }
234 
236 {
237  if (submit)
238  {
239  CreateBusyDialog(tr("Deleting your hardware profile..."));
241  {
242  if (m_busyPopup)
243  {
244  m_busyPopup->Close();
245  m_busyPopup = nullptr;
246  }
247  ShowOkPopup(tr("Hardware profile deleted."));
248  if (m_profileLocation)
250  if (m_adminPassword)
252  }
253  else
254  {
255  if (m_busyPopup)
256  {
257  m_busyPopup->Close();
258  m_busyPopup = nullptr;
259  }
260  ShowOkPopup(tr("Encountered a problem while deleting your profile."));
261  }
262  }
263 }
264 
266 {
267 }
268 
269 bool GeneralSetupWizard::keyPressEvent(QKeyEvent *event)
270 {
271  if (GetFocusWidget()->keyPressEvent(event))
272  return true;
273 
274  bool handled = false;
275 
277  handled = true;
278 
279  return handled;
280 }
281 
282 void GeneralSetupWizard::CreateBusyDialog(const QString& message)
283 {
284  if (m_busyPopup)
285  return;
286 
288  "setupwizardbusydialog");
289 
290  if (m_busyPopup->Create())
292 }
avoid disabling UI drawing
Definition: mythsystem.h:35
MythUIButton * m_cancelButton
Dialog asking for user confirmation.
MythConfirmationDialog * ShowOkPopup(const QString &message, QObject *parent, const char *slot, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
MythUIText * m_profileLocation
virtual void SetText(const QString &text)
Definition: mythuitext.cpp:136
void AllowInput(bool allow)
MythScreenStack * GetStack(const QString &stackname)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythScreenStack * GetMainStack()
MythUIButton * m_viewButton
void BuildFocusList(void)
MythUIButton * m_nextButton
void CreateBusyDialog(const QString &message)
void Hide(void)
virtual void Close()
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
void SetHelpText(const QString &text)
Definition: mythuitype.h:150
bool Create(void) override
QString GetAdminPasswordFromFile(void) const
HardwareProfile * m_hardwareProfile
QString GetSetting(const QString &key, const QString &defaultval="")
MythUIButton * m_deleteButton
bool Create(void) override
MythUIButton * m_submitButton
const char * name
Definition: ParseText.cpp:328
uint myth_system(const QString &command, uint flags, uint timeout)
void GenerateUUIDs(void)
static bool LoadWindowFromXML(const QString &xmlfile, const QString &windowname, MythUIType *parent)
MythUIType * GetFocusWidget(void) const
MythMainWindow * GetMythMainWindow(void)
QString GetProfileURL(void) const
bool keyPressEvent(QKeyEvent *) override
Key event handler.
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
bool Create(void) override
bool SubmitProfile(bool updateTime=true)
MythUIBusyDialog * m_busyPopup
bool Create(void) override
void OnSubmitPromptReturn(bool submit)
void OnDeletePromptReturn(bool submit)
MythUIText * m_adminPassword
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="", int lenMins=120, const QString &year="1895", const QString &id="", bool useBookmarks=false)
Screen in which all other widgets are contained and rendered.
MythScreenStack * m_popupStack
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
Definition: mythuitype.cpp:132
GeneralSetupWizard(MythScreenStack *parent, const char *name=nullptr)
bool keyPressEvent(QKeyEvent *) override
Key event handler.
bool DeleteProfile(void)