Commit f763217c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix code for building against qt6

parent d5b782ea
Pipeline #116096 passed with stage
in 1 minute and 14 seconds
......@@ -1810,7 +1810,11 @@ void KolfGame::openFile()
const int len = (*it).length();
const int dashIndex = (*it).indexOf(QLatin1Char('-'));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const int holeNum = (*it).leftRef(dashIndex).toInt();
#else
const int holeNum = QStringView(*it).left(dashIndex).toInt();
#endif
if (holeNum > _highestHole)
_highestHole = holeNum;
......@@ -1830,9 +1834,13 @@ void KolfGame::openFile()
const int commaIndex = (*it).indexOf(QLatin1Char(','));
const int pipeIndex = (*it).indexOf(QLatin1Char('|'));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const int x = (*it).midRef(atIndex + 1, commaIndex - (atIndex + 1)).toInt();
const int y = (*it).midRef(commaIndex + 1, pipeIndex - (commaIndex + 1)).toInt();
#else
const int x = QStringView(*it).mid(atIndex + 1, commaIndex - (atIndex + 1)).toInt();
const int y = QStringView(*it).mid(commaIndex + 1, pipeIndex - (commaIndex + 1)).toInt();
#endif
// will tell where ball is
if (name == QLatin1String("ball"))
{
......@@ -1841,9 +1849,11 @@ void KolfGame::openFile()
whiteBall->setPos(x, y);
continue;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
const int id = (*it).rightRef(len - (pipeIndex + 1)).toInt();
#else
const int id = QStringView(*it).right(len - (pipeIndex + 1)).toInt();
#endif
QGraphicsItem* newItem = m_factory.createInstance(name, courseBoard, g_world);
if (newItem)
{
......@@ -2180,7 +2190,11 @@ void KolfGame::save()
// wipe out all groups from this hole
for (QStringList::const_iterator it = groups.begin(); it != groups.end(); ++it)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
int holeNum = (*it).leftRef((*it).indexOf(QLatin1Char('-'))).toInt();
#else
int holeNum = QStringView(*it).left((*it).indexOf(QLatin1Char('-'))).toInt();
#endif
if (holeNum == curHole)
cfg->deleteGroup(*it);
}
......
......@@ -110,21 +110,21 @@ void KolfWindow::setupActions()
editingAction = new KToggleAction(QIcon::fromTheme( QStringLiteral( "document-properties") ), i18n("&Edit"), this);
actionCollection()->addAction(QStringLiteral("editing"), editingAction);
connect(editingAction, &QAction::triggered, this, &KolfWindow::emptySlot);
actionCollection()->setDefaultShortcut(editingAction, Qt::CTRL+Qt::Key_E);
actionCollection()->setDefaultShortcut(editingAction, Qt::CTRL|Qt::Key_E);
newHoleAction = actionCollection()->addAction(QStringLiteral("newhole"));
newHoleAction->setIcon(QIcon::fromTheme( QStringLiteral( "document-new" )));
newHoleAction->setText(i18n("&New"));
connect(newHoleAction, &QAction::triggered, this, &KolfWindow::emptySlot);
actionCollection()->setDefaultShortcut(newHoleAction, Qt::CTRL+Qt::SHIFT+Qt::Key_N);
actionCollection()->setDefaultShortcut(newHoleAction, Qt::CTRL|Qt::SHIFT|Qt::Key_N);
clearHoleAction = actionCollection()->addAction(QStringLiteral("clearhole"));
clearHoleAction->setIcon(QIcon::fromTheme( QStringLiteral( "edit-clear-locationbar-ltr" )));
clearHoleAction->setText(KStandardGuiItem::clear().text());
connect(clearHoleAction, &QAction::triggered, this, &KolfWindow::emptySlot);
actionCollection()->setDefaultShortcut(clearHoleAction, Qt::CTRL+Qt::Key_Delete);
actionCollection()->setDefaultShortcut(clearHoleAction, Qt::CTRL|Qt::Key_Delete);
resetHoleAction = actionCollection()->addAction(QStringLiteral("resethole"));
resetHoleAction->setText(i18n("&Reset"));
connect(resetHoleAction, &QAction::triggered, this, &KolfWindow::emptySlot);
actionCollection()->setDefaultShortcut(resetHoleAction, Qt::CTRL+Qt::Key_R);
actionCollection()->setDefaultShortcut(resetHoleAction, Qt::CTRL|Qt::Key_R);
undoShotAction = KStandardAction::undo(this, &KolfWindow::emptySlot, this);
actionCollection()->addAction(QStringLiteral("undoshot"), undoShotAction);
undoShotAction->setText(i18n("&Undo Shot"));
......@@ -152,7 +152,7 @@ void KolfWindow::setupActions()
lastAction = actionCollection()->addAction(QStringLiteral("lasthole"));
lastAction->setText(i18n("&Last Hole"));
connect(lastAction, &QAction::triggered, this, &KolfWindow::emptySlot);
actionCollection()->setDefaultShortcut(lastAction, Qt::CTRL+Qt::SHIFT+Qt::Key_End); // why not KStandardShortcut::End (Ctrl+End)?
actionCollection()->setDefaultShortcut(lastAction, Qt::CTRL|Qt::SHIFT|Qt::Key_End); // why not KStandardShortcut::End (Ctrl+End)?
randAction = actionCollection()->addAction(QStringLiteral("randhole"));
randAction->setIcon(QIcon::fromTheme( QStringLiteral( "go-jump" )));
randAction->setText(i18n("&Random Hole"));
......@@ -175,7 +175,7 @@ void KolfWindow::setupActions()
showInfoAction = new KToggleAction(QIcon::fromTheme( QStringLiteral( "help-about")), i18n("Show &Info"), this);
actionCollection()->addAction(QStringLiteral("showinfo"), showInfoAction);
connect(showInfoAction, &QAction::triggered, this, &KolfWindow::emptySlot);
actionCollection()->setDefaultShortcut(showInfoAction, Qt::CTRL+Qt::Key_I);
actionCollection()->setDefaultShortcut(showInfoAction, Qt::CTRL|Qt::Key_I);
connect(showInfoAction, &QAction::toggled, this, &KolfWindow::showInfoChanged);
showInfoAction->setChecked(configGroup.readEntry("showInfo", true));
......@@ -632,7 +632,7 @@ void KolfWindow::openUrl(const QUrl &url)
{
isTutorial = false;
QMimeDatabase db;
QString mimeType = db.mimeTypeForFile(tempFile).name();
QString mimeType = db.mimeTypeForFile(tempFile.fileName()).name();
if (mimeType == QLatin1String("application/x-kourse"))
filename = tempFile.fileName();
else if (mimeType == QLatin1String("application/x-kolf"))
......
......@@ -38,7 +38,9 @@ using namespace std;
int main(int argc, char **argv)
{
// Fixes blurry icons with fractional scaling
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
QApplication app(argc, argv);
KLocalizedString::setApplicationDomain("kolf");
......
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