Skip to content

Commit

Permalink
New "Open Windows" menu, showing currently open windows by title.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Carpenter authored and Michael Carpenter committed Nov 21, 2013
1 parent 74a2d6d commit f5c31ad
Show file tree
Hide file tree
Showing 22 changed files with 129 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/src/aboutview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ void AboutView::closeEvent(QCloseEvent *event)
{
event->ignore();
((QMdiSubWindow*)this->parent())->hide();
emit windowHiding((QMdiSubWindow*)this->parent());
}
2 changes: 2 additions & 0 deletions core/src/aboutview.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class AboutView : public QWidget
QString m_commit;
QString m_hash;
Ui::AboutView ui;
signals:
void windowHiding(QWidget *parent);
};

#endif // ABOUTVIEW_H
1 change: 1 addition & 0 deletions core/src/emsinfoview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ void EmsInfoView::closeEvent(QCloseEvent *event)
{
event->ignore();
((QMdiSubWindow*)this->parent())->hide();
emit windowHiding((QMdiSubWindow*)this->parent());
}
void EmsInfoView::locationIdInfo(unsigned short locationid,QString title,MemoryLocationInfo info)
{
Expand Down
2 changes: 2 additions & 0 deletions core/src/emsinfoview.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <QWidget>
#include <QCloseEvent>
#include <QMdiSubWindow>
#include "memorylocationinfo.h"
#include "datatype.h"
#include "ui_emsinfo.h"
Expand Down Expand Up @@ -52,6 +53,7 @@ public slots:
signals:
void displayLocationId(int locid, bool isram,DataType type);
void checkSync();
void windowHiding(QMdiSubWindow *parent);
};

#endif // EMSINFO_H
1 change: 1 addition & 0 deletions core/src/emsstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void EmsStatus::closeEvent(QCloseEvent *event)
{
event->ignore();
this->hide();
emit windowHiding((QMdiSubWindow*)this->parent());
}
EmsStatus::~EmsStatus()
{
Expand Down
2 changes: 2 additions & 0 deletions core/src/emsstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <QDockWidget>
#include <QCloseEvent>
#include <QMdiSubWindow>
#include "ui_emsstatus.h"

class EmsStatus : public QDockWidget
Expand All @@ -40,6 +41,7 @@ class EmsStatus : public QDockWidget
signals:
void hardResetRequest();
void softResetRequest();
void windowHiding(QMdiSubWindow *parent);
private:
Ui::EmsStatus ui;
};
Expand Down
1 change: 1 addition & 0 deletions core/src/flagview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void FlagView::closeEvent(QCloseEvent *event)
{
event->ignore();
((QMdiSubWindow*)this->parent())->hide();
emit windowHiding((QMdiSubWindow*)this->parent());
}
void FlagView::passData(QVariantMap data)
{
Expand Down
2 changes: 2 additions & 0 deletions core/src/flagview.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class FlagView : public QWidget
void closeEvent(QCloseEvent *event);
private:
Ui::DataFlags ui;
signals:
void windowHiding(QMdiSubWindow *parent);
};

#endif // DATAFLAGS_H
1 change: 1 addition & 0 deletions core/src/gaugeview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void GaugeView::closeEvent(QCloseEvent *event)
{
event->ignore();
((QMdiSubWindow*)this->parent())->hide();
emit windowHiding((QMdiSubWindow*)this->parent());
}
void GaugeView::passData(QVariantMap data)
{
Expand Down
3 changes: 3 additions & 0 deletions core/src/gaugeview.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <QWidget>
#include <QCloseEvent>
#include <QMdiSubWindow>
#include "ui_datagauges.h"
#include "gaugewidget.h"
#include "datapacketdecoder.h"
Expand All @@ -49,6 +50,8 @@ class GaugeView : public QWidget
void closeEvent(QCloseEvent *event);
private slots:
void guiUpdateTimerTick();
signals:
void windowHiding(QMdiSubWindow *parent);
};

#endif // GAUGEVIEW_H
6 changes: 6 additions & 0 deletions core/src/interrogateprogressview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ void InterrogateProgressView::closeEvent(QCloseEvent *event)
{
event->ignore();
((QMdiSubWindow*)this->parent())->hide();
emit windowHiding((QMdiSubWindow*)this->parent());
}
void InterrogateProgressView::hideEvent(QHideEvent *event)
{
Q_UNUSED(event)
emit windowHiding((QMdiSubWindow*)this->parent());
}
void InterrogateProgressView::reset()
{
Expand Down
3 changes: 3 additions & 0 deletions core/src/interrogateprogressview.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <QWidget>
#include <QCloseEvent>
#include <QMdiSubWindow>
#include "ui_interrogateprogressview.h"
#include "overviewprogressitemdelegate.h"
class InterrogateProgressView : public QWidget
Expand All @@ -45,13 +46,15 @@ class InterrogateProgressView : public QWidget
int progress() { return ui.progressBar->value(); }
protected:
void closeEvent(QCloseEvent *event);
void hideEvent(QHideEvent *event);
private:
Ui::InterrogateProgressView ui;
QMap<int,int> m_typeToOverviewListMap;
private slots:
void cancelClickedSlot();
signals:
void cancelClicked();
void windowHiding(QMdiSubWindow *parent);
};

