mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 01:20:06 +00:00 
			
		
		
		
	Add Update Dialog
This commit is contained in:
		
							parent
							
								
									26ea4f4771
								
							
						
					
					
						commit
						c1aa34607f
					
				
					 4 changed files with 334 additions and 3 deletions
				
			
		|  | @ -145,7 +145,8 @@ set(HDR_UI source/scwx/qt/ui/about_dialog.hpp | ||||||
|            source/scwx/qt/ui/level2_settings_widget.hpp |            source/scwx/qt/ui/level2_settings_widget.hpp | ||||||
|            source/scwx/qt/ui/level3_products_widget.hpp |            source/scwx/qt/ui/level3_products_widget.hpp | ||||||
|            source/scwx/qt/ui/radar_site_dialog.hpp |            source/scwx/qt/ui/radar_site_dialog.hpp | ||||||
|            source/scwx/qt/ui/settings_dialog.hpp) |            source/scwx/qt/ui/settings_dialog.hpp | ||||||
|  |            source/scwx/qt/ui/update_dialog.hpp) | ||||||
| set(SRC_UI source/scwx/qt/ui/about_dialog.cpp | set(SRC_UI source/scwx/qt/ui/about_dialog.cpp | ||||||
|            source/scwx/qt/ui/alert_dialog.cpp |            source/scwx/qt/ui/alert_dialog.cpp | ||||||
|            source/scwx/qt/ui/alert_dock_widget.cpp |            source/scwx/qt/ui/alert_dock_widget.cpp | ||||||
|  | @ -156,13 +157,15 @@ set(SRC_UI source/scwx/qt/ui/about_dialog.cpp | ||||||
|            source/scwx/qt/ui/level2_settings_widget.cpp |            source/scwx/qt/ui/level2_settings_widget.cpp | ||||||
|            source/scwx/qt/ui/level3_products_widget.cpp |            source/scwx/qt/ui/level3_products_widget.cpp | ||||||
|            source/scwx/qt/ui/radar_site_dialog.cpp |            source/scwx/qt/ui/radar_site_dialog.cpp | ||||||
|            source/scwx/qt/ui/settings_dialog.cpp) |            source/scwx/qt/ui/settings_dialog.cpp | ||||||
|  |            source/scwx/qt/ui/update_dialog.cpp) | ||||||
| set(UI_UI  source/scwx/qt/ui/about_dialog.ui | set(UI_UI  source/scwx/qt/ui/about_dialog.ui | ||||||
|            source/scwx/qt/ui/alert_dialog.ui |            source/scwx/qt/ui/alert_dialog.ui | ||||||
|            source/scwx/qt/ui/alert_dock_widget.ui |            source/scwx/qt/ui/alert_dock_widget.ui | ||||||
|            source/scwx/qt/ui/imgui_debug_dialog.ui |            source/scwx/qt/ui/imgui_debug_dialog.ui | ||||||
|            source/scwx/qt/ui/radar_site_dialog.ui |            source/scwx/qt/ui/radar_site_dialog.ui | ||||||
|            source/scwx/qt/ui/settings_dialog.ui) |            source/scwx/qt/ui/settings_dialog.ui | ||||||
|  |            source/scwx/qt/ui/update_dialog.ui) | ||||||
| set(HDR_UTIL source/scwx/qt/util/color.hpp | set(HDR_UTIL source/scwx/qt/util/color.hpp | ||||||
|              source/scwx/qt/util/file.hpp |              source/scwx/qt/util/file.hpp | ||||||
|              source/scwx/qt/util/font.hpp |              source/scwx/qt/util/font.hpp | ||||||
|  |  | ||||||
							
								
								
									
										71
									
								
								scwx-qt/source/scwx/qt/ui/update_dialog.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								scwx-qt/source/scwx/qt/ui/update_dialog.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,71 @@ | ||||||
|  | #include "update_dialog.hpp" | ||||||
|  | #include "ui_update_dialog.h" | ||||||
|  | #include <scwx/qt/main/versions.hpp> | ||||||
|  | #include <scwx/qt/manager/resource_manager.hpp> | ||||||
|  | 
 | ||||||
|  | #include <QDesktopServices> | ||||||
|  | #include <QFontDatabase> | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace qt | ||||||
|  | { | ||||||
|  | namespace ui | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | class UpdateDialogImpl | ||||||
|  | { | ||||||
|  | public: | ||||||
|  |    explicit UpdateDialogImpl() = default; | ||||||
|  |    ~UpdateDialogImpl()         = default; | ||||||
|  | 
 | ||||||
|  |    std::string downloadUrl_ {}; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | UpdateDialog::UpdateDialog(QWidget* parent) : | ||||||
|  |     QDialog(parent), | ||||||
|  |     p {std::make_unique<UpdateDialogImpl>()}, | ||||||
|  |     ui(new Ui::UpdateDialog) | ||||||
|  | { | ||||||
|  |    ui->setupUi(this); | ||||||
|  | 
 | ||||||
|  |    int titleFontId = | ||||||
|  |       manager::ResourceManager::FontId(types::Font::din1451alt_g); | ||||||
|  |    QString titleFontFamily = | ||||||
|  |       QFontDatabase::applicationFontFamilies(titleFontId).at(0); | ||||||
|  |    QFont titleFont(titleFontFamily, 12); | ||||||
|  |    ui->bannerLabel->setFont(titleFont); | ||||||
|  | 
 | ||||||
|  |    ui->releaseNotesText->setOpenExternalLinks(true); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | UpdateDialog::~UpdateDialog() | ||||||
|  | { | ||||||
|  |    delete ui; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void UpdateDialog::UpdateReleaseInfo(const std::string&        latestVersion, | ||||||
|  |                                      const types::gh::Release& latestRelease) | ||||||
|  | { | ||||||
|  |    ui->versionLabel->setText(tr("Supercell Wx v%1 is now available. You are " | ||||||
|  |                                 "currently running version %2.") | ||||||
|  |                                 .arg(latestVersion.c_str()) | ||||||
|  |                                 .arg(main::kVersionString_.c_str())); | ||||||
|  | 
 | ||||||
|  |    ui->releaseNotesText->setMarkdown( | ||||||
|  |       QString::fromStdString(latestRelease.body_)); | ||||||
|  | 
 | ||||||
|  |    p->downloadUrl_ = latestRelease.htmlUrl_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void UpdateDialog::on_downloadButton_clicked() | ||||||
|  | { | ||||||
|  |    if (!p->downloadUrl_.empty()) | ||||||
|  |    { | ||||||
|  |       QDesktopServices::openUrl(QUrl {QString::fromStdString(p->downloadUrl_)}); | ||||||
|  |    } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | } // namespace ui
 | ||||||
|  | } // namespace qt
 | ||||||
|  | } // namespace scwx
 | ||||||
							
								
								
									
										43
									
								
								scwx-qt/source/scwx/qt/ui/update_dialog.hpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								scwx-qt/source/scwx/qt/ui/update_dialog.hpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,43 @@ | ||||||
|  | #pragma once | ||||||
|  | 
 | ||||||
|  | #include <scwx/qt/types/github_types.hpp> | ||||||
|  | 
 | ||||||
|  | #include <QDialog> | ||||||
|  | 
 | ||||||
|  | namespace Ui | ||||||
|  | { | ||||||
|  | class UpdateDialog; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | namespace scwx | ||||||
|  | { | ||||||
|  | namespace qt | ||||||
|  | { | ||||||
|  | namespace ui | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  | class UpdateDialogImpl; | ||||||
|  | 
 | ||||||
|  | class UpdateDialog : public QDialog | ||||||
|  | { | ||||||
|  |    Q_OBJECT | ||||||
|  | 
 | ||||||
|  | public: | ||||||
|  |    explicit UpdateDialog(QWidget* parent = nullptr); | ||||||
|  |    ~UpdateDialog(); | ||||||
|  | 
 | ||||||
|  |    void UpdateReleaseInfo(const std::string&        latestVersion, | ||||||
|  |                           const types::gh::Release& latestRelease); | ||||||
|  | 
 | ||||||
|  | private slots: | ||||||
|  |    void on_downloadButton_clicked(); | ||||||
|  | 
 | ||||||
|  | private: | ||||||
|  |    friend UpdateDialogImpl; | ||||||
|  |    std::unique_ptr<UpdateDialogImpl> p; | ||||||
|  |    Ui::UpdateDialog*                 ui; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | } // namespace ui
 | ||||||
|  | } // namespace qt
 | ||||||
|  | } // namespace scwx
 | ||||||
							
								
								
									
										214
									
								
								scwx-qt/source/scwx/qt/ui/update_dialog.ui
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										214
									
								
								scwx-qt/source/scwx/qt/ui/update_dialog.ui
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,214 @@ | ||||||
|  | <?xml version="1.0" encoding="UTF-8"?> | ||||||
|  | <ui version="4.0"> | ||||||
|  |  <class>UpdateDialog</class> | ||||||
|  |  <widget class="QDialog" name="UpdateDialog"> | ||||||
|  |   <property name="geometry"> | ||||||
|  |    <rect> | ||||||
|  |     <x>0</x> | ||||||
|  |     <y>0</y> | ||||||
|  |     <width>400</width> | ||||||
|  |     <height>300</height> | ||||||
|  |    </rect> | ||||||
|  |   </property> | ||||||
|  |   <property name="windowTitle"> | ||||||
|  |    <string>Update Available</string> | ||||||
|  |   </property> | ||||||
|  |   <layout class="QVBoxLayout" name="verticalLayout"> | ||||||
|  |    <item> | ||||||
|  |     <widget class="QFrame" name="topFrame"> | ||||||
|  |      <property name="frameShape"> | ||||||
|  |       <enum>QFrame::StyledPanel</enum> | ||||||
|  |      </property> | ||||||
|  |      <property name="frameShadow"> | ||||||
|  |       <enum>QFrame::Raised</enum> | ||||||
|  |      </property> | ||||||
|  |      <layout class="QHBoxLayout" name="horizontalLayout"> | ||||||
|  |       <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="iconLabel"> | ||||||
|  |         <property name="maximumSize"> | ||||||
|  |          <size> | ||||||
|  |           <width>64</width> | ||||||
|  |           <height>64</height> | ||||||
|  |          </size> | ||||||
|  |         </property> | ||||||
|  |         <property name="text"> | ||||||
|  |          <string/> | ||||||
|  |         </property> | ||||||
|  |         <property name="pixmap"> | ||||||
|  |          <pixmap resource="../../../../scwx-qt.qrc">:/res/icons/scwx-256.png</pixmap> | ||||||
|  |         </property> | ||||||
|  |         <property name="scaledContents"> | ||||||
|  |          <bool>true</bool> | ||||||
|  |         </property> | ||||||
|  |        </widget> | ||||||
|  |       </item> | ||||||
|  |       <item> | ||||||
|  |        <widget class="QFrame" name="textFrame"> | ||||||
|  |         <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="bannerLabel"> | ||||||
|  |            <property name="text"> | ||||||
|  |             <string>A new version of Supercell Wx is available!</string> | ||||||
|  |            </property> | ||||||
|  |            <property name="wordWrap"> | ||||||
|  |             <bool>true</bool> | ||||||
|  |            </property> | ||||||
|  |           </widget> | ||||||
|  |          </item> | ||||||
|  |          <item> | ||||||
|  |           <widget class="QLabel" name="versionLabel"> | ||||||
|  |            <property name="text"> | ||||||
|  |             <string>Supercell Wx X.Y.Z is now available. You are running version X.Y.Z.</string> | ||||||
|  |            </property> | ||||||
|  |            <property name="wordWrap"> | ||||||
|  |             <bool>true</bool> | ||||||
|  |            </property> | ||||||
|  |           </widget> | ||||||
|  |          </item> | ||||||
|  |         </layout> | ||||||
|  |        </widget> | ||||||
|  |       </item> | ||||||
|  |      </layout> | ||||||
|  |     </widget> | ||||||
|  |    </item> | ||||||
|  |    <item> | ||||||
|  |     <widget class="QLabel" name="releaseNotesLabel"> | ||||||
|  |      <property name="text"> | ||||||
|  |       <string>Release Notes:</string> | ||||||
|  |      </property> | ||||||
|  |     </widget> | ||||||
|  |    </item> | ||||||
|  |    <item> | ||||||
|  |     <widget class="QTextBrowser" name="releaseNotesText"/> | ||||||
|  |    </item> | ||||||
|  |    <item> | ||||||
|  |     <widget class="QCheckBox" name="enableUpdatesCheckBox"> | ||||||
|  |      <property name="text"> | ||||||
|  |       <string>&Enable Update Notifications</string> | ||||||
|  |      </property> | ||||||
|  |     </widget> | ||||||
|  |    </item> | ||||||
|  |    <item> | ||||||
|  |     <widget class="QFrame" name="bottomFrame"> | ||||||
|  |      <property name="frameShape"> | ||||||
|  |       <enum>QFrame::StyledPanel</enum> | ||||||
|  |      </property> | ||||||
|  |      <property name="frameShadow"> | ||||||
|  |       <enum>QFrame::Raised</enum> | ||||||
|  |      </property> | ||||||
|  |      <layout class="QHBoxLayout" name="horizontalLayout_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="QPushButton" name="downloadButton"> | ||||||
|  |         <property name="text"> | ||||||
|  |          <string>Download</string> | ||||||
|  |         </property> | ||||||
|  |        </widget> | ||||||
|  |       </item> | ||||||
|  |       <item> | ||||||
|  |        <spacer name="horizontalSpacer"> | ||||||
|  |         <property name="orientation"> | ||||||
|  |          <enum>Qt::Horizontal</enum> | ||||||
|  |         </property> | ||||||
|  |         <property name="sizeHint" stdset="0"> | ||||||
|  |          <size> | ||||||
|  |           <width>40</width> | ||||||
|  |           <height>20</height> | ||||||
|  |          </size> | ||||||
|  |         </property> | ||||||
|  |        </spacer> | ||||||
|  |       </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> | ||||||
|  |    </item> | ||||||
|  |   </layout> | ||||||
|  |  </widget> | ||||||
|  |  <resources> | ||||||
|  |   <include location="../../../../scwx-qt.qrc"/> | ||||||
|  |  </resources> | ||||||
|  |  <connections> | ||||||
|  |   <connection> | ||||||
|  |    <sender>buttonBox</sender> | ||||||
|  |    <signal>accepted()</signal> | ||||||
|  |    <receiver>UpdateDialog</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>UpdateDialog</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> | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat