mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-30 10:55:37 -04:00
[welcome] Switch API for buttons to an enum + string
- Handle buttons and their URL-opening in a more general way with an enum; drop existing three-boot method and special setupDonateButton() - Doesn't compile because consumers haven't changed.
This commit is contained in:
parent
03e506a826
commit
64d4b0a46c
2 changed files with 52 additions and 13 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include "modulesystem/ModuleManager.h"
|
#include "modulesystem/ModuleManager.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/NamedEnum.h"
|
||||||
#include "utils/Retranslator.h"
|
#include "utils/Retranslator.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -244,27 +245,59 @@ WelcomePage::setUpLinks( bool showSupportUrl, bool showKnownIssuesUrl, bool show
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WelcomePage::setupDonateButton( const QString& url )
|
WelcomePage::setupButton( Button role, const QString& url )
|
||||||
{
|
{
|
||||||
|
QPushButton* button = nullptr;
|
||||||
|
CalamaresUtils::ImageType icon = CalamaresUtils::Information;
|
||||||
|
|
||||||
|
switch ( role )
|
||||||
|
{
|
||||||
|
case Button::Donate:
|
||||||
|
button = ui->donateButton;
|
||||||
|
icon = CalamaresUtils::Donate;
|
||||||
|
break;
|
||||||
|
case Button::KnownIssues:
|
||||||
|
button = ui->knownIssuesButton;
|
||||||
|
icon = CalamaresUtils::Bugs;
|
||||||
|
break;
|
||||||
|
case Button::ReleaseNotes:
|
||||||
|
button = ui->releaseNotesButton;
|
||||||
|
icon = CalamaresUtils::Release;
|
||||||
|
break;
|
||||||
|
case Button::Support:
|
||||||
|
button = ui->supportButton;
|
||||||
|
icon = CalamaresUtils::Help;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( !button )
|
||||||
|
{
|
||||||
|
qWarning() << "Unknown button role" << smash( role );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( url.isEmpty() )
|
if ( url.isEmpty() )
|
||||||
{
|
{
|
||||||
ui->donateButton->hide();
|
button->hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl u( url );
|
QUrl u( url );
|
||||||
if ( u.isValid() )
|
if ( u.isValid() )
|
||||||
{
|
{
|
||||||
ui->donateButton->setIcon( CalamaresUtils::defaultPixmap(
|
auto size = 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) );
|
||||||
CalamaresUtils::Donate,
|
button->setIcon( CalamaresUtils::defaultPixmap(
|
||||||
CalamaresUtils::Original,
|
icon,
|
||||||
2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) );
|
CalamaresUtils::Original,size
|
||||||
connect( ui->donateButton, &QPushButton::clicked, [u]() { QDesktopServices::openUrl( u ); } );
|
);
|
||||||
|
connect( button, &QPushButton::clicked, [u]()
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl( u );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qWarning() << "Donate URL" << url << "is invalid.";
|
qWarning() << "Welcome button" << smash( role ) << "URL" << url << "is invalid.";
|
||||||
ui->donateButton->hide();
|
button->hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,10 +38,16 @@ class WelcomePage : public QWidget
|
||||||
public:
|
public:
|
||||||
explicit WelcomePage( QWidget* parent = nullptr );
|
explicit WelcomePage( QWidget* parent = nullptr );
|
||||||
|
|
||||||
/// @brief Configure the buttons for URLs from the branding configuration
|
enum class Button
|
||||||
void setUpLinks( bool showSupportUrl, bool showKnownIssuesUrl, bool showReleaseNotesUrl );
|
{
|
||||||
/// @brief Configure the "Donate" button
|
Support,
|
||||||
void setupDonateButton( const QString& );
|
Donate,
|
||||||
|
KnownIssues,
|
||||||
|
ReleaseNotes
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @brief Configure the button @p n, to open @p url
|
||||||
|
void setupButton( Button b, const QString& url );
|
||||||
|
|
||||||
/// @brief Set international language-selector icon
|
/// @brief Set international language-selector icon
|
||||||
void setLanguageIcon( QPixmap );
|
void setLanguageIcon( QPixmap );
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue