Made connection window store window size/position. Tweaked teardown
code.
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "canconmanager.h"
|
||||
|
||||
|
||||
CANConManager* CANConManager::mInstance = NULL;
|
||||
|
||||
CANConManager* CANConManager::getInstance()
|
||||
@@ -14,7 +13,6 @@ CANConManager* CANConManager::getInstance()
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
|
||||
CANConManager::CANConManager(QObject *parent): QObject(parent)
|
||||
{
|
||||
connect(&mTimer, SIGNAL(timeout()), this, SLOT(refreshCanList()));
|
||||
@@ -46,6 +44,13 @@ CANConManager::~CANConManager()
|
||||
mInstance = NULL;
|
||||
}
|
||||
|
||||
void CANConManager::stopAllConnections()
|
||||
{
|
||||
foreach (CANConnection *conn, mConns)
|
||||
{
|
||||
conn->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void CANConManager::add(CANConnection* pConn_p)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
void add(CANConnection* pConn_p);
|
||||
void remove(CANConnection* pConn_p);
|
||||
QList<CANConnection*>& getConnections();
|
||||
void stopAllConnections();
|
||||
|
||||
CANConnection* getByName(const QString& pName) const;
|
||||
|
||||
|
||||
@@ -32,6 +32,9 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
|
||||
ui->tableConnections->setColumnWidth(5, 75);
|
||||
ui->tableConnections->setColumnWidth(6, 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->cbSpeed->addItem(tr("125000"));
|
||||
@@ -94,10 +97,37 @@ void ConnectionWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
qDebug() << "Show connectionwindow";
|
||||
readSettings();
|
||||
ui->tableConnections->selectRow(0);
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,6 @@ class ConnectionWindow : public QDialog
|
||||
public:
|
||||
explicit ConnectionWindow(QWidget *parent = 0);
|
||||
~ConnectionWindow();
|
||||
void showEvent(QShowEvent *);
|
||||
|
||||
CANCon::type getConnectionType();
|
||||
bool getSWMode();
|
||||
@@ -78,6 +77,10 @@ private:
|
||||
CANConnection* create(CANCon::type pTye, QString pPortName);
|
||||
void loadConnections();
|
||||
void saveConnections();
|
||||
void showEvent(QShowEvent *);
|
||||
void closeEvent(QCloseEvent *event);
|
||||
void readSettings();
|
||||
void writeSettings();
|
||||
};
|
||||
|
||||
#endif // CONNECTIONWINDOW_H
|
||||
|
||||
Reference in New Issue
Block a user