Skip to content

Commit

Permalink
migrate to qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfseifert committed Jan 17, 2023
1 parent 8580fd8 commit e6d816f
Show file tree
Hide file tree
Showing 83 changed files with 271 additions and 212 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ if(NOT DEBUG_OUTPUT)
endif()

find_package(
Qt5 5.12
Qt6
COMPONENTS ${QT_MODULES} LinguistTools
REQUIRED)
if(FLATPAK)
find_package(
Qt5 5.15
Qt6
COMPONENTS XcbQpa
REQUIRED)
add_compile_definitions(FLATPAK)
Expand All @@ -109,7 +109,7 @@ endif()

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

set(QT_TRANSLATIONS_DIR "${Qt5_DIR}/../../../translations")
set(QT_TRANSLATIONS_DIR "${Qt6_DIR}/../../../translations")
set(QT_TRANSLATIONS_DIR "/usr/share/qt/translations")

if(APPLE)
Expand All @@ -119,8 +119,8 @@ if(APPLE)
# dependencies are to the release libraries (e.g. QtGui_debug depends on
# QtCore). This causes multiple symbol definition errors at application load
# time.
get_target_property(LOCATION Qt5::${QT_MODULE} LOCATION)
set_target_properties(Qt5::${QT_MODULE} PROPERTIES IMPORTED_LOCATION_DEBUG
get_target_property(LOCATION Qt6::${QT_MODULE} LOCATION)
set_target_properties(Qt6::${QT_MODULE} PROPERTIES IMPORTED_LOCATION_DEBUG
${LOCATION})
endforeach()
endif()
Expand Down
2 changes: 1 addition & 1 deletion dep/scintilla/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ target_compile_definitions(

target_include_directories(scintilla PUBLIC ${SCINTILLA_DIR}/src)

target_link_libraries(scintilla Qt5::Widgets lexilla)
target_link_libraries(scintilla Qt6::Widgets lexilla)

set_target_properties(scintilla PROPERTIES AUTOMOC ON)

Expand Down
4 changes: 2 additions & 2 deletions l10n/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ endforeach()

if(UPDATE_TRANSLATIONS)
# FIXME: Clean removes the .ts files.
qt5_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES})
qt6_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES})
else()
qt5_add_translation(QM_FILES ${TS_FILES})
qt6_add_translation(QM_FILES ${TS_FILES})
endif()

add_custom_target(translations DEPENDS ${QM_FILES})
Expand Down
10 changes: 5 additions & 5 deletions pack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ if(FLATPAK)
qt_import_plugins(gittyup INCLUDE ${QT_PLUGINS})
elseif(NOT USE_SYSTEM_QT)
foreach(QT_PLUGIN ${QT_PLUGINS})
if(NOT TARGET Qt5::${QT_PLUGIN})
if(NOT TARGET Qt6::${QT_PLUGIN})
if(UNIX OR APPLE)
continue()
endif()
endif()

get_target_property(PLUGIN Qt5::${QT_PLUGIN} LOCATION_${CMAKE_BUILD_TYPE})
get_target_property(PLUGIN Qt6::${QT_PLUGIN} LOCATION_${CMAKE_BUILD_TYPE})
get_filename_component(FILE_NAME ${PLUGIN} NAME)
get_filename_component(DIR ${PLUGIN} DIRECTORY)
get_filename_component(DIR_NAME ${DIR} NAME)
Expand Down Expand Up @@ -71,7 +71,7 @@ elseif(NOT USE_SYSTEM_QT)