#endif // INTERROGATEPROGRESSVIEW_H
2 changes: 1 addition & 1 deletion core/src/interrogateprogressview.ui
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
<string>Interrogation Progress</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
Expand Down
66 changes: 64 additions & 2 deletions core/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
connect(ui.actionParameter_View,SIGNAL(triggered()),this,SLOT(menu_windows_ParameterViewClicked()));
ui.actionInterrogation_Progress->setEnabled(false);


emsInfo=0;
dataTables=0;
dataFlags=0;
Expand Down Expand Up @@ -321,7 +322,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)


//ui.menuWizards

connect(ui.mdiArea,SIGNAL(subWindowActivated(QMdiSubWindow*)),this,SLOT(subMdiWindowActivated(QMdiSubWindow*)));

}
void MainWindow::menu_windows_interrogateProgressViewClicked()
Expand Down Expand Up @@ -1107,6 +1108,7 @@ void MainWindow::createView(unsigned short locid,DataType type)
view->setData(locid,data);

QMdiSubWindow *win = ui.mdiArea->addSubWindow(view);
connect(win,SIGNAL(destroyed(QObject*)),this,SLOT(rawDataViewDestroyed(QObject*)));
win->setWindowTitle("Ram Location 0x" + QString::number(locid,16).toUpper());
win->setGeometry(0,0,((view->width() < this->width()-160) ? view->width() : this->width()-160),((view->height() < this->height()-100) ? view->height() : this->height()-100));
m_rawDataView[locid] = view;
Expand Down Expand Up @@ -1163,8 +1165,14 @@ void MainWindow::rawDataViewDestroyed(QObject *object)
QMdiSubWindow *win = qobject_cast<QMdiSubWindow*>(object->parent());
if (!win)
{
return;
win = qobject_cast<QMdiSubWindow*>(object);
if (!win)
{
return;
}
}
ui.menuOpen_Windows->removeAction(m_mdiSubWindowToActionMap[win]);
m_mdiSubWindowToActionMap.remove(win);
win->hide();
ui.mdiArea->removeSubWindow(win);
return;
Expand Down Expand Up @@ -1561,6 +1569,7 @@ void MainWindow::emsCommsConnected()
progressView = new InterrogateProgressView();
connect(progressView,SIGNAL(destroyed(QObject*)),this,SLOT(interrogateProgressViewDestroyed(QObject*)));
interrogateProgressMdiWindow = ui.mdiArea->addSubWindow(progressView);
interrogateProgressMdiWindow->setWindowTitle(progressView->windowTitle());
interrogateProgressMdiWindow->setGeometry(progressView->geometry());
connect(progressView,SIGNAL(cancelClicked()),this,SLOT(interrogateProgressViewCancelClicked()));
progressView->setMaximum(0);
Expand Down Expand Up @@ -1950,6 +1959,59 @@ void MainWindow::logPayloadReceived(QByteArray header,QByteArray payload)
Q_UNUSED(payload)
pidcount++;
}
void MainWindow::windowHidden(QMdiSubWindow* window)
{
if (window && m_mdiSubWindowToActionMap.contains(window))
{
ui.menuOpen_Windows->removeAction(m_mdiSubWindowToActionMap[window]);
m_mdiSubWindowToActionMap.remove(window);
}
}
void MainWindow::windowDestroyed(QObject *window)
{
if (window && m_mdiSubWindowToActionMap.contains((QMdiSubWindow*)window))
{
ui.menuOpen_Windows->removeAction(m_mdiSubWindowToActionMap[(QMdiSubWindow*)window]);
m_mdiSubWindowToActionMap.remove((QMdiSubWindow*)window);
}
}

void MainWindow::bringToFrontAndShow()
{
for (QMap<QMdiSubWindow*,QAction*>::const_iterator i=m_mdiSubWindowToActionMap.constBegin();i!=m_mdiSubWindowToActionMap.constEnd();i++)
{
if (i.value() == sender())
{
i.key()->show();
QApplication::postEvent(i.key(), new QEvent(QEvent::Show));
QApplication::postEvent(i.key(), new QEvent(QEvent::WindowActivate));
}

}
}

void MainWindow::subMdiWindowActivated(QMdiSubWindow* window)
{
if (window && !m_mdiSubWindowToActionMap.contains(window))
{
if (window->isVisible())
{
//connect(window,SIGNAL(windowStateChanged(Qt::WindowStates,Qt::WindowStates))
QAction *action = ui.menuOpen_Windows->addAction(window->windowTitle());
connect(action,SIGNAL(triggered()),this,SLOT(bringToFrontAndShow()));
connect(window->widget(),SIGNAL(windowHiding(QMdiSubWindow*)),this,SLOT(windowHidden(QMdiSubWindow*)));
connect(window,SIGNAL(destroyed(QObject*)),this,SLOT(windowDestroyed(QObject*)));
m_mdiSubWindowToActionMap[window] = action;
}
//connect(action,SIGNAL(triggered(bool)),window,SLOT(setVisible(bool)));
//connect(action,SIGNAL(triggered()),this,SLOT(bringToFrontAndShow()));
QLOG_DEBUG() << "Window Activated New:" << window->windowTitle();
}
else if (window)
{
QLOG_DEBUG() << "Window Activated Old:" << window->windowTitle();
}
}

