Commit 847e63cffd54eae72f6899fbe6eccea1644ef271
1 parent
d649f091
Properly using saved dock window and toolbar settings now
Showing
3 changed files
with
41 additions
and
18 deletions
openhantek/ChangeLog
| ... | ... | @@ -115,3 +115,6 @@ |
| 115 | 115 | * Bugfix: Wrong pretrigger position when using a DSO-2090 |
| 116 | 116 | * Improved timing of the Hantek DSO sampling routine |
| 117 | 117 | * Bugfix: Wrong misc field in measurement table after enabling a channel |
| 118 | + | |
| 119 | +2011-01-23 Oliver Haag <oliver.haag@gmail.com> | |
| 120 | +* Properly applying saved dock window and toolbar positions on startup now | ... | ... |
openhantek/src/openhantek.cpp
| ... | ... | @@ -292,7 +292,8 @@ void OpenHantekMainWindow::createMenus() { |
| 292 | 292 | |
| 293 | 293 | /// \brief Create the toolbars and their buttons. |
| 294 | 294 | void OpenHantekMainWindow::createToolBars() { |
| 295 | - this->fileToolBar = this->addToolBar(tr("File")); | |
| 295 | + this->fileToolBar = new QToolBar(tr("File")); | |
| 296 | + this->fileToolBar->setAllowedAreas(Qt::TopToolBarArea); | |
| 296 | 297 | this->fileToolBar->addAction(this->openAction); |
| 297 | 298 | this->fileToolBar->addAction(this->saveAction); |
| 298 | 299 | this->fileToolBar->addAction(this->saveAsAction); |
| ... | ... | @@ -300,10 +301,10 @@ void OpenHantekMainWindow::createToolBars() { |
| 300 | 301 | this->fileToolBar->addAction(this->printAction); |
| 301 | 302 | this->fileToolBar->addAction(this->exportAsAction); |
| 302 | 303 | |
| 303 | - this->oscilloscopeToolBar = this->addToolBar(tr("Oscilloscope")); | |
| 304 | + this->oscilloscopeToolBar = new QToolBar(tr("Oscilloscope")); | |
| 304 | 305 | this->oscilloscopeToolBar->addAction(this->startStopAction); |
| 305 | 306 | |
| 306 | - this->viewToolBar = this->addToolBar(tr("View")); | |
| 307 | + this->viewToolBar = new QToolBar(tr("View")); | |
| 307 | 308 | this->viewToolBar->addAction(this->digitalPhosphorAction); |
| 308 | 309 | this->viewToolBar->addAction(this->zoomAction); |
| 309 | 310 | } |
| ... | ... | @@ -476,33 +477,33 @@ void OpenHantekMainWindow::applySettings() { |
| 476 | 477 | // Docking windows |
| 477 | 478 | QList<QDockWidget *> docks; |
| 478 | 479 | docks.append(this->horizontalDock); |
| 479 | - docks.append(this->spectrumDock); | |
| 480 | 480 | docks.append(this->triggerDock); |
| 481 | 481 | docks.append(this->voltageDock); |
| 482 | + docks.append(this->spectrumDock); | |
| 482 | 483 | |
| 483 | 484 | QList<DsoSettingsOptionsWindowPanel *> dockSettings; |
| 484 | 485 | dockSettings.append(&(this->settings->options.window.dock.horizontal)); |
| 485 | - dockSettings.append(&(this->settings->options.window.dock.spectrum)); | |
| 486 | 486 | dockSettings.append(&(this->settings->options.window.dock.trigger)); |
| 487 | 487 | dockSettings.append(&(this->settings->options.window.dock.voltage)); |
| 488 | + dockSettings.append(&(this->settings->options.window.dock.spectrum)); | |
| 488 | 489 | |
| 489 | - QList<int> docked[2]; // Docks docked on the sides of the main window | |
| 490 | + QList<int> dockedWindows[2]; // Docks docked on the sides of the main window | |
| 490 | 491 | |
| 491 | 492 | for(int dockId = 0; dockId < docks.size(); dockId++) { |
| 492 | 493 | docks[dockId]->setVisible(dockSettings[dockId]->visible); |
| 493 | - docks[dockId]->setFloating(dockSettings[dockId]->floating); | |
| 494 | 494 | if(!dockSettings[dockId]->position.isNull()) { |
| 495 | 495 | if(dockSettings[dockId]->floating) { |
| 496 | + this->addDockWidget(Qt::RightDockWidgetArea, docks[dockId]); | |
| 497 | + docks[dockId]->setFloating(dockSettings[dockId]->floating); | |
| 496 | 498 | docks[dockId]->move(dockSettings[dockId]->position); |
| 497 | 499 | } |
| 498 | 500 | else { |
| 499 | 501 | // Check in which order the docking windows where placed |
| 500 | - int side = (dockSettings[dockId]->position.x() == 0) ? 0 : 1; | |
| 502 | + int side = (dockSettings[dockId]->position.x() < this->settings->options.window.size.width() / 2) ? 0 : 1; | |
| 501 | 503 | int index = 0; |
| 502 | - while(index < docked[side].size() && dockSettings[docked[side][index]]->position.y() < dockSettings[dockId]->position.y()) | |
| 504 | + while(index < dockedWindows[side].size() && dockSettings[dockedWindows[side][index]]->position.y() <= dockSettings[dockId]->position.y()) | |
| 503 | 505 | index++; |
| 504 | - docked[side].insert(index, dockId); | |
| 505 | - //docks[dockId]->setVisible(false); | |
| 506 | + dockedWindows[side].insert(index, dockId); | |
| 506 | 507 | } |
| 507 | 508 | } |
| 508 | 509 | else { |
| ... | ... | @@ -511,10 +512,10 @@ void OpenHantekMainWindow::applySettings() { |
| 511 | 512 | } |
| 512 | 513 | |
| 513 | 514 | // Put the docked docking windows into the main window |
| 514 | - for(int position = 0; position < docked[0].size(); position++) | |
| 515 | - this->addDockWidget(Qt::LeftDockWidgetArea, docks[docked[0][position]]); | |
| 516 | - for(int position = 0; position < docked[1].size(); position++) | |
| 517 | - this->addDockWidget(Qt::RightDockWidgetArea, docks[docked[1][position]]); | |
| 515 | + for(int position = 0; position < dockedWindows[0].size(); position++) | |
| 516 | + this->addDockWidget(Qt::LeftDockWidgetArea, docks[dockedWindows[0][position]]); | |
| 517 | + for(int position = 0; position < dockedWindows[1].size(); position++) | |
| 518 | + this->addDockWidget(Qt::RightDockWidgetArea, docks[dockedWindows[1][position]]); | |
| 518 | 519 | |
| 519 | 520 | // Toolbars |
| 520 | 521 | QList<QToolBar *> toolbars; |
| ... | ... | @@ -527,12 +528,31 @@ void OpenHantekMainWindow::applySettings() { |
| 527 | 528 | toolbarSettings.append(&(this->settings->options.window.toolbar.oscilloscope)); |
| 528 | 529 | toolbarSettings.append(&(this->settings->options.window.toolbar.view)); |
| 529 | 530 | |
| 531 | + QList<int> dockedToolbars; // Docks docked on the sides of the main window | |
| 532 | + | |
| 530 | 533 | for(int toolbarId = 0; toolbarId < toolbars.size(); toolbarId++) { |
| 531 | 534 | toolbars[toolbarId]->setVisible(toolbarSettings[toolbarId]->visible); |
| 532 | 535 | //toolbars[toolbarId]->setFloating(toolbarSettings[toolbarId]->floating); // setFloating missing, a bug in Qt? |
| 533 | - if(!toolbarSettings[toolbarId]->position.isNull()) | |
| 534 | - toolbars[toolbarId]->move(toolbarSettings[toolbarId]->position); | |
| 536 | + if(!toolbarSettings[toolbarId]->position.isNull() && !toolbarSettings[toolbarId]->floating) { | |
| 537 | + /*if(toolbarSettings[toolbarId]->floating) { | |
| 538 | + toolbars[toolbarId]->move(toolbarSettings[toolbarId]->position); | |
| 539 | + } | |
| 540 | + else*/ { | |
| 541 | + // Check in which order the toolbars where placed | |
| 542 | + int index = 0; | |
| 543 | + while(index < dockedToolbars.size() && toolbarSettings[dockedToolbars[index]]->position.x() <= toolbarSettings[toolbarId]->position.x()) | |
| 544 | + index++; | |
| 545 | + dockedToolbars.insert(index, toolbarId); | |
| 546 | + } | |
| 547 | + } | |
| 548 | + else { | |
| 549 | + this->addToolBar(toolbars[toolbarId]); | |
| 550 | + } | |
| 535 | 551 | } |
| 552 | + | |
| 553 | + // Put the docked toolbars into the main window | |
| 554 | + for(int position = 0; position < dockedToolbars.size(); position++) | |
| 555 | + this->addToolBar(toolbars[dockedToolbars[position]]); | |
| 536 | 556 | } |
| 537 | 557 | |
| 538 | 558 | /// \brief Update the window layout in the settings. | ... | ... |
openhantek/src/settings.cpp
| ... | ... | @@ -41,7 +41,7 @@ DsoSettings::DsoSettings(QWidget *parent) : QObject(parent) { |
| 41 | 41 | this->options.imageSize = QSize(640, 480); |
| 42 | 42 | // Main window |
| 43 | 43 | this->options.window.position = QPoint(); |
| 44 | - this->options.window.size = QSize(); | |
| 44 | + this->options.window.size = QSize(800, 600); | |
| 45 | 45 | // Docking windows and toolbars |
| 46 | 46 | QList<DsoSettingsOptionsWindowPanel *> panels; |
| 47 | 47 | panels.append(&(this->options.window.dock.horizontal)); | ... | ... |