# Install Qt libraries.
foreach(QT_MODULE ${QT_MODULES})
get_target_property(QT_LIBRARY Qt5::${QT_MODULE}
get_target_property(QT_LIBRARY Qt6::${QT_MODULE}
LOCATION_${CMAKE_BUILD_TYPE})

if(APPLE)
Expand Down Expand Up @@ -124,8 +124,8 @@ endif()

# Install XcbQpa library.
if(UNIX AND NOT APPLE)
set(LIB_NAME libQt5XcbQpa)
get_target_property(QT_CORE_LIBRARY Qt5::Core LOCATION)
set(LIB_NAME libQt6XcbQpa)
get_target_property(QT_CORE_LIBRARY Qt6::Core LOCATION)
get_filename_component(LIB_PATH ${QT_CORE_LIBRARY} PATH)
get_filename_component(LIB_EXT ${QT_CORE_LIBRARY} EXT)

Expand Down
8 changes: 4 additions & 4 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ file(GLOB SCINTILLUA_LEXERS ${SCINTILLUA_LEXERS_DIR}/*.lua)
file(GLOB LUA_PLUGINS ${CONF_DIR}/plugins/*.lua ${CONF_DIR}/plugins/*.txt)

# Build resources.
qt5_add_resources(RESOURCES ${RSRC_DIR}/resources.qrc)
qt6_add_resources(RESOURCES ${RSRC_DIR}/resources.qrc)

# Generate acknowledgments.
set(DOC_SOURCE_DIR ${CMAKE_SOURCE_DIR}/docs)
Expand Down Expand Up @@ -63,12 +63,12 @@ target_compile_definitions(
PRIVATE QT_TRANSLATIONS_DIR="${QT_TRANSLATIONS_DIR}"
BUILD_DESCRIPTION="${BUILD_DESCRIPTION}")

target_link_libraries(app conf git ui update Qt5::Widgets)
target_link_libraries(app conf git ui update Qt6::Widgets)

set_target_properties(app PROPERTIES AUTOMOC ON)

if(UNIX AND NOT APPLE)
target_link_libraries(app Qt5::DBus)
target_link_libraries(app Qt6::DBus)
endif()

# Add main executable.
Expand Down Expand Up @@ -167,7 +167,7 @@ else()
endif()

if(APPLE)
get_target_property(QT_LIBRARY Qt5::Core LOCATION)
get_target_property(QT_LIBRARY Qt6::Core LOCATION)
get_filename_component(QT_FRAMEWORK ${QT_LIBRARY} DIRECTORY)
get_filename_component(RPATH ${QT_FRAMEWORK} DIRECTORY)

Expand Down
4 changes: 4 additions & 0 deletions src/app/CustomTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ QColor CustomTheme::commitEditor(CommitEditor color) {
case CommitEditor::LengthWarning:
return commitEditor.value("lengthwarning").value<QColor>();
}
return QColor{};
}

QColor CustomTheme::diff(Diff color) {
Expand Down Expand Up @@ -450,6 +451,7 @@ QColor CustomTheme::diff(Diff color) {
case Diff::Error:
return diff.value("error").value<QColor>();
}
return QColor{};
}

QColor CustomTheme::heatMap(HeatMap color) {
Expand All @@ -461,6 +463,7 @@ QColor CustomTheme::heatMap(HeatMap color) {
case HeatMap::Cold:
return QColor(heatmap.value("cold").toString());
}
return QColor{};
}

QColor CustomTheme::remoteComment(Comment color) {
Expand All @@ -476,6 +479,7 @@ QColor CustomTheme::remoteComment(Comment color) {
case Comment::Timestamp:
return QColor(comment.value("timestamp").toString());
}
return QColor{};
}

QColor CustomTheme::star() {
Expand Down
2 changes: 0 additions & 2 deletions src/app/Gittyup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include <QMessageBox>

int main(int argc, char *argv[]) {
Application::setAttribute(Qt::AA_EnableHighDpiScaling);
Application::setAttribute(Qt::AA_UseHighDpiPixmaps);
Application app(argc, argv, true);

// Check if only one running instance is allowed and already running
Expand Down
5 changes: 5 additions & 0 deletions src/app/Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ QColor Theme::badge(BadgeRole role, BadgeState state) {
return mDark ? "#8C2026" : "#FF0000";
}
}
return QColor{};
}

QList<QColor> Theme::branchTopologyEdges() {
Expand Down Expand Up @@ -152,6 +153,7 @@ QColor Theme::commitEditor(CommitEditor color) {
case CommitEditor::LengthWarning:
return Qt::yellow;
}
return QColor{};
}

QColor Theme::diff(Diff color) {
Expand Down Expand Up @@ -206,6 +208,7 @@ QColor Theme::diff(Diff color) {
case Diff::Error:
return "#FF0000";
}
return QColor{};
}

QColor Theme::heatMap(HeatMap color) {
Expand All @@ -216,6 +219,7 @@ QColor Theme::heatMap(HeatMap color) {
return mDark ? QPalette().color(QPalette::Inactive, QPalette::Highlight)
: QPalette().color(QPalette::Mid);
}
return QColor{};
}

QColor Theme::remoteComment(Comment color) {
Expand All @@ -229,6 +233,7 @@ QColor Theme::remoteComment(Comment color) {
case Comment::Timestamp:
return QPalette().color(QPalette::WindowText);
}
return QColor{};
}

QColor Theme::star() { return QPalette().color(QPalette::Highlight); }
Expand Down
2 changes: 1 addition & 1 deletion src/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ endif()

add_library(cli Installer.cpp ${INSTALLER_IMPL_FILE})

target_link_libraries(cli Qt5::Core ${INSTALLER_IMPL_LIBS})
target_link_libraries(cli Qt6::Core ${INSTALLER_IMPL_LIBS})
2 changes: 1 addition & 1 deletion src/conf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_library(conf ConfFile.cpp Settings.cpp Setting.cpp RecentRepositories.cpp
RecentRepository.cpp)

target_link_libraries(conf lua Qt5::Core util)
target_link_libraries(conf lua Qt6::Core util)

target_compile_definitions(
conf PRIVATE SCINTILLUA_LEXERS_DIR="${SCINTILLUA_LEXERS_DIR}")
Expand Down
8 changes: 5 additions & 3 deletions src/conf/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "ConfFile.h"
#include <QCoreApplication>
#include <QDir>
#include <QRegularExpression>
#include <QSettings>
#include <QStandardPaths>

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

// Look up variant at key relative to root.
QVariant lookup(const QVariantMap &root, const QString &key) {
QStringList list = key.split("/", QString::SkipEmptyParts);
QStringList list = key.split("/", Qt::SkipEmptyParts);
if (list.isEmpty())
return root;

Expand Down Expand Up @@ -129,8 +130,8 @@ QString Settings::lexer(const QString &filename) {
QVariantMap map = lexers.value(key).toMap();
if (map.contains("patterns")) {
foreach (QString pattern, map.value("patterns").toString().split(",")) {
QRegExp regExp(pattern, CS, QRegExp::Wildcard);
if (regExp.exactMatch(name))
QRegularExpression regExp{QRegularExpression::fromWildcard(pattern, CS)};
if (regExp.match(name).hasMatch())
return key;
}
}
Expand Down Expand Up @@ -184,6 +185,7 @@ QString Settings::promptDescription(Prompt::Kind kind) const {
case Prompt::Kind::LargeFiles:
return tr("Prompt to stage large files");
}
return QString();
}

void Settings::setHotkey(const QString &action, const QString &hotkey) {
Expand Down
2 changes: 1 addition & 1 deletion src/cred/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ endif()
add_library(cred Cache.cpp CredentialHelper.cpp GitCredential.cpp
${CREDENTIAL_IMPL_FILE})

target_link_libraries(cred conf Qt5::Core)
target_link_libraries(cred conf Qt6::Core)

set_target_properties(cred PROPERTIES AUTOMOC ON)
2 changes: 1 addition & 1 deletion src/cred/CredentialHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ void CredentialHelper::log(const QString &text) {
return;

QString time = QTime::currentTime().toString(Qt::ISODateWithMs);
QTextStream(&file) << time << " - " << text << endl;
QTextStream(&file) << time << " - " << text << Qt::endl;
}
18 changes: 9 additions & 9 deletions src/cred/GitCredential.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ bool GitCredential::get(const QString &url, QString &username,
return false;

QTextStream out(&process);
out << "protocol=" << protocol(url) << endl;
out << "host=" << host(url) << endl;
out << "protocol=" << protocol(url) << Qt::endl;
out << "host=" << host(url) << Qt::endl;
if (!username.isEmpty())
out << "username=" << username << endl;
out << endl;
out << "username=" << username << Qt::endl;
out << Qt::endl;

process.closeWriteChannel();
process.waitForFinished();
Expand Down Expand Up @@ -79,11 +79,11 @@ bool GitCredential::store(const QString &url, const QString &username,
return false;

QTextStream out(&process);
out << "protocol=" << protocol(url) << endl;
out << "host=" << host(url) << endl;
out << "username=" << username << endl;
out << "password=" << password << endl;
out << endl;
out << "protocol=" << protocol(url) << Qt::endl;
out << "host=" << host(url) << Qt::endl;
out << "username=" << username << Qt::endl;
out << "password=" << password << Qt::endl;
out << Qt::endl;

process.closeWriteChannel();
process.waitForFinished();
Expand Down
4 changes: 3 additions & 1 deletion src/dialogs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ target_compile_definitions(

target_include_directories(dialogs PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

find_package(Qt6 COMPONENTS Core5Compat REQUIRED)

target_link_libraries(
dialogs
cli
conf
cred
host
index
Qt5::Widgets)
Qt6::Widgets)

set_target_properties(dialogs PROPERTIES AUTOMOC ON)
3 changes: 2 additions & 1 deletion src/dialogs/ConfigDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "ui/MainWindow.h"
#include "ui/RepoView.h"
#include <QAction>
#include <QActionGroup>
#include <QCheckBox>
#include <QDialogButtonBox>
#include <QFormLayout>
Expand Down Expand Up @@ -505,7 +506,7 @@ class LfsPanel : public QWidget {
watcher->deleteLater();
});

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

Footer *footer = new Footer(includedList);
connect(footer, &Footer::plusClicked, this,
Expand Down
3 changes: 2 additions & 1 deletion src/dialogs/DeleteBranchDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ DeleteBranchDialog::DeleteBranchDialog(const git::Branch &branch,

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

connect(watcher, &QFutureWatcher<git::Result>::finished, watcher,
[entry, watcher, callbacks, remoteName] {
Expand Down
3 changes: 2 additions & 1 deletion src/dialogs/DeleteTagDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ DeleteTagDialog::DeleteTagDialog(const git::TagRef &tag, QWidget *parent)

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

connect(watcher, &QFutureWatcher<git::Result>::finished, watcher,
[entry, watcher, callbacks, remoteName] {
Expand Down
19 changes: 15 additions & 4 deletions src/dialogs/DiffPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <QHBoxLayout>
#include <QPushButton>
#include <QSpinBox>
#include <QTextCodec>

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

// encoding

static std::array encodings{
"Utf8",
"Utf16",
"Utf16LE",
"Utf16BE",
"Utf32",
"Utf32LE",
"Utf32BE",
"Latin1",
};

QComboBox *encoding = new QComboBox(this);
encoding->addItem(tr("System Locale"), -1);
encoding->insertSeparator(encoding->count());
foreach (int mib, QTextCodec::availableMibs())
encoding->addItem(QTextCodec::codecForMib(mib)->name(), mib);

for (int i = 0; i < encodings.size(); i++) {
encoding->addItem(encodings[i], i);
}
QString name = mConfig.value<QString>("gui.encoding");
if (!name.isEmpty())
encoding->setCurrentIndex(encoding->findText(name));
Expand Down
Loading

0 comments on commit e6d816f

Please sign in to comment.