Made connection window store window size/position. Tweaked teardown
code.
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "canconmanager.h"
|
#include "canconmanager.h"
|
||||||
|
|
||||||
|
|
||||||
CANConManager* CANConManager::mInstance = NULL;
|
CANConManager* CANConManager::mInstance = NULL;
|
||||||
|
|
||||||
CANConManager* CANConManager::getInstance()
|
CANConManager* CANConManager::getInstance()
|
||||||
@@ -14,7 +13,6 @@ CANConManager* CANConManager::getInstance()
|
|||||||
return mInstance;
|
return mInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CANConManager::CANConManager(QObject *parent): QObject(parent)
|
CANConManager::CANConManager(QObject *parent): QObject(parent)
|
||||||
{
|
{
|
||||||
connect(&mTimer, SIGNAL(timeout()), this, SLOT(refreshCanList()));
|
connect(&mTimer, SIGNAL(timeout()), this, SLOT(refreshCanList()));
|
||||||
@@ -46,6 +44,13 @@ CANConManager::~CANConManager()
|
|||||||
mInstance = NULL;
|
mInstance = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CANConManager::stopAllConnections()
|
||||||
|
{
|
||||||
|
foreach (CANConnection *conn, mConns)
|
||||||
|
{
|
||||||
|
conn->stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CANConManager::add(CANConnection* pConn_p)
|
void CANConManager::add(CANConnection* pConn_p)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public:
|
|||||||
void add(CANConnection* pConn_p);
|
void add(CANConnection* pConn_p);
|
||||||
void remove(CANConnection* pConn_p);
|
void remove(CANConnection* pConn_p);
|
||||||
QList<CANConnection*>& getConnections();
|
QList<CANConnection*>& getConnections();
|
||||||
|
void stopAllConnections();
|
||||||
|
|
||||||
CANConnection* getByName(const QString& pName) const;
|
CANConnection* getByName(const QString& pName) const;
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
|
|||||||
ui->tableConnections->setColumnWidth(5, 75);
|
ui->tableConnections->setColumnWidth(5, 75);
|
||||||
ui->tableConnections->setColumnWidth(6, 75);
|
ui->tableConnections->setColumnWidth(6, 75);
|
||||||
ui->tableConnections->setColumnWidth(7, 75);
|
ui->tableConnections->setColumnWidth(7, 75);
|
||||||
|
QHeaderView *HorzHdr = ui->tableConnections->horizontalHeader();
|
||||||
|
HorzHdr->setStretchLastSection(true); //causes the data column to automatically fill the tableview
|
||||||
|
|
||||||
ui->ckSingleWire->setChecked(settings.value("Main/SingleWireMode", false).toBool());
|
ui->ckSingleWire->setChecked(settings.value("Main/SingleWireMode", false).toBool());
|
||||||
|
|
||||||
ui->cbSpeed->addItem(tr("125000"));
|
ui->cbSpeed->addItem(tr("125000"));
|
||||||
@@ -94,10 +97,37 @@ void ConnectionWindow::showEvent(QShowEvent* event)
|
|||||||
{
|
{
|
||||||
QDialog::showEvent(event);
|
QDialog::showEvent(event);
|
||||||
qDebug() << "Show connectionwindow";
|
qDebug() << "Show connectionwindow";
|
||||||
|
readSettings();
|
||||||
ui->tableConnections->selectRow(0);
|
ui->tableConnections->selectRow(0);
|
||||||
currentRowChanged(ui->tableConnections->currentIndex(), ui->tableConnections->currentIndex());
|
currentRowChanged(ui->tableConnections->currentIndex(), ui->tableConnections->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectionWindow::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
writeSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionWindow::readSettings()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
if (settings.value("Main/SaveRestorePositions", false).toBool())
|
||||||
|
{
|
||||||
|
resize(settings.value("ConnWindow/WindowSize", QSize(956, 665)).toSize());
|
||||||
|
move(settings.value("ConnWindow/WindowPos", QPoint(100, 100)).toPoint());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionWindow::writeSettings()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
if (settings.value("Main/SaveRestorePositions", false).toBool())
|
||||||
|
{
|
||||||
|
settings.setValue("ConnWindow/WindowSize", size());
|
||||||
|
settings.setValue("ConnWindow/WindowPos", pos());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConnectionWindow::setSuspendAll(bool pSuspend)
|
void ConnectionWindow::setSuspendAll(bool pSuspend)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ class ConnectionWindow : public QDialog
|
|||||||
public:
|
public:
|
||||||
explicit ConnectionWindow(QWidget *parent = 0);
|
explicit ConnectionWindow(QWidget *parent = 0);
|
||||||
~ConnectionWindow();
|
~ConnectionWindow();
|
||||||
void showEvent(QShowEvent *);
|
|
||||||
|
|
||||||
CANCon::type getConnectionType();
|
CANCon::type getConnectionType();
|
||||||
bool getSWMode();
|
bool getSWMode();
|
||||||
@@ -78,6 +77,10 @@ private:
|
|||||||
CANConnection* create(CANCon::type pTye, QString pPortName);
|
CANConnection* create(CANCon::type pTye, QString pPortName);
|
||||||
void loadConnections();
|
void loadConnections();
|
||||||
void saveConnections();
|
void saveConnections();
|
||||||
|
void showEvent(QShowEvent *);
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
void readSettings();
|
||||||
|
void writeSettings();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONNECTIONWINDOW_H
|
#endif // CONNECTIONWINDOW_H
|
||||||
|
|||||||
+5
-4
@@ -174,11 +174,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
//killEmAll(); //Ride the lightning
|
updateTimer.stop();
|
||||||
|
killEmAll(); //Ride the lightning
|
||||||
|
delete ui;
|
||||||
delete model;
|
delete model;
|
||||||
delete elapsedTime;
|
delete elapsedTime;
|
||||||
delete dbcHandler;
|
delete dbcHandler;
|
||||||
delete ui;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//kill every sub window that could be open. At the moment a hard coded list
|
//kill every sub window that could be open. At the moment a hard coded list
|
||||||
@@ -194,7 +196,6 @@ void MainWindow::killEmAll()
|
|||||||
killWindow(dbcMainEditor);
|
killWindow(dbcMainEditor);
|
||||||
killWindow(settingsDialog);
|
killWindow(settingsDialog);
|
||||||
killWindow(discreteStateWindow);
|
killWindow(discreteStateWindow);
|
||||||
killWindow(connectionWindow);
|
|
||||||
killWindow(scriptingWindow);
|
killWindow(scriptingWindow);
|
||||||
killWindow(rangeWindow);
|
killWindow(rangeWindow);
|
||||||
killWindow(dbcFileWindow);
|
killWindow(dbcFileWindow);
|
||||||
@@ -206,6 +207,7 @@ void MainWindow::killEmAll()
|
|||||||
killWindow(firmwareUploaderWindow);
|
killWindow(firmwareUploaderWindow);
|
||||||
killWindow(motorctrlConfigWindow);
|
killWindow(motorctrlConfigWindow);
|
||||||
killWindow(signalViewerWindow);
|
killWindow(signalViewerWindow);
|
||||||
|
killWindow(connectionWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
//forcefully close the window, kill it, and salt the earth
|
//forcefully close the window, kill it, and salt the earth
|
||||||
@@ -226,7 +228,6 @@ void MainWindow::killWindow(QDialog *win)
|
|||||||
|
|
||||||
void MainWindow::exitApp()
|
void MainWindow::exitApp()
|
||||||
{
|
{
|
||||||
killEmAll();
|
|
||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user