MythTV  master
mythuilocation.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "mythmainwindow.h"
3 #include "mythuilocation.h"
4 
5 void 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 QString("UNKNOWN");
17  return m_currentLocation.takeLast();
18 }
19 
20 QString 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 }
MythMainWindow::GetMainStack
MythScreenStack * GetMainStack()
Definition: mythmainwindow.cpp:324
MythUILocation::RemoveCurrentLocation
QString RemoveCurrentLocation()
Definition: mythuilocation.cpp:12
MythScreenStack
Definition: mythscreenstack.h:16
MythMainWindow::GetStack
MythScreenStack * GetStack(const QString &stackname)
Definition: mythmainwindow.cpp:329
MythUILocation::m_currentLocation
QStringList m_currentLocation
Definition: mythuilocation.h:20
MythUILocation::m_locationLock
QReadWriteLock m_locationLock
Definition: mythuilocation.h:19
mythuilocation.h
MythUILocation::GetCurrentLocation
QString GetCurrentLocation(bool FullPath=false, bool MainStackOnly=true)
Definition: mythuilocation.cpp:20
GetMythMainWindow
MythMainWindow * GetMythMainWindow(void)
Definition: mythmainwindow.cpp:108
MythScreenStack::GetLocation
QString GetLocation(bool fullPath) const
Definition: mythscreenstack.cpp:363
MythUILocation::AddCurrentLocation
void AddCurrentLocation(const QString &Location)
Definition: mythuilocation.cpp:5
mythmainwindow.h
MythMainWindow
Definition: mythmainwindow.h:35