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 result += '/' + m_currentLocation.join('/');
48 }
49 }
50 else
51 {
52 // get main stack top screen
53 MythScreenStack *stack = window->GetMainStack();
54 result = stack->GetLocation(false);
55
56 if (!MainStackOnly)
57 {
58 // get popup stack top screen
59 stack = window->GetStack("popup stack");
60
61 if (!stack->GetLocation(false).isEmpty())
62 result = stack->GetLocation(false);
63 }
64
65 // if there's a location in the stringlist use that (non mythui screen or external app running)
66 if (!m_currentLocation.isEmpty())
67 result = m_currentLocation.at(m_currentLocation.size()-1);
68 }
69
70 if (result.isEmpty())
71 result = "UNKNOWN";
72
73 return result;
74}
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)