From 0d89ba761a18eed4d6e1eb882adf98c91b11a131 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Thu, 20 Nov 2014 09:40:55 +0100 Subject: [PATCH] Uic in GreetingPage. --- src/modules/greeting/CMakeLists.txt | 1 + src/modules/greeting/GreetingPage.cpp | 71 ++++++++----- src/modules/greeting/GreetingPage.h | 9 +- src/modules/greeting/GreetingPage.ui | 146 ++++++++++++++++++++++++++ 4 files changed, 199 insertions(+), 28 deletions(-) create mode 100644 src/modules/greeting/GreetingPage.ui diff --git a/src/modules/greeting/CMakeLists.txt b/src/modules/greeting/CMakeLists.txt index cffeefb82..e217be22d 100644 --- a/src/modules/greeting/CMakeLists.txt +++ b/src/modules/greeting/CMakeLists.txt @@ -6,6 +6,7 @@ calamares_add_plugin( greeting GreetingViewStep.cpp GreetingPage.cpp UI + GreetingPage.ui LINK_LIBRARIES calamaresui SHARED_LIB diff --git a/src/modules/greeting/GreetingPage.cpp b/src/modules/greeting/GreetingPage.cpp index 5814753ff..19580f992 100644 --- a/src/modules/greeting/GreetingPage.cpp +++ b/src/modules/greeting/GreetingPage.cpp @@ -18,9 +18,11 @@ #include "GreetingPage.h" +#include "ui_GreetingPage.h" +#include "AboutDialog.h" #include "CalamaresVersion.h" #include "utils/Logger.h" -#include "utils/CalamaresUtils.h" +#include "utils/CalamaresUtilsGui.h" #include "utils/Retranslator.h" #include "ViewManager.h" @@ -29,20 +31,18 @@ #include #include #include +#include #include "Branding.h" GreetingPage::GreetingPage( QWidget* parent ) - : QWidget() + : QWidget( parent ) + , ui( new Ui::GreetingPage ) { - QBoxLayout *mainLayout = new QHBoxLayout; - setLayout( mainLayout ); + ui->setupUi( this ); QString defaultLocale = QLocale::system().name(); - - m_languageWidget = new QListWidget( this ); - mainLayout->addWidget( m_languageWidget ); { foreach ( const QString& locale, QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') ) { @@ -52,16 +52,16 @@ GreetingPage::GreetingPage( QWidget* parent ) lang.append( QString( " (%1)" ) .arg( QLocale::countryToString( thisLocale.country() ) ) ); - m_languageWidget->addItem( lang ); - m_languageWidget->item( m_languageWidget->count() - 1 ) + ui->languageWidget->addItem( lang ); + ui->languageWidget->item( ui->languageWidget->count() - 1 ) ->setData( Qt::UserRole, thisLocale ); if ( thisLocale.language() == QLocale( defaultLocale ).language() && thisLocale.country() == QLocale( defaultLocale ).country() ) - m_languageWidget->setCurrentRow( m_languageWidget->count() - 1 ); + ui->languageWidget->setCurrentRow( ui->languageWidget->count() - 1 ); } - m_languageWidget->sortItems(); + ui->languageWidget->sortItems(); - connect( m_languageWidget, &QListWidget::currentItemChanged, + connect( ui->languageWidget, &QListWidget::currentItemChanged, this, [ & ]( QListWidgetItem *current, QListWidgetItem *previous ) { QLocale selectedLocale = current->data( Qt::UserRole ).toLocale(); @@ -71,24 +71,19 @@ GreetingPage::GreetingPage( QWidget* parent ) CalamaresUtils::installTranslator( selectedLocale.name(), qApp ); } ); - connect( m_languageWidget, &QListWidget::itemActivated, + connect( ui->languageWidget, &QListWidget::itemDoubleClicked, this, [] { Calamares::ViewManager::instance()->next(); } ); } - m_text = new QLabel( this ); - m_text->setAlignment( Qt::AlignCenter ); - m_text->setWordWrap( true ); - m_text->setOpenExternalLinks( true ); - - mainLayout->addStretch(); - mainLayout->addWidget( m_text ); - mainLayout->addStretch(); + ui->mainText->setAlignment( Qt::AlignCenter ); + ui->mainText->setWordWrap( true ); + ui->mainText->setOpenExternalLinks( true ); CALAMARES_RETRANSLATE( - m_text->setText( tr( "

Welcome to the %1 installer.


" + ui->mainText->setText( tr( "

Welcome to the %1 installer.


" "This program will ask you some questions and " "set up %2 on your computer." ) .arg( Calamares::Branding::instance()-> @@ -96,14 +91,42 @@ GreetingPage::GreetingPage( QWidget* parent ) .arg( Calamares::Branding::instance()-> string( Calamares::Branding::ProductName ) ) ); ) + + ui->aboutButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Information, + CalamaresUtils::Original, + 2*QSize( CalamaresUtils::defaultFontHeight(), + CalamaresUtils::defaultFontHeight() ) ) ); + connect( ui->aboutButton, &QPushButton::clicked, + this, [ this ] + { + QMessageBox::about( this, + tr( "About %1 installer" ) + .arg( CALAMARES_APPLICATION_NAME ), + tr( + "

%1


" + "%2
" + "for %3


" + "Copyright 2014 Teo Mrnjavac <teo@kde.org>
" + "Thanks to: Anke Boersma, Aurélien Gâteau, Kevin Kofler, Philip Müller, " + "Pier Luigi Fiorini and Rohan Garg.

" + "Calamares " + "development is sponsored by
" + "Blue Systems - " + "technologies for a better world." + ) + .arg( CALAMARES_APPLICATION_NAME ) + .arg( CALAMARES_VERSION ) + .arg( Calamares::Branding::instance()->string( + Calamares::Branding::VersionedName ) ) ); + } ); } void GreetingPage::focusInEvent( QFocusEvent* e ) { - if ( m_languageWidget ) - m_languageWidget->setFocus(); + if ( ui->languageWidget ) + ui->languageWidget->setFocus(); e->accept(); } diff --git a/src/modules/greeting/GreetingPage.h b/src/modules/greeting/GreetingPage.h index 260cdbbdd..e6825c9b9 100644 --- a/src/modules/greeting/GreetingPage.h +++ b/src/modules/greeting/GreetingPage.h @@ -21,8 +21,10 @@ #include -class QLabel; -class QListWidget; +namespace Ui +{ +class GreetingPage; +} class GreetingPage : public QWidget { @@ -34,8 +36,7 @@ protected: void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus private: - QListWidget* m_languageWidget; - QLabel* m_text; + Ui::GreetingPage* ui; }; #endif // GREETINGPAGE_H diff --git a/src/modules/greeting/GreetingPage.ui b/src/modules/greeting/GreetingPage.ui new file mode 100644 index 000000000..d43a857ed --- /dev/null +++ b/src/modules/greeting/GreetingPage.ui @@ -0,0 +1,146 @@ + + + GreetingPage + + + + 0 + 0 + 593 + 400 + + + + Form + + + + + + + 0 + 0 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 3 + 0 + + + + <Calamares welcome text> + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + &About + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + +