Skip to content

Commit

Permalink
Reason:
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfseifert authored and Murmele committed Oct 8, 2023
1 parent 820c0fd commit 2b558bd
Show file tree
Hide file tree
Showing 69 changed files with 195 additions and 159 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ else()
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 @@ -135,7 +135,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 @@ -145,8 +145,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/openssl/openssl
Submodule openssl updated 123 files
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 @@ -28,13 +28,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 @@ -78,7 +78,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 @@ -131,8 +131,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 ${SRC_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 @@ -67,12 +67,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 @@ -164,7 +164,7 @@ install(
COMPONENT ${GITTYUP_NAME})

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
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
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)

# SRC_ definitions point to the source directly
target_compile_definitions(
Expand Down
5 changes: 3 additions & 2 deletions src/conf/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "qtsupport.h"
#include <QCoreApplication>
#include <QDir>
#include <QRegularExpression>
#include <QSettings>
#include <QStandardPaths>

Expand Down Expand Up @@ -117,8 +118,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
4 changes: 3 additions & 1 deletion src/cred/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
add_library(cred Cache.cpp Store.cpp CredentialHelper.cpp GitCredential.cpp)

target_link_libraries(cred conf git Qt5::Core)
target_link_libraries(cred conf git Qt6::Core)
add_library(cred Cache.cpp CredentialHelper.cpp GitCredential.cpp
${CREDENTIAL_IMPL_FILE})

set_target_properties(cred PROPERTIES AUTOMOC ON)
4 changes: 3 additions & 1 deletion src/dialogs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,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 @@ -506,7 +507,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),
Expand All @@ -45,12 +44,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
3 changes: 1 addition & 2 deletions src/dialogs/IconLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ QSize IconLabel::minimumSizeHint() const { return sizeHint(); }

void IconLabel::paintEvent(QPaintEvent *event) {
QSize size = sizeHint();
QWidget *win = window();
QPainter(this).drawPixmap(
QStyle::alignedRect(Qt::LeftToRight, Qt::AlignHCenter, size, rect()),
mIcon.pixmap(win ? win->windowHandle() : nullptr, size));
mIcon.pixmap(size, window()->devicePixelRatio()));
}
1 change: 1 addition & 0 deletions src/dialogs/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "ui/RepoView.h"
#include "update/Updater.h"
#include <QAction>
#include <QActionGroup>
#include <QApplication>
#include <QCheckBox>
#include <QComboBox>
Expand Down
2 changes: 1 addition & 1 deletion src/editor/PlatQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ void SurfaceImpl::MeasureWidths(Font &font, std::string_view s,

XYPOSITION SurfaceImpl::WidthText(Font &font, std::string_view s) {
QFontMetricsF metrics(*static_cast<QFont *>(font.GetID()), device);
return metrics.width(QString::fromUtf8(s.data(), s.length()));
return metrics.horizontalAdvance(QString::fromUtf8(s.data(), s.length()));
}

XYPOSITION SurfaceImpl::Ascent(Font &font) {
Expand Down
15 changes: 8 additions & 7 deletions src/editor/ScintillaQt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ void ScintillaQt::keyPressEvent(QKeyEvent *event) {

QString text = event->text();
if (input && !text.isEmpty() && text[0].isPrint()) {
InsertCharacter(text.toStdString(), CharacterSource::directInput);
QByteArray utext = text.toUtf8();
InsertCharacter(std::string_view(utext.data(), utext.size()), CharacterSource::directInput);
} else {
event->ignore();
}
Expand Down Expand Up @@ -430,7 +431,7 @@ void ScintillaQt::dragEnterEvent(QDragEnterEvent *event) {
if (event->mimeData()->hasText()) {
event->acceptProposedAction();

Point point = PointFromQPoint(event->pos());
Point point = PointFromQPoint(event->position().toPoint());
SetDragPosition(
SPositionFromLocation(point, false, false, UserVirtualSpace()));
} else {
Expand All @@ -447,7 +448,7 @@ void ScintillaQt::dragMoveEvent(QDragMoveEvent *event) {
if (event->mimeData()->hasText()) {
event->acceptProposedAction();

Point point = PointFromQPoint(event->pos());
Point point = PointFromQPoint(event->position().toPoint());
SetDragPosition(
SPositionFromLocation(point, false, false, UserVirtualSpace()));
} else {
Expand All @@ -460,7 +461,7 @@ void ScintillaQt::dropEvent(QDropEvent *event) {
event->acceptProposedAction();

const QMimeData *data = event->mimeData();
Point point = PointFromQPoint(event->pos());
Point point = PointFromQPoint(event->position().toPoint());
bool move =
(event->source() == this && event->proposedAction() == Qt::MoveAction);

Expand Down Expand Up @@ -520,8 +521,8 @@ void ScintillaQt::inputMethodEvent(QInputMethodEvent *event) {
const unsigned int ucWidth = commitStr.at(i).isHighSurrogate() ? 2 : 1;
const QString oneCharUTF16 = commitStr.mid(i, ucWidth);
const QByteArray oneChar = oneCharUTF16.toUtf8();

InsertCharacter(oneChar.toStdString(), CharacterSource::directInput);
const int oneCharLen = oneChar.length();
InsertCharacter(std::string_view(oneChar.data(), oneCharLen), CharacterSource::directInput);
i += ucWidth;
}

Expand Down Expand Up @@ -604,7 +605,7 @@ void ScintillaQt::inputMethodEvent(QInputMethodEvent *event) {
numBytes += oneCharLen;
imeCharPos[i + 1] = numBytes;

InsertCharacter(oneChar.toStdString(), CharacterSource::directInput);
InsertCharacter(std::string_view(oneChar.data(), oneCharLen), CharacterSource::directInput);

#ifdef Q_OS_LINUX
// Segment marked with imeCaretPos is for target input.
Expand Down
2 changes: 1 addition & 1 deletion src/git/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ add_library(
TagRef.cpp
Tree.cpp)

target_link_libraries(git git2 Qt5::Core Qt5::Network util)
target_link_libraries(git git2 Qt6::Core Qt6::Network util)

set_target_properties(git PROPERTIES AUTOMOC ON)
8 changes: 5 additions & 3 deletions src/git/Commit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
#include <QJsonDocument>
#include <QJsonObject>
#include <QRegularExpression>
#include <QTextCodec>
#include <QStringConverter>
#include <QStringDecoder>
#include <QVector>

namespace git {
Expand Down Expand Up @@ -291,8 +292,9 @@ void Commit::setStarred(bool starred) {

QString Commit::decodeMessage(const char *msg) const {
if (const char *encoding = git_commit_message_encoding(*this)) {
if (QTextCodec *codec = QTextCodec::codecForName(encoding))
return codec->toUnicode(msg);
auto conv = QStringConverter::encodingForName(encoding);
if (conv.has_value())
return QStringDecoder{conv.value()}.decode(msg);
}

return msg;
Expand Down
1 change: 1 addition & 0 deletions src/git/Commit.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "git2/revwalk.h"
#include "git2/reset.h"
#include "Blob.h"
#include <QStringList>

class QDateTime;

Expand Down
Loading

0 comments on commit 2b558bd

Please sign in to comment.