UI mostly remade

This commit is contained in:
2019-08-19 16:56:38 -04:00
parent d678119de0
commit ac6a4a582e
9 changed files with 580 additions and 261 deletions

View File

@@ -91,16 +91,17 @@ uint16_t DevicePID;
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindowClass)
{
int i;
hexOpen = false;
fileWatcher = NULL;
timer = new QTimer();
ui->setupUi(this);
setWindowTitle(APPLICATION + QString(" v") + VERSION);
ui->menuBar->setVisible(false);
ui->mainToolBar->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
//ui->menuBar->setVisible(false);
//ui->mainToolBar->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
// by default hide the advanced controls
on_checkBoxAdvancedMode_stateChanged(0);
QSettings settings;
settings.beginGroup("MainWindow");
@@ -131,10 +132,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
connect(comm, SIGNAL(SetProgressBar(int)), this, SLOT(UpdateProgressBar(int)));
this->statusBar()->addPermanentWidget(&deviceLabel);
deviceLabel.setText("Disconnected");
//Assume initally that the USB device that we are trying to find is using the default VID/PID.
DeviceVID = DEFAULT_VID;
DevicePID = DEFAULT_PID;
@@ -207,8 +204,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
}
else
{
ui->plainTextEdit->appendPlainText("Device not detected. Verify device is attached and in firmware update mode.");
deviceLabel.setText("Disconnected");
//ui->plainTextEdit->appendPlainText("Device not detected. Verify device is attached and in firmware update mode.");
hexOpen = false;
setBootloadEnabled(false);
emit SetProgressBar(0);
@@ -349,7 +345,6 @@ void MainWindow::Connection(void)
{
qWarning("Closing device.");
comm->close();
deviceLabel.setText("Disconnected");
ui->plainTextEdit->setPlainText("Device Detached.");
hexOpen = false;
setBootloadEnabled(false);
@@ -1001,6 +996,34 @@ void MainWindow::on_actionErase_Device_triggered()
future = QtConcurrent::run(this, &MainWindow::EraseDevice);
}
void MainWindow::on_checkBoxAdvancedMode_stateChanged(int state)
{
ui->groupBoxAdvanced->setVisible(state != 0);
// handle adjustment of window height when advanced controls are hidden
if (state == 0)
{
/*
* Qt's adjustSize() method on widget objects will scale the widget to only fit its' children.
* This is useful for "collapsing" the window when the advanced controls are hidden, but will
* scale both the height and the width. We want to retain the current width but change the
* height, so first we will back up the min and max width values then set the current width as
* the fixed width to prevent it from being scaled.
*/
int minWidthBackup = minimumWidth();
int maxWidthBackup = maximumWidth();
setFixedWidth(width());
// perform the size adjustments
ui->centralWidget->adjustSize();
adjustSize();
// restore the min/max width values so the width is no longer fixed
setMinimumWidth(minWidthBackup);
setMaximumWidth(maxWidthBackup);
}
}
void MainWindow::EraseDevice(void)
{
QTime elapsed;
@@ -1265,7 +1288,7 @@ void MainWindow::GetQuery()
case Comm::Success:
wasBootloaderMode = true;
ss << "Device Ready";
deviceLabel.setText("Connected");
//deviceLabel.setText("Connected");
break;
default:
return;