MythTV  master
mythuihelper.cpp
Go to the documentation of this file.
1 #include "mythuihelper.h"
2 
3 #include <cmath>
4 #include <unistd.h>
5 #include <iostream>
6 
7 #include <QMutex>
8 #include <QMap>
9 #include <QDir>
10 #include <QFileInfo>
11 #include <QApplication>
12 #include <QStyleFactory>
13 #include <QFile>
14 #include <QTimer>
15 
16 // mythbase headers
17 #include "mythdirs.h"
18 #include "mythlogging.h"
19 #include "mythdb.h"
20 #include "mythcorecontext.h"
21 #include "storagegroup.h"
22 
23 // mythui headers
24 #include "mythprogressdialog.h"
25 #include "mythimage.h"
26 #include "mythmainwindow.h"
27 #include "themeinfo.h"
28 #include "x11colors.h"
29 #include "mythdisplay.h"
30 
31 #define LOC QString("MythUIHelper: ")
32 
33 static MythUIHelper *mythui = nullptr;
34 static QMutex uiLock;
35 
37 {
38  if (mythui)
39  return mythui;
40 
41  uiLock.lock();
42 
43  if (!mythui)
44  mythui = new MythUIHelper();
45 
46  uiLock.unlock();
47 
48  // These directories should always exist. Don't test first as
49  // there's no harm in trying to create an existing directory.
50  QDir dir;
51  dir.mkdir(GetThemeBaseCacheDir());
52  dir.mkdir(GetRemoteCacheDir());
53  dir.mkdir(GetThumbnailDir());
54 
55  return mythui;
56 }
57 
59 {
60  uiLock.lock();
61  delete mythui;
62  mythui = nullptr;
63  uiLock.unlock();
64 }
65 
67 {
68  return MythUIHelper::getMythUI();
69 }
70 
72 {
74 }
75 
77 {
78  m_screenSetup = true;
80  m_callbacks = cbs;
81 }
82 
83 // This init is used for showing the startup UI that is shown
84 // before the database is initialized. The above init is called later,
85 // after the DB is available.
86 // This class does not mind being Initialized twice.
88 {
89  m_screenSetup = true;
91 }
92 
94 {
95  return &m_callbacks;
96 }
97 
99 {
100  return m_screenSetup;
101 }
x11colors.h
uiLock
static QMutex uiLock
Definition: mythuihelper.cpp:34
mythdb.h
MythUIHelper::Init
void Init()
Definition: mythuihelper.cpp:87
MythUIHelper::IsScreenSetup
bool IsScreenSetup() const
Definition: mythuihelper.cpp:98
MythUIHelper::getMythUI
static MythUIHelper * getMythUI()
Definition: mythuihelper.cpp:36
mythdirs.h
MythUIHelper::m_callbacks
MythUIMenuCallbacks m_callbacks
Definition: mythuihelper.h:43
mythprogressdialog.h
mythdisplay.h
mythlogging.h
themeinfo.h
MythUIHelper::m_screenSetup
bool m_screenSetup
Definition: mythuihelper.h:44
MythUIHelper::GetMenuCBs
MythUIMenuCallbacks * GetMenuCBs()
Definition: mythuihelper.cpp:93
GetThemeBaseCacheDir
QString GetThemeBaseCacheDir(void)
Returns the base directory where all theme related files should be cached.
Definition: mythdirs.cpp:257
storagegroup.h
GetThumbnailDir
QString GetThumbnailDir(void)
Returns the directory where all non-theme thumbnail files should be cached.
Definition: mythdirs.cpp:249
MythUIThemeHelper::InitThemeHelper
void InitThemeHelper()
Definition: mythuithemehelper.cpp:13
GetRemoteCacheDir
QString GetRemoteCacheDir(void)
Returns the directory for all files cached from the backend.
Definition: mythdirs.cpp:241
mythuihelper.h
mythimage.h
mythcorecontext.h
dir
QDir dir
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1174
MythUIHelper::MythUIHelper
MythUIHelper()=default
MythUIHelper::destroyMythUI
static void destroyMythUI()
Definition: mythuihelper.cpp:58
MythUIHelper
Definition: mythuihelper.h:25
GetMythUI
MythUIHelper * GetMythUI()
Definition: mythuihelper.cpp:66
mythmainwindow.h
mythui
static MythUIHelper * mythui
Definition: mythuihelper.cpp:33
DestroyMythUI
void DestroyMythUI()
Definition: mythuihelper.cpp:71
MythUIMenuCallbacks
Definition: mythuihelper.h:15