MainWindow::~MainWindow()
{
Expand Down
5 changes: 5 additions & 0 deletions core/src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ class MainWindow : public QMainWindow
//EmsData *emsData;
//EmsData *checkEmsData;
int m_currentEcuClock;
QMap<QMdiSubWindow*,QAction*> m_mdiSubWindowToActionMap;
private slots:
void windowHidden(QMdiSubWindow* window);
void bringToFrontAndShow();
void windowDestroyed(QObject *window);
void interrogationData(QMap<QString,QString> datamap);
void emsCommsSilence();
void emsCommsSilenceBroken();
Expand Down Expand Up @@ -232,6 +236,7 @@ private slots:
void interrogateTaskSucceed(int sequence);
void interrogateTaskFail(int sequence);
void locationIdList(QList<unsigned short> idlist);
void subMdiWindowActivated(QMdiSubWindow* window);

};

Expand Down
9 changes: 8 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>27</height>
<height>29</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down Expand Up @@ -79,6 +79,7 @@
<addaction name="actionEMS_Status"/>
<addaction name="actionInterrogation_Progress"/>
<addaction name="actionParameter_View"/>
<addaction name="separator"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
Expand All @@ -91,9 +92,15 @@
<string>Wizards</string>
</property>
</widget>
<widget class="QMenu" name="menuOpen_Windows">
<property name="title">
<string>Open Windows</string>
</property>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuWindows"/>
<addaction name="menuOpen_Windows"/>
<addaction name="menuWizards"/>
<addaction name="menuHelp"/>
</widget>
Expand Down
7 changes: 7 additions & 0 deletions core/src/packetstatusview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,14 @@ void PacketStatusView::closeEvent(QCloseEvent *event)
{
event->ignore();
((QMdiSubWindow*)this->parent())->hide();
emit windowHiding((QMdiSubWindow*)this->parent());
}
void PacketStatusView::hideEvent(QHideEvent *event)
{
Q_UNUSED(event)
emit windowHiding((QMdiSubWindow*)this->parent());
}

PacketStatusView::~PacketStatusView()
{
}
4 changes: 4 additions & 0 deletions core/src/packetstatusview.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define PACKETSTATUSVIEW_H

#include <QWidget>
#include <QMdiSubWindow>
#include "ui_packetstatusview.h"
class PacketStatusView : public QWidget
{
Expand All @@ -39,8 +40,11 @@ public slots:
void passDecoderFailure(QByteArray packet);
protected:
void closeEvent(QCloseEvent *event);
void hideEvent(QHideEvent *event);
private:
Ui::PacketStatusView ui;
signals:
void windowHiding(QMdiSubWindow *parent);
};

#endif // PACKETSTATUSVIEW_H
7 changes: 7 additions & 0 deletions core/src/parameterview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <QLabel>
#include <QLineEdit>
#include <QScrollArea>
#include <QCloseEvent>
#include <parameterwidget.h>
#include "QsLog.h"

Expand All @@ -24,6 +25,12 @@ void ParameterView::addConfig(QString name,ConfigData *data)
Q_UNUSED(data)

}
void ParameterView::closeEvent(QCloseEvent *event)
{
event->ignore();
((QMdiSubWindow*)this->parent())->hide();
emit windowHiding((QMdiSubWindow*)this->parent());
}

void ParameterView::currentItemChanged(QTreeWidgetItem *current,QTreeWidgetItem *prev)
{
Expand Down
4 changes: 4 additions & 0 deletions core/src/parameterview.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define PARAMETERVIEW_H

#include <QWidget>
#include <QMdiSubWindow>
#include "ui_parameterview.h"
#include "configblock.h"
#include "parameterwidget.h"
Expand Down Expand Up @@ -30,8 +31,11 @@ class ParameterView : public QWidget
MenuSetup m_metaMenu;
QList<ConfigBlock> m_memoryConfigBlockList;
Ui::Form ui;
protected:
void closeEvent(QCloseEvent *event);
signals:
void saveSingleData(unsigned short locationid,QByteArray data, unsigned short offset, unsigned short size);
void windowHiding(QMdiSubWindow *parent);
public slots:
void currentItemChanged(QTreeWidgetItem *current,QTreeWidgetItem *prev);
void itemSelectionChanged();
Expand Down
1 change: 1 addition & 0 deletions core/src/tableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void TableView::closeEvent(QCloseEvent *event)
{
event->ignore();
((QMdiSubWindow*)this->parent())->hide();
emit windowHiding((QMdiSubWindow*)this->parent());
}
void TableView::passDecoder(DataPacketDecoder *decoder)
{
Expand Down
Loading

0 comments on commit f5c31ad

Please sign in to comment.