Show/hide available links based on greeting.conf and Branding.

main
Teo Mrnjavac 10 years ago
parent 23ddfaae67
commit 262ef38c0a

@ -28,6 +28,7 @@
#include <QApplication>
#include <QBoxLayout>
#include <QDesktopServices>
#include <QFocusEvent>
#include <QLabel>
#include <QListWidget>
@ -121,38 +122,15 @@ GreetingPage::GreetingPage( QWidget* parent )
ui->mainText->setWordWrap( true );
ui->mainText->setOpenExternalLinks( true );
if ( Calamares::Branding::instance()->
string( Calamares::Branding::ProductUrl ).isEmpty() ||
Calamares::Branding::instance()->
string( Calamares::Branding::ProductUrlText ).isEmpty() )
{
CALAMARES_RETRANSLATE(
ui->mainText->setText( tr( "<h1>Welcome to the %1 installer.</h1><br/>"
"This program will ask you some questions and "
"set up %2 on your computer." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ProductName ) ) );
)
}
else
{
CALAMARES_RETRANSLATE(
ui->mainText->setText( tr( "<h1>Welcome to the %1 installer.</h1><br/>"
"This program will ask you some questions and "
"set up %2 on your computer.<br/>"
"<a href=\"%3\"> %4 </a>" )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ProductName ) )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ProductUrl ) )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ProductUrlText ) ) );
)
}
CALAMARES_RETRANSLATE(
ui->mainText->setText( tr( "<h1>Welcome to the %1 installer.</h1><br/>"
"This program will ask you some questions and "
"set up %2 on your computer." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::ProductName ) ) );
)
ui->aboutButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Information,
CalamaresUtils::Original,
@ -184,6 +162,55 @@ GreetingPage::GreetingPage( QWidget* parent )
}
void
GreetingPage::setUpLinks( bool showSupportUrl,
bool showKnownIssuesUrl,
bool showReleaseNotesUrl )
{
using namespace Calamares;
Branding* b = Branding::instance();
if ( showSupportUrl && !b->string( Branding::SupportUrl ).isEmpty() )
{
CALAMARES_RETRANSLATE(
ui->supportButton->setText( tr( "%1 support" )
.arg( b->string( Branding::ShortProductName ) ) );
)
connect( ui->supportButton, &QPushButton::clicked, []
{
QDesktopServices::openUrl( Branding::instance()->string( Branding::SupportUrl ) );
} );
}
else
{
ui->supportButton->hide();
}
if ( showKnownIssuesUrl && !b->string( Branding::KnownIssuesUrl ).isEmpty() )
{
connect( ui->knownIssuesButton, &QPushButton::clicked, []
{
QDesktopServices::openUrl( Branding::instance()->string( Branding::KnownIssuesUrl ) );
} );
}
else
{
ui->knownIssuesButton->hide();
}
if ( showReleaseNotesUrl && !b->string( Branding::ReleaseNotesUrl ).isEmpty() )
{
connect( ui->releaseNotesButton, &QPushButton::clicked, []
{
QDesktopServices::openUrl( Branding::instance()->string( Branding::ReleaseNotesUrl ) );
} );
}
else
{
ui->releaseNotesButton->hide();
}
}
void
GreetingPage::focusInEvent( QFocusEvent* e )
{

@ -32,6 +32,10 @@ class GreetingPage : public QWidget
public:
explicit GreetingPage( QWidget* parent = nullptr );
void setUpLinks( bool showSupportUrl,
bool showKnownIssuesUrl,
bool showReleaseNotesUrl );
protected:
void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus

@ -97,14 +97,48 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="aboutButton">
<property name="text">
<string>&amp;About</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QPushButton" name="releaseNotesButton">
<property name="text">
<string>&amp;Release notes</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="knownIssuesButton">
<property name="text">
<string>&amp;Known issues</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="supportButton">
<property name="text">
<string>&amp;Support</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="aboutButton">
<property name="text">
<string>&amp;About</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">

Loading…
Cancel
Save