diff --git a/CMakeLists.txt b/CMakeLists.txt index a1ca20d21..ca068116c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) @@ -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() diff --git a/dep/scintilla/CMakeLists.txt b/dep/scintilla/CMakeLists.txt index c91a62251..b62c748f9 100644 --- a/dep/scintilla/CMakeLists.txt +++ b/dep/scintilla/CMakeLists.txt @@ -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) diff --git a/l10n/CMakeLists.txt b/l10n/CMakeLists.txt index 734d92004..a61a75f64 100644 --- a/l10n/CMakeLists.txt +++ b/l10n/CMakeLists.txt @@ -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}) diff --git a/pack/CMakeLists.txt b/pack/CMakeLists.txt index eea79fe59..0a151feb9 100644 --- a/pack/CMakeLists.txt +++ b/pack/CMakeLists.txt @@ -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) @@ -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) @@ -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) diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index bc1e81128..a05e5f28b 100755 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -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) @@ -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. @@ -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) diff --git a/src/app/CustomTheme.cpp b/src/app/CustomTheme.cpp index 679dc99e6..bd75f890f 100644 --- a/src/app/CustomTheme.cpp +++ b/src/app/CustomTheme.cpp @@ -421,6 +421,7 @@ QColor CustomTheme::commitEditor(CommitEditor color) { case CommitEditor::LengthWarning: return commitEditor.value("lengthwarning").value(); } + return QColor{}; } QColor CustomTheme::diff(Diff color) { @@ -450,6 +451,7 @@ QColor CustomTheme::diff(Diff color) { case Diff::Error: return diff.value("error").value(); } + return QColor{}; } QColor CustomTheme::heatMap(HeatMap color) { @@ -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) { @@ -476,6 +479,7 @@ QColor CustomTheme::remoteComment(Comment color) { case Comment::Timestamp: return QColor(comment.value("timestamp").toString()); } + return QColor{}; } QColor CustomTheme::star() { diff --git a/src/app/Gittyup.cpp b/src/app/Gittyup.cpp index 69649f8c2..5238195e7 100644 --- a/src/app/Gittyup.cpp +++ b/src/app/Gittyup.cpp @@ -13,8 +13,6 @@ #include 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 diff --git a/src/app/Theme.cpp b/src/app/Theme.cpp index 7a0f7b498..f53c7d71f 100644 --- a/src/app/Theme.cpp +++ b/src/app/Theme.cpp @@ -125,6 +125,7 @@ QColor Theme::badge(BadgeRole role, BadgeState state) { return mDark ? "#8C2026" : "#FF0000"; } } + return QColor{}; } QList Theme::branchTopologyEdges() { @@ -152,6 +153,7 @@ QColor Theme::commitEditor(CommitEditor color) { case CommitEditor::LengthWarning: return Qt::yellow; } + return QColor{}; } QColor Theme::diff(Diff color) { @@ -206,6 +208,7 @@ QColor Theme::diff(Diff color) { case Diff::Error: return "#FF0000"; } + return QColor{}; } QColor Theme::heatMap(HeatMap color) { @@ -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) { @@ -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); } diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 74dcd7e16..156fc39bf 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -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}) diff --git a/src/conf/CMakeLists.txt b/src/conf/CMakeLists.txt index 41a8dd323..8af36fee4 100644 --- a/src/conf/CMakeLists.txt +++ b/src/conf/CMakeLists.txt @@ -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}") diff --git a/src/conf/Settings.cpp b/src/conf/Settings.cpp index d03f9050a..5d466acb8 100644 --- a/src/conf/Settings.cpp +++ b/src/conf/Settings.cpp @@ -11,6 +11,7 @@ #include "ConfFile.h" #include #include +#include #include #include @@ -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; @@ -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; } } @@ -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) { diff --git a/src/cred/CMakeLists.txt b/src/cred/CMakeLists.txt index ce7784104..59bfb92a0 100644 --- a/src/cred/CMakeLists.txt +++ b/src/cred/CMakeLists.txt @@ -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) diff --git a/src/cred/CredentialHelper.cpp b/src/cred/CredentialHelper.cpp index bda260ae8..e5c5d80b9 100644 --- a/src/cred/CredentialHelper.cpp +++ b/src/cred/CredentialHelper.cpp @@ -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; } diff --git a/src/cred/GitCredential.cpp b/src/cred/GitCredential.cpp index b471f88a2..fb5ff1229 100644 --- a/src/cred/GitCredential.cpp +++ b/src/cred/GitCredential.cpp @@ -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(); @@ -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(); diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt index bcb82b873..7018093ed 100644 --- a/src/dialogs/CMakeLists.txt +++ b/src/dialogs/CMakeLists.txt @@ -38,6 +38,8 @@ target_compile_definitions( target_include_directories(dialogs PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +find_package(Qt6 COMPONENTS Core5Compat REQUIRED) + target_link_libraries( dialogs cli @@ -45,6 +47,6 @@ target_link_libraries( cred host index - Qt5::Widgets) + Qt6::Widgets) set_target_properties(dialogs PROPERTIES AUTOMOC ON) diff --git a/src/dialogs/ConfigDialog.cpp b/src/dialogs/ConfigDialog.cpp index eeb21b6cb..e2aae134d 100644 --- a/src/dialogs/ConfigDialog.cpp +++ b/src/dialogs/ConfigDialog.cpp @@ -30,6 +30,7 @@ #include "ui/MainWindow.h" #include "ui/RepoView.h" #include +#include #include #include #include @@ -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, diff --git a/src/dialogs/DeleteBranchDialog.cpp b/src/dialogs/DeleteBranchDialog.cpp index 975732415..381c19f1d 100644 --- a/src/dialogs/DeleteBranchDialog.cpp +++ b/src/dialogs/DeleteBranchDialog.cpp @@ -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::finished, watcher, [entry, watcher, callbacks, remoteName] { diff --git a/src/dialogs/DeleteTagDialog.cpp b/src/dialogs/DeleteTagDialog.cpp index cd0db7af9..1e46bfe3f 100644 --- a/src/dialogs/DeleteTagDialog.cpp +++ b/src/dialogs/DeleteTagDialog.cpp @@ -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::finished, watcher, [entry, watcher, callbacks, remoteName] { diff --git a/src/dialogs/DiffPanel.cpp b/src/dialogs/DiffPanel.cpp index f2183cac7..8b533984b 100644 --- a/src/dialogs/DiffPanel.cpp +++ b/src/dialogs/DiffPanel.cpp @@ -21,7 +21,6 @@ #include #include #include -#include DiffPanel::DiffPanel(const git::Repository &repo, QWidget *parent) : QWidget(parent), mConfig(repo ? repo.config() : git::Config::global()) { @@ -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("gui.encoding"); if (!name.isEmpty()) encoding->setCurrentIndex(encoding->findText(name)); diff --git a/src/dialogs/IconLabel.cpp b/src/dialogs/IconLabel.cpp index 6bd33e1f0..ac7d418de 100644 --- a/src/dialogs/IconLabel.cpp +++ b/src/dialogs/IconLabel.cpp @@ -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())); } diff --git a/src/dialogs/SettingsDialog.cpp b/src/dialogs/SettingsDialog.cpp index 6fe3eb8fc..d26bdb0a2 100644 --- a/src/dialogs/SettingsDialog.cpp +++ b/src/dialogs/SettingsDialog.cpp @@ -27,6 +27,7 @@ #include "ui/RepoView.h" #include "update/Updater.h" #include +#include #include #include #include diff --git a/src/editor/PlatQt.cpp b/src/editor/PlatQt.cpp index 5d866e2d6..f0ad90c5a 100644 --- a/src/editor/PlatQt.cpp +++ b/src/editor/PlatQt.cpp @@ -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(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) { diff --git a/src/editor/ScintillaQt.cpp b/src/editor/ScintillaQt.cpp index 82f580f78..e6715936a 100644 --- a/src/editor/ScintillaQt.cpp +++ b/src/editor/ScintillaQt.cpp @@ -185,7 +185,7 @@ void ScintillaQt::paintEvent(QPaintEvent *event) { } void ScintillaQt::wheelEvent(QWheelEvent *event) { - if (event->orientation() == Qt::Horizontal) { + if (event->angleDelta().x() != 0) { if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) event->ignore(); else @@ -194,7 +194,7 @@ void ScintillaQt::wheelEvent(QWheelEvent *event) { if (QApplication::keyboardModifiers() & Qt::ControlModifier) { // Zoom! We play with the font sizes in the styles. // Number of steps/line is ignored, we just care if sizing up or down - if (event->delta() > 0) { + if (event->angleDelta().y() > 0) { KeyCommand(SCI_ZOOMIN); } else { KeyCommand(SCI_ZOOMOUT); @@ -328,7 +328,7 @@ void ScintillaQt::keyPressEvent(QKeyEvent *event) { QString text = event->text(); if (input && !text.isEmpty() && text[0].isPrint()) { QByteArray utext = text.toUtf8(); - AddCharUTF(utext.data(), utext.size()); + InsertCharacter(std::string_view(utext.data(), utext.size()), CharacterSource::directInput); } else { event->ignore(); } @@ -355,7 +355,7 @@ static int modifierTranslated(int sciModifier) { void ScintillaQt::mousePressEvent(QMouseEvent *event) { Point pos = PointFromQPoint(event->pos()); - if (event->button() == Qt::MidButton && + if (event->button() == Qt::MiddleButton && QApplication::clipboard()->supportsSelection()) { SelectionPosition selPos = SPositionFromLocation(pos, false, false, UserVirtualSpace()); @@ -431,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 { @@ -447,7 +447,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 { @@ -460,7 +460,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); @@ -522,7 +522,7 @@ void ScintillaQt::inputMethodEvent(QInputMethodEvent *event) { const QByteArray oneChar = oneCharUTF16.toUtf8(); const int oneCharLen = oneChar.length(); - AddCharUTF(oneChar.data(), oneCharLen); + InsertCharacter(std::string_view(oneChar.data(), oneCharLen), CharacterSource::directInput); i += ucWidth; } @@ -605,7 +605,7 @@ void ScintillaQt::inputMethodEvent(QInputMethodEvent *event) { numBytes += oneCharLen; imeCharPos[i + 1] = numBytes; - AddCharUTF(oneChar.data(), oneCharLen); + InsertCharacter(std::string_view(oneChar.data(), oneCharLen), CharacterSource::directInput); #ifdef Q_OS_LINUX // Segment marked with imeCaretPos is for target input. @@ -642,7 +642,7 @@ QVariant ScintillaQt::inputMethodQuery(Qt::InputMethodQuery query) const { int line = send(SCI_LINEFROMPOSITION, pos); switch (query) { - case Qt::ImMicroFocus: { + case Qt::ImCursorRectangle: { int startPos = (preeditPos >= 0) ? preeditPos : pos; Point pt = const_cast(this)->LocationFromPosition(startPos); diff --git a/src/git/CMakeLists.txt b/src/git/CMakeLists.txt index c9553149b..479eae927 100644 --- a/src/git/CMakeLists.txt +++ b/src/git/CMakeLists.txt @@ -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) diff --git a/src/git/Commit.cpp b/src/git/Commit.cpp index 771dbccb0..798f599bd 100644 --- a/src/git/Commit.cpp +++ b/src/git/Commit.cpp @@ -26,7 +26,8 @@ #include #include #include -#include +#include +#include #include namespace git { @@ -288,8 +289,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; diff --git a/src/git/Commit.h b/src/git/Commit.h index 1a30d7b90..4a9b01e35 100644 --- a/src/git/Commit.h +++ b/src/git/Commit.h @@ -15,6 +15,7 @@ #include "git2/revwalk.h" #include "git2/reset.h" #include "Blob.h" +#include class QDateTime; diff --git a/src/git/Diff.cpp b/src/git/Diff.cpp index 5a6b167aa..d18034e34 100644 --- a/src/git/Diff.cpp +++ b/src/git/Diff.cpp @@ -15,11 +15,11 @@ bool containsPath(QString &str, QString &occurence, Qt::CaseSensitivity cs) { if (str.contains(occurence, cs)) { - if (str.count() == occurence.count()) { + if (str.size() == occurence.size()) { // file/folder matches exactly return true; - } else if (str.count() >= occurence.length() + 1 && - str[occurence.length()] == "/") { + } else if (str.size() >= occurence.length() + 1 && + str[occurence.length()] == '/') { // file or folder in occurence return true; } @@ -108,10 +108,10 @@ QByteArray Diff::print() { QByteArray diff; for (auto file : data.files) { for (auto hunk : file.hunks) { - diff.append(hunk.header); + diff.append(hunk.header.toUtf8()); for (auto line : hunk.lines) - diff.append(line); + diff.append(line.toUtf8()); } } qDebug() << QString(diff); @@ -195,6 +195,7 @@ void Diff::sort(SortRole role, Qt::SortOrder order) { : (rhsStatus < lhsStatus); } } + return false; }); } diff --git a/src/git/Diff.h b/src/git/Diff.h index d1f7d278a..042b06156 100644 --- a/src/git/Diff.h +++ b/src/git/Diff.h @@ -59,7 +59,7 @@ class Diff { * \return */ QByteArray print(); - bool isValid() const { return d; } + bool isValid() const { return d ? true : false; } explicit operator bool() const { return isValid(); } bool isConflicted() const; diff --git a/src/git/Index.cpp b/src/git/Index.cpp index 0e07af4cb..11d73ede3 100644 --- a/src/git/Index.cpp +++ b/src/git/Index.cpp @@ -180,7 +180,7 @@ void Index::setStaged(const QStringList &files, bool staged, bool yieldFocus) { if (!smHead.isValid()) continue; - git_time_t time = smHead.committer().date().toTime_t(); + git_time_t time = smHead.committer().date().toSecsSinceEpoch(); entry.ctime.seconds = time; entry.ctime.nanoseconds = 0; entry.mtime.seconds = time; diff --git a/src/git/Remote.cpp b/src/git/Remote.cpp index 4095556b8..100b334c6 100644 --- a/src/git/Remote.cpp +++ b/src/git/Remote.cpp @@ -174,8 +174,8 @@ class ConfigFile { bool matched = false; for (const QString &pattern : host.patterns) { - QRegExp re(pattern, Qt::CaseSensitive, QRegExp::Wildcard); - if (re.exactMatch(hostname)) { + QRegularExpression re{QRegularExpression::wildcardToRegularExpression(pattern)}; + if (re.match(hostname).hasMatch()) { handler(host); matched = true; break; @@ -674,7 +674,7 @@ void Remote::log(const QString &text) { return; QString time = QTime::currentTime().toString(Qt::ISODateWithMs); - QTextStream(&file) << time << " - " << text << endl; + QTextStream(&file) << time << " - " << text << Qt::endl; } } // namespace git diff --git a/src/git/Repository.cpp b/src/git/Repository.cpp index cd0d9692b..f51b5c92f 100644 --- a/src/git/Repository.cpp +++ b/src/git/Repository.cpp @@ -50,7 +50,6 @@ #include #include #include -#include #include #ifdef Q_OS_UNIX @@ -1009,14 +1008,14 @@ void Repository::cleanupState() { } } -QTextCodec *Repository::codec() const { +QStringConverter::Encoding Repository::encoding() const { QString encoding = config().value("gui.encoding"); - QTextCodec *codec = QTextCodec::codecForName(encoding.toUtf8()); - return codec ? codec : QTextCodec::codecForLocale(); + auto conv = QStringConverter::encodingForName(encoding.toLocal8Bit().data()); + return conv ? conv.value() : QStringConverter::System; } QString Repository::decode(const QByteArray &text) const { - return codec()->toUnicode(text); + return QStringDecoder{encoding()}.decode(text); } bool Repository::lfsIsInitialized() { return dir().exists("hooks/pre-push"); } @@ -1040,7 +1039,7 @@ QStringList Repository::lfsEnvironment() { Repository::LfsTracking Repository::lfsTracked() { QString output = lfsExecute({"track"}); - QStringList lines = output.split('\n', QString::SkipEmptyParts); + QStringList lines = output.split('\n', Qt::SkipEmptyParts); if (!lines.isEmpty()) lines.removeFirst(); diff --git a/src/git/Repository.h b/src/git/Repository.h index b8baa1bb3..33baabbc3 100644 --- a/src/git/Repository.h +++ b/src/git/Repository.h @@ -26,6 +26,7 @@ #include #include #include +#include struct git_repository; class QProcess; @@ -225,7 +226,7 @@ class Repository { void cleanupState(); // encoding - QTextCodec *codec() const; + QStringConverter::Encoding encoding() const; QString decode(const QByteArray &text) const; // clean diff --git a/src/git/Signature.cpp b/src/git/Signature.cpp index 55cace9ef..e366de228 100644 --- a/src/git/Signature.cpp +++ b/src/git/Signature.cpp @@ -42,7 +42,7 @@ QString Signature::email() const { return d->email; } QDateTime Signature::date() const { int offset = d->when.offset * 60; // Convert from minutes to seconds. - return QDateTime::fromTime_t(d->when.time, Qt::OffsetFromUTC, offset); + return QDateTime::fromSecsSinceEpoch(d->when.time, Qt::OffsetFromUTC, offset); } git_time Signature::gitDate() const { return d->when; } diff --git a/src/git/Signature.h b/src/git/Signature.h index c3a516e0c..2f916923d 100644 --- a/src/git/Signature.h +++ b/src/git/Signature.h @@ -21,7 +21,7 @@ namespace git { class Signature { public: - bool isValid() const { return d; } + bool isValid() const { return d ? true : false; } explicit operator bool() const { return isValid(); } QString name() const; diff --git a/src/host/Account.cpp b/src/host/Account.cpp index 3c7d53103..80c814164 100644 --- a/src/host/Account.cpp +++ b/src/host/Account.cpp @@ -204,6 +204,7 @@ QString Account::helpText(Kind kind) { case Beanstalk: return QString(); } + return QString(); } QString Account::defaultUrl(Kind kind) { @@ -219,6 +220,7 @@ QString Account::defaultUrl(Kind kind) { case GitLab: return GitLab::defaultUrl(); } + return QString(); } Account::Kind Account::kindFromString(const QString &kind, bool *ok) { @@ -258,6 +260,7 @@ QString Account::kindToString(Kind kind) { case GitLab: return "gitlab"; } + return QString(); } void Account::startProgress() { diff --git a/src/host/CMakeLists.txt b/src/host/CMakeLists.txt index 027107356..d189c0aa6 100644 --- a/src/host/CMakeLists.txt +++ b/src/host/CMakeLists.txt @@ -9,7 +9,7 @@ add_library( GitLab.cpp Repository.cpp) -target_link_libraries(host conf cred Qt5::Core Qt5::Gui Qt5::Network) +target_link_libraries(host conf cred Qt6::Core Qt6::Gui Qt6::Network) target_compile_definitions( host diff --git a/src/host/Repository.h b/src/host/Repository.h index 02f389baf..b6011f67a 100644 --- a/src/host/Repository.h +++ b/src/host/Repository.h @@ -10,6 +10,7 @@ #ifndef HOST_REPOSITORY_H #define HOST_REPOSITORY_H +#include #include #include #include diff --git a/src/index/CMakeLists.txt b/src/index/CMakeLists.txt index 207a9e186..93ec0aab4 100644 --- a/src/index/CMakeLists.txt +++ b/src/index/CMakeLists.txt @@ -7,8 +7,8 @@ target_link_libraries( git lpeg lua - Qt5::Core - Qt5::Concurrent) + Qt6::Core + Qt6::Concurrent) set_target_properties(index PROPERTIES AUTOMOC ON) @@ -16,7 +16,7 @@ add_executable(lexer_test lexer_test.cpp) target_link_libraries(lexer_test index) add_executable(index_test index_test.cpp) -target_link_libraries(index_test index Qt5::Widgets) +target_link_libraries(index_test index Qt6::Widgets) add_executable(indexer indexer.cpp) target_link_libraries(indexer index) diff --git a/src/index/Index.cpp b/src/index/Index.cpp index 362162d6a..3ba71dd7a 100644 --- a/src/index/Index.cpp +++ b/src/index/Index.cpp @@ -443,6 +443,7 @@ QByteArray Index::fieldName(Index::Field field) { case Index::Pathspec: return "pathspec"; } + return QByteArray(); } QDir Index::indexDir(const git::Repository &repo) { diff --git a/src/index/Query.cpp b/src/index/Query.cpp index 0fbee5429..f0cd3b225 100644 --- a/src/index/Query.cpp +++ b/src/index/Query.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include namespace { @@ -89,9 +89,9 @@ class WildcardQuery : public TermQuery { WildcardQuery(const Index::Term &term) : TermQuery(term) {} QList commits(const Index *index) const override { - QRegExp re(mTerm.text, Qt::CaseInsensitive, QRegExp::Wildcard); + QRegularExpression re{QRegularExpression::fromWildcard(mTerm.text, Qt::CaseInsensitive)}; Index::Predicate pred = [re](const QByteArray &word) { - return re.exactMatch(word); + return re.match(word).hasMatch(); }; return index->commits(index->postings(pred, mTerm.field)); @@ -183,7 +183,7 @@ class BooleanQuery : public Query { QList commits = mLhs->commits(index); if (mKind == And) { // Remove commits that don't match the right hand side. - QSet set = QSet::fromList(rhs); + QSet set(rhs.begin(), rhs.end()); QMutableListIterator it(commits); while (it.hasNext()) { if (!set.contains(it.next())) @@ -191,7 +191,7 @@ class BooleanQuery : public Query { } } else { // Add commits that aren't already in the result set. - QSet set = QSet::fromList(commits); + QSet set(commits.begin(), commits.end()); foreach (const git::Commit &commit, rhs) { if (!set.contains(commit)) commits.append(commit); @@ -214,9 +214,9 @@ class PathspecQuery : public TermQuery { QList commits(const Index *index) const override { QByteArray term = mTerm.text.toUtf8(); QByteArray prefix = term.endsWith('/') ? term : term + '/'; - QRegExp re(mTerm.text, Qt::CaseInsensitive, QRegExp::Wildcard); + QRegularExpression re{QRegularExpression::fromWildcard(mTerm.text, Qt::CaseInsensitive)}; Index::Predicate pred = [prefix, re](const QByteArray &word) { - return word.startsWith(prefix) || re.exactMatch(word); + return word.startsWith(prefix) || re.match(word).hasMatch(); }; return index->commits(index->postings(pred, Index::Path)); diff --git a/src/index/indexer.cpp b/src/index/indexer.cpp index 2910f0dfe..e256cc0cc 100644 --- a/src/index/indexer.cpp +++ b/src/index/indexer.cpp @@ -105,7 +105,7 @@ void log(QFile *out, const QString &text) { return; QString time = QTime::currentTime().toString(Qt::ISODateWithMs); - QTextStream(out) << time << " - " << text << endl; + QTextStream(out) << time << " - " << text << Qt::endl; } void log(QFile *out, const QString &fmt, const git::Id &id) { @@ -405,7 +405,7 @@ class Indexer : public QObject, public QAbstractNativeEventFilter { int count = 0; QList commits; git::Commit commit = mWalker.next(); - QSet ids = QSet::fromList(mIndex.ids()); + QSet ids(mIndex.ids().begin(), mIndex.ids().end()); while (commit.isValid() && count < 8192) { // Don't index merge commits. if (!commit.isMerge() && !ids.contains(commit.id())) { @@ -426,7 +426,7 @@ class Indexer : public QObject, public QAbstractNativeEventFilter { using CommitList = QList; mWatcher.setFuture( QtConcurrent::mappedReduced( - commits, Map(mIndex.repo(), mLexers, mOut), + std::move(commits), Map(mIndex.repo(), mLexers, mOut), Reduce(mIndex.ids(), mOut))); return true; } @@ -440,7 +440,7 @@ class Indexer : public QObject, public QAbstractNativeEventFilter { // Write to disk. log(mOut, "start write"); if (mIndex.write(mWatcher.result()) && mNotify) - QTextStream(stdout) << "write" << endl; + QTextStream(stdout) << "write" << Qt::endl; log(mOut, "end write"); // Restart. @@ -449,7 +449,7 @@ class Indexer : public QObject, public QAbstractNativeEventFilter { } bool nativeEventFilter(const QByteArray &type, void *message, - long *result) override { + qintptr *result) override { #ifdef Q_OS_WIN MSG *msg = static_cast(message); if (msg->message == WM_CLOSE) diff --git a/src/index/lexer_test.cpp b/src/index/lexer_test.cpp index 4b5881a49..c07f5b56a 100644 --- a/src/index/lexer_test.cpp +++ b/src/index/lexer_test.cpp @@ -29,7 +29,7 @@ void print(QTextStream &out, const Lexer::Lexeme &lexeme, int indent = 0) { out << lexeme.text << " - " << lexeme.token; if (lexeme.token < kStyleNames.length()) out << " (" << kStyleNames.at(lexeme.token) << ")"; - out << endl; + out << Qt::endl; } void print(QTextStream &out, Lexer *lexer, int indent = 0) { @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) { // Lex buffer. Lexer *lexer = lexers.value(name); if (lexer->lex(buffer)) { - out << name << " - " << arg << ":" << endl; + out << name << " - " << arg << ":" << Qt::endl; print(out, lexer); } } diff --git a/src/log/CMakeLists.txt b/src/log/CMakeLists.txt index 675c3c2f4..a6d385bbe 100644 --- a/src/log/CMakeLists.txt +++ b/src/log/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(loglib LogDelegate.cpp LogEntry.cpp LogModel.cpp LogView.cpp) -target_link_libraries(loglib Qt5::Widgets) +target_link_libraries(loglib Qt6::Widgets) set_target_properties(loglib PROPERTIES AUTOMOC ON) diff --git a/src/log/LogDelegate.cpp b/src/log/LogDelegate.cpp index 527917bec..212a6c25a 100644 --- a/src/log/LogDelegate.cpp +++ b/src/log/LogDelegate.cpp @@ -78,7 +78,7 @@ void LogDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, return; QRect rect = decorationRect(option, index); - if (static_cast(variant.type()) == QMetaType::QChar) { + if (variant.typeId() == QMetaType::QChar) { Badge::paint(painter, {Badge::Label(variant.toChar())}, rect, &opt); } else if (variant.canConvert()) { int progress = variant.toInt(); @@ -125,7 +125,7 @@ void LogDelegate::initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const { QStyledItemDelegate::initStyleOption(option, index); QVariant variant = index.data(Qt::DecorationRole); - if (static_cast(variant.type()) == QMetaType::QChar) { + if (variant.typeId() == QMetaType::QChar) { option->decorationSize = Badge::size(option->font) - ADJUSTMENT_SIZE; } else if (variant.canConvert()) { option->decorationSize = ProgressIndicator::size(); diff --git a/src/log/LogModel.cpp b/src/log/LogModel.cpp index 4b0bdb8ad..62b35edc5 100644 --- a/src/log/LogModel.cpp +++ b/src/log/LogModel.cpp @@ -10,6 +10,7 @@ #include "LogModel.h" #include "LogEntry.h" #include +#include namespace { @@ -74,8 +75,8 @@ QVariant LogModel::data(const QModelIndex &index, int role) const { QDateTime date = entry->timestamp(); QString timestamp = (date.date() == QDate::currentDate()) - ? date.time().toString(Qt::DefaultLocaleShortDate) - : date.toString(Qt::DefaultLocaleShortDate); + ? QLocale().toString(date.time(), QLocale::ShortFormat) + : QLocale().toString(date, QLocale::ShortFormat); text = kTimeFmt.arg(timestamp, text); } } diff --git a/src/log/LogView.cpp b/src/log/LogView.cpp index 878611e31..7eed2d249 100644 --- a/src/log/LogView.cpp +++ b/src/log/LogView.cpp @@ -18,6 +18,7 @@ #include #include #include +#include namespace { @@ -94,7 +95,7 @@ void LogView::copy() { QString text = index.data().toString(); plainText += - QString("%1 %2\n").arg(prefix, text.remove(QRegExp("<[^>]*>"))); + QString("%1 %2\n").arg(prefix, text.remove(QRegularExpression("<[^>]*>"))); richText += QString("%1 %2
").arg(prefix, text); } @@ -169,7 +170,8 @@ QString LogView::linkAt(const QModelIndex &index, const QPoint &pos) { return QString(); LogDelegate *delegate = static_cast(itemDelegate()); - QStyleOptionViewItem options = viewOptions(); + QStyleOptionViewItem options; + initViewItemOption(&options); options.rect = visualRect(index); QPoint docPos = pos - delegate->documentPosition(options, index); return delegate->document(index)->documentLayout()->anchorAt(docPos); @@ -180,7 +182,8 @@ bool LogView::isDecoration(const QModelIndex &index, const QPoint &pos) { return false; LogDelegate *delegate = static_cast(itemDelegate()); - QStyleOptionViewItem options = viewOptions(); + QStyleOptionViewItem options; + initViewItemOption(&options); options.rect = visualRect(index); return delegate->decorationRect(options, index).contains(pos); } diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index a2246fb84..91538b5e8 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(plugins Plugin.cpp) -target_link_libraries(plugins editor git lua Qt5::Core) +target_link_libraries(plugins editor git lua Qt6::Core) set_target_properties(plugins PROPERTIES AUTOMOC ON) diff --git a/src/plugins/Plugin.cpp b/src/plugins/Plugin.cpp index 53f48e341..b34d14192 100644 --- a/src/plugins/Plugin.cpp +++ b/src/plugins/Plugin.cpp @@ -491,7 +491,7 @@ Plugin::Plugin(const QString &file, const git::Repository &repo, // Print error messages to the console. connect(this, &Plugin::error, [](const QString &msg) { - QTextStream(stderr) << "plugin error: " << msg << endl; + QTextStream(stderr) << "plugin error: " << msg << Qt::endl; }); // Load libraries. @@ -613,6 +613,7 @@ QVariant Plugin::optionValue(const QString &key) const { case String: return config().value(kKeyFmt.arg(mName, key), value.toString()); } + return QVariant(); } Plugin::OptionKind Plugin::optionKind(const QString &key) const { diff --git a/src/tools/CMakeLists.txt b/src/tools/CMakeLists.txt index a9e6a4998..baae75c30 100644 --- a/src/tools/CMakeLists.txt +++ b/src/tools/CMakeLists.txt @@ -1,6 +1,6 @@ add_library(tools DiffTool.cpp EditTool.cpp ExternalTool.cpp MergeTool.cpp ShowTool.cpp) -target_link_libraries(tools conf git Qt5::Gui) +target_link_libraries(tools conf git Qt6::Gui) set_target_properties(tools PROPERTIES AUTOMOC ON) diff --git a/src/tools/DiffTool.cpp b/src/tools/DiffTool.cpp index 60230590e..0841d6e5d 100644 --- a/src/tools/DiffTool.cpp +++ b/src/tools/DiffTool.cpp @@ -73,7 +73,7 @@ bool DiffTool::start() { if (!bash.isEmpty()) { process->start(bash, {"-c", command}); } else if (!shell) { - process->start(git::Command::substitute(env, command)); + process->start(git::Command::substitute(env, command), QStringList()); } else { emit error(BashNotFound); return false; diff --git a/src/tools/MergeTool.cpp b/src/tools/MergeTool.cpp index c310c0f0e..d3a93cf72 100644 --- a/src/tools/MergeTool.cpp +++ b/src/tools/MergeTool.cpp @@ -125,7 +125,7 @@ bool MergeTool::start() { if (!bash.isEmpty()) { process->start(bash, {"-c", command}); } else if (!shell) { - process->start(git::Command::substitute(env, command)); + process->start(git::Command::substitute(env, command), QStringList()); } else { emit error(BashNotFound); return false; diff --git a/src/ui/AdvancedSearchWidget.cpp b/src/ui/AdvancedSearchWidget.cpp index a4181ea3f..ad10e269a 100644 --- a/src/ui/AdvancedSearchWidget.cpp +++ b/src/ui/AdvancedSearchWidget.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -144,7 +143,7 @@ void AdvancedSearchWidget::exec(QLineEdit *parent, Index *index) { } // Load completion data in the background. - QtConcurrent::run([this, index] { + std::ignore = QtConcurrent::run([this, index] { QMap fields = index->fieldMap(); foreach (QLineEdit *lineEdit, mLineEdits) { QVariant var = lineEdit->property(kFieldProp); diff --git a/src/ui/BlameEditor.cpp b/src/ui/BlameEditor.cpp index e3a610bb4..53275caae 100644 --- a/src/ui/BlameEditor.cpp +++ b/src/ui/BlameEditor.cpp @@ -157,7 +157,7 @@ bool BlameEditor::load(const QString &name, const git::Blob &blob, // Calculate blame. if (mRepo.isValid() && !content.isEmpty()) { mMargin->startBlame(name); - mBlame.setFuture(QtConcurrent::run(mRepo, &git::Repository::blame, name, + mBlame.setFuture(QtConcurrent::run(&git::Repository::blame, mRepo, name, commit, mCallbacks.data())); } @@ -192,8 +192,7 @@ void BlameEditor::save() { QTextStream out(&file); if (mRepo.isValid()) - out.setCodec(mRepo.codec()); - + out.setEncoding(mRepo.encoding()); out << mEditor->text(); file.commit(); diff --git a/src/ui/BlameMargin.cpp b/src/ui/BlameMargin.cpp index c815ddbde..f09778c97 100644 --- a/src/ui/BlameMargin.cpp +++ b/src/ui/BlameMargin.cpp @@ -67,8 +67,8 @@ void BlameMargin::setBlame(const git::Repository &repo, .toBool()) { git::Commit first = repo.walker(GIT_SORT_TIME | GIT_SORT_REVERSE).next(); git::Commit last = repo.walker(GIT_SORT_TIME).next(); - mMinTime = first ? first.committer().date().toTime_t() : -1; - mMaxTime = last ? last.committer().date().toTime_t() : -1; + mMinTime = first ? first.committer().date().toSecsSinceEpoch() : -1; + mMaxTime = last ? last.committer().date().toSecsSinceEpoch() : -1; } mTimer.stop(); @@ -110,7 +110,7 @@ bool BlameMargin::event(QEvent *event) { git::Signature signature = mBlame.signature(index); if (signature.isValid()) { email = QString("<%1>").arg(signature.email()); - date = signature.date().toString(Qt::DefaultLocaleLongDate); + date = QLocale().toString(signature.date(), QLocale::LongFormat); } if (!name.isEmpty()) @@ -136,11 +136,11 @@ bool BlameMargin::event(QEvent *event) { } void BlameMargin::mousePressEvent(QMouseEvent *event) { - mIndex = mBlame.isValid() ? index(event->y()) : -1; + mIndex = mBlame.isValid() ? index(event->position().y()) : -1; } void BlameMargin::mouseReleaseEvent(QMouseEvent *event) { - if (mBlame.isValid() && mIndex >= 0 && mIndex == index(event->y())) { + if (mBlame.isValid() && mIndex >= 0 && mIndex == index(event->position().y())) { // Update selection. git::Id id = mBlame.id(mIndex); mSelection = (mSelection != id) ? id : git::Id(); @@ -154,7 +154,7 @@ void BlameMargin::mouseDoubleClickEvent(QMouseEvent *event) { if (!mBlame.isValid()) return; - int index = this->index(event->y()); + int index = this->index(event->position().y()); if (index < 0) return; @@ -172,7 +172,7 @@ void BlameMargin::mouseDoubleClickEvent(QMouseEvent *event) { void BlameMargin::paintEvent(QPaintEvent *event) { // Draw background. QStyleOption opt; - opt.init(this); + opt.initFrom(this); QPainter painter(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); @@ -223,9 +223,9 @@ void BlameMargin::paintEvent(QPaintEvent *event) { if (signature.isValid()) { QDateTime dateTime = signature.date(); date = (dateTime.date() == today) - ? dateTime.time().toString(Qt::DefaultLocaleShortDate) - : dateTime.date().toString(Qt::DefaultLocaleShortDate); - time = dateTime.toTime_t(); + ? QLocale().toString(dateTime.time(), QLocale::ShortFormat) + : QLocale().toString(dateTime.date(), QLocale::ShortFormat); + time = dateTime.toSecsSinceEpoch(); } // Draw background. @@ -284,8 +284,8 @@ void BlameMargin::paintEvent(QPaintEvent *event) { QDateTime dateTime = signature.date(); QString longDate = (dateTime.date() == today) - ? dateTime.time().toString(Qt::DefaultLocaleLongDate) - : dateTime.date().toString(Qt::DefaultLocaleLongDate); + ? QLocale().toString(dateTime.time(), QLocale::LongFormat) + : QLocale().toString(dateTime.date(), QLocale::LongFormat); QRectF dateRect = regularMetrics.boundingRect(longDate); if (nameRect.width() + dateRect.width() + 4 <= rect.width()) diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index d6f89c561..c0022a54f 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -73,8 +73,8 @@ target_link_libraries( tools update watcher - Qt5::Concurrent - Qt5::Network - Qt5::Widgets) + Qt6::Concurrent + Qt6::Network + Qt6::Widgets) set_target_properties(ui PROPERTIES AUTOMOC ON) diff --git a/src/ui/ColumnView.cpp b/src/ui/ColumnView.cpp index da2da30dd..5a67fd4af 100644 --- a/src/ui/ColumnView.cpp +++ b/src/ui/ColumnView.cpp @@ -84,7 +84,7 @@ class PreviewWidget : public QFrame { QWindow *win = window()->windowHandle(); QIcon icon = index.data(Qt::DecorationRole).value(); - mIcon->setPixmap(icon.pixmap(win, QSize(ICON_SIZE, ICON_SIZE))); + mIcon->setPixmap(icon.pixmap(QSize(ICON_SIZE, ICON_SIZE), window()->devicePixelRatio())); mName->setText(kNameFmt.arg(index.data(Qt::DisplayRole).toString())); @@ -139,7 +139,7 @@ void ColumnView::setModel(QAbstractItemModel *model) { bool ColumnView::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { QWidget *columnViewport = static_cast(obj); - QPoint globalPos = static_cast(event)->globalPos(); + QPoint globalPos = static_cast(event)->globalPosition().toPoint(); QModelIndex index = indexAt(viewport()->mapFromGlobal(globalPos)); if (!columnViewport->hasFocus() && index.row() < 0) { columnViewport->setFocus(); diff --git a/src/ui/CommitList.cpp b/src/ui/CommitList.cpp index 59c301610..df461dc57 100644 --- a/src/ui/CommitList.cpp +++ b/src/ui/CommitList.cpp @@ -311,6 +311,8 @@ class CommitModel : public QAbstractListModel { } QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const { + if (index.row() >= mRows.size()) + return QVariant(); const Row &row = mRows.at(index.row()); bool status = !row.commit.isValid(); switch (role) { @@ -769,8 +771,8 @@ class CommitDelegate : public QStyledItemDelegate { QDateTime date = commit.committer().date().toLocalTime(); QString timestamp = (date.date() == QDate::currentDate()) - ? date.time().toString(Qt::DefaultLocaleShortDate) - : date.date().toString(Qt::DefaultLocaleShortDate); + ? QLocale().toString(date.time(), QLocale::ShortFormat) + : QLocale().toString(date.date(), QLocale::ShortFormat); int timestampWidth = fm.horizontalAdvance(timestamp); if (compact) { @@ -1165,8 +1167,10 @@ git::Diff CommitList::selectedDiff() const { if (indexes.isEmpty()) return git::Diff(); - if (indexes.size() == 1) - return indexes.first().data(DiffRole).value(); + if (indexes.size() == 1) { + auto first = indexes.first().data(DiffRole); + return first.isValid() ? first.value() : git::Diff(); + } git::Commit first = indexes.first().data(CommitRole).value(); if (!first.isValid()) @@ -1670,7 +1674,8 @@ bool CommitList::isDecoration(const QModelIndex &index, const QPoint &pos) { return false; CommitDelegate *delegate = static_cast(itemDelegate()); - QStyleOptionViewItem options = viewOptions(); + QStyleOptionViewItem options; + initViewItemOption(&options); options.rect = visualRect(index); return delegate->decorationRect(options, index).contains(pos); } @@ -1680,7 +1685,8 @@ bool CommitList::isStar(const QModelIndex &index, const QPoint &pos) { return false; CommitDelegate *delegate = static_cast(itemDelegate()); - QStyleOptionViewItem options = viewOptions(); + QStyleOptionViewItem options; + initViewItemOption(&options); options.rect = visualRect(index); return delegate->starRect(options, index).contains(pos); } diff --git a/src/ui/CommitToolBar.cpp b/src/ui/CommitToolBar.cpp index c6dc1ebc5..4bbeb6d8a 100644 --- a/src/ui/CommitToolBar.cpp +++ b/src/ui/CommitToolBar.cpp @@ -12,6 +12,7 @@ #include "RepoView.h" #include "conf/Settings.h" #include "git/Config.h" +#include #include #include #include diff --git a/src/ui/DetailView.cpp b/src/ui/DetailView.cpp index 130ad6696..0894e0f0c 100644 --- a/src/ui/DetailView.cpp +++ b/src/ui/DetailView.cpp @@ -30,6 +30,7 @@ #include "git/TagRef.h" #include #include +#include #include #include #include @@ -130,7 +131,8 @@ class AuthorCommitterDate : public QWidget { mDate = new QLabel(this); mDate->setTextInteractionFlags(kTextFlags); - mSpacing = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); + mHorizontalSpacing = style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing); + mVerticalSpacing = style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing); } void moveEvent(QMoveEvent *event) override { updateLayout(); } @@ -141,13 +143,13 @@ class AuthorCommitterDate : public QWidget { QSize date = mDate->sizeHint(); QSize author = mAuthor->sizeHint(); QSize committer = mCommitter->sizeHint(); - int width = author.width() + date.width() + mSpacing; + int width = author.width() + date.width() + mHorizontalSpacing; int height; if (mSameAuthorCommitter) height = qMax(qMax(author.height(), committer.height()), date.height()); else height = - qMax(author.height(), date.height()) + committer.height() + mSpacing; + qMax(author.height(), date.height()) + committer.height() + mVerticalSpacing; return QSize(width, height); } @@ -161,7 +163,7 @@ class AuthorCommitterDate : public QWidget { height = qMax(qMax(author.height(), committer.height()), date.height()); else height = - qMax(author.height(), date.height()) + committer.height() + mSpacing; + qMax(author.height(), date.height()) + committer.height() + mVerticalSpacing; return QSize(width, height); } @@ -174,8 +176,8 @@ class AuthorCommitterDate : public QWidget { bool wrapped = (width < sizeHint().width()); int unwrappedHeight = mSameAuthorCommitter ? qMax(committer, qMax(author, date)) - : qMax(author + committer + mSpacing, date); - return wrapped ? (author + committer + date + 2 * mSpacing) + : qMax(author + committer + mVerticalSpacing, date); + return wrapped ? (author + committer + date + 2 * mVerticalSpacing) : unwrappedHeight; } @@ -205,12 +207,12 @@ class AuthorCommitterDate : public QWidget { void updateLayout() { mAuthor->move(0, 0); if (mCommitter->isVisible()) - mCommitter->move(0, mAuthor->height() + mSpacing); + mCommitter->move(0, mAuthor->height() + mVerticalSpacing); bool wrapped = (width() < sizeHint().width()); int x = wrapped ? 0 : width() - mDate->width(); int y = - wrapped ? mAuthor->height() + mCommitter->height() + 2 * mSpacing : 0; + wrapped ? mAuthor->height() + mCommitter->height() + 2 * mVerticalSpacing : 0; mDate->move(x, y); updateGeometry(); } @@ -219,7 +221,8 @@ class AuthorCommitterDate : public QWidget { QLabel *mCommitter; QLabel *mDate; - int mSpacing; + int mHorizontalSpacing; + int mVerticalSpacing; bool mSameAuthorCommitter{false}; }; @@ -311,7 +314,7 @@ class CommitDetail : public QFrame { // Compute description asynchronously. if (commits.size() == 1) mWatcher.setFuture( - QtConcurrent::run(commits.first(), &git::Commit::description)); + QtConcurrent::run(&git::Commit::description, commits.first())); } void setCommits(const QList &commits) { @@ -356,8 +359,8 @@ class CommitDetail : public QFrame { // Set date range. QDate lastDate = last.committer().date().toLocalTime().date(); QDate firstDate = first.committer().date().toLocalTime().date(); - QString lastDateStr = lastDate.toString(Qt::DefaultLocaleShortDate); - QString firstDateStr = firstDate.toString(Qt::DefaultLocaleShortDate); + QString lastDateStr = QLocale().toString(lastDate, QLocale::ShortFormat); + QString firstDateStr = QLocale().toString(firstDate, QLocale::ShortFormat); QString dateStr = (lastDate == firstDate) ? lastDateStr : kDateRangeFmt.arg(lastDateStr, firstDateStr); @@ -395,7 +398,7 @@ class CommitDetail : public QFrame { QDateTime date = commit.committer().date().toLocalTime(); mHash->setText(brightText(tr("Id:")) + " " + commit.shortId()); mAuthorCommitterDate->setDate( - brightText(date.toString(Qt::DefaultLocaleLongDate))); + brightText(QLocale().toString(date, QLocale::LongFormat))); mAuthorCommitterDate->setAuthorCommitter( kAuthorFmt.arg(author.name(), author.email()), kAuthorFmt.arg(committer.name(), committer.email())); diff --git a/src/ui/DiffView/Comment.cpp b/src/ui/DiffView/Comment.cpp index bc4a2c89d..58508a839 100644 --- a/src/ui/DiffView/Comment.cpp +++ b/src/ui/DiffView/Comment.cpp @@ -25,7 +25,7 @@ Comment::Comment(const QDateTime &date, const Account::Comment &comment, QTextCharFormat timestamp; timestamp.setForeground(theme->remoteComment(Theme::Comment::Timestamp)); cursor.setCharFormat(timestamp); - cursor.insertText(date.toString(Qt::DefaultLocaleLongDate)); + cursor.insertText(QLocale().toString(date, QLocale::LongFormat)); QTextBlockFormat indent; indent.setLeftMargin(fontMetrics().horizontalAdvance(' ') * diff --git a/src/ui/DiffView/HunkWidget.cpp b/src/ui/DiffView/HunkWidget.cpp index 6ff3569ab..7bbe9931d 100644 --- a/src/ui/DiffView/HunkWidget.cpp +++ b/src/ui/DiffView/HunkWidget.cpp @@ -269,7 +269,7 @@ HunkWidget::HunkWidget(DiffView *view, const git::Diff &diff, return; QTextStream out(&file); - out.setCodec(repo.codec()); + out.setEncoding(repo.encoding()); out << editor.text(); file.commit(); @@ -396,7 +396,7 @@ HunkWidget::HunkWidget(DiffView *view, const git::Diff &diff, return; QTextStream out(&file); - out.setCodec(repo.codec()); + out.setEncoding(repo.encoding()); out << editor.text(); file.commit(); @@ -1124,7 +1124,7 @@ void HunkWidget::createMarkersAndLineNumbers(const Line &line, int lidx, } QString author = comment.author; - QString time = key.toString(Qt::DefaultLocaleLongDate); + QString time = QLocale().toString(key, QLocale::LongFormat); QString body = paragraphs.join('\n'); QString text = author + ' ' + time + '\n' + body; QByteArray styles = @@ -1163,18 +1163,18 @@ QByteArray HunkWidget::hunk() const { int mask = mEditor->markers(i); if (mask & 1 << TextEditor::Marker::Addition) { if (!(mask & 1 << TextEditor::Marker::DiscardMarker)) { - ar.append(mEditor->line(i)); + ar.append(mEditor->line(i).toUtf8()); appended = true; } } else if (mask & 1 << TextEditor::Marker::Deletion) { if (mask & 1 << TextEditor::Marker::DiscardMarker) { // with a discard, a deletion becomes reverted // and the line is still present - ar.append(mEditor->line(i)); + ar.append(mEditor->line(i).toUtf8()); appended = true; } } else { - ar.append(mEditor->line(i)); + ar.append(mEditor->line(i).toUtf8()); appended = true; } @@ -1197,16 +1197,16 @@ QByteArray HunkWidget::apply() { int mask = mEditor->markers(i); if (mask & 1 << TextEditor::Marker::Addition) { if (mask & 1 << TextEditor::Marker::StagedMarker) { - ar.append(mEditor->line(i)); + ar.append(mEditor->line(i).toUtf8()); appended = true; } } else if (mask & 1 << TextEditor::Marker::Deletion) { if (!(mask & 1 << TextEditor::Marker::StagedMarker)) { - ar.append(mEditor->line(i)); + ar.append(mEditor->line(i).toUtf8()); appended = true; } } else { - ar.append(mEditor->line(i)); + ar.append(mEditor->line(i).toUtf8()); appended = true; } diff --git a/src/ui/DiffView/Images.cpp b/src/ui/DiffView/Images.cpp index f3098bb93..c51d4c06d 100644 --- a/src/ui/DiffView/Images.cpp +++ b/src/ui/DiffView/Images.cpp @@ -120,7 +120,7 @@ QPixmap Images::loadPixmap(git::Diff::File type, int &size, bool lfs) { QFileIconProvider provider; QString path = mPatch.repo().workdir().filePath(mPatch.name()); QIcon icon = provider.icon(QFileInfo(path)); - return icon.pixmap(windowHandle(), QSize(64, 64)); + return icon.pixmap(QSize(64, 64), window()->devicePixelRatio()); } QVBoxLayout *Images::imageLayout(const QPixmap pixmap, int size) { diff --git a/src/ui/FindWidget.cpp b/src/ui/FindWidget.cpp index 2404599b5..e047417c0 100644 --- a/src/ui/FindWidget.cpp +++ b/src/ui/FindWidget.cpp @@ -227,7 +227,7 @@ void FindWidget::showAndSetFocus() { void FindWidget::paintEvent(QPaintEvent *) { QStyleOption opt; - opt.init(this); + opt.initFrom(this); QPainter painter(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); } diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index 4e0d53bd4..765e5dcae 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -189,7 +188,7 @@ void MainWindow::setSideBarVisible(bool visible) { QTimeLine *timeline = new QTimeLine(250, this); timeline->setDirection(visible ? QTimeLine::Forward : QTimeLine::Backward); - timeline->setCurveShape(QTimeLine::LinearCurve); + timeline->setEasingCurve(QEasingCurve()); timeline->setUpdateInterval(20); connect(timeline, &QTimeLine::valueChanged, [this, pos](qreal value) { diff --git a/src/ui/MenuBar.cpp b/src/ui/MenuBar.cpp index f29e3a2a0..d3980ab90 100644 --- a/src/ui/MenuBar.cpp +++ b/src/ui/MenuBar.cpp @@ -498,7 +498,7 @@ MenuBar::MenuBar(QWidget *parent) : QMenuBar(parent) { mToggleMaximize = new StateAction(tr("Normal"), tr("Maximize"), viewMenu); viewMenu->addAction(mToggleMaximize); toggleMaximizeHotkey.use(mToggleMaximize); - mToggleMaximize->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); + mToggleMaximize->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_M)); connect(mToggleMaximize, &QAction::triggered, [this] { bool maximize = mToggleMaximize->isActive(); RepoView *view = this->view(); diff --git a/src/ui/ReferenceModel.cpp b/src/ui/ReferenceModel.cpp index d7ef1e64b..db76a1463 100644 --- a/src/ui/ReferenceModel.cpp +++ b/src/ui/ReferenceModel.cpp @@ -266,7 +266,7 @@ QVariant ReferenceModel::data(const QModelIndex &index, int role) const { QString email = QString("<%1>").arg(signature.email()); lines.append(kNowrapFmt.arg(QString("%1 %2").arg(name, email))); - QString date = signature.date().toString(Qt::DefaultLocaleLongDate); + QString date = QLocale().toString(signature.date(), QLocale::LongFormat); lines.append(kNowrapFmt.arg(date)); } diff --git a/src/ui/ReferenceView.cpp b/src/ui/ReferenceView.cpp index 00f7e9843..8cfe7c7b8 100644 --- a/src/ui/ReferenceView.cpp +++ b/src/ui/ReferenceView.cpp @@ -40,7 +40,8 @@ class FilterProxyModel : public QSortFilterProxyModel { FilterProxyModel(QObject *parent = nullptr) : QSortFilterProxyModel(parent) {} void setFilter(const QString &filter) { - setFilterRegExp(QRegExp(filter, Qt::CaseInsensitive, QRegExp::FixedString)); + setFilterCaseSensitivity(Qt::CaseSensitivity::CaseInsensitive); + setFilterFixedString(filter); } protected: diff --git a/src/ui/RemoteCallbacks.cpp b/src/ui/RemoteCallbacks.cpp index 9d3fdf932..90a164c98 100644 --- a/src/ui/RemoteCallbacks.cpp +++ b/src/ui/RemoteCallbacks.cpp @@ -235,7 +235,7 @@ bool RemoteCallbacks::negotiation( QTextStream out(&process); foreach (const git::Remote::PushUpdate &update, updates) out << update.dstName << " " << update.dstId.toString() << " " - << update.srcName << " " << update.srcId.toString() << endl; + << update.srcName << " " << update.srcId.toString() << Qt::endl; process.closeWriteChannel(); if (loop.exec()) { diff --git a/src/ui/RepoView.cpp b/src/ui/RepoView.cpp index 075f5d65a..87fae673e 100644 --- a/src/ui/RepoView.cpp +++ b/src/ui/RepoView.cpp @@ -878,7 +878,7 @@ void RepoView::setLogVisible(bool visible) { QTimeLine *timeline = new QTimeLine(250, this); timeline->setDirection(visible ? QTimeLine::Forward : QTimeLine::Backward); - timeline->setCurveShape(QTimeLine::LinearCurve); + timeline->setEasingCurve(QEasingCurve()); timeline->setUpdateInterval(20); connect(timeline, &QTimeLine::valueChanged, this, [this, pos](qreal value) { @@ -903,7 +903,7 @@ LogEntry *RepoView::error(LogEntry *parent, const QString &action, ? tr("Unable to %1 - %2").arg(action, detail) : tr("Unable to %1 '%2' - %3").arg(action, name, detail); - QStringList items = text.split("\\n", QString::KeepEmptyParts); + QStringList items = text.split("\\n", Qt::KeepEmptyParts); if (items.last() == "\n") items.removeLast(); @@ -1789,7 +1789,8 @@ void RepoView::push(const git::Remote &rmt, const git::Reference &src, &RepoView::notifyReferenceUpdated); entry->setBusy(true); - mWatcher->setFuture(QtConcurrent::run(remote, &git::Remote::push, mCallbacks, + git::Result (git::Remote::*push)(git::Remote::Callbacks*, const git::Reference&, const QString&, bool, bool) = &git::Remote::push; + mWatcher->setFuture(QtConcurrent::run(push, remote, mCallbacks, ref, dst, force, tags)); } @@ -2341,7 +2342,7 @@ void RepoView::resetSubmodulesAsync(const QList &submodules, QString(), mWatcher, repo); entry->setBusy(true); - mWatcher->setFuture(QtConcurrent::run(submodule, &git::Submodule::update, + mWatcher->setFuture(QtConcurrent::run(&git::Submodule::update, submodule, mCallbacks, false, true)); } @@ -2501,7 +2502,7 @@ void RepoView::updateSubmodulesAsync(const QList &submodules, QString(), mWatcher, repo); entry->setBusy(true); - mWatcher->setFuture(QtConcurrent::run(submodule, &git::Submodule::update, + mWatcher->setFuture(QtConcurrent::run(&git::Submodule::update, submodule, mCallbacks, init, checkout_force)); } diff --git a/src/ui/SpellChecker.cpp b/src/ui/SpellChecker.cpp index fb1563e13..9cf2722d1 100644 --- a/src/ui/SpellChecker.cpp +++ b/src/ui/SpellChecker.cpp @@ -4,7 +4,7 @@ #include "SpellChecker.h" #include #include -#include +#include SpellChecker::SpellChecker(const QString &dictionaryPath, const QString &userDictionary) @@ -26,12 +26,13 @@ SpellChecker::SpellChecker(const QString &dictionaryPath, QFile affixFile(affixFileName); if (affixFile.open(QIODevice::ReadOnly)) { QTextStream stream(&affixFile); - QRegExp enc_detector("^\\s*SET\\s+([A-Z0-9\\-]+)\\s*", - Qt::CaseInsensitive); + QRegularExpression enc_detector("^\\s*SET\\s+([A-Z0-9\\-]+)\\s*", + QRegularExpression::CaseInsensitiveOption); QString line = stream.readLine(); while (!line.isEmpty()) { - if (enc_detector.indexIn(line) >= 0) { - encoding = enc_detector.cap(1); + auto match = enc_detector.match(line); + if (match.hasMatch() >= 0) { + encoding = match.captured(1); break; } line = stream.readLine(); @@ -40,7 +41,8 @@ SpellChecker::SpellChecker(const QString &dictionaryPath, mValid = true; } - mCodec = QTextCodec::codecForName(encoding.toLatin1().constData()); + auto conv = QStringConverter::encodingForName(encoding.toLocal8Bit().data()); + mEncoding = conv ? conv.value() : QStringConverter::System; // Add user dictionary words to spell checker. if (!mUserDictionary.isEmpty()) { @@ -49,7 +51,8 @@ SpellChecker::SpellChecker(const QString &dictionaryPath, QTextStream stream(&userDictonaryFile); QString line = stream.readLine(); while (!line.isEmpty()) { - mHunspell->add(mCodec->fromUnicode(line).constData()); + QByteArray ba = QStringEncoder{mEncoding}.encode(line); + mHunspell->add(ba.toStdString()); line = stream.readLine(); } userDictonaryFile.close(); @@ -62,29 +65,34 @@ SpellChecker::~SpellChecker() { delete mHunspell; } bool SpellChecker::spell(const QString &word) { // Encode from Unicode to the encoding used by current dictionary. - return mHunspell->spell(mCodec->fromUnicode(word).toStdString()); + QByteArray ba = QStringEncoder{mEncoding}.encode(word); + return mHunspell->spell(ba.toStdString()); } QStringList SpellChecker::suggest(const QString &word) { QStringList suggestions; // Retrive suggestions for word. + QByteArray ba = QStringEncoder{mEncoding}.encode(word); std::vector suggestion = - mHunspell->suggest(mCodec->fromUnicode(word).toStdString()); + mHunspell->suggest(ba.toStdString()); // Decode from the encoding used by current dictionary to Unicode. + auto decoder = QStringDecoder{mEncoding}; foreach (const std::string &str, suggestion) - suggestions.append(mCodec->toUnicode(str.data())); + suggestions.append(decoder.decode(str.data())); return suggestions; } void SpellChecker::ignoreWord(const QString &word) { - mHunspell->add(mCodec->fromUnicode(word).constData()); + QByteArray ba = QStringEncoder{mEncoding}.encode(word); + mHunspell->add(ba.toStdString()); } void SpellChecker::addToUserDict(const QString &word) { - mHunspell->add(mCodec->fromUnicode(word).constData()); + QByteArray ba = QStringEncoder{mEncoding}.encode(word); + mHunspell->add(ba.toStdString()); if (!mUserDictionary.isEmpty()) { QFile userDictonaryFile(mUserDictionary); diff --git a/src/ui/SpellChecker.h b/src/ui/SpellChecker.h index f244bee6c..4dd1d88ce 100644 --- a/src/ui/SpellChecker.h +++ b/src/ui/SpellChecker.h @@ -4,6 +4,7 @@ #define SPELLCHECKER_H #include +#include class Hunspell; @@ -24,7 +25,7 @@ class SpellChecker { private: Hunspell *mHunspell = nullptr; - QTextCodec *mCodec; + QStringConverter::Encoding mEncoding; QString mUserDictionary; bool mValid = false; diff --git a/src/ui/ToolBar.cpp b/src/ui/ToolBar.cpp index 55ffb6196..741ec7475 100644 --- a/src/ui/ToolBar.cpp +++ b/src/ui/ToolBar.cpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace { @@ -916,7 +917,7 @@ ToolBar::ToolBar(MainWindow *parent) : QToolBar(parent) { addWidget(mode); using Signal = void (QButtonGroup::*)(int); - auto signal = static_cast(&QButtonGroup::buttonClicked); + auto signal = static_cast(&QButtonGroup::idClicked); connect(mModeGroup, signal, [this](int index) { currentView()->setViewMode(static_cast(index)); }); @@ -944,7 +945,7 @@ ToolBar::ToolBar(MainWindow *parent) : QToolBar(parent) { // Hook up star button to search field. connect(mStarButton, &QToolButton::toggled, [this](bool checked) { - QStringList terms = mSearchField->text().split(QRegExp("\\s+")); + QStringList terms = mSearchField->text().split(QRegularExpression("\\s+")); if (checked) { terms.append(kStarredQuery); } else { @@ -958,7 +959,7 @@ ToolBar::ToolBar(MainWindow *parent) : QToolBar(parent) { QSignalBlocker blocker(mStarButton); (void)blocker; - QStringList terms = mSearchField->text().split(QRegExp("\\s+")); + QStringList terms = mSearchField->text().split(QRegularExpression("\\s+")); mStarButton->setChecked(terms.contains(kStarredQuery)); }); } diff --git a/src/ui/TreeView.cpp b/src/ui/TreeView.cpp index 6be22adba..cfa6ee5cf 100644 --- a/src/ui/TreeView.cpp +++ b/src/ui/TreeView.cpp @@ -103,7 +103,7 @@ void TreeView::discard(DiffTreeModel *model, const QModelIndex &index) { bool TreeView::eventFilter(QObject *obj, QEvent *event) { if (event->type() == QEvent::MouseButtonPress) { QWidget *TreeViewport = static_cast(obj); - QPoint globalPos = static_cast(event)->globalPos(); + QPoint globalPos = static_cast(event)->globalPosition().toPoint(); QModelIndex index = indexAt(viewport()->mapFromGlobal(globalPos)); if (!TreeViewport->hasFocus() && index.row() < 0) { TreeViewport->setFocus(); @@ -266,7 +266,8 @@ void TreeView::deselectAll() { } QRect TreeView::checkRect(const QModelIndex &index) { - QStyleOptionViewItem options = viewOptions(); + QStyleOptionViewItem options; + initViewItemOption(&options); options.rect = visualRect(index); options.features |= QStyleOptionViewItem::HasCheckIndicator; diff --git a/src/ui/ViewDelegate.cpp b/src/ui/ViewDelegate.cpp index 19232a04e..4b05d76f8 100644 --- a/src/ui/ViewDelegate.cpp +++ b/src/ui/ViewDelegate.cpp @@ -51,7 +51,7 @@ void ViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, // Add extra space. opt.rect.adjust(0, 0, -3, 0); - for (int i = 0; i < status.count(); ++i) { + for (int i = 0; i < status.size(); ++i) { int x = opt.rect.x() + opt.rect.width(); int y = opt.rect.y() + (opt.rect.height() / 2); QRect rect(x - width, y - (height / 2), width, height); diff --git a/src/update/CMakeLists.txt b/src/update/CMakeLists.txt index be292e827..247e7bcc4 100644 --- a/src/update/CMakeLists.txt +++ b/src/update/CMakeLists.txt @@ -13,14 +13,14 @@ target_link_libraries( conf ${LIBCMARK_LIBRARIES} git - Qt5::Network - Qt5::Widgets + Qt6::Network + Qt6::Widgets ${UPDATER_IMPL_LIBS}) set_target_properties(update PROPERTIES AUTOMOC ON) add_executable(relauncher relauncher.cpp) -target_link_libraries(relauncher Qt5::Core) +target_link_libraries(relauncher Qt6::Core) set_target_properties(relauncher PROPERTIES RUNTIME_OUTPUT_DIRECTORY $) diff --git a/src/update/relauncher.cpp b/src/update/relauncher.cpp index 0e0637c0a..ad14eab91 100644 --- a/src/update/relauncher.cpp +++ b/src/update/relauncher.cpp @@ -45,7 +45,7 @@ int main(int argc, char *argv[]) { #endif // Restart from the path argument. - QProcess::startDetached(args.first()); + QProcess::startDetached(args.first(), QStringList()); return 0; } diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 07d638256..77d08c35a 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -1,5 +1,5 @@ add_library(util Path.cpp) -target_link_libraries(util Qt5::Core) +target_link_libraries(util Qt6::Core) set_target_properties(util PROPERTIES AUTOMOC ON) diff --git a/src/watcher/CMakeLists.txt b/src/watcher/CMakeLists.txt index af80dbbed..b830409fd 100644 --- a/src/watcher/CMakeLists.txt +++ b/src/watcher/CMakeLists.txt @@ -11,6 +11,6 @@ add_library(watcher RepositoryWatcher.cpp ${WATCHER_IMPL_FILE}) target_include_directories(watcher PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) -target_link_libraries(watcher git Qt5::Core ${WATCHER_IMPL_LIBS}) +target_link_libraries(watcher git Qt6::Core ${WATCHER_IMPL_LIBS}) set_target_properties(watcher PROPERTIES AUTOMOC ON) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4761029c5..220a250c6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -23,10 +23,10 @@ macro(test) endif() if(WIN32) - find_package(Qt5Gui) + find_package(Qt6Gui) string(REPLACE ";" "\;" NEWPATH "$ENV{PATH}") string(REPLACE ";" "\;" PLUGIN_PATH - "$") + "$") if(${ARG_NO_WIN32_OFFSCREEN}) set(PLATFORM "windows") @@ -73,7 +73,7 @@ set(CMAKE_DISABLE_TESTING ON) add_subdirectory(dep/zip) add_library(testlib EXCLUDE_FROM_ALL Test.cpp) -target_link_libraries(testlib app git ui Qt5::Test zip) +target_link_libraries(testlib app git ui Qt6::Test zip) target_include_directories(testlib PRIVATE ${CMAKE_SOURCE_DIR}/src) target_compile_definitions( testlib diff --git a/test/Submodule.cpp b/test/Submodule.cpp index 19f8b2752..d796c9545 100644 --- a/test/Submodule.cpp +++ b/test/Submodule.cpp @@ -147,14 +147,14 @@ void TestSubmodule::discardFile() { { QFile file(repo.workdir().filePath("README.md")); QVERIFY(file.open(QFile::WriteOnly)); - QTextStream(&file) << "Changing readme of main repository" << endl; + QTextStream(&file) << "Changing readme of main repository" << Qt::endl; file.close(); } { QFile file(repo.workdir().filePath("GittyupTestRepo/README.md")); QVERIFY(file.open(QFile::WriteOnly)); - QTextStream(&file) << "Changing content of submodule readme" << endl; + QTextStream(&file) << "Changing content of submodule readme" << Qt::endl; file.close(); } diff --git a/test/amend.cpp b/test/amend.cpp index 8198db312..c15a1f06b 100644 --- a/test/amend.cpp +++ b/test/amend.cpp @@ -93,7 +93,7 @@ void TestAmend::testAmendAddFile() { // Add file and refresh. QFile file(mRepo->workdir().filePath("test")); QVERIFY(file.open(QFile::WriteOnly)); - QTextStream(&file) << "This will be a test." << endl; + QTextStream(&file) << "This will be a test." << Qt::endl; Test::refresh(view); @@ -138,7 +138,7 @@ void TestAmend::testAmendAddFile() { { QFile file(mRepo->workdir().filePath("test")); QVERIFY(file.open(QFile::WriteOnly)); - QTextStream(&file) << "Changes made" << endl; + QTextStream(&file) << "Changes made" << Qt::endl; Test::refresh(view); diff --git a/test/index.cpp b/test/index.cpp index e26c3ff0b..b7b0efdca 100644 --- a/test/index.cpp +++ b/test/index.cpp @@ -44,7 +44,7 @@ void TestIndex::stageAddition() { // Add file and refresh. QFile file(mRepo->workdir().filePath("test")); QVERIFY(file.open(QFile::WriteOnly)); - QTextStream(&file) << "This is a test." << endl; + QTextStream(&file) << "This is a test." << Qt::endl; RepoView *view = mWindow->currentView(); refresh(view); @@ -135,11 +135,11 @@ void TestIndex::stageDirectory() { QFile file1(dir.filePath("test1")); QVERIFY(file1.open(QFile::WriteOnly)); - QTextStream(&file1) << "This is a test." << endl; + QTextStream(&file1) << "This is a test." << Qt::endl; QFile file2(dir.filePath("test2")); QVERIFY(file2.open(QFile::WriteOnly)); - QTextStream(&file2) << "This is a test." << endl; + QTextStream(&file2) << "This is a test." << Qt::endl; RepoView *view = mWindow->currentView(); refresh(view); diff --git a/test/merge.cpp b/test/merge.cpp index 836ad3690..44b93c3ea 100644 --- a/test/merge.cpp +++ b/test/merge.cpp @@ -54,7 +54,7 @@ void TestMerge::firstCommit() { // Add file and refresh. QFile file(mRepo->workdir().filePath("test")); QVERIFY(file.open(QFile::WriteOnly)); - QTextStream(&file) << "This will be a test." << endl; + QTextStream(&file) << "This will be a test." << Qt::endl; RepoView *view = mWindow->currentView(); refresh(view); @@ -92,7 +92,7 @@ void TestMerge::secondCommit() { QFile file(mRepo->workdir().filePath("test")); QVERIFY(file.open(QFile::WriteOnly)); - QTextStream(&file) << "This is a conflict." << endl; + QTextStream(&file) << "This is a conflict." << Qt::endl; refresh(view); @@ -130,7 +130,7 @@ void TestMerge::thirdCommit() { QFile file(mRepo->workdir().filePath("test")); QVERIFY(file.open(QFile::WriteOnly)); - QTextStream(&file) << "This is a test." << endl; + QTextStream(&file) << "This is a test." << Qt::endl; refresh(view);