Merge branch 'issue-1374'

SEE #1374

This isn't a fix, it just adds a test that demonstrates the
scope of the problem.
main
Adriaan de Groot 5 years ago
commit da440256d9

@ -20,7 +20,7 @@ calamares_add_plugin( locale
LocaleViewStep.cpp
SetTimezoneJob.cpp
timezonewidget/timezonewidget.cpp
timezonewidget/localeglobal.cpp
timezonewidget/TimeZoneImage.cpp
UI
RESOURCES
locale.qrc
@ -37,4 +37,9 @@ calamares_add_test(
SOURCES
Tests.cpp
LocaleConfiguration.cpp
timezonewidget/TimeZoneImage.cpp
DEFINITIONS
SOURCE_DIR="${CMAKE_CURRENT_LIST_DIR}/images"
LIBRARIES
Qt5::Gui
)

@ -209,7 +209,13 @@ Config::updateGlobalStorage()
const auto* location = currentLocation();
bool locationChanged = ( location->region() != gs->value( "locationRegion" ) )
|| ( location->zone() != gs->value( "locationZone" ) );
#ifdef DEBUG_TIMEZONES
if ( locationChanged )
{
cDebug() << "Location changed" << gs->value( "locationRegion" ) << ',' << gs->value( "locationZone" ) << "to"
<< location->region() << ',' << location->zone();
}
#endif
gs->insert( "locationRegion", location->region() );
gs->insert( "locationZone", location->zone() );

@ -21,7 +21,6 @@
#define LOCALE_CONFIG_H
#include "LocaleConfiguration.h"
#include "timezonewidget/localeglobal.h"
#include "Job.h"
#include "locale/TimeZone.h"

@ -21,7 +21,6 @@
#define LOCALEPAGE_H
#include "LocaleConfiguration.h"
#include "timezonewidget/localeglobal.h"
#include "Job.h"
#include "locale/TimeZone.h"

@ -20,7 +20,6 @@
#include "LocaleViewStep.h"
#include "LocalePage.h"
#include "timezonewidget/localeglobal.h"
#include "widgets/WaitingWidget.h"
#include "GlobalStorage.h"
@ -225,7 +224,6 @@ LocaleViewStep::setConfigurationMap( const QVariantMap& configurationMap )
Calamares::RequirementsList
LocaleViewStep::checkRequirements()
{
LocaleGlobal::init();
if ( m_geoip && m_geoip->isValid() )
{
auto& network = CalamaresUtils::Network::Manager::instance();

@ -1,6 +1,6 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2019, Adriaan de Groot <groot@kde.org>
* Copyright 2019-2020, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,10 +19,13 @@
#include "Tests.h"
#include "LocaleConfiguration.h"
#include "timezonewidget/TimeZoneImage.h"
#include "locale/TimeZone.h"
#include <QtTest/QtTest>
QTEST_GUILESS_MAIN( LocaleTests )
QTEST_MAIN( LocaleTests )
LocaleTests::LocaleTests() {}
@ -77,3 +80,66 @@ LocaleTests::testSplitLocaleConfiguration()
QCOMPARE( lc3.toBcp47(), QStringLiteral( "da" ) );
QCOMPARE( lc3.lc_numeric, QStringLiteral( "de_DE.UTF-8" ) );
}
void
LocaleTests::testTZImages()
{
Logger::setupLogLevel( Logger::LOGDEBUG );
// Number of zone images
//
//
auto images = TimeZoneImageList::fromDirectory( SOURCE_DIR );
QCOMPARE( images.count(), images.zoneCount );
// All image sizes consistent
//
//
const QSize windowSize( 780, 340 );
{
QImage background( SOURCE_DIR "/bg.png" );
QVERIFY( !background.isNull() );
QCOMPARE( background.size(), windowSize );
}
for ( const auto& image : images )
{
QCOMPARE( image.size(), windowSize );
}
// Check zones are uniquely-claimed
//
//
using namespace CalamaresUtils::Locale;
const CStringPairList& regions = TZRegion::fromZoneTab();
int overlapcount = 0;
for ( const auto* pr : regions )
{
const TZRegion* region = dynamic_cast< const TZRegion* >( pr );
QVERIFY( region );
cDebug() << "Region" << region->region() << "zones #" << region->zones().count();
Logger::setupLogLevel( Logger::LOGERROR );
const auto zones = region->zones();
for ( const auto* pz : zones )
{
const TZZone* zone = dynamic_cast< const TZZone* >( pz );
QVERIFY( zone );
int overlap = 0;
auto pos = images.getLocationPosition( zone->longitude(), zone->latitude() );
QVERIFY( images.index( pos, overlap ) >= 0 );
if ( overlap > 1 )
{
Logger::setupLogLevel( Logger::LOGDEBUG );
cDebug() << Logger::SubEntry << "Zone" << zone->zone() << pos;
(void)images.index( pos, overlap );
Logger::setupLogLevel( Logger::LOGERROR );
overlapcount++;
}
}
}
QCOMPARE( overlapcount, 0 );
}

@ -1,6 +1,6 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2019, Adriaan de Groot <groot@kde.org>
* Copyright 2019-2020, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -35,6 +35,9 @@ private Q_SLOTS:
void testEmptyLocaleConfiguration();
void testDefaultLocaleConfiguration();
void testSplitLocaleConfiguration();
// Check the TZ images for consistency
void testTZImages();
};
#endif

@ -0,0 +1,205 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2020, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "TimeZoneImage.h"
#include "utils/Logger.h"
#include <QDir>
static const char* zoneNames[]
= { "0.0", "1.0", "2.0", "3.0", "3.5", "4.0", "4.5", "5.0", "5.5", "5.75", "6.0", "6.5", "7.0",
"8.0", "9.0", "9.5", "10.0", "10.5", "11.0", "11.5", "12.0", "12.75", "13.0", "-1.0", "-2.0", "-3.0",
"-3.5", "-4.0", "-4.5", "-5.0", "-5.5", "-6.0", "-7.0", "-8.0", "-9.0", "-9.5", "-10.0", "-11.0" };
static_assert( TimeZoneImageList::zoneCount == ( sizeof( zoneNames ) / sizeof( zoneNames[ 0 ] ) ),
"Incorrect number of zones" );
#define ZONE_NAME QStringLiteral( "zone" )
TimeZoneImageList::TimeZoneImageList() {}
TimeZoneImageList
TimeZoneImageList::fromQRC()
{
TimeZoneImageList l;
for ( const auto* zoneName : zoneNames )
{
l.append( QImage( QStringLiteral( ":/images/timezone_" ) + zoneName + ".png" ) );
l.last().setText( ZONE_NAME, zoneName );
}
return l;
}
TimeZoneImageList
TimeZoneImageList::fromDirectory( const QString& dirName )
{
TimeZoneImageList l;
QDir dir( dirName );
if ( !dir.exists() )
{
cWarning() << "TimeZone images directory" << dirName << "does not exist.";
return l;
}
for ( const auto* zoneName : zoneNames )
{
l.append( QImage( dir.filePath( QStringLiteral( "timezone_" ) + zoneName + ".png" ) ) );
l.last().setText( ZONE_NAME, zoneName );
}
return l;
}
QPoint
TimeZoneImageList::getLocationPosition( double longitude, double latitude )
{
constexpr double MAP_Y_OFFSET = 0.125;
constexpr double MAP_X_OFFSET = -0.0370;
constexpr double MATH_PI = 3.14159265;
const int width = imageSize.width();
const int height = imageSize.height();
double x = ( width / 2.0 + ( width / 2.0 ) * longitude / 180.0 ) + MAP_X_OFFSET * width;
double y = ( height / 2.0 - ( height / 2.0 ) * latitude / 90.0 ) + MAP_Y_OFFSET * height;
// Far north, the MAP_Y_OFFSET no longer holds, cancel the Y offset; it's noticeable
// from 62 degrees north, so scale those 28 degrees as if the world is flat south
// of there, and we have a funny "rounded" top of the world. In practice the locations
// of the different cities / regions looks ok -- at least Thule ends up in the right
// country, and Inuvik isn't in the ocean.
if ( latitude > 70.0 )
{
y -= sin( MATH_PI * ( latitude - 70.0 ) / 56.0 ) * MAP_Y_OFFSET * height * 0.8;
}
if ( latitude > 74.0 )
{
y += 4;
}
if ( latitude > 69.0 )
{
y -= 2;
}
if ( latitude > 59.0 )
{
y -= 4 * int( ( latitude - 54.0 ) / 5.0 );
}
if ( latitude > 54.0 )
{
y -= 2;
}
if ( latitude > 49.0 )
{
y -= int( ( latitude - 44.0 ) / 5.0 );
}
// Far south, some stretching occurs as well, but it is less pronounced.
// Move down by 1 pixel per 5 degrees past 10 south
if ( latitude < 0 )
{
y += int( ( -latitude ) / 5.0 );
}
// Antarctica isn't shown on the map, but you could try clicking there
if ( latitude < -60 )
{
y = height - 1;
}
if ( x < 0 )
{
x = width + x;
}
if ( x >= width )
{
x -= width;
}
if ( y < 0 )
{
y = height + y;
}
if ( y >= height )
{
y -= height;
}
return QPoint( int( x ), int( y ) );
}
// Pixel value indicating that a spot is outside of a zone
static constexpr const int RGB_TRANSPARENT = 0;
int
TimeZoneImageList::index( QPoint pos, int& count ) const
{
count = 0;
#ifdef DEBUG_TIMEZONES
for ( int i = 0; i < size(); ++i )
{
const QImage& zone = at( i );
// If not transparent set as current
if ( zone.pixel( pos ) != RGB_TRANSPARENT )
{
// Log *all* the zones that contain this point,
// but only pick the first.
if ( !count )
{
cDebug() << Logger::SubEntry << "First zone found" << i << zone.text( ZONE_NAME );
}
else
{
cDebug() << Logger::SubEntry << "Also in zone" << i << zone.text( ZONE_NAME );
}
count++;
}
}
if ( !count )
{
return -1;
}
#endif
return index( pos );
}
int
TimeZoneImageList::index( QPoint pos ) const
{
for ( int i = 0; i < size(); ++i )
{
const QImage& zone = at( i );
// If not transparent set as current
if ( zone.pixel( pos ) != RGB_TRANSPARENT )
{
return i;
}
}
return -1;
}
QImage
TimeZoneImageList::find( QPoint p ) const
{
int i = index( p );
if ( i < 0 || size() <= i )
{
return QImage();
}
return at( i );
}

@ -0,0 +1,85 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2020, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TIMEZONEIMAGE_H
#define TIMEZONEIMAGE_H
#include <QImage>
#include <QList>
using TimeZoneImage = QImage;
/** @brief All the timezone images
*
* There's one fixed list of timezone images that can be loaded
* from the QRC, or from the source directory.
*/
class TimeZoneImageList : public QList< TimeZoneImage >
{
private:
TimeZoneImageList();
public:
/** @brief loads all the images from QRC.
*
* The images are assumed to be compiled into the Qt resource
* system and are loaded from there.
*/
static TimeZoneImageList fromQRC();
/** @brief loads all the images from a specified directory.
*
* No error is returned if files are missing.
*/
static TimeZoneImageList fromDirectory( const QString& dirName );
/** @brief Map longitude and latitude to pixel positions
*
* The image is flat, and stretched at the poles and generally
* a bit weird, so this maps the global coordinates (as found in
* the zones table as a floating-point longitude and latitude value)
* to an x,y position.
*/
static QPoint getLocationPosition( double longitude, double latitude );
/** @brief Find the index of the image claiming point @p p
*
* This maps a point (presumably from getLocationPosition(), so
* originating from a longitude and latitude) to a specific zone
* image index. Returns -1 if no image claims the point (e.g. if
* it is out of bounds).
*/
int index( QPoint p ) const;
/** @brief Find the index of the image claiming point @p p
*
* As `index(p)`, but also fills in @p count with the number of
* zones that claim the point.
*/
int index( QPoint p, int& count ) const;
/** @brief Get image of the zone claiming @p p
*
* Can return a null image, if the point is unclaimed or invalid.
*/
QImage find( QPoint p ) const;
/// @brief The **expected** number of zones in the list.
static constexpr const int zoneCount = 38;
/// @brief The expected size of each zone image.
static constexpr const QSize imageSize = QSize( 780, 340 );
};
#endif

@ -1,126 +0,0 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
*
* Originally from the Manjaro Installation Framework
* by Roland Singer <roland@manjaro.org>
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "localeglobal.h"
#include "locale/TimeZone.h"
#include <QTimeZone>
//###
//### Private variables
//###
QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > LocaleGlobal::locales;
//###
//### Public methods
//###
void
LocaleGlobal::init()
{
// TODO: Error handling
initLocales();
}
QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > >
LocaleGlobal::getLocales()
{
return locales;
}
//###
//### Private methods
//###
void
LocaleGlobal::initLocales()
{
static const char LOCALESDIR[] = "/usr/share/i18n/locales";
locales.clear();
QStringList files = QDir( LOCALESDIR ).entryList( QDir::Files, QDir::Name );
for ( int i = 0; i < files.size(); ++i )
{
QString filename = files.at( i );
QFile file( QString( LOCALESDIR ) + "/" + filename );
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{
continue;
}
QTextStream in( &file );
QString commentChar = "%";
Locale locale;
QString lang, territory;
locale.locale = filename;
while ( !in.atEnd() )
{
QString line = in.readLine().trimmed();
QStringList split = line.split( commentChar, QString::KeepEmptyParts )
.first()
.split( QRegExp( " (?=[^\"]*(\"[^\"]*\"[^\"]*)*$)" ), QString::SkipEmptyParts );
if ( split.size() < 2 )
{
continue;
}
QString sub1 = QString( split.at( 0 ) ).remove( "\"" );
QString sub2 = QString( split.at( 1 ) ).remove( "\"" );
if ( sub1 == "comment_char" )
{
commentChar = sub2;
}
else if ( sub1 == "title" )
{
locale.description = sub2;
}
else if ( sub1 == "territory" )
{
territory = sub2;
}
else if ( sub1 == "language" )
{
lang = sub2;
}
}
if ( lang.isEmpty() || territory.isEmpty() )
{
continue;
}
locales[ lang ][ territory ].append( locale );
}
}

@ -1,63 +0,0 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
* Copyright 2019, Adriaan de Groot <groot@kde.org>
*
* Originally from the Manjaro Installation Framework
* by Roland Singer <roland@manjaro.org>
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LOCALEGLOBAL_H
#define LOCALEGLOBAL_H
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QHash>
#include <QList>
#include <QMap>
#include <QRegExp>
#include <QString>
#include <QStringList>
#include <QTextStream>
namespace CalamaresUtils
{
namespace Locale
{
class TZZone;
}
} // namespace CalamaresUtils
class LocaleGlobal
{
public:
struct Locale
{
QString description, locale;
};
static void init();
static QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > getLocales();
private:
static QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > locales;
static void initLocales();
};
#endif // LOCALEGLOBAL_H

@ -28,13 +28,6 @@
#include "timezonewidget.h"
// Pixel value indicating that a spot is outside of a zone
#define RGB_TRANSPARENT 0
static constexpr double MAP_Y_OFFSET = 0.125;
static constexpr double MAP_X_OFFSET = -0.0370;
constexpr static double MATH_PI = 3.14159265;
#ifdef DEBUG_TIMEZONES
// Adds a label to the timezone with this name
#define ZONE_NAME QStringLiteral( "zone" )
@ -42,6 +35,7 @@ constexpr static double MATH_PI = 3.14159265;
TimeZoneWidget::TimeZoneWidget( QWidget* parent )
: QWidget( parent )
, timeZoneImages( TimeZoneImageList::fromQRC() )
{
setMouseTracking( false );
setCursor( Qt::PointingHandCursor );
@ -54,32 +48,9 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent )
background = QImage( ":/images/bg.png" );
pin = QImage( ":/images/pin.png" );
#ifdef DEBUG_TIMEZONES
if ( background.size() != QSize( 780, 340 ) )
{
cWarning() << "Timezone background size mismatch" << background.size();
}
#endif
// Set size
setMinimumSize( background.size() );
setMaximumSize( background.size() );
// Zone images
for ( const auto* zoneName :
{ "0.0", "1.0", "2.0", "3.0", "3.5", "4.0", "4.5", "5.0", "5.5", "5.75", "6.0", "6.5", "7.0",
"8.0", "9.0", "9.5", "10.0", "10.5", "11.0", "11.5", "12.0", "12.75", "13.0", "-1.0", "-2.0", "-3.0",
"-3.5", "-4.0", "-4.5", "-5.0", "-5.5", "-6.0", "-7.0", "-8.0", "-9.0", "-9.5", "-10.0", "-11.0" } )
{
timeZoneImages.append( QImage( QStringLiteral( ":/images/timezone_" ) + zoneName + ".png" ) );
#ifdef DEBUG_TIMEZONES
if ( timeZoneImages.last().size() != background.size() )
{
cWarning() << "Timezone image size mismatch" << zoneName << timeZoneImages.last().size();
}
timeZoneImages.last().setText( ZONE_NAME, zoneName );
#endif
}
}
@ -114,37 +85,9 @@ TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone* locati
cDebug() << "Setting location" << location->region() << location->zone() << '(' << location->country() << '@'
<< location->latitude() << 'N' << location->longitude() << 'E' << ')';
cDebug() << Logger::SubEntry << "pixel x" << pos.x() << "pixel y" << pos.y();
bool found = false;
#endif
for ( int i = 0; i < timeZoneImages.size(); ++i )
{
QImage zone = timeZoneImages[ i ];
// If not transparent set as current
if ( zone.pixel( pos ) != RGB_TRANSPARENT )
{
#ifdef DEBUG_TIMEZONES
// Log *all* the zones that contain this point,
// but only pick the first.
if ( !found )
{
currentZoneImage = zone;
found = true;
cDebug() << Logger::SubEntry << "First zone found" << i << zone.text( ZONE_NAME );
}
else
{
cDebug() << Logger::SubEntry << "Also in zone" << i << zone.text( ZONE_NAME );
}
#else
currentZoneImage = zone;
break;
#endif
}
}
currentZoneImage = timeZoneImages.find( pos );
// Repaint widget
repaint();
@ -156,78 +99,6 @@ TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone* locati
//### Private
//###
QPoint
TimeZoneWidget::getLocationPosition( double longitude, double latitude )
{
const int width = this->width();
const int height = this->height();
double x = ( width / 2.0 + ( width / 2.0 ) * longitude / 180.0 ) + MAP_X_OFFSET * width;
double y = ( height / 2.0 - ( height / 2.0 ) * latitude / 90.0 ) + MAP_Y_OFFSET * height;
// Far north, the MAP_Y_OFFSET no longer holds, cancel the Y offset; it's noticeable
// from 62 degrees north, so scale those 28 degrees as if the world is flat south
// of there, and we have a funny "rounded" top of the world. In practice the locations
// of the different cities / regions looks ok -- at least Thule ends up in the right
// country, and Inuvik isn't in the ocean.
if ( latitude > 70.0 )
{
y -= sin( MATH_PI * ( latitude - 70.0 ) / 56.0 ) * MAP_Y_OFFSET * height * 0.8;
}
if ( latitude > 74.0 )
{
y += 4;
}
if ( latitude > 69.0 )
{
y -= 2;
}
if ( latitude > 59.0 )
{
y -= 4 * int( ( latitude - 54.0 ) / 5.0 );
}
if ( latitude > 54.0 )
{
y -= 2;
}
if ( latitude > 49.0 )
{
y -= int( ( latitude - 44.0 ) / 5.0 );
}
// Far south, some stretching occurs as well, but it is less pronounced.
// Move down by 1 pixel per 5 degrees past 10 south
if ( latitude < 0 )
{
y += int( ( -latitude ) / 5.0 );
}
// Antarctica isn't shown on the map, but you could try clicking there
if ( latitude < -60 )
{
y = height - 1;
}
if ( x < 0 )
{
x = width + x;
}
if ( x >= width )
{
x -= width;
}
if ( y < 0 )
{
y = height + y;
}
if ( y >= height )
{
y -= height;
}
return QPoint( int( x ), int( y ) );
}
void
TimeZoneWidget::paintEvent( QPaintEvent* )
{
@ -251,7 +122,7 @@ TimeZoneWidget::paintEvent( QPaintEvent* )
QPen p( y_lat ? Qt::black : Qt::red );
p.setWidth( 0 );
painter.setPen( p );
QPoint latLine0( getLocationPosition( 0, y_lat ) );
QPoint latLine0( TimeZoneImageList::getLocationPosition( 0, y_lat ) );
painter.drawLine( 0, latLine0.y(), this->width() - 1, latLine0.y() );
}
// Just a dot in the selected location, no label
@ -331,7 +202,7 @@ TimeZoneWidget::mousePressEvent( QMouseEvent* event )
const auto* zone = dynamic_cast< const TZZone* >( zone_p );
if ( zone )
{
QPoint locPos = getLocationPosition( zone->longitude(), zone->latitude() );
QPoint locPos = TimeZoneImageList::getLocationPosition( zone->longitude(), zone->latitude() );
if ( ( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) < abs( mX - nX ) + abs( mY - nY ) ) )
{

@ -24,15 +24,13 @@
#ifndef TIMEZONEWIDGET_H
#define TIMEZONEWIDGET_H
#include "localeglobal.h"
#include "TimeZoneImage.h"
#include "locale/TimeZone.h"
#include <QFile>
#include <QFont>
#include <QFontMetrics>
#include <QImage>
#include <QList>
#include <QMouseEvent>
#include <QPainter>
#include <QStringList>
@ -58,11 +56,13 @@ signals:
private:
QFont font;
QImage background, pin, currentZoneImage;
QList< QImage > timeZoneImages;
TimeZoneImageList timeZoneImages;
const TZZone* m_currentLocation = nullptr; // Not owned by me
QPoint getLocationPosition( const TZZone* l ) { return getLocationPosition( l->longitude(), l->latitude() ); }
QPoint getLocationPosition( double longitude, double latitude );
QPoint getLocationPosition( const TZZone* l )
{
return timeZoneImages.getLocationPosition( l->longitude(), l->latitude() );
}
void paintEvent( QPaintEvent* event );
void mousePressEvent( QMouseEvent* event );

@ -19,7 +19,6 @@ calamares_add_plugin( localeq
${_locale}/LocaleConfiguration.cpp
${_locale}/Config.cpp
${_locale}/SetTimezoneJob.cpp
${_locale}/timezonewidget/localeglobal.cpp
RESOURCES
localeq.qrc
LINK_PRIVATE_LIBRARIES

@ -29,8 +29,6 @@
#include "utils/Variant.h"
#include "utils/Yaml.h"
#include "timezonewidget/localeglobal.h"
#include "Branding.h"
#include "modulesystem/ModuleManager.h"
#include <QQmlEngine>
@ -72,7 +70,6 @@ LocaleQmlViewStep::fetchGeoIpTimezone()
Calamares::RequirementsList LocaleQmlViewStep::checkRequirements()
{
LocaleGlobal::init();
if ( m_geoip && m_geoip->isValid() )
{
auto& network = CalamaresUtils::Network::Manager::instance();

Loading…
Cancel
Save