diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index 384135d4c..853ad8cc2 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -4,6 +4,11 @@ if( ECM_FOUND AND BUILD_TESTING ) find_package( Qt5 COMPONENTS Core Test REQUIRED ) endif() +# When debugging the timezone widget, add this debugging definition +# to have a debugging-friendly timezone widget, debug logging, +# and no intrusive timezone-setting while clicking around. +add_definitions( -DDEBUG_TIMEZONES ) + include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) set( geoip_src GeoIP.cpp GeoIPJSON.cpp ) diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index e2571d085..e4f36daad 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -494,13 +494,15 @@ LocalePage::updateGlobalStorage() Calamares::JobQueue::instance()->globalStorage()->insert( "locale", bcp47 ); // If we're in chroot mode (normal install mode), then we immediately set the - // timezone on the live system. + // timezone on the live system. When debugging timezones, don't bother. +#ifndef DEBUG_TIMEZONES if ( Calamares::Settings::instance()->doChroot() ) { QProcess ::execute( "timedatectl", // depends on systemd { "set-timezone", location.region + '/' + location.zone } ); } +#endif // Preserve those settings that have been made explicit. auto newLocale = guessLocaleConfiguration(); diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index 976c139fc..a06d3169d 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -23,6 +23,8 @@ #include +#include "utils/Logger.h" + #include "timezonewidget.h" constexpr double MATH_PI = 3.14159265; @@ -75,6 +77,13 @@ void TimeZoneWidget::setCurrentLocation( LocaleGlobal::Location location ) { currentLocation = location; +#ifdef DEBUG_TIMEZONES + cDebug() << "Setting location" << location.region << location.zone << location.country; + cDebug() << " .. long" << location.longitude << "lat" << location.latitude; + + bool found = false; +#endif + // Set zone QPoint pos = getLocationPosition( currentLocation.longitude, currentLocation.latitude ); @@ -85,8 +94,21 @@ void TimeZoneWidget::setCurrentLocation( LocaleGlobal::Location location ) // 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() << " .. First zone found" << i; + } + else + cDebug() << " .. Also in zone" << i; +#else currentZoneImage = zone; break; +#endif } } @@ -149,8 +171,28 @@ void TimeZoneWidget::paintEvent( QPaintEvent* ) // Draw zone image painter.drawImage( 0, 0, currentZoneImage ); - // Draw pin +#ifdef DEBUG_TIMEZONES QPoint point = getLocationPosition( currentLocation.longitude, currentLocation.latitude ); + // Draw latitude lines + for ( int y_lat = -50; y_lat < 80 ; y_lat+=5 ) + { + QPen p( y_lat ? Qt::black : Qt::red ); + p.setWidth( 0 ); + painter.setPen( p ); + QPoint latLine0( getLocationPosition( 0, y_lat ) ); + int llx = latLine0.x() + ((y_lat & 1) ? -10 : 0); + int lly = latLine0.y(); + + for ( int c = 0 ; c < width ; ++c ) + painter.drawPoint( c, lly ); + } + // Just a dot in the selected location, no label + painter.setPen( Qt::red ); + painter.drawPoint( point ); +#else + // Draw pin at current location + QPoint point = getLocationPosition( currentLocation.longitude, currentLocation.latitude ); + painter.drawImage( point.x() - pin.width()/2, point.y() - pin.height()/2, pin ); // Draw text and box @@ -173,6 +215,7 @@ void TimeZoneWidget::paintEvent( QPaintEvent* ) painter.drawRoundedRect( rect, 3, 3 ); painter.setPen( Qt::white ); painter.drawText( rect.x() + 5, rect.bottom() - 4, LocaleGlobal::Location::pretty( currentLocation.zone ) ); +#endif painter.end(); }