mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 16:30:05 +00:00
Add toolbox for radar display control
This commit is contained in:
parent
cd5d60bc0b
commit
7c606b85ff
8 changed files with 325 additions and 6 deletions
|
|
@ -2,6 +2,12 @@
|
|||
#include "./ui_main_window.h"
|
||||
|
||||
#include <scwx/qt/map/map_widget.hpp>
|
||||
#include <scwx/qt/ui/flow_layout.hpp>
|
||||
#include <scwx/common/products.hpp>
|
||||
|
||||
#include <QToolButton>
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
|
||||
namespace scwx
|
||||
{
|
||||
|
|
@ -10,6 +16,8 @@ namespace qt
|
|||
namespace main
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "[scwx::qt::main::main_window] ";
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent) :
|
||||
QMainWindow(parent), ui(new Ui::MainWindow)
|
||||
{
|
||||
|
|
@ -20,6 +28,20 @@ MainWindow::MainWindow(QWidget* parent) :
|
|||
settings.setCacheDatabaseMaximumSize(20 * 1024 * 1024);
|
||||
|
||||
ui->centralwidget->layout()->addWidget(new map::MapWidget(settings));
|
||||
|
||||
// Add Level2 Products
|
||||
QLayout* level2Layout = new ui::FlowLayout();
|
||||
ui->level2Products->setLayout(level2Layout);
|
||||
|
||||
for (common::Level2Product product : common::Level2ProductIterator())
|
||||
{
|
||||
QToolButton* toolButton = new QToolButton();
|
||||
toolButton->setText(
|
||||
QString::fromStdString(common::GetLevel2Name(product)));
|
||||
toolButton->setStatusTip(
|
||||
tr(common::GetLevel2Description(product).c_str()));
|
||||
level2Layout->addWidget(toolButton);
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
|
@ -27,6 +49,33 @@ MainWindow::~MainWindow()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
QMainWindow::showEvent(event);
|
||||
|
||||
// Cycle through each item in the toolbox to render
|
||||
QToolBox* toolbox = ui->radarToolbox;
|
||||
int currentIndex = toolbox->currentIndex();
|
||||
for (int i = 0; i < toolbox->count(); i++)
|
||||
{
|
||||
toolbox->setCurrentIndex(i);
|
||||
}
|
||||
toolbox->setCurrentIndex(currentIndex);
|
||||
|
||||
// Set each level 2 product's tool button to the same size
|
||||
int level2MaxWidth = 0;
|
||||
for (QWidget* widget : ui->level2Products->findChildren<QWidget*>())
|
||||
{
|
||||
level2MaxWidth = std::max(level2MaxWidth, widget->width());
|
||||
}
|
||||
for (QWidget* widget : ui->level2Products->findChildren<QWidget*>())
|
||||
{
|
||||
widget->setMinimumWidth(level2MaxWidth);
|
||||
}
|
||||
|
||||
resizeDocks({ui->radarToolboxDock}, {150}, Qt::Horizontal);
|
||||
}
|
||||
|
||||
} // namespace main
|
||||
} // namespace qt
|
||||
} // namespace scwx
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue