Fix up identifiers + use QComboBox instead of QListView.

main
Teo Mrnjavac 10 years ago
parent 7bcb060967
commit 3dd1d7932f

@ -1,12 +1,12 @@
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )
calamares_add_plugin( greeting
calamares_add_plugin( welcome
TYPE viewmodule
EXPORT_MACRO PLUGINDLLEXPORT_PRO
SOURCES
GreetingViewStep.cpp
GreetingPage.cpp
WelcomeViewStep.cpp
WelcomePage.cpp
UI
GreetingPage.ui
WelcomePage.ui
LINK_LIBRARIES
calamaresui
SHARED_LIB

@ -17,9 +17,9 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GreetingPage.h"
#include "WelcomePage.h"
#include "ui_GreetingPage.h"
#include "ui_WelcomePage.h"
#include "CalamaresVersion.h"
#include "utils/Logger.h"
#include "utils/CalamaresUtilsGui.h"
@ -31,17 +31,18 @@
#include <QDesktopServices>
#include <QFocusEvent>
#include <QLabel>
#include <QListWidget>
#include <QComboBox>
#include <QMessageBox>
#include "Branding.h"
GreetingPage::GreetingPage( QWidget* parent )
WelcomePage::WelcomePage( QWidget* parent )
: QWidget( parent )
, ui( new Ui::GreetingPage )
, ui( new Ui::WelcomePage )
{
ui->setupUi( this );
ui->languageWidget->setInsertPolicy( QComboBox::InsertAlphabetically );
QLocale defaultLocale = QLocale( QLocale::system().name() );
{
@ -55,33 +56,30 @@ GreetingPage::GreetingPage( QWidget* parent )
lang.append( QString( " (%1)" )
.arg( QLocale::countryToString( thisLocale.country() ) ) );
ui->languageWidget->addItem( lang );
ui->languageWidget->item( ui->languageWidget->count() - 1 )
->setData( Qt::UserRole, thisLocale );
ui->languageWidget->addItem( lang, thisLocale );
if ( thisLocale.language() == defaultLocale.language() &&
thisLocale.country() == defaultLocale.country() )
{
isTranslationAvailable = true;
ui->languageWidget->setCurrentRow( ui->languageWidget->count() - 1 );
ui->languageWidget->setCurrentIndex( ui->languageWidget->count() - 1 );
cDebug() << "Initial locale " << thisLocale.name();
CalamaresUtils::installTranslator( thisLocale,
CalamaresUtils::installTranslator( thisLocale.name(),
Calamares::Branding::instance()->translationsPathPrefix(),
qApp );
}
}
ui->languageWidget->sortItems();
if ( !isTranslationAvailable )
{
for (int i = 0; i < ui->languageWidget->count(); i++)
{
QLocale thisLocale = ui->languageWidget->item(i)->data( Qt::UserRole ).toLocale();
QLocale thisLocale = ui->languageWidget->itemData( i, Qt::UserRole ).toLocale();
if ( thisLocale.language() == defaultLocale.language() )
{
isTranslationAvailable = true;
ui->languageWidget->setCurrentRow( i );
ui->languageWidget->setCurrentIndex( i );
cDebug() << "Initial locale " << thisLocale.name();
CalamaresUtils::installTranslator( thisLocale,
CalamaresUtils::installTranslator( thisLocale.name(),
Calamares::Branding::instance()->translationsPathPrefix(),
qApp );
break;
@ -93,13 +91,13 @@ GreetingPage::GreetingPage( QWidget* parent )
{
for (int i = 0; i < ui->languageWidget->count(); i++)
{
QLocale thisLocale = ui->languageWidget->item(i)->data( Qt::UserRole ).toLocale();
QLocale thisLocale = ui->languageWidget->itemData( i, Qt::UserRole ).toLocale();
if ( thisLocale == QLocale( QLocale::English, QLocale::UnitedStates ) )
{
ui->languageWidget->setCurrentRow( i );
ui->languageWidget->setCurrentIndex( i );
cDebug() << "Translation unavailable, so initial locale set to " << thisLocale.name();
QLocale::setDefault( thisLocale );
CalamaresUtils::installTranslator( thisLocale,
CalamaresUtils::installTranslator( thisLocale.name(),
Calamares::Branding::instance()->translationsPathPrefix(),
qApp );
break;
@ -107,10 +105,11 @@ GreetingPage::GreetingPage( QWidget* parent )
}
}
connect( ui->languageWidget, &QListWidget::currentItemChanged,
this, [ & ]( QListWidgetItem *current, QListWidgetItem *previous )
connect( ui->languageWidget,
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
this, [ & ]( int newIndex )
{
QLocale selectedLocale = current->data( Qt::UserRole ).toLocale();
QLocale selectedLocale = ui->languageWidget->itemData( newIndex, Qt::UserRole ).toLocale();
cDebug() << "Selected locale" << selectedLocale.name();
QLocale::setDefault( selectedLocale );
@ -118,12 +117,6 @@ GreetingPage::GreetingPage( QWidget* parent )
Calamares::Branding::instance()->translationsPathPrefix(),
qApp );
} );
connect( ui->languageWidget, &QListWidget::itemDoubleClicked,
this, []
{
Calamares::ViewManager::instance()->next();
} );
}
ui->mainText->setAlignment( Qt::AlignCenter );
@ -172,7 +165,7 @@ GreetingPage::GreetingPage( QWidget* parent )
void
GreetingPage::setUpLinks( bool showSupportUrl,
WelcomePage::setUpLinks( bool showSupportUrl,
bool showKnownIssuesUrl,
bool showReleaseNotesUrl )
{
@ -233,7 +226,7 @@ GreetingPage::setUpLinks( bool showSupportUrl,
void
GreetingPage::focusInEvent( QFocusEvent* e )
WelcomePage::focusInEvent( QFocusEvent* e )
{
if ( ui->languageWidget )
ui->languageWidget->setFocus();

@ -16,21 +16,21 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GREETINGPAGE_H
#define GREETINGPAGE_H
#ifndef WELCOMEPAGE_H
#define WELCOMEPAGE_H
#include <QWidget>
namespace Ui
{
class GreetingPage;
class WelcomePage;
}
class GreetingPage : public QWidget
class WelcomePage : public QWidget
{
Q_OBJECT
public:
explicit GreetingPage( QWidget* parent = nullptr );
explicit WelcomePage( QWidget* parent = nullptr );
void setUpLinks( bool showSupportUrl,
bool showKnownIssuesUrl,
@ -40,7 +40,7 @@ protected:
void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus
private:
Ui::GreetingPage* ui;
Ui::WelcomePage* ui;
};
#endif // GREETINGPAGE_H
#endif // WELCOMEPAGE_H

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GreetingPage</class>
<widget class="QWidget" name="GreetingPage">
<class>WelcomePage</class>
<widget class="QWidget" name="WelcomePage">
<property name="geometry">
<rect>
<x>0</x>
@ -15,17 +15,7 @@
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QListWidget" name="languageWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0,0,0,0,0">
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
@ -81,6 +71,71 @@
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Language:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>languageWidget</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="languageWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>

@ -16,21 +16,21 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "GreetingViewStep.h"
#include "WelcomeViewStep.h"
#include "GreetingPage.h"
#include "WelcomePage.h"
#include <QVariant>
GreetingViewStep::GreetingViewStep( QObject* parent )
WelcomeViewStep::WelcomeViewStep( QObject* parent )
: Calamares::ViewStep( parent )
, m_widget( new GreetingPage() )
, m_widget( new WelcomePage() )
{
emit nextStatusChanged( true );
}
GreetingViewStep::~GreetingViewStep()
WelcomeViewStep::~WelcomeViewStep()
{
if ( m_widget && m_widget->parent() == nullptr )
m_widget->deleteLater();
@ -38,68 +38,68 @@ GreetingViewStep::~GreetingViewStep()
QString
GreetingViewStep::prettyName() const
WelcomeViewStep::prettyName() const
{
return tr( "Welcome" );
}
QWidget*
GreetingViewStep::widget()
WelcomeViewStep::widget()
{
return m_widget;
}
void
GreetingViewStep::next()
WelcomeViewStep::next()
{
emit done();
}
void
GreetingViewStep::back()
WelcomeViewStep::back()
{}
bool
GreetingViewStep::isNextEnabled() const
WelcomeViewStep::isNextEnabled() const
{
return true;
}
bool
GreetingViewStep::isBackEnabled() const
WelcomeViewStep::isBackEnabled() const
{
return false;
}
bool
GreetingViewStep::isAtBeginning() const
WelcomeViewStep::isAtBeginning() const
{
return true;
}
bool
GreetingViewStep::isAtEnd() const
WelcomeViewStep::isAtEnd() const
{
return true;
}
QList< Calamares::job_ptr >
GreetingViewStep::jobs() const
WelcomeViewStep::jobs() const
{
return QList< Calamares::job_ptr >();
}
void
GreetingViewStep::setConfigurationMap( const QVariantMap& configurationMap )
WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
bool showSupportUrl =
configurationMap.contains( "showSupportUrl" ) &&

@ -16,8 +16,8 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GREETINGPAGEPLUGIN_H
#define GREETINGPAGEPLUGIN_H
#ifndef WELCOMEPAGEPLUGIN_H
#define WELCOMEPAGEPLUGIN_H
#include <QObject>
@ -26,9 +26,9 @@
#include <QVariantMap>
class GreetingPage;
class WelcomePage;
class PLUGINDLLEXPORT GreetingViewStep : public Calamares::ViewStep
class PLUGINDLLEXPORT WelcomeViewStep : public Calamares::ViewStep
{
Q_OBJECT
Q_PLUGIN_METADATA( IID "calamares.ViewModule/1.0" )
@ -36,8 +36,8 @@ class PLUGINDLLEXPORT GreetingViewStep : public Calamares::ViewStep
Q_INTERFACES( Calamares::ViewStep )
public:
explicit GreetingViewStep( QObject* parent = nullptr );
virtual ~GreetingViewStep();
explicit WelcomeViewStep( QObject* parent = nullptr );
virtual ~WelcomeViewStep();
QString prettyName() const override;
@ -57,7 +57,7 @@ public:
void setConfigurationMap( const QVariantMap& configurationMap ) override;
private:
GreetingPage* m_widget;
WelcomePage* m_widget;
};
#endif // GREETINGPAGEPLUGIN_H
#endif // WELCOMEPAGEPLUGIN_H

@ -1,7 +1,7 @@
# Module metadata file for greeting viewmodule
# Module metadata file for welcome viewmodule
# Syntax is YAML 1.2
---
type: "view" #core or view
name: "greeting" #the module name. must be unique and same as the parent directory
name: "welcome" #the module name. must be unique and same as the parent directory
interface: "qtplugin" #can be: qtplugin, python, process, ...
load: "libcalamares_viewmodule_greeting.so"
load: "libcalamares_viewmodule_welcome.so"

Loading…
Cancel
Save