Several adjustments related to Qt6

* Avoid ambiguous definition during unity build on Windows
* Add missing include
* Add Qt6 to expressionparser
* Add Qt6 to nightcharts
* Replace forward define of QStringList with include <QStringList>
* Use toMSecsSinceEpoch
* Use setContentsMargins
This commit is contained in:
Magne Sjaastad
2024-04-16 14:22:15 +02:00
committed by GitHub
parent 39b9a25faa
commit 030688cff6
30 changed files with 81 additions and 49 deletions

View File

@@ -7,9 +7,14 @@ if(MSVC)
message(STATUS "MSVC: Enabled increased number of sections in object files")
endif()
find_package(Qt5 COMPONENTS REQUIRED Core)
set(QT_LIBRARIES Qt5::Core)
if (CEE_USE_QT6)
find_package(Qt6 COMPONENTS REQUIRED Core)
set(QT_LIBRARIES Qt6::Core)
qt_standard_project_setup()
else()
find_package(Qt5 COMPONENTS REQUIRED Core)
set(QT_LIBRARIES Qt5::Core)
endif()
list (APPEND MAIN_SOURCE_FILES
ExpressionParser.h

View File

@@ -2,9 +2,14 @@ cmake_minimum_required (VERSION 2.8.12)
project (nightcharts)
find_package(Qt5 COMPONENTS REQUIRED Core Widgets)
set(QT_LIBRARIES Qt5::Core Qt5::Widgets)
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES})
if (CEE_USE_QT6)
find_package(Qt6 COMPONENTS REQUIRED Core Gui Widgets)
set(QT_LIBRARIES Qt6::Core Qt6::Gui Qt6::Widgets)
qt_standard_project_setup()
else()
find_package(Qt5 COMPONENTS REQUIRED Core Gui Widgets)
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Widgets)
endif()
list (APPEND MAIN_SOURCE_FILES
nightcharts.h

View File

@@ -330,7 +330,7 @@ int Nightcharts::draw(QPainter *painter)
painter->drawRect(cX+pDist+i*(pW + pDist),cY+cH,pW,-cH/100*pieces[i].pPerc-5);
QString label = QString::number(pieces[i].pPerc)+"%";
painter->setPen(Qt::SolidLine);
painter->drawText(cX+pDist+i*(pW + pDist)+pW/2-painter->fontMetrics().width(label)/2,cY+cH-cH/100*pieces[i].pPerc-painter->fontMetrics().height()/2,label);
painter->drawText(cX+pDist+i*(pW + pDist)+pW/2-painter->fontMetrics().horizontalAdvance(label)/2,cY+cH-cH/100*pieces[i].pPerc-painter->fontMetrics().height()/2,label);
}
painter->setPen(Qt::SolidLine);
for (int i=1;i<10;i++)
@@ -386,12 +386,12 @@ void Nightcharts::drawLegend(QPainter *painter)
}
painter->drawLine(p.x(),p.y(),p_.x(),p_.y());
QString label = pieces[i].pname + " - " + QString::number(pieces[i].pPerc)+"%";
float recW = painter->fontMetrics().width(label)+10;
float recW = painter->fontMetrics().horizontalAdvance(label)+10;
float recH = painter->fontMetrics().height()+10;
p_.setX(p_.x()-recW/2 + recW/2*cos(angle*M_PI/180));
p_.setY(p_.y()+recH/2 + recH/2*sin(angle*M_PI/180));
painter->setBrush(textColor);
painter->drawRoundRect(p_.x() ,p_.y(), recW, -recH);
painter->drawRect(p_.x() ,p_.y(), recW, -recH);
painter->drawText(p_.x()+5, p_.y()-recH/2+5, label);
angle -= pdegree/2;
}