1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
#if defined(Hiro_AboutDialog)
auto AboutDialog::setAlignment(Alignment alignment) -> type& {
state.alignment = alignment;
state.relativeTo = {};
return *this;
}
auto AboutDialog::setAlignment(sWindow relativeTo, Alignment alignment) -> type& {
state.alignment = alignment;
state.relativeTo = relativeTo;
return *this;
}
auto AboutDialog::setCopyright(const string& copyright, const string& uri) -> type& {
state.copyright = copyright;
state.copyrightURI = uri;
return *this;
}
auto AboutDialog::setDescription(const string& description) -> type& {
state.description = description;
return *this;
}
auto AboutDialog::setLicense(const string& license, const string& uri) -> type& {
state.license = license;
state.licenseURI = uri;
return *this;
}
auto AboutDialog::setLogo(const multiFactorImage& logo) -> type& {
state.logo = logo;
state.logo.transform();
return *this;
}
auto AboutDialog::setName(const string& name) -> type& {
state.name = name;
return *this;
}
auto AboutDialog::setVersion(const string& version) -> type& {
state.version = version;
return *this;
}
auto AboutDialog::setWebsite(const string& website, const string& uri) -> type& {
state.website = website;
state.websiteURI = uri;
return *this;
}
auto AboutDialog::show() -> void {
Window window;
window.onClose([&] { window.setModal(false); });
VerticalLayout layout{&window};
layout.setPadding(5_sx, 5_sy);
Label nameLabel{&layout, Size{~0, 0}};
nameLabel.setCollapsible();
nameLabel.setAlignment(0.5);
nameLabel.setFont(Font().setFamily(Font::Serif).setBold().setSize(36.0));
nameLabel.setText(state.name ? state.name : Application::name());
nameLabel.setVisible((bool)state.name && !(bool)state.logo);
Canvas logoCanvas{&layout, Size{~0, state.logo.height()}, 5_sy};
logoCanvas.setCollapsible();
if(state.logo) {
logoCanvas.setIcon(state.logo);
} else {
logoCanvas.setVisible(false);
}
Label descriptionLabel{&layout, Size{~0, 0}};
descriptionLabel.setCollapsible();
descriptionLabel.setAlignment(0.5);
descriptionLabel.setText(state.description);
if(!state.description) descriptionLabel.setVisible(false);
HorizontalLayout versionLayout{&layout, Size{~0, 0}, 0};
versionLayout.setCollapsible();
Label versionLabel{&versionLayout, Size{~0, 0}, 3_sx};
versionLabel.setAlignment(1.0);
versionLabel.setFont(Font().setBold());
versionLabel.setText("Version:");
Label versionValue{&versionLayout, Size{~0, 0}};
versionValue.setAlignment(0.0);
versionValue.setText(state.version);
if(!state.version) versionLayout.setVisible(false);
HorizontalLayout copyrightLayout{&layout, Size{~0, 0}, 0};
copyrightLayout.setCollapsible();
Label copyrightLabel{©rightLayout, Size{~0, 0}, 3_sx};
copyrightLabel.setAlignment(1.0);
copyrightLabel.setFont(Font().setBold());
copyrightLabel.setText("Copyright:");
HorizontalLayout copyrightValueLayout{©rightLayout, Size{~0, 0}};
Label copyrightValue{©rightValueLayout, Size{~0, 0}};
copyrightValue.setAlignment(0.0);
copyrightValue.setText(state.copyright);
if(state.copyrightURI) {
copyrightValue.setForegroundColor(SystemColor::Link).setFont(Font().setBold());;
copyrightValue.setMouseCursor(MouseCursor::Hand);
copyrightValue.onMouseRelease([&](auto button) {
if(button == Mouse::Button::Left) invoke(state.copyrightURI);
});
}
if(!state.copyright) copyrightLayout.setVisible(false);
HorizontalLayout licenseLayout{&layout, Size{~0, 0}, 0};
licenseLayout.setCollapsible();
Label licenseLabel{&licenseLayout, Size{~0, 0}, 3_sx};
licenseLabel.setAlignment(1.0);
licenseLabel.setFont(Font().setBold());
licenseLabel.setText("License:");
HorizontalLayout licenseValueLayout{&licenseLayout, Size{~0, 0}};
Label licenseValue{&licenseValueLayout, Size{0, 0}};
licenseValue.setAlignment(0.0);
licenseValue.setText(state.license);
if(state.licenseURI) {
licenseValue.setForegroundColor(SystemColor::Link).setFont(Font().setBold());;
licenseValue.setMouseCursor(MouseCursor::Hand);
licenseValue.onMouseRelease([&](auto button) {
if(button == Mouse::Button::Left) invoke(state.licenseURI);
});
}
if(!state.license) licenseLayout.setVisible(false);
HorizontalLayout websiteLayout{&layout, Size{~0, 0}, 0};
websiteLayout.setCollapsible();
Label websiteLabel{&websiteLayout, Size{~0, 0}, 3_sx};
websiteLabel.setAlignment(1.0);
websiteLabel.setFont(Font().setBold());
websiteLabel.setText("Website:");
HorizontalLayout websiteValueLayout{&websiteLayout, Size{~0, 0}};
Label websiteValue{&websiteValueLayout, Size{0, 0}};
websiteValue.setAlignment(0.0);
websiteValue.setText(state.website);
if(state.websiteURI) {
websiteValue.setForegroundColor(SystemColor::Link).setFont(Font().setBold());;
websiteValue.setMouseCursor(MouseCursor::Hand);
websiteValue.onMouseRelease([&](auto button) {
if(button == Mouse::Button::Left) invoke(state.websiteURI);
});
}
if(!state.website) websiteLayout.setVisible(false);
window.setTitle({"About ", state.name ? state.name : Application::name()});
window.setSize({max(320_sx, layout.minimumSize().width()), layout.minimumSize().height()});
window.setResizable(false);
window.setAlignment(state.relativeTo, state.alignment);
window.setDismissable();
window.setVisible();
window.setModal();
window.setVisible(false);
}
#endif
|