Skip to content

Commit e6d816f

Browse files
committed
migrate to qt6
1 parent 8580fd8 commit e6d816f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+271
-212
lines changed

CMakeLists.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ if(NOT DEBUG_OUTPUT)
9292
endif()
9393

9494
find_package(
95-
Qt5 5.12
95+
Qt6
9696
COMPONENTS ${QT_MODULES} LinguistTools
9797
REQUIRED)
9898
if(FLATPAK)
9999
find_package(
100-
Qt5 5.15
100+
Qt6
101101
COMPONENTS XcbQpa
102102
REQUIRED)
103103
add_compile_definitions(FLATPAK)
@@ -109,7 +109,7 @@ endif()
109109

110110
include(GNUInstallDirs) # Defines some variables as BINDIR, LIBDIR, ...
111111

112-
set(QT_TRANSLATIONS_DIR "${Qt5_DIR}/../../../translations")
112+
set(QT_TRANSLATIONS_DIR "${Qt6_DIR}/../../../translations")
113113
set(QT_TRANSLATIONS_DIR "/usr/share/qt/translations")
114114

115115
if(APPLE)
@@ -119,8 +119,8 @@ if(APPLE)
119119
# dependencies are to the release libraries (e.g. QtGui_debug depends on
120120
# QtCore). This causes multiple symbol definition errors at application load
121121
# time.
122-
get_target_property(LOCATION Qt5::${QT_MODULE} LOCATION)
123-
set_target_properties(Qt5::${QT_MODULE} PROPERTIES IMPORTED_LOCATION_DEBUG
122+
get_target_property(LOCATION Qt6::${QT_MODULE} LOCATION)
123+
set_target_properties(Qt6::${QT_MODULE} PROPERTIES IMPORTED_LOCATION_DEBUG
124124
${LOCATION})
125125
endforeach()
126126
endif()

dep/scintilla/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ target_compile_definitions(
5454

5555
target_include_directories(scintilla PUBLIC ${SCINTILLA_DIR}/src)
5656

57-
target_link_libraries(scintilla Qt5::Widgets lexilla)
57+
target_link_libraries(scintilla Qt6::Widgets lexilla)
5858

5959
set_target_properties(scintilla PROPERTIES AUTOMOC ON)
6060

l10n/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ endforeach()
2020

2121
if(UPDATE_TRANSLATIONS)
2222
# FIXME: Clean removes the .ts files.
23-
qt5_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES})
23+
qt6_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES})
2424
else()
25-
qt5_add_translation(QM_FILES ${TS_FILES})
25+
qt6_add_translation(QM_FILES ${TS_FILES})
2626
endif()
2727

2828
add_custom_target(translations DEPENDS ${QM_FILES})

pack/CMakeLists.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ if(FLATPAK)
2121
qt_import_plugins(gittyup INCLUDE ${QT_PLUGINS})
2222
elseif(NOT USE_SYSTEM_QT)
2323
foreach(QT_PLUGIN ${QT_PLUGINS})
24-
if(NOT TARGET Qt5::${QT_PLUGIN})
24+
if(NOT TARGET Qt6::${QT_PLUGIN})
2525
if(UNIX OR APPLE)
2626
continue()
2727
endif()
2828
endif()
2929

30-
get_target_property(PLUGIN Qt5::${QT_PLUGIN} LOCATION_${CMAKE_BUILD_TYPE})
30+
get_target_property(PLUGIN Qt6::${QT_PLUGIN} LOCATION_${CMAKE_BUILD_TYPE})
3131
get_filename_component(FILE_NAME ${PLUGIN} NAME)
3232
get_filename_component(DIR ${PLUGIN} DIRECTORY)
3333
get_filename_component(DIR_NAME ${DIR} NAME)
@@ -71,7 +71,7 @@ elseif(NOT USE_SYSTEM_QT)
7171

