added "Check for Update" button to HelpDialog (see #407)

This commit is contained in:
Thomas Jentzsch 2021-08-25 22:19:41 +02:00
parent 5c775ab807
commit 094ea6cfa4
2 changed files with 25 additions and 5 deletions

View File

@ -33,7 +33,8 @@ HelpDialog::HelpDialog(OSystem& osystem, DialogContainer& parent,
fontHeight = Dialog::fontHeight(),
fontWidth = Dialog::fontWidth(),
buttonHeight = Dialog::buttonHeight(),
buttonWidth = Dialog::buttonWidth("Previous"),
buttonWidth = Dialog::buttonWidth(" << "),
closeButtonWidth = Dialog::buttonWidth("Close"),
VBORDER = Dialog::vBorder(),
HBORDER = Dialog::hBorder(),
VGAP = Dialog::vGap();
@ -48,19 +49,27 @@ HelpDialog::HelpDialog(OSystem& osystem, DialogContainer& parent,
xpos = HBORDER; ypos = _h - buttonHeight - VBORDER;
myPrevButton =
new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Previous", GuiObject::kPrevCmd);
"<<", GuiObject::kPrevCmd);
myPrevButton->clearFlags(Widget::FLAG_ENABLED);
wid.push_back(myPrevButton);
xpos += buttonWidth + fontWidth;
myNextButton =
new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
"Next", GuiObject::kNextCmd);
">>", GuiObject::kNextCmd);
wid.push_back(myNextButton);
xpos = _w - buttonWidth - HBORDER;
xpos += buttonWidth + fontWidth;
int updButtonWidth = Dialog::buttonWidth("Check for Update" + ELLIPSIS);
myUpdateButton =
new ButtonWidget(this, font, xpos, ypos, updButtonWidth, buttonHeight,
"Check for Update" + ELLIPSIS, kUpdateCmd);
wid.push_back(myUpdateButton);
xpos = _w - closeButtonWidth - HBORDER;
ButtonWidget* b =
new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight,
new ButtonWidget(this, font, xpos, ypos, closeButtonWidth, buttonHeight,
"Close", GuiObject::kCloseCmd);
wid.push_back(b);
addCancelWidget(b);
@ -229,6 +238,11 @@ void HelpDialog::handleCommand(CommandSender* sender, int cmd,
displayInfo();
break;
case kUpdateCmd:
MediaFactory::openURL("https://stella-emu.github.io/downloads.html?version="
+ instance().settings().getString("stella.version"));
break;
case StaticTextWidget::kOpenUrlCmd:
{
const string url = myDesc[id]->getUrl();

View File

@ -43,6 +43,7 @@ class HelpDialog : public Dialog
static constexpr uInt32 LINES_PER_PAGE = 10;
ButtonWidget* myNextButton{nullptr};
ButtonWidget* myPrevButton{nullptr};
ButtonWidget* myUpdateButton{nullptr};
StaticTextWidget* myTitle;
std::array<StaticTextWidget*, LINES_PER_PAGE> myKey{nullptr};
@ -53,6 +54,11 @@ class HelpDialog : public Dialog
uInt8 myPage{1};
uInt8 myNumPages{5};
enum {
kUpdateCmd = 'upCm'
};
private:
// Following constructors and assignment operators not supported
HelpDialog() = delete;