MythTV master
mythuilocation.cpp
Go to the documentation of this file.
1// MythTV
2#include "mythmainwindow.h"
3#include "mythuilocation.h"
4
5void MythUILocation::AddCurrentLocation(const QString& Location)
6{
7 QWriteLocker locker(&m_locationLock);
8 if (m_currentLocation.isEmpty() || m_currentLocation.last() != Location)
9 m_currentLocation.push_back(Location);
10}
11
13{
14 QWriteLocker locker(&m_locationLock);
15 if (m_currentLocation.isEmpty())
16 return {"UNKNOWN"};
17 return m_currentLocation.takeLast();
18}
19
20QString MythUILocation::GetCurrentLocation(bool FullPath, bool MainStackOnly)
21{
22 QString result;
23 QReadLocker locker(&m_locationLock);
24
26 if (!window)
27 return result;
28
29 if (FullPath)
30 {
31 // get main stack top screen
32 MythScreenStack *stack = window->GetMainStack();
33 result = stack->GetLocation(true);
34
35 if (!MainStackOnly)
36 {
37 // get popup stack main screen
38 stack = window->GetStack("popup stack");
39
40 if (!stack->GetLocation(true).isEmpty())
41 result += '/' + stack->GetLocation(false);
42 }
43
44 // if there's a location in the stringlist add that (non mythui screen or external app running)
45 if (!m_currentLocation.isEmpty())
46 {
47 for (int x = 0; x < m_currentLocation.count(); x++)
48 result += '/' + m_currentLocation[x];
49 }
50 }
51 else
52 {
53 // get main stack top screen
54 MythScreenStack *stack = window->GetMainStack();
55 result = stack->GetLocation(false);
56
57 if (!MainStackOnly)
58 {
59 // get popup stack top screen
60 stack = window->GetStack("popup stack");
61
62 if (!stack->GetLocation(false).isEmpty())
63 result = stack->GetLocation(false);
64 }
65
66 // if there's a location in the stringlist use that (non mythui screen or external app running)
67 if (!m_currentLocation.isEmpty())
68 result = m_currentLocation.last();
69 }
70
71 if (result.isEmpty())
72 result = "UNKNOWN";
73
74 return result;
75}
MythScreenStack * GetMainStack()
MythScreenStack * GetStack(const QString &Stackname)
QString GetLocation(bool fullPath) const
QString RemoveCurrentLocation()
QString GetCurrentLocation(bool FullPath=false, bool MainStackOnly=true)
void AddCurrentLocation(const QString &Location)
QStringList m_currentLocation
QReadWriteLock m_locationLock
MythMainWindow * GetMythMainWindow(void)