7272
# Install Qt libraries.
7373
foreach(QT_MODULE ${QT_MODULES})
74-
get_target_property(QT_LIBRARY Qt5::${QT_MODULE}
74+
get_target_property(QT_LIBRARY Qt6::${QT_MODULE}
7575
LOCATION_${CMAKE_BUILD_TYPE})
7676

7777
if(APPLE)
@@ -124,8 +124,8 @@ endif()
124124

125125
# Install XcbQpa library.
126126
if(UNIX AND NOT APPLE)
127-
set(LIB_NAME libQt5XcbQpa)
128-
get_target_property(QT_CORE_LIBRARY Qt5::Core LOCATION)
127+
set(LIB_NAME libQt6XcbQpa)
128+
get_target_property(QT_CORE_LIBRARY Qt6::Core LOCATION)
129129
get_filename_component(LIB_PATH ${QT_CORE_LIBRARY} PATH)
130130
get_filename_component(LIB_EXT ${QT_CORE_LIBRARY} EXT)
131131

src/app/CMakeLists.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ file(GLOB SCINTILLUA_LEXERS ${SCINTILLUA_LEXERS_DIR}/*.lua)
2222
file(GLOB LUA_PLUGINS ${CONF_DIR}/plugins/*.lua ${CONF_DIR}/plugins/*.txt)
2323

2424
# Build resources.
25-
qt5_add_resources(RESOURCES ${RSRC_DIR}/resources.qrc)
25+
qt6_add_resources(RESOURCES ${RSRC_DIR}/resources.qrc)
2626

2727
# Generate acknowledgments.
2828
set(DOC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/docs)
@@ -63,12 +63,12 @@ target_compile_definitions(
6363
PRIVATE QT_TRANSLATIONS_DIR="${QT_TRANSLATIONS_DIR}"
6464
BUILD_DESCRIPTION="${BUILD_DESCRIPTION}")
6565

66-
target_link_libraries(app conf git ui update Qt5::Widgets)
66+
target_link_libraries(app conf git ui update Qt6::Widgets)
6767

6868
set_target_properties(app PROPERTIES AUTOMOC ON)
6969

7070
if(UNIX AND NOT APPLE)
71-
target_link_libraries(app Qt5::DBus)
71+
target_link_libraries(app Qt6::DBus)
7272
endif()
7373

7474
# Add main executable.
@@ -167,7 +167,7 @@ else()
167167
endif()
168168

169169
if(APPLE)
170-
get_target_property(QT_LIBRARY Qt5::Core LOCATION)
170+
get_target_property(QT_LIBRARY Qt6::Core LOCATION)
171171
get_filename_component(QT_FRAMEWORK ${QT_LIBRARY} DIRECTORY)
172172
get_filename_component(RPATH ${QT_FRAMEWORK} DIRECTORY)
173173

src/app/CustomTheme.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ QColor CustomTheme::commitEditor(CommitEditor color) {
421421
case CommitEditor::LengthWarning:
422422
return commitEditor.value("lengthwarning").value<QColor>();
423423
}
424+
return QColor{};
424425
}
425426

426427
QColor CustomTheme::diff(Diff color) {
@@ -450,6 +451,7 @@ QColor CustomTheme::diff(Diff color) {
450451
case Diff::Error:
451452
return diff.value("error").value<QColor>();
452453
}
454+
return QColor{};
453455
}
454456

455457
QColor CustomTheme::heatMap(HeatMap color) {
@@ -461,6 +463,7 @@ QColor CustomTheme::heatMap(HeatMap color) {
461463
case HeatMap::Cold:
462464
return QColor(heatmap.value("cold").toString());
463465
}
466+
return QColor{};
464467
}
465468

466469
QColor CustomTheme::remoteComment(Comment color) {
@@ -476,6 +479,7 @@ QColor CustomTheme::remoteComment(Comment color) {
476479
case Comment::Timestamp:
477480
return QColor(comment.value("timestamp").toString());
478481
}
482+
return QColor{};
479483
}
480484

481485
QColor CustomTheme::star() {

src/app/Gittyup.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include <QMessageBox>
1414

1515
int main(int argc, char *argv[]) {
16-
Application::setAttribute(Qt::AA_EnableHighDpiScaling);
17-
Application::setAttribute(Qt::AA_UseHighDpiPixmaps);
1816
Application app(argc, argv, true);
1917

2018
// Check if only one running instance is allowed and already running

src/app/Theme.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ QColor Theme::badge(BadgeRole role, BadgeState state) {
125125
return mDark ? "#8C2026" : "#FF0000";
126126
}
127127
}
128+
return QColor{};
128129
}
129130

130131
QList<QColor> Theme::branchTopologyEdges() {
@@ -152,6 +153,7 @@ QColor Theme::commitEditor(CommitEditor color) {
152153
case CommitEditor::LengthWarning:
153154
return Qt::yellow;
154155
}
156+
return QColor{};
155157
}
156158

157159
QColor Theme::diff(Diff color) {
@@ -206,6 +208,7 @@ QColor Theme::diff(Diff color) {
206208
case Diff::Error:
207209
return "#FF0000";
208210
}
211+
return QColor{};
209212
}
210213

211214
QColor Theme::heatMap(HeatMap color) {
@@ -216,6 +219,7 @@ QColor Theme::heatMap(HeatMap color) {
216219
return mDark ? QPalette().color(QPalette::Inactive, QPalette::Highlight)
217220
: QPalette().color(QPalette::Mid);
218221
}
222+
return QColor{};
219223
}
220224

221225
QColor Theme::remoteComment(Comment color) {
@@ -229,6 +233,7 @@ QColor Theme::remoteComment(Comment color) {
229233
case Comment::Timestamp:
230234
return QPalette().color(QPalette::WindowText);
231235
}
236+
return QColor{};
232237
}
233238

234239
QColor Theme::star() { return QPalette().color(QPalette::Highlight); }

src/cli/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ endif()
77

88
add_library(cli Installer.cpp ${INSTALLER_IMPL_FILE})
99

10-
target_link_libraries(cli Qt5::Core ${INSTALLER_IMPL_LIBS})
10+
target_link_libraries(cli Qt6::Core ${INSTALLER_IMPL_LIBS})

src/conf/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
add_library(conf ConfFile.cpp Settings.cpp Setting.cpp RecentRepositories.cpp
22
RecentRepository.cpp)
33

4-
target_link_libraries(conf lua Qt5::Core util)
4+
target_link_libraries(conf lua Qt6::Core util)
55

66
target_compile_definitions(
77
conf PRIVATE SCINTILLUA_LEXERS_DIR="${SCINTILLUA_LEXERS_DIR}")

src/conf/Settings.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "ConfFile.h"
1212
#include <QCoreApplication>
1313
#include <QDir>
14+
#include <QRegularExpression>
1415
#include <QSettings>
1516
#include <QStandardPaths>
1617

@@ -29,7 +30,7 @@ const QString kLastPathKey = "lastpath";
2930

3031
// Look up variant at key relative to root.
3132
QVariant lookup(const QVariantMap &root, const QString &key) {
32-
QStringList list = key.split("/", QString::SkipEmptyParts);
33+
QStringList list = key.split("/", Qt::SkipEmptyParts);
3334
if (list.isEmpty())
3435
return root;
3536

@@ -129,8 +130,8 @@ QString Settings::lexer(const QString &filename) {
129130
QVariantMap map = lexers.value(key).toMap();
130131
if (map.contains("patterns")) {
131132
foreach (QString pattern, map.value("patterns").toString().split(",")) {
132-
QRegExp regExp(pattern, CS, QRegExp::Wildcard);
133-
if (regExp.exactMatch(name))
133+
QRegularExpression regExp{QRegularExpression::fromWildcard(pattern, CS)};
134+
if (regExp.match(name).hasMatch())
134135
return key;
135136
}
136137
}
@@ -184,6 +185,7 @@ QString Settings::promptDescription(Prompt::Kind kind) const {
184185
case Prompt::Kind::LargeFiles:
185186
return tr("Prompt to stage large files");
186187
}
188+
return QString();
187189
}
188190

189191
void Settings::setHotkey(const QString &action, const QString &hotkey) {

src/cred/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ endif()
55
add_library(cred Cache.cpp CredentialHelper.cpp GitCredential.cpp
66
${CREDENTIAL_IMPL_FILE})
77

8-
target_link_libraries(cred conf Qt5::Core)
8+
target_link_libraries(cred conf Qt6::Core)
99

1010
set_target_properties(cred PROPERTIES AUTOMOC ON)

src/cred/CredentialHelper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ void CredentialHelper::log(const QString &text) {
6969
return;
7070

7171
QString time = QTime::currentTime().toString(Qt::ISODateWithMs);
72-
QTextStream(&file) << time << " - " << text << endl;
72+
QTextStream(&file) << time << " - " << text << Qt::endl;
7373
}

src/cred/GitCredential.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ bool GitCredential::get(const QString &url, QString &username,
4444
return false;
4545

4646
QTextStream out(&process);
47-
out << "protocol=" << protocol(url) << endl;
48-
out << "host=" << host(url) << endl;
47+
out << "protocol=" << protocol(url) << Qt::endl;
48+
out << "host=" << host(url) << Qt::endl;
4949
if (!username.isEmpty())
50-
out << "username=" << username << endl;
51-
out << endl;
50+
out << "username=" << username << Qt::endl;
51+
out << Qt::endl;
5252

5353
process.closeWriteChannel();
5454
process.waitForFinished();
@@ -79,11 +79,11 @@ bool GitCredential::store(const QString &url, const QString &username,
7979
return false;
8080

8181
QTextStream out(&process);
82-
out << "protocol=" << protocol(url) << endl;
83-
out << "host=" << host(url) << endl;
84-
out << "username=" << username << endl;
85-
out << "password=" << password << endl;
86-
out << endl;
82+
out << "protocol=" << protocol(url) << Qt::endl;
83+
out << "host=" << host(url) << Qt::endl;
84+
out << "username=" << username << Qt::endl;
85+
out << "password=" << password << Qt::endl;
86+
out << Qt::endl;
8787

8888
process.closeWriteChannel();
8989
process.waitForFinished();

src/dialogs/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ target_compile_definitions(
3838

3939
target_include_directories(dialogs PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
4040

41+
find_package(Qt6 COMPONENTS Core5Compat REQUIRED)
42+
4143
target_link_libraries(
4244
dialogs
4345
cli
4446
conf
4547
cred
4648
host
4749
index
48-
Qt5::Widgets)
50+
Qt6::Widgets)
4951

5052
set_target_properties(dialogs PROPERTIES AUTOMOC ON)

src/dialogs/ConfigDialog.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "ui/MainWindow.h"
3131
#include "ui/RepoView.h"
3232
#include <QAction>
33+
#include <QActionGroup>
3334
#include <QCheckBox>
3435
#include <QDialogButtonBox>
3536
#include <QFormLayout>
@@ -505,7 +506,7 @@ class LfsPanel : public QWidget {
505506
watcher->deleteLater();
506507
});
507508

508-
watcher->setFuture(QtConcurrent::run(repo, &git::Repository::lfsTracked));
509+
watcher->setFuture(QtConcurrent::run(&git::Repository::lfsTracked, repo));
509510

510511
Footer *footer = new Footer(includedList);
511512
connect(footer, &Footer::plusClicked, this,

src/dialogs/DeleteBranchDialog.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ DeleteBranchDialog::DeleteBranchDialog(const git::Branch &branch,
6161

6262
entry->setBusy(true);
6363
QStringList refspecs(QString(":%1").arg(upstreamName));
64+
git::Result (git::Remote::*push)(git::Remote::Callbacks*, const QStringList&) = &git::Remote::push;
6465
watcher->setFuture(
65-
QtConcurrent::run(remote, &git::Remote::push, callbacks, refspecs));
66+
QtConcurrent::run(push, remote, callbacks, refspecs));
6667

6768
connect(watcher, &QFutureWatcher<git::Result>::finished, watcher,
6869
[entry, watcher, callbacks, remoteName] {

src/dialogs/DeleteTagDialog.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ DeleteTagDialog::DeleteTagDialog(const git::TagRef &tag, QWidget *parent)
5353

5454
entry->setBusy(true);
5555
QStringList refspecs(QString(":refs/tags/%1").arg(name));
56+
git::Result (git::Remote::*push)(git::Remote::Callbacks*, const QStringList&) = &git::Remote::push;
5657
watcher->setFuture(
57-
QtConcurrent::run(remote, &git::Remote::push, callbacks, refspecs));
58+
QtConcurrent::run(push, remote, callbacks, refspecs));
5859

5960
connect(watcher, &QFutureWatcher<git::Result>::finished, watcher,
6061
[entry, watcher, callbacks, remoteName] {

src/dialogs/DiffPanel.cpp

+15-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <QHBoxLayout>
2222
#include <QPushButton>
2323
#include <QSpinBox>
24-
#include <QTextCodec>
2524

2625
DiffPanel::DiffPanel(const git::Repository &repo, QWidget *parent)
2726
: QWidget(parent), mConfig(repo ? repo.config() : git::Config::global()) {
@@ -44,12 +43,24 @@ DiffPanel::DiffPanel(const git::Repository &repo, QWidget *parent)
4443
});
4544

4645
// encoding
46+
47+
static std::array encodings{
48+
"Utf8",
49+
"Utf16",
50+
"Utf16LE",
51+
"Utf16BE",
52+
"Utf32",
53+
"Utf32LE",
54+
"Utf32BE",
55+
"Latin1",
56+
};
57+
4758
QComboBox *encoding = new QComboBox(this);
4859
encoding->addItem(tr("System Locale"), -1);
4960
encoding->insertSeparator(encoding->count());
50-
foreach (int mib, QTextCodec::availableMibs())
51-
encoding->addItem(QTextCodec::codecForMib(mib)->name(), mib);
52-
61+
for (int i = 0; i < encodings.size(); i++) {
62+
encoding->addItem(encodings[i], i);
63+
}
5364
QString name = mConfig.value<QString>("gui.encoding");
5465
if (!name.isEmpty())
5566
encoding->setCurrentIndex(encoding->findText(name));

0 commit comments

Comments
 (0)