Commit 0ca3e600 authored by Laurent Montel's avatar Laurent Montel
Browse files

Allow to compile against qt6

parent a3c82353
Pipeline #133992 passed with stage
in 37 seconds
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.16)
# KDE Application Version, managed by release script
set(RELEASE_SERVICE_VERSION_MAJOR "22")
......@@ -8,6 +8,17 @@ set(RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_
project(kanagram VERSION ${RELEASE_SERVICE_VERSION})
find_package(ECM 5.90.0 NO_MODULE REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} )
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
include(ECMAddAppIcon)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(ECMInstallIcons)
include(ECMSetupVersion)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Wall -Wno-switch -O2 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-Wall -Wno-switch -O2")
......@@ -15,23 +26,14 @@ if(NOT MSVC)
endif(NOT MSVC)
include(FeatureSummary)
find_package(Qt5 REQUIRED COMPONENTS Core Qml Quick)
find_package(Qt5 QUIET OPTIONAL_COMPONENTS TextToSpeech)
if (NOT Qt5TextToSpeech_FOUND)
find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS Core Qml Quick)
find_package(Qt${QT_MAJOR_VERSION} QUIET OPTIONAL_COMPONENTS TextToSpeech)
if (NOT Qt${QT_MAJOR_VERSION}TextToSpeech_FOUND)
message(STATUS "Qt5TextToSpeech not found, speech feature will be disabled")
else()
add_definitions(-DHAVE_SPEECH)
endif()
find_package(ECM 5.17.0 NO_MODULE REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} )
include(ECMAddAppIcon)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(ECMInstallIcons)
include(ECMSetupVersion)
find_package(KF5 REQUIRED COMPONENTS
I18n
......
......@@ -8,6 +8,12 @@ set(kanagram_SRCS
mainsettings.cpp
vocabsettings.cpp
vocabedit.cpp
kanagramconfigdialog.h
kanagramgame.h
mainwindow.h
mainsettings.h
vocabsettings.h
vocabedit.h
)
include_directories(
......@@ -36,11 +42,11 @@ ecm_add_app_icon(kanagram_SRCS ICONS
add_executable(kanagram ${kanagram_SRCS})
target_link_libraries(kanagram
Qt5::Quick
Qt5::Core
Qt::Quick
Qt::Core
KF5::CoreAddons
KF5::I18n
KF5::NewStuff
KF5::NewStuffWidgets
KF5::SonnetCore
KF5::Crash
LibKEduVocDocumentImport__KEduVocDocument
......
......@@ -54,7 +54,7 @@ KanagramConfigDialog::~KanagramConfigDialog()
void KanagramConfigDialog::updateSettings()
{
if (m_mainSettingsPage->saveLanguage()) {
emit settingsChanged(objectName());
Q_EMIT settingsChanged(objectName());
m_hasChanged = false;
}
KConfigDialog::updateSettings();
......
......@@ -85,7 +85,7 @@ bool KanagramGame::checkFile()
{
if (!QFile::exists(m_filename) && !QFile::exists(QStandardPaths::locate(QStandardPaths::GenericDataLocation, m_filename)))
{
emit fileError(m_filename);
Q_EMIT fileError(m_filename);
return false;
}
......@@ -122,7 +122,7 @@ void KanagramGame::loadDefaultVocabulary()
void KanagramGame::setSinglePlayerMode(bool singlePlayer)
{
KanagramSettings::setSinglePlayerMode(singlePlayer);
emit singlePlayerChanged();
Q_EMIT singlePlayerChanged();
}
bool KanagramGame::singlePlayerMode()
......@@ -138,7 +138,7 @@ int KanagramGame::getPlayerNumber()
void KanagramGame::setPlayerNumber(int pnumber)
{
m_currentPlayerNumber = pnumber;
emit currentPlayerChanged();
Q_EMIT currentPlayerChanged();
}
bool KanagramGame::refreshVocabularyList()
......@@ -186,7 +186,7 @@ void KanagramGame::useVocabulary(int index)
// Save the setting
KanagramSettings::setCurrentVocabulary(index);
KanagramSettings::self()->save();
emit titleChanged();
Q_EMIT titleChanged();
}
}
......@@ -254,8 +254,8 @@ void KanagramGame::nextAnagram()
m_audioUrl = QUrl();
// TODO: add some error reporting here
}
emit userAnswerChanged();
emit wordChanged();
Q_EMIT userAnswerChanged();
Q_EMIT wordChanged();
}
}
......@@ -378,7 +378,7 @@ void KanagramGame::setDataLanguage(const QString& dataLanguage)
KanagramSettings::self()->save();
// Update the speller's language accordingly
m_speller->setLanguage(sanitizedDataLanguage());
emit dataLanguageChanged();
Q_EMIT dataLanguageChanged();
}
QUrl KanagramGame::picHint()
......@@ -440,24 +440,24 @@ void KanagramGame::moveLetterToUserAnswer(int position)
{
m_userAnswer.append(m_anagram[position]);
m_anagram.remove(position, 1);
emit wordChanged();
emit userAnswerChanged();
Q_EMIT wordChanged();
Q_EMIT userAnswerChanged();
}
void KanagramGame::moveLetterToAnagram(int position)
{
m_anagram.append(m_userAnswer[position]);
m_userAnswer.remove(position, 1);
emit wordChanged();
emit userAnswerChanged();
Q_EMIT wordChanged();
Q_EMIT userAnswerChanged();
}
void KanagramGame::resetAnagram()
{
m_anagram = m_userAnswer;
m_userAnswer.clear();
emit wordChanged();
emit userAnswerChanged();
Q_EMIT wordChanged();
Q_EMIT userAnswerChanged();
}
void KanagramGame::moveLetter(const QString &letter)
......@@ -507,7 +507,11 @@ int KanagramGame::getNumericSetting(const QString &settingString)
break;
}
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return settingString.leftRef(indexFound_setting).toInt();
#else
return QStringView(settingString).left(indexFound_setting).toInt();
#endif
}
void KanagramGame::resetTotalScore()
......@@ -516,7 +520,7 @@ void KanagramGame::resetTotalScore()
{
m_totalScore = 0;
m_totalScore2 = 0;
emit scoreChanged();
Q_EMIT scoreChanged();
}
}
......@@ -526,7 +530,7 @@ void KanagramGame::adjustScore(int points)
m_totalScore += points;
else
m_totalScore2 += points;
emit scoreChanged();
Q_EMIT scoreChanged();
}
int KanagramGame::totalScore()
......@@ -542,7 +546,7 @@ int KanagramGame::totalScore2()
void KanagramGame::revealWord()
{
m_anagram = m_originalWord;
emit wordChanged();
Q_EMIT wordChanged();
}
bool KanagramGame::checkWord()
......@@ -672,7 +676,7 @@ void KanagramGame::answerCorrect()
m_totalScore += m_correctAnswerScore;
else
m_totalScore2 += m_correctAnswerScore;
emit scoreChanged();
Q_EMIT scoreChanged();
}
void KanagramGame::answerIncorrect()
......@@ -681,7 +685,7 @@ void KanagramGame::answerIncorrect()
m_totalScore += m_incorrectAnswerScore;
else
m_totalScore2 += m_incorrectAnswerScore;
emit scoreChanged();
Q_EMIT scoreChanged();
}
void KanagramGame::answerRevealed()
......@@ -690,7 +694,7 @@ void KanagramGame::answerRevealed()
m_totalScore += m_revealAnswerScore;
else
m_totalScore2 += m_revealAnswerScore;
emit scoreChanged();
Q_EMIT scoreChanged();
}
void KanagramGame::answerSkipped()
......@@ -699,5 +703,5 @@ void KanagramGame::answerSkipped()
m_totalScore += m_skippedWordScore;
else
m_totalScore2 += m_skippedWordScore;
emit scoreChanged();
Q_EMIT scoreChanged();
}
......@@ -28,7 +28,9 @@
#include <KAboutData>
#include <KCrash>
#include <KLocalizedString>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <Kdelibs4ConfigMigrator>
#endif
#include "mainwindow.h"
#include "kanagram_version.h"
......@@ -39,9 +41,11 @@ int main(int argc, char **argv)
{
QStringList configFiles;
configFiles << QStringLiteral("kanagramrc");
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
Kdelibs4ConfigMigrator migrator(QStringLiteral("kanagram"));
migrator.setConfigFiles(configFiles);
migrator.migrate();
#endif
QApplication::setApplicationName(QStringLiteral("kanagram"));
QApplication::setApplicationVersion(QStringLiteral(KANAGRAM_VERSION_STRING));
......
......@@ -42,12 +42,12 @@ public:
*/
bool saveLanguage();
public slots:
public Q_SLOTS:
/** toggle advanced settings */
void slotToggleAdvancedSettings();
signals:
Q_SIGNALS:
/** signifies the language widget has been changed */
void widgetModified();
......
......@@ -58,7 +58,7 @@ MainWindow::MainWindow()
setWindowState(Qt::WindowState(windowConfig.readEntry("windowState").toInt()));
}
QString location = QStandardPaths::locate(QStandardPaths::DataLocation, QStringLiteral("ui/main.qml"));
QString location = QStandardPaths::locate(QStandardPaths::AppLocalDataLocation, QStringLiteral("ui/main.qml"));
setSource(QUrl::fromLocalFile(location));
qCDebug(KANAGRAM) << "Set qml file location";
......
......@@ -39,7 +39,7 @@ public:
MainWindow();
~MainWindow();
public slots:
public Q_SLOTS:
void showAboutKanagram();
void showAboutKDE();
void showHandbook();
......@@ -47,7 +47,7 @@ public slots:
/** invoke the settings dialog */
void showSettings();
private slots:
private Q_SLOTS:
void categoryChanged();
private:
......
......@@ -35,7 +35,7 @@ Q_OBJECT
VocabEdit(QWidget *parent, const QString &fileName);
~VocabEdit();
public slots:
public Q_SLOTS:
void slotSave();
void slotClose();
void slotNewWord();
......
......@@ -21,13 +21,14 @@
#include "vocabsettings.h"
#include <KConfigDialog>
#include <KNSWidgets/Button>
#include <sharedkvtmlfiles.h>
#include <QIcon>
#include <QFileInfo>
#include <QPointer>
#include "kanagramsettings.h"
#include "vocabedit.h"
......@@ -38,7 +39,7 @@ VocabSettings::VocabSettings(QWidget *parent)
connect(lviewVocab, &QTreeWidget::currentItemChanged, this, &VocabSettings::slotSelectionChanged);
connect(btnDownloadNew, &KNS3::Button::dialogFinished, this, [this] (const QList<KNS3::Entry> &changedEntries) {
connect(btnDownloadNew, &KNSWidgets::Button::dialogFinished, this, [this] (const QList<KNSCore::Entry> &changedEntries) {
if (!changedEntries.isEmpty()) {
refreshView();
}
......@@ -74,7 +75,7 @@ void VocabSettings::loadView()
void VocabSettings::refreshView()
{
loadView();
emit widgetModified();
Q_EMIT widgetModified();
}
void VocabSettings::on_btnEdit_clicked()
......
......@@ -39,12 +39,12 @@ Q_OBJECT
/** default destructor */
virtual ~VocabSettings();
signals:
Q_SIGNALS:
/** signifies the widget has been changed */
void widgetModified();
private slots:
private Q_SLOTS:
/** create a new vocabulary
* called when the btnCreateNew is clicked
......
......@@ -53,7 +53,7 @@
</widget>
</item>
<item>
<widget class="KNS3::Button" name="btnDownloadNew">
<widget class="KNSWidgets::Button" name="btnDownloadNew">
<property name="toolTip">
<string>Download new vocabulary from &quot;Get hot new Stuff&quot;</string>
</property>
......@@ -105,9 +105,9 @@
<connections/>
<customwidgets>
<customwidget>
<class>KNS3::Button</class>
<class>KNSWidgets::Button</class>
<extends>QPushButton</extends>
<header>KNS3/Button</header>
<header>KNSWidgets/Button</header>
</customwidget>
</customwidgets>
</ui>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment