Code-formatting, add copyright notice
This commit is contained in:
parent
c10d7470bb
commit
00fa7bff1c
@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Originally from the Manjaro Installation Framework
|
* Originally from the Manjaro Installation Framework
|
||||||
* by Roland Singer <roland@manjaro.org>
|
* by Roland Singer <roland@manjaro.org>
|
||||||
@ -51,15 +52,18 @@ TimeZoneWidget::TimeZoneWidget(QWidget* parent) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TimeZoneWidget::setCurrentLocation(QString region, QString zone) {
|
void TimeZoneWidget::setCurrentLocation( QString region, QString zone )
|
||||||
|
{
|
||||||
QHash<QString, QList<LocaleGlobal::Location> > hash = LocaleGlobal::getLocations();
|
QHash<QString, QList<LocaleGlobal::Location> > hash = LocaleGlobal::getLocations();
|
||||||
|
|
||||||
if ( !hash.contains( region ) )
|
if ( !hash.contains( region ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QList<LocaleGlobal::Location> locations = hash.value( region );
|
QList<LocaleGlobal::Location> locations = hash.value( region );
|
||||||
for (int i = 0; i < locations.size(); ++i) {
|
for ( int i = 0; i < locations.size(); ++i )
|
||||||
if (locations.at(i).zone == zone) {
|
{
|
||||||
|
if ( locations.at( i ).zone == zone )
|
||||||
|
{
|
||||||
setCurrentLocation( locations.at( i ) );
|
setCurrentLocation( locations.at( i ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -67,18 +71,20 @@ void TimeZoneWidget::setCurrentLocation(QString region, QString zone) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TimeZoneWidget::setCurrentLocation( LocaleGlobal::Location location )
|
||||||
void TimeZoneWidget::setCurrentLocation(LocaleGlobal::Location location) {
|
{
|
||||||
currentLocation = location;
|
currentLocation = location;
|
||||||
|
|
||||||
// Set zone
|
// Set zone
|
||||||
QPoint pos = getLocationPosition( currentLocation.longitude, currentLocation.latitude );
|
QPoint pos = getLocationPosition( currentLocation.longitude, currentLocation.latitude );
|
||||||
|
|
||||||
for (int i = 0; i < timeZoneImages.size(); ++i) {
|
for ( int i = 0; i < timeZoneImages.size(); ++i )
|
||||||
|
{
|
||||||
QImage zone = timeZoneImages[i];
|
QImage zone = timeZoneImages[i];
|
||||||
|
|
||||||
// If not transparent set as current
|
// If not transparent set as current
|
||||||
if (zone.pixel(pos) != RGB_TRANSPARENT) {
|
if ( zone.pixel( pos ) != RGB_TRANSPARENT )
|
||||||
|
{
|
||||||
currentZoneImage = zone;
|
currentZoneImage = zone;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -95,7 +101,8 @@ void TimeZoneWidget::setCurrentLocation(LocaleGlobal::Location location) {
|
|||||||
//###
|
//###
|
||||||
|
|
||||||
|
|
||||||
QPoint TimeZoneWidget::getLocationPosition(double longitude, double latitude) {
|
QPoint TimeZoneWidget::getLocationPosition( double longitude, double latitude )
|
||||||
|
{
|
||||||
const int width = this->width();
|
const int width = this->width();
|
||||||
const int height = this->height();
|
const int height = this->height();
|
||||||
|
|
||||||
@ -126,8 +133,8 @@ QPoint TimeZoneWidget::getLocationPosition(double longitude, double latitude) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TimeZoneWidget::paintEvent( QPaintEvent* )
|
||||||
void TimeZoneWidget::paintEvent(QPaintEvent*) {
|
{
|
||||||
const int width = this->width();
|
const int width = this->width();
|
||||||
const int height = this->height();
|
const int height = this->height();
|
||||||
QFontMetrics fontMetrics( font );
|
QFontMetrics fontMetrics( font );
|
||||||
@ -172,7 +179,8 @@ void TimeZoneWidget::paintEvent(QPaintEvent*) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void TimeZoneWidget::mousePressEvent(QMouseEvent* event) {
|
void TimeZoneWidget::mousePressEvent( QMouseEvent* event )
|
||||||
|
{
|
||||||
if ( event->button() != Qt::LeftButton )
|
if ( event->button() != Qt::LeftButton )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -182,14 +190,17 @@ void TimeZoneWidget::mousePressEvent(QMouseEvent* event) {
|
|||||||
QHash<QString, QList<LocaleGlobal::Location> > hash = LocaleGlobal::getLocations();
|
QHash<QString, QList<LocaleGlobal::Location> > hash = LocaleGlobal::getLocations();
|
||||||
QHash<QString, QList<LocaleGlobal::Location> >::iterator iter = hash.begin();
|
QHash<QString, QList<LocaleGlobal::Location> >::iterator iter = hash.begin();
|
||||||
|
|
||||||
while (iter != hash.end()) {
|
while ( iter != hash.end() )
|
||||||
|
{
|
||||||
QList<LocaleGlobal::Location> locations = iter.value();
|
QList<LocaleGlobal::Location> locations = iter.value();
|
||||||
|
|
||||||
for (int i = 0; i < locations.size(); ++i) {
|
for ( int i = 0; i < locations.size(); ++i )
|
||||||
|
{
|
||||||
LocaleGlobal::Location loc = locations[i];
|
LocaleGlobal::Location loc = locations[i];
|
||||||
QPoint locPos = getLocationPosition( loc.longitude, loc.latitude );
|
QPoint locPos = getLocationPosition( loc.longitude, loc.latitude );
|
||||||
|
|
||||||
if ((abs(mX - locPos.x()) + abs(mY - locPos.y()) < abs(mX - nX) + abs(mY - nY))) {
|
if ( ( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) < abs( mX - nX ) + abs( mY - nY ) ) )
|
||||||
|
{
|
||||||
currentLocation = loc;
|
currentLocation = loc;
|
||||||
nX = locPos.x();
|
nX = locPos.x();
|
||||||
nY = locPos.y();
|
nY = locPos.y();
|
||||||
|
Loading…
Reference in New Issue
Block a user