Merge branch '3.1.x-stable'
- pull in northern-locations fixes - pull in testing yaml-config
This commit is contained in:
commit
9f84519e87
@ -50,7 +50,7 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||
|
||||
# Clang warnings: doing *everything* is counter-productive, since it warns
|
||||
# about things which we can't fix (e.g. C++98 incompatibilities, but
|
||||
# Calaares is C++14).
|
||||
# Calamares is C++14).
|
||||
foreach( CLANG_WARNINGS
|
||||
-Weverything
|
||||
-Wno-c++98-compat
|
||||
@ -88,6 +88,8 @@ else()
|
||||
set( SUPPRESS_BOOST_WARNINGS "" )
|
||||
endif()
|
||||
|
||||
# Use mark_thirdparty_code() to reduce warnings from the compiler
|
||||
# on code that we're not going to fix. Call this with a list of files.
|
||||
macro(mark_thirdparty_code)
|
||||
set_source_files_properties( ${ARGV}
|
||||
PROPERTIES
|
||||
|
@ -6,9 +6,12 @@ set( MODULE_DATA_DESTINATION share/calamares/modules )
|
||||
function( calamares_add_module_subdirectory )
|
||||
set( SUBDIRECTORY ${ARGV0} )
|
||||
|
||||
set( MODULE_CONFIG_FILES "" )
|
||||
|
||||
# If this subdirectory has a CMakeLists.txt, we add_subdirectory it...
|
||||
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" )
|
||||
add_subdirectory( ${SUBDIRECTORY} )
|
||||
file( GLOB MODULE_CONFIG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY} "${SUBDIRECTORY}/*.conf" )
|
||||
# ...otherwise, we look for a module.desc.
|
||||
elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/module.desc" )
|
||||
set( MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/calamares/modules )
|
||||
@ -56,9 +59,23 @@ function( calamares_add_module_subdirectory )
|
||||
RENAME calamares-${SUBDIRECTORY}.mo
|
||||
)
|
||||
endif()
|
||||
|
||||
else()
|
||||
message( "-- ${BoldYellow}Warning:${ColorReset} tried to add module subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no CMakeLists.txt or module.desc." )
|
||||
message( "" )
|
||||
endif()
|
||||
|
||||
# Check any config files for basic correctness
|
||||
if ( BUILD_TESTING AND MODULE_CONFIG_FILES )
|
||||
set( _count 0 )
|
||||
foreach( _config_file ${MODULE_CONFIG_FILES} )
|
||||
set( _count_str "-${_count}" )
|
||||
if ( _count EQUAL 0 )
|
||||
set( _count_str "" )
|
||||
endif()
|
||||
add_test(
|
||||
NAME config-${SUBDIRECTORY}${_count_str}
|
||||
COMMAND test_conf ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${_config_file} )
|
||||
math( EXPR _count "${_count} + 1" )
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -1,5 +1,10 @@
|
||||
include( CMakeColors )
|
||||
|
||||
if( BUILD_TESTING )
|
||||
add_executable( test_conf test_conf.cpp )
|
||||
target_link_libraries( test_conf ${YAMLCPP_LIBRARY} )
|
||||
endif()
|
||||
|
||||
file( GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*" )
|
||||
string( REPLACE " " ";" SKIP_LIST "${SKIP_MODULES}" )
|
||||
foreach( SUBDIRECTORY ${SUBDIRECTORIES} )
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* Originally from the Manjaro Installation Framework
|
||||
* by Roland Singer <roland@manjaro.org>
|
||||
@ -20,8 +21,12 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "timezonewidget.h"
|
||||
|
||||
constexpr double MATH_PI = 3.14159265;
|
||||
|
||||
TimeZoneWidget::TimeZoneWidget( QWidget* parent ) :
|
||||
QWidget( parent )
|
||||
{
|
||||
@ -47,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();
|
||||
|
||||
if ( !hash.contains( region ) )
|
||||
return;
|
||||
|
||||
QList<LocaleGlobal::Location> locations = hash.value( region );
|
||||
for (int i = 0; i < locations.size(); ++i) {
|
||||
if (locations.at(i).zone == zone) {
|
||||
for ( int i = 0; i < locations.size(); ++i )
|
||||
{
|
||||
if ( locations.at( i ).zone == zone )
|
||||
{
|
||||
setCurrentLocation( locations.at( i ) );
|
||||
break;
|
||||
}
|
||||
@ -63,18 +71,20 @@ void TimeZoneWidget::setCurrentLocation(QString region, QString zone) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
void TimeZoneWidget::setCurrentLocation(LocaleGlobal::Location location) {
|
||||
void TimeZoneWidget::setCurrentLocation( LocaleGlobal::Location location )
|
||||
{
|
||||
currentLocation = location;
|
||||
|
||||
// Set zone
|
||||
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];
|
||||
|
||||
// If not transparent set as current
|
||||
if (zone.pixel(pos) != RGB_TRANSPARENT) {
|
||||
if ( zone.pixel( pos ) != RGB_TRANSPARENT )
|
||||
{
|
||||
currentZoneImage = zone;
|
||||
break;
|
||||
}
|
||||
@ -91,13 +101,25 @@ 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 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 > 62.0 )
|
||||
y -= sin( MATH_PI * ( latitude - 62.0 ) / 56.0 ) * MAP_Y_OFFSET * height;
|
||||
// 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 )
|
||||
@ -111,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 height = this->height();
|
||||
QFontMetrics fontMetrics( font );
|
||||
@ -157,7 +179,8 @@ void TimeZoneWidget::paintEvent(QPaintEvent*) {
|
||||
|
||||
|
||||
|
||||
void TimeZoneWidget::mousePressEvent(QMouseEvent* event) {
|
||||
void TimeZoneWidget::mousePressEvent( QMouseEvent* event )
|
||||
{
|
||||
if ( event->button() != Qt::LeftButton )
|
||||
return;
|
||||
|
||||
@ -167,14 +190,17 @@ void TimeZoneWidget::mousePressEvent(QMouseEvent* event) {
|
||||
QHash<QString, QList<LocaleGlobal::Location> > hash = LocaleGlobal::getLocations();
|
||||
QHash<QString, QList<LocaleGlobal::Location> >::iterator iter = hash.begin();
|
||||
|
||||
while (iter != hash.end()) {
|
||||
while ( iter != hash.end() )
|
||||
{
|
||||
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];
|
||||
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;
|
||||
nX = locPos.x();
|
||||
nY = locPos.y();
|
||||
|
@ -50,7 +50,10 @@ class TimeZoneWidget : public QWidget
|
||||
public:
|
||||
explicit TimeZoneWidget( QWidget* parent = nullptr );
|
||||
|
||||
LocaleGlobal::Location getCurrentLocation() { return currentLocation; }
|
||||
LocaleGlobal::Location getCurrentLocation()
|
||||
{
|
||||
return currentLocation;
|
||||
}
|
||||
void setCurrentLocation( QString region, QString zone );
|
||||
void setCurrentLocation( LocaleGlobal::Location location );
|
||||
|
||||
@ -63,6 +66,10 @@ private:
|
||||
QList<QImage> timeZoneImages;
|
||||
LocaleGlobal::Location currentLocation;
|
||||
|
||||
QPoint getLocationPosition( const LocaleGlobal::Location& l )
|
||||
{
|
||||
return getLocationPosition( l.longitude, l.latitude );
|
||||
}
|
||||
QPoint getLocationPosition( double longitude, double latitude );
|
||||
|
||||
void paintEvent( QPaintEvent* event );
|
||||
|
66
src/modules/test_conf.cpp
Normal file
66
src/modules/test_conf.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2017, 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is a test-application that just checks the YAML config-file
|
||||
* shipped with each module for correctness -- well, for parseability.
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
using std::cerr;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
cerr << "Usage: test_conf <file.conf>\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
YAML::Node doc = YAML::LoadFile( argv[1] );
|
||||
|
||||
if ( doc.IsNull() )
|
||||
{
|
||||
// Special case: empty config files are valid,
|
||||
// but aren't a map. For the example configs,
|
||||
// this is still an error.
|
||||
cerr << "WARNING:" << argv[1] << '\n';
|
||||
cerr << "WARNING: empty YAML\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( !doc.IsMap() )
|
||||
{
|
||||
cerr << "WARNING:" << argv[1] << '\n';
|
||||
cerr << "WARNING: not-a-YAML-map\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch ( YAML::Exception& e )
|
||||
{
|
||||
cerr << "WARNING:" << argv[1] << '\n';
|
||||
cerr << "WARNING: YAML parser error " << e.what() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user