Skip to content

Commit

Permalink
Changes for allowing dashboard qml files to be read in and available …
Browse files Browse the repository at this point in the history
…instead of just a single gauge view
  • Loading branch information
malcom2073 committed Jan 26, 2014
1 parent a33ee51 commit f69ab6d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
30 changes: 30 additions & 0 deletions core/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
gaugesMdiWindow->hide();
gaugesMdiWindow->setWindowTitle(dataGauges->windowTitle());

loadDashboards("src/");
loadDashboards(".");
loadDashboards(m_defaultsDir + "/" + "dashboards");

if (QFile::exists(m_defaultsDir + "/" + "dashboards/gauges.qml"))
{
//qml file is in the program files directory, or in /usr/share
Expand Down Expand Up @@ -1245,6 +1249,28 @@ void MainWindow::emsOperatingSystem(QString os)
{
emsinfo.operatingSystem = os;
}
void MainWindow::loadDashboards(QString dir)
{
QDir dashboards(dir);
foreach (QString file,dashboards.entryList(QDir::Files | QDir::NoDotAndDotDot))
{
if (file.endsWith(".qml"))
{
GaugeView *view = new GaugeView();
QMdiSubWindow *mdiView = ui.mdiArea->addSubWindow(view);
mdiView->setGeometry(view->geometry());
mdiView->hide();
mdiView->setWindowTitle(view->windowTitle());
view->setFile(dashboards.absoluteFilePath(file));
QAction *action = new QAction(this);
action->setText(file.mid(0,file.lastIndexOf(".")));
action->setCheckable(true);
ui.menuDashboards->addAction(action);
connect(action,SIGNAL(triggered(bool)),mdiView,SLOT(setVisible(bool)));
m_dashboardList.append(view);
}
}
}
void MainWindow::loadWizards(QString dir)
{
QDir wizards(dir);
Expand Down Expand Up @@ -1837,6 +1863,10 @@ void MainWindow::dataLogDecoded(QVariantMap data)
dview->passDatalog(data);
}
}
for (int i=0;i<m_dashboardList.size();i++)
{
m_dashboardList[i]->passData(data);
}
}
void MainWindow::logPayloadReceived(QByteArray header,QByteArray payload)
{
Expand Down
2 changes: 2 additions & 0 deletions core/src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ class MainWindow : public QMainWindow
void connectToEms();
private:
void loadWizards(QString dir);
void loadDashboards(QString dir);
QList<GaugeView*> m_dashboardList;
QList<unsigned short> m_locationIdList;
bool m_checkEmsDataInUse;
bool m_offlineMode;
Expand Down
8 changes: 7 additions & 1 deletion core/src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<x>0</x>
<y>0</y>
<width>1525</width>
<height>25</height>
<height>29</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down Expand Up @@ -97,10 +97,16 @@
<string>Open Windows</string>
</property>
</widget>
<widget class="QMenu" name="menuDashboards">
<property name="title">
<string>Dashboards</string>
</property>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuWindows"/>
<addaction name="menuOpen_Windows"/>
<addaction name="menuDashboards"/>
<addaction name="menuWizards"/>
<addaction name="menuHelp"/>
</widget>
Expand Down

0 comments on commit f69ab6d

Please sign in to comment.