API Documentation
Loading...
Searching...
No Matches
CheckForUpdatesDialog.h
Go to the documentation of this file.
1#pragma once
2#include <NDEVR/UpdateButton.h>
3#include <NDEVR/InterfaceOrientationController.h>
4#include <NDEVR/Translator.h>
5#include <NDEVR/ApplicationResource.h>
6#include <QWidget>
7#include <QLabel>
8#include <QHBoxLayout>
9namespace NDEVR
10{
11 class CheckForUpdatesDialog : public QWidget
12 {
13 Q_OBJECT
14 public:
15 CheckForUpdatesDialog(const TranslatedString& message, String update_url, QWidget* parent = nullptr)
16 : QWidget(parent)
17 {
18 TranslatedString app_update_dialog_title = _td("app_update_dialog_title", "[app_name] Updates");
19 app_update_dialog_title.replace("[app_name]", ApplicationResource::application_name.get());
20 setWindowTitle(app_update_dialog_title.translation().getAs<QString>());
21 QVBoxLayout* layout = new QVBoxLayout();
22 QLabel* label = new QLabel();
23 label->setText(message.translation().getAs<QString>());
24 label->setWordWrap(true);
25 label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);
26 label->setTextInteractionFlags(Qt::TextSelectableByMouse);
27 layout->addWidget(label);
28 QHBoxLayout* bottom_layout = new QHBoxLayout();
29
30 UpdateButton* update_button = new UpdateButton();
31 update_button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
32 bottom_layout->addWidget(update_button);
33
34 if (update_url.size() > 0)
35 {
36 Button* open_url_button = new Button(_t("Web"), "export_to_window", [update_url](Button*)
37 {
39 });
40 bottom_layout->addWidget(open_url_button);
41 open_url_button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
42 }
43
44 Button* ignore_button = new Button(_t("Ignore"), "close_highlight", [this](Button*)
45 {
47 });
48 ignore_button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
49 bottom_layout->addWidget(ignore_button);
50
51
52
54 layout->addLayout(bottom_layout);
55 setLayout(layout);
56
57 }
58 QSize sizeHint() const override
59 {
60 QSize size = QWidget::sizeHint();
61 size.setWidth(cast<int>(size.width() * 1.5));
62 return size;
63 }
64 signals:
66
67 };
68}
#define _t(english_string)
Definition Translator.h:87
#define _td(def, english_string)
Definition Translator.h:91
static Resource< TranslatedString > application_name
Definition ApplicationResource.h:133
static void OpenExplorerWindow(const String &location)
constexpr t_index_type size() const
Definition Buffer.hpp:1461
Definition Button.h:60
Definition CheckForUpdatesDialog.h:12
QSize sizeHint() const override
Definition CheckForUpdatesDialog.h:58
CheckForUpdatesDialog(const TranslatedString &message, String update_url, QWidget *parent=nullptr)
Definition CheckForUpdatesDialog.h:15
static InterfaceOrientationController & Default()
Definition InterfaceOrientationController.cpp:187
void run(QBoxLayout *l, QBoxLayout::Direction horz=QBoxLayout::LeftToRight, QBoxLayout::Direction vert=QBoxLayout::TopToBottom)
Definition InterfaceOrientationController.cpp:130
Definition String.h:40
t_type getAs() const
Definition String.h:334
Definition TranslatedString.h:9
NDEVR_BASE_API TranslatedString & replace(const String &sub_string, const TranslatedString &replacement)
Definition TranslatedString.cpp:51
NDEVR_BASE_API const String & translation() const
Definition TranslatedString.cpp:104
Definition UpdateButton.h:8
Definition ACIColor.h:37
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:514