About dialog

This commit is contained in:
Dan Paulat 2023-01-08 00:48:47 -06:00
parent aaeea156f3
commit 5c793e07d8
10 changed files with 294 additions and 7 deletions

View file

@ -11,6 +11,7 @@
#include <scwx/qt/model/radar_product_model.hpp>
#include <scwx/qt/ui/alert_dock_widget.hpp>
#include <scwx/qt/ui/flow_layout.hpp>
#include <scwx/qt/ui/about_dialog.hpp>
#include <scwx/qt/ui/imgui_debug_dialog.hpp>
#include <scwx/qt/ui/level2_products_widget.hpp>
#include <scwx/qt/ui/level2_settings_widget.hpp>
@ -52,6 +53,7 @@ public:
level2SettingsWidget_ {nullptr},
level3ProductsWidget_ {nullptr},
alertDockWidget_ {nullptr},
aboutDialog_ {nullptr},
imGuiDebugDialog_ {nullptr},
radarSiteDialog_ {nullptr},
settingsDialog_ {nullptr},
@ -116,6 +118,7 @@ public:
ui::Level3ProductsWidget* level3ProductsWidget_;
ui::AlertDockWidget* alertDockWidget_;
ui::AboutDialog* aboutDialog_;
ui::ImGuiDebugDialog* imGuiDebugDialog_;
ui::RadarSiteDialog* radarSiteDialog_;
ui::SettingsDialog* settingsDialog_;
@ -213,6 +216,9 @@ MainWindow::MainWindow(QWidget* parent) :
// ImGui Debug Dialog
p->imGuiDebugDialog_ = new ui::ImGuiDebugDialog(this);
// About Dialog
p->aboutDialog_ = new ui::AboutDialog(this);
auto& mapSettings = manager::SettingsManager::map_settings();
for (size_t i = 0; i < p->maps_.size(); i++)
{
@ -366,7 +372,10 @@ void MainWindow::on_actionGitHubRepository_triggered()
QDesktopServices::openUrl(QUrl {"https://github.com/dpaulat/supercell-wx"});
}
void MainWindow::on_actionAboutSupercellWx_triggered() {}
void MainWindow::on_actionAboutSupercellWx_triggered()
{
p->aboutDialog_->show();
}
void MainWindow::on_radarSiteSelectButton_clicked()
{

View file

@ -7,6 +7,8 @@
#include <imgui.h>
#include <QFontDatabase>
namespace scwx
{
namespace qt
@ -15,12 +17,19 @@ namespace manager
{
namespace ResourceManager
{
static const std::string logPrefix_ = "scwx::qt::manager::resource_manager";
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
static void LoadFonts();
static void LoadTextures();
static const std::unordered_map<types::Font, std::string> fontNames_ {
{types::Font::din1451alt, ":/res/fonts/din1451alt.ttf"},
{types::Font::din1451alt_g, ":/res/fonts/din1451alt_g.ttf"}};
static std::unordered_map<types::Font, int> fontIds_ {};
void Initialize()
{
config::CountyDatabase::Initialize();
@ -31,10 +40,26 @@ void Initialize()
void Shutdown() {}
int FontId(types::Font font)
{
auto it = fontIds_.find(font);
if (it != fontIds_.cend())
{
return it->second;
}
return -1;
}
static void LoadFonts()
{
util::Font::Create(":/res/fonts/din1451alt.ttf");
util::Font::Create(":/res/fonts/din1451alt_g.ttf");
for (auto& fontName : fontNames_)
{
int fontId = QFontDatabase::addApplicationFont(
QString::fromStdString(fontName.second));
fontIds_.emplace(fontName.first, fontId);
util::Font::Create(fontName.second);
}
ImFontAtlas* fontAtlas = model::ImGuiContextModel::Instance().font_atlas();
fontAtlas->AddFontDefault();

View file

@ -1,5 +1,7 @@
#pragma once
#include <scwx/qt/types/font_types.hpp>
namespace scwx
{
namespace qt
@ -8,8 +10,12 @@ namespace manager
{
namespace ResourceManager
{
void Initialize();
void Shutdown();
int FontId(types::Font font);
} // namespace ResourceManager
} // namespace manager
} // namespace qt

View file

@ -0,0 +1,18 @@
#pragma once
namespace scwx
{
namespace qt
{
namespace types
{
enum class Font
{
din1451alt,
din1451alt_g
};
} // namespace types
} // namespace qt
} // namespace scwx

View file

@ -0,0 +1,43 @@
#include "about_dialog.hpp"
#include "ui_about_dialog.h"
#include <scwx/qt/manager/resource_manager.hpp>
#include <QFontDatabase>
namespace scwx
{
namespace qt
{
namespace ui
{
class AboutDialogImpl
{
public:
explicit AboutDialogImpl() = default;
~AboutDialogImpl() = default;
};
AboutDialog::AboutDialog(QWidget* parent) :
QDialog(parent),
p {std::make_unique<AboutDialogImpl>()},
ui(new Ui::AboutDialog)
{
ui->setupUi(this);
int titleFontId =
manager::ResourceManager::FontId(types::Font::din1451alt_g);
QString titleFontFamily =
QFontDatabase::applicationFontFamilies(titleFontId).at(0);
QFont titleFont(titleFontFamily, 14);
ui->titleLabel->setFont(titleFont);
}
AboutDialog::~AboutDialog()
{
delete ui;
}
} // namespace ui
} // namespace qt
} // namespace scwx

View file

@ -0,0 +1,38 @@
#pragma once
#include <QDialog>
namespace Ui
{
class AboutDialog;
}
namespace scwx
{
namespace qt
{
namespace ui
{
class AboutDialogImpl;
class AboutDialog : public QDialog
{
Q_OBJECT
private:
Q_DISABLE_COPY(AboutDialog)
public:
explicit AboutDialog(QWidget* parent = nullptr);
~AboutDialog();
private:
friend AboutDialogImpl;
std::unique_ptr<AboutDialogImpl> p;
Ui::AboutDialog* ui;
};
} // namespace ui
} // namespace qt
} // namespace scwx

View file

@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>276</width>
<height>404</height>
</rect>
</property>
<property name="windowTitle">
<string>About Supercell Wx</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame_2">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../../../../scwx-qt.qrc">:/res/icons/scwx-256.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="titleLabel">
<property name="text">
<string>Supercell Wx</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="versionLabel">
<property name="text">
<string>Version X.Y.Z</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="revisionLabel">
<property name="text">
<string>Git Revision 0000000000</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="copyrightLabel">
<property name="text">
<string>Copyright © 2021-YYYY Dan Paulat</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../../../scwx-qt.qrc"/>
</resources>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AboutDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AboutDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>