Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal porting to Qt6. #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Dockerfile.arch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM archlinux
MAINTAINER Ilya V. Portnov <[email protected]>

RUN pacman -Sy && yes | pacman -S gcc make qt6-base qt6-svg qt6-tools icu

VOLUME /dst
VOLUME /src
WORKDIR /src/qcheckers

ADD arch_entrypoint.sh .

CMD ["/bin/bash", "-c", "./arch_entrypoint.sh"]
6 changes: 6 additions & 0 deletions arch_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

set -e

qmake6
make
11 changes: 11 additions & 0 deletions build_on_arch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
set -e

rm -f Makefile src/Makefile
qmake
make clean
rm -f Makefile src/Makefile

docker build -t qcheckers-arch -f Dockerfile.arch .

docker run --rm --name qcheckers-arch -v $(pwd):/src/qcheckers -v $(pwd):/dst qcheckers-arch
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: qcheckers
Section: games
Priority: optional
Maintainer: Ilya Portnov <[email protected]>
Build-Depends: debhelper (>= 11), qt5-qmake-bin, qtbase5-dev, libqt5svg5-dev
Build-Depends: debhelper (>= 9), qt5-qmake, qtbase5-dev, libqt5svg5-dev
Standards-Version: 4.1.3
Homepage: https://portnov.github.io/qcheckers/

Expand Down
1 change: 0 additions & 1 deletion lang/qcheckers_de.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0">
<defaultcodec>UTF-8</defaultcodec>
<context>
<name>myHistory</name>
<message>
Expand Down
1 change: 0 additions & 1 deletion lang/qcheckers_fr.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0">
<defaultcodec>UTF-8</defaultcodec>
<context>
<name>myHistory</name>
<message>
Expand Down
4 changes: 2 additions & 2 deletions src/board.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ bool myBoard::convert_move(const QString& move_orig, int* from_num, int* to_num)
from = move.section('-', 0, 0);
to = move.section('-', sect, sect);

if(from!=QString::null && to!=QString::null) {
if(!from.isNull() && !to.isNull()) {
for(int i=0; i<32; i++) {
if(m_fields[i]->label()==from) {
*from_num = m_fields[i]->number();
Expand Down Expand Up @@ -379,7 +379,7 @@ QString myBoard::doMove(int from_num, int to_num, bool white_player)
m_game->fromString(m_game->toString(true));
}
if(!m_game->go1(from_pos, to_pos)) {
return QString::null;
return QString();
/*
qDebug() << __PRETTY_FUNCTION__
<< from_pos << "," << to_pos
Expand Down
2 changes: 1 addition & 1 deletion src/checkers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ QString Checkers::toString(bool rotate) const

QString str;
for(int i=0; i<32; i++)
str += QString("").sprintf("%.2u", fields[i]);
str += QString("").asprintf("%.2u", fields[i]);

return str;
}
Expand Down
14 changes: 14 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,19 @@
//
#define MAX_TILE_SIZE 64

// Qt5 / 6 compatibility workarounds

#if QT_VERSION < QT_VERSION_CHECK(5,14,0)
#define QT_ENDL endl
#else
#define QT_ENDL Qt::endl
#endif

#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
#define QT_SKIP_EMPTY_PARTS QString::SkipEmptyParts
#else
#define QT_SKIP_EMPTY_PARTS Qt::SkipEmptyParts
#endif

#endif

2 changes: 1 addition & 1 deletion src/history.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ myHistory::myHistory(QWidget* parent)

// layout
QVBoxLayout* vb = new QVBoxLayout(this);
vb->setMargin(0);
vb->setContentsMargins(0,0,0,0);
vb->addWidget(m_gamelist, 0);
vb->addWidget(m_taglist, 2);
vb->addWidget(m_movelist, 4);
Expand Down
8 changes: 4 additions & 4 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ int main(int argc, char *argv[])
QString current_lang = QLocale::system().name().split("_").front();
QString qt_lang_path = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
//QString qcheckers_share_path = PREFIX"/share/qcheckers/lang";
QString lang_path = QStandardPaths::locate(QStandardPaths::DataLocation, "lang", QStandardPaths::LocateDirectory);
QString lang_path = QStandardPaths::locate(QStandardPaths::AppDataLocation, "lang", QStandardPaths::LocateDirectory);

qDebug()
<< "Your Locale:" << current_lang << endl
<< "QCheckers Translations path:" << lang_path << endl
<< "QT Translations path:" << qt_lang_path << endl;
<< "Your Locale:" << current_lang << QT_ENDL
<< "QCheckers Translations path:" << lang_path << QT_ENDL
<< "QT Translations path:" << qt_lang_path << QT_ENDL;

// Qt translations
QTranslator qt_tr;
Expand Down
3 changes: 2 additions & 1 deletion src/pdn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <QProgressDialog>
#include <QDebug>

#include "common.h"
#include "checkers.h"
#include "pdn.h"

Expand Down Expand Up @@ -133,7 +134,7 @@ bool Pdn::save(const QString& filename)
QTextStream ts(&file);

foreach(PdnGame* game, m_database) {
ts << game->toString() << endl << endl;
ts << game->toString() << QT_ENDL << QT_ENDL;
}

file.close();
Expand Down
4 changes: 2 additions & 2 deletions src/toplevel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ QDockWidget* myTopLevel::make_dock(const QString& name, const QString& title, Qt

void myTopLevel::make_actions()
{
QString theme_path = QStandardPaths::locate(QStandardPaths::DataLocation, THEME_DIR, QStandardPaths::LocateDirectory);
QString theme_path = QStandardPaths::locate(QStandardPaths::AppDataLocation, THEME_DIR, QStandardPaths::LocateDirectory);
qDebug()
<< "Themes directory: " << theme_path << endl;
<< "Themes directory: " << theme_path << QT_ENDL;
// game menu actions
gameNew = new QAction(QIcon(":/icons/logo.svg"), tr("&New..."), this);
gameNew->setShortcut(tr("CTRL+N", "File|New"));
Expand Down
2 changes: 1 addition & 1 deletion src/view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ void myView::slot_preview_game(int rules)

void myView::slot_apply_moves(const QString& moves)
{
QStringList move_list= moves.split(MOVE_SPLIT, QString::SkipEmptyParts);
QStringList move_list= moves.split(MOVE_SPLIT, QT_SKIP_EMPTY_PARTS);

m_board->reset();

Expand Down