From 312d984f0f6e5af3a8ca5c0d5936a4d7911abd57 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 27 Jan 2024 21:56:26 -0500 Subject: [PATCH 01/23] Req. Qt5.15 in preparation to support for Qt6 --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3153ea3..4109cad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,9 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -set(QT_MIN_VERSION 5.11.0) +set(QT_MIN_VERSION 5.15.0) find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets) +add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) include_directories( ${CMAKE_SOURCE_DIR}/src From 1cb9acfa385e81cb9249e444603d7eff5be64c92 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 21 Dec 2024 15:28:11 -0500 Subject: [PATCH 02/23] port to qt6: QRegExp -> QRegularExpression --- src/commitimpl.cpp | 6 +++--- src/fileview.cpp | 2 +- src/git.cpp | 16 ++++++++-------- src/git.h | 6 +++--- src/inputdialog.cpp | 4 ++-- src/listview.cpp | 2 +- src/listview.h | 4 ++-- src/mainimpl.cpp | 4 ++-- src/mainimpl.h | 8 ++++---- src/patchcontent.h | 2 +- src/rangeselectimpl.cpp | 6 +++--- src/revdesc.cpp | 6 +++--- src/settingsimpl.cpp | 2 +- 13 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/commitimpl.cpp b/src/commitimpl.cpp index afd1834..d69024f 100644 --- a/src/commitimpl.cpp +++ b/src/commitimpl.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include #include @@ -191,8 +191,8 @@ bool CommitImpl::checkFiles(SList selFiles) { bool CommitImpl::checkMsg(QString& msg) { msg = textEditMsg->toPlainText(); - msg.remove(QRegExp("(^|\\n)\\s*#[^\\n]*")); // strip comments - msg.replace(QRegExp("[ \\t\\r\\f\\v]+\\n"), "\n"); // strip line trailing cruft + msg.remove(QRegularExpression("(^|\\n)\\s*#[^\\n]*")); // strip comments + msg.replace(QRegularExpression("[ \\t\\r\\f\\v]+\\n"), "\n"); // strip line trailing cruft msg = msg.trimmed(); if (msg.isEmpty()) { QMessageBox::warning(this, "Commit changes - QGit", diff --git a/src/fileview.cpp b/src/fileview.cpp index 561419a..5a851ce 100644 --- a/src/fileview.cpp +++ b/src/fileview.cpp @@ -98,7 +98,7 @@ bool FileView::eventFilter(QObject* obj, QEvent* e) { if (e->type() == QEvent::ToolTip && obj == lw) { QHelpEvent* h = static_cast(e); int id = fileTab->textEditFile->itemAnnId(lw->itemAt(h->pos())); - QRegExp re; + QRegularExpression re; SCRef sha(fileTab->histListView->shaFromAnnId(id)); SCRef d(git->getDesc(sha, re, re, false, model())); lw->setToolTip(d); diff --git a/src/git.cpp b/src/git.cpp index a1d2723..e5f2a4d 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include //#include //CT TODO remove #include #include @@ -420,8 +420,8 @@ const QString Git::getTagMsg(SCRef sha) { if (!rf.tagMsg.isEmpty()) return rf.tagMsg; - QRegExp pgp("-----BEGIN PGP SIGNATURE*END PGP SIGNATURE-----", - Qt::CaseSensitive, QRegExp::Wildcard); + QRegularExpression pgp("-----BEGIN PGP SIGNATURE*END PGP SIGNATURE-----", + Qt::CaseSensitive, QRegularExpression::Wildcard); if (!rf.tagObj.isEmpty()) { QString ro; @@ -1001,7 +1001,7 @@ const QString Git::getNewCommitMsg() { return ""; } QString status = c->longLog(); - status.prepend('\n').replace(QRegExp("\\n([^#\\n]?)"), "\n#\\1"); // comment all the lines + status.prepend('\n').replace(QRegularExpression("\\n([^#\\n]?)"), "\n#\\1"); // comment all the lines if (isMergeHead) { QFile file(QDir(gitDir).absoluteFilePath("MERGE_MSG")); @@ -1018,7 +1018,7 @@ const QString Git::getNewCommitMsg() { } //CT TODO utility function; can go elsewhere -const QString Git::colorMatch(SCRef txt, QRegExp& regExp) { +const QString Git::colorMatch(SCRef txt, QRegularExpression& regExp) { QString text = qt4and5escaping(txt); @@ -1051,7 +1051,7 @@ const QString Git::formatList(SCList sl, SCRef name, bool inOneLine) { return ls; } -const QString Git::getDesc(SCRef sha, QRegExp& shortLogRE, QRegExp& longLogRE, +const QString Git::getDesc(SCRef sha, QRegularExpression& shortLogRE, QRegularExpression& longLogRE, bool showHeader, FileHistory* fh) { if (sha.isEmpty()) @@ -1116,7 +1116,7 @@ const QString Git::getDesc(SCRef sha, QRegExp& shortLogRE, QRegExp& longLogRE, // sha if there isn't a leading trailing space or an open parenthesis and, // in that case, before the space must not be a ':' character. // It's an ugly heuristic, but seems to work in most cases. - QRegExp reSHA("..[0-9a-f]{21,40}|[^:][\\s(][0-9a-f]{6,20}", Qt::CaseInsensitive); + QRegularExpression reSHA("..[0-9a-f]{21,40}|[^:][\\s(][0-9a-f]{6,20}", Qt::CaseInsensitive); reSHA.setMinimal(false); int pos = 0; while ((pos = text.indexOf(reSHA, pos)) != -1) { @@ -1293,7 +1293,7 @@ const QString Git::getNewestFileName(SCList branches, SCRef fileName) { void Git::getFileFilter(SCRef path, ShaSet& shaSet) const { shaSet.clear(); - QRegExp rx(path, Qt::CaseInsensitive, QRegExp::Wildcard); + QRegularExpression rx(path, Qt::CaseInsensitive, QRegularExpression::Wildcard); FOREACH (ShaVect, it, revData->revOrder) { if (!revsFiles.contains(*it)) diff --git a/src/git.h b/src/git.h index a0e20c8..247a458 100644 --- a/src/git.h +++ b/src/git.h @@ -11,7 +11,7 @@ #include "common.h" template struct QPair; -class QRegExp; +class QRegularExpression; class QTextCodec; class Annotate; //class DataLoader; @@ -98,7 +98,7 @@ Q_OBJECT bool getTree(SCRef ts, TreeInfo& ti, bool wd, SCRef treePath); static const QString getLocalDate(SCRef gitDate); const QString getCurrentBranchName() const {return curBranchName;} - const QString getDesc(SCRef sha, QRegExp& slogRE, QRegExp& lLogRE, bool showH, FileHistory* fh); + const QString getDesc(SCRef sha, QRegularExpression& slogRE, QRegularExpression& lLogRE, bool showH, FileHistory* fh); const QString getLastCommitMsg(); const QString getNewCommitMsg(); const QString getLaneParent(SCRef fromSHA, int laneNum); @@ -247,7 +247,7 @@ private slots: const QStringList getOthersFiles(); const QStringList getOtherFiles(SCList selFiles, bool onlyInIndex); const QString getNewestFileName(SCList args, SCRef fileName); - static const QString colorMatch(SCRef txt, QRegExp& regExp); + static const QString colorMatch(SCRef txt, QRegularExpression& regExp); void appendFileName(RevFile& rf, SCRef name, FileNamesLoader& fl); void flushFileNames(FileNamesLoader& fl); void populateFileNamesMap(); diff --git a/src/inputdialog.cpp b/src/inputdialog.cpp index 5244e46..ec15379 100644 --- a/src/inputdialog.cpp +++ b/src/inputdialog.cpp @@ -47,7 +47,7 @@ class RefNameValidator : public QValidator { void fixup(QString& input) const; State validate(QString & input, int & pos) const; private: - const QRegExp invalid; + const QRegularExpression invalid; bool allowEmpty; }; @@ -89,7 +89,7 @@ InputDialog::InputDialog(const QString &cmd, const VariableMap &variables, this->setWindowTitle(title); QGridLayout *layout = new QGridLayout(this); - QRegExp re("%(([a-z_]+)([[]([a-z ,]+)[]])?:)?([^%=]+)(=[^%]+)?%"); + QRegularExpression re("%(([a-z_]+)([[]([a-z ,]+)[]])?:)?([^%=]+)(=[^%]+)?%"); int start = 0; int row = 0; while ((start = re.indexIn(cmd, start)) != -1) { diff --git a/src/listview.cpp b/src/listview.cpp index e42bc5e..3bf330e 100644 --- a/src/listview.cpp +++ b/src/listview.cpp @@ -1272,7 +1272,7 @@ bool ListViewProxy::filterAcceptsRow(int source_row, const QModelIndex&) const { int ListViewProxy::setFilter(bool isOn, bool h, SCRef fl, int cn, ShaSet* s) { - filter = QRegExp(fl, Qt::CaseInsensitive, QRegExp::Wildcard); + filter = QRegularExpression(fl, Qt::CaseInsensitive, QRegularExpression::Wildcard); colNum = cn; if (s) shaSet = *s; diff --git a/src/listview.h b/src/listview.h index dc1e06b..00a857a 100644 --- a/src/listview.h +++ b/src/listview.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "common.h" class Git; @@ -139,7 +139,7 @@ Q_OBJECT Domain* d; Git* git; bool isHighLight; - QRegExp filter; + QRegularExpression filter; int colNum; ShaSet shaSet; }; diff --git a/src/mainimpl.cpp b/src/mainimpl.cpp index e1dd0dc..8204d81 100644 --- a/src/mainimpl.cpp +++ b/src/mainimpl.cpp @@ -273,10 +273,10 @@ void MainImpl::ActExternalDiff_activated() { } } -const QRegExp MainImpl::emptySha("0*"); +const QRegularExpression MainImpl::emptySha("0*"); QString MainImpl::copyFileToDiffIfNeeded(QStringList* filenames, QString sha) { - if (emptySha.exactMatch(sha)) + if (emptySha.match(sha).hasMatch()) { return QString(curDir + "/" + rv->st.fileName()); } diff --git a/src/mainimpl.h b/src/mainimpl.h index 3089a95..77a44aa 100644 --- a/src/mainimpl.h +++ b/src/mainimpl.h @@ -8,7 +8,7 @@ #define MAINIMPL_H #include -#include +#include #include #include "exceptionmanager.h" #include "common.h" @@ -185,9 +185,9 @@ protected slots: QString startUpDir; QString startUpFile; QString textToFind; - QRegExp shortLogRE; - QRegExp longLogRE; - static const QRegExp emptySha; + QRegularExpression shortLogRE; + QRegularExpression longLogRE; + static const QRegularExpression emptySha; QMap revision_variables; // variables used in generic input dialogs bool setRepositoryBusy; diff --git a/src/patchcontent.h b/src/patchcontent.h index f9f1912..ed3522a 100644 --- a/src/patchcontent.h +++ b/src/patchcontent.h @@ -71,7 +71,7 @@ public slots: QByteArray patchRowData; QString halfLine; bool isRegExp; - QRegExp pickAxeRE; + QRegularExpression pickAxeRE; QString target; bool seekTarget; diff --git a/src/rangeselectimpl.cpp b/src/rangeselectimpl.cpp index a55a338..9fdfe0c 100644 --- a/src/rangeselectimpl.cpp +++ b/src/rangeselectimpl.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include "common.h" #include "git.h" #include "rangeselectimpl.h" @@ -84,7 +84,7 @@ void RangeSelectImpl::orderRefs(const QStringList& src, QStringList& dst) { // releases as example v.2.6.18-rc4 before v.2.6.18 // match a (dotted) number + something else + a number + EOL - QRegExp re("[\\d\\.]+([^\\d\\.]+\\d+$)"); + QRegularExpression re("[\\d\\.]+([^\\d\\.]+\\d+$)"); // in ASCII the space ' ' (32) comes before '!' (33) and both // before the rest, we need this to correctly order a sequence like @@ -95,7 +95,7 @@ void RangeSelectImpl::orderRefs(const QStringList& src, QStringList& dst) { const QString noRcMark("!$$%%"); // an impossible to find string starting with a '!' typedef QMap OrderedMap; - QRegExp verRE("([^\\d])(\\d{1,2})(?=[^\\d])"); + QRegularExpression verRE("([^\\d])(\\d{1,2})(?=[^\\d])"); OrderedMap map; FOREACH_SL (it, src) { diff --git a/src/revdesc.cpp b/src/revdesc.cpp index e1dcd15..b99b59b 100644 --- a/src/revdesc.cpp +++ b/src/revdesc.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include "domain.h" #include "revdesc.h" @@ -22,8 +22,8 @@ RevDesc::RevDesc(QWidget* p) : QTextBrowser(p), d(NULL) { void RevDesc::on_anchorClicked(const QUrl& link) { - QRegExp re("[0-9a-f]{40}", Qt::CaseInsensitive); - if (re.exactMatch(link.toString())) { + QRegularExpression re("[0-9a-f]{40}", Qt::CaseInsensitive); + if (re.match(link.toString()).hasMatch()) { setSource(QUrl()); // override default navigation behavior d->st.setSha(link.toString()); diff --git a/src/settingsimpl.cpp b/src/settingsimpl.cpp index 3fd9621..430c26a 100644 --- a/src/settingsimpl.cpp +++ b/src/settingsimpl.cpp @@ -212,7 +212,7 @@ void SettingsImpl::setupCodecsCombo() { return; } const QString curCodec(tc != 0 ? tc->name() : "Latin1"); - QRegExp re("*" + curCodec + "*", Qt::CaseInsensitive, QRegExp::Wildcard); + QRegularExpression re("*" + curCodec + "*", Qt::CaseInsensitive, QRegularExpression::Wildcard); int idx = codecs.indexOf(re); if (idx == -1) { dbp("ASSERT: codec <%1> not available, using local codec", curCodec); From 7b3e0beb82676b6e4813ebd710b576cac6f0a160 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 21 Dec 2024 16:22:34 -0500 Subject: [PATCH 03/23] Convert all .ui files to Qt6 --- src/commit.ui | 213 ++++++++++++++++--------------- src/console.ui | 13 +- src/customaction.ui | 31 +++-- src/fileview.ui | 30 ++--- src/help.ui | 4 +- src/mainview.ui | 78 +++++++++--- src/patchview.ui | 167 ++++++++++++------------ src/rangeselect.ui | 302 ++++++++++++++++++++++---------------------- src/revsview.ui | 135 ++++++++------------ src/settings.ui | 84 +++++++++--- 10 files changed, 574 insertions(+), 483 deletions(-) diff --git a/src/commit.ui b/src/commit.ui index 4055499..ce88e1a 100644 --- a/src/commit.ui +++ b/src/commit.ui @@ -1,7 +1,8 @@ - + + CommitBase - - + + 0 0 @@ -9,106 +10,107 @@ 531 - + Commit changes - - :/icons/resources/svn-commit.svg + + + :/icons/resources/svn-commit.svg:/icons/resources/svn-commit.svg - - + + 0 - + 0 - + 0 - + 0 - + 0 - - + + 6 - + 0 - + 0 - + 0 - + 0 - - - Qt::Vertical + + + Qt::Orientation::Vertical - - - Qt::CustomContextMenu + + + Qt::ContextMenuPolicy::CustomContextMenu - + Check files to commit - + false - + false - + true - + 2 - + File - + Index status - - - + + + 0 - + 0 - + 0 - + 0 - + 0 - - + + Commit message (first line is the sub&ject): - + false - + textEditMsg @@ -119,13 +121,13 @@ Lines starting with '#' will be ignored Press <Ctrl+Enter> to commit changes - - QTextEdit::NoWrap + + QTextEdit::LineWrapMode::NoWrap - + false - + false @@ -135,55 +137,55 @@ Press <Ctrl+Enter> to commit changes - - + + 6 - + 0 - + 0 - + 0 - + 0 - - + + 150 24 - + Monospace - - QFrame::Sunken + + QFrame::Shadow::Sunken - + Line: %1 Col: %2 - + false - - Qt::Horizontal + + Qt::Orientation::Horizontal - - QSizePolicy::Expanding + + QSizePolicy::Policy::Expanding - + 30 20 @@ -192,80 +194,80 @@ Press <Ctrl+Enter> to commit changes - - - + + + 0 0 - + Settin&gs - + Alt+G - + false - + false - - - + + + 0 0 - + Canc&el - + Alt+E - + false - + true - - - + + + 0 0 - + Update index for selected files - + Update &Index - - - + + + 0 0 - + Commit selected files - + &Commit - + Alt+C @@ -276,14 +278,14 @@ Press <Ctrl+Enter> to commit changes - + pushButtonCancel pushButtonUpdateCache pushButtonOk - + @@ -292,11 +294,11 @@ Press <Ctrl+Enter> to commit changes CommitBase pushButtonCancel_clicked() - - 20 - 20 + + 375 + 511 - + 20 20 @@ -308,11 +310,11 @@ Press <Ctrl+Enter> to commit changes CommitBase pushButtonUpdateCache_clicked() - - 20 - 20 + + 465 + 511 - + 20 20 @@ -324,15 +326,20 @@ Press <Ctrl+Enter> to commit changes CommitBase pushButtonSettings_clicked() - - 20 - 20 + + 285 + 511 - + 20 20 + + pushButtonCancel_clicked() + pushButtonUpdateCache_clicked() + pushButtonSettings_clicked() + diff --git a/src/console.ui b/src/console.ui index 7a4b10d..e9542d2 100644 --- a/src/console.ui +++ b/src/console.ui @@ -48,7 +48,6 @@ Sans Serif 9 - 75 false true false @@ -62,10 +61,10 @@ ... - Qt::PlainText + Qt::TextFormat::PlainText - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop true @@ -75,7 +74,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -277,7 +276,7 @@ - QDialogButtonBox::Close + QDialogButtonBox::StandardButton::Close @@ -330,4 +329,8 @@ + + pushButtonTerminate_clicked() + pushButtonOk_clicked() + diff --git a/src/customaction.ui b/src/customaction.ui index 875029e..4befff8 100644 --- a/src/customaction.ui +++ b/src/customaction.ui @@ -6,7 +6,7 @@ 0 0 - 579 + 604 492 @@ -27,10 +27,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -78,7 +78,7 @@ - Qt::LeftToRight + Qt::LayoutDirection::LeftToRight Move &up @@ -118,14 +118,14 @@ - Qt::Horizontal + Qt::Orientation::Horizontal - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -145,10 +145,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -200,7 +200,7 @@ variables <code>$CURRENT_BRANCH</code> and <code>$SHA</code - QDialogButtonBox::Ok + QDialogButtonBox::StandardButton::Ok @@ -356,4 +356,15 @@ variables <code>$CURRENT_BRANCH</code> and <code>$SHA</code + + pushButtonNew_clicked() + pushButtonRename_clicked() + pushButtonRemove_clicked() + checkBoxRefreshAfterAction_toggled(bool) + pushButtonMoveUp_clicked() + pushButtonMoveDown_clicked() + textEditAction_textChanged() + listWidgetNames_currentItemChanged(QListWidgetItem*,QListWidgetItem*) + pushButtonOk_clicked() + diff --git a/src/fileview.ui b/src/fileview.ui index c9de01d..e4b1881 100644 --- a/src/fileview.ui +++ b/src/fileview.ui @@ -230,10 +230,10 @@ - Qt::Horizontal + Qt::Orientation::Horizontal - QSizePolicy::Expanding + QSizePolicy::Policy::Expanding @@ -246,10 +246,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -321,11 +321,11 @@ - Qt::Vertical + Qt::Orientation::Vertical - Qt::CustomContextMenu + Qt::ContextMenuPolicy::CustomContextMenu true @@ -345,10 +345,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Sunken + QFrame::Shadow::Sunken @@ -386,32 +386,32 @@ - QFrame::NoFrame + QFrame::Shape::NoFrame - Qt::ScrollBarAlwaysOff + Qt::ScrollBarPolicy::ScrollBarAlwaysOff - Qt::ScrollBarAlwaysOff + Qt::ScrollBarPolicy::ScrollBarAlwaysOff - QAbstractItemView::ScrollPerPixel + QAbstractItemView::ScrollMode::ScrollPerPixel - QAbstractItemView::ScrollPerPixel + QAbstractItemView::ScrollMode::ScrollPerPixel - QFrame::NoFrame + QFrame::Shape::NoFrame false - QTextEdit::NoWrap + QTextEdit::LineWrapMode::NoWrap true diff --git a/src/help.ui b/src/help.ui index 754b002..c5ab7d4 100644 --- a/src/help.ui +++ b/src/help.ui @@ -21,7 +21,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -36,7 +36,7 @@ - QDialogButtonBox::Close + QDialogButtonBox::StandardButton::Close diff --git a/src/mainview.ui b/src/mainview.ui index d3fdff2..ccedb75 100644 --- a/src/mainview.ui +++ b/src/mainview.ui @@ -40,14 +40,14 @@ - Qt::Horizontal + Qt::Orientation::Horizontal - Qt::CustomContextMenu + Qt::ContextMenuPolicy::CustomContextMenu - QAbstractItemView::ExtendedSelection + QAbstractItemView::SelectionMode::ExtendedSelection false @@ -80,7 +80,7 @@ Toolbar - Qt::Horizontal + Qt::Orientation::Horizontal @@ -113,7 +113,7 @@ 0 0 905 - 20 + 34 @@ -286,7 +286,7 @@ Settings - QAction::PreferencesRole + QAction::MenuRole::PreferencesRole @@ -450,7 +450,7 @@ false - View file + Vie&w file View file @@ -497,7 +497,7 @@ :/icons/resources/autocorrection.svg:/icons/resources/autocorrection.svg - Toggle filter by tree + To&ggle filter by tree Filter by tree @@ -518,7 +518,7 @@ :/icons/resources/view-list-tree.svg:/icons/resources/view-list-tree.svg - Toggle tree view + &Toggle tree view Archive tree @@ -611,7 +611,7 @@ false - View revision + &View revision View revision @@ -629,7 +629,7 @@ :/icons/resources/view-split-top-bottom.svg:/icons/resources/view-split-top-bottom.svg - Toggle split view + T&oggle split view Toggle split view @@ -717,7 +717,7 @@ Setup actions... - QAction::NoRole + QAction::MenuRole::NoRole @@ -728,7 +728,7 @@ - View file in new tab + View file &in new tab View file in new tab @@ -745,7 +745,7 @@ - View patch in new tab + View patch in &new tab View patch in new tab @@ -812,7 +812,7 @@ - Toggle message/diff + Toggle message/&diff Toggle message/diff @@ -830,7 +830,7 @@ :/icons/resources/join.svg:/icons/resources/join.svg - Select range... + &Select range... Show 'Select range' dialog @@ -866,7 +866,7 @@ - &Checkout... + Ch&eckout... Checkout @@ -1564,4 +1564,48 @@ + + ActAbout_activated() + ActCheckWorkDir_toggled(bool) + ActCheckout_activated() + ActClose_activated() + ActCommit_activated() + ActExit_activated() + ActExternalDiff_activated() + ActExternalEditor_activated() + ActFilterTree_toggled(bool) + ActHelp_activated() + ActMailApplyPatch_activated() + ActMailFormatPatch_activated() + ActOpenRepo_activated() + ActOpenRepoNewWindow_activated() + ActPop_activated() + ActPush_activated() + ActRefresh_activated() + ActSaveFile_activated() + ActSettings_activated() + ActShowTree_toggled(bool) + ActBranch_activated() + ActTag_activated() + ActDelete_activated() + ActViewFile_activated() + ActViewDiff_activated() + ActViewRev_activated() + ActSplitView_activated() + ActFind_activated() + ActFindNext_activated() + ActBack_activated() + ActForward_activated() + ActCustomActionSetup_activated() + ActViewFileNewTab_activated() + ActViewDiffNewTab_activated() + tabWdg_currentChanged(int) + ActSearchAndFilter_toggled(bool) + ActSearchAndHighlight_toggled(bool) + ActShowDescHeader_activated() + ActToggleLogsDiff_activated() + ActRangeDlg_activated() + ActAmend_activated() + ActMarkDiffToSha_activated() + diff --git a/src/patchview.ui b/src/patchview.ui index b4d3081..cc8d444 100644 --- a/src/patchview.ui +++ b/src/patchview.ui @@ -1,7 +1,8 @@ - + + TabPatch - - + + 0 0 @@ -9,126 +10,126 @@ 449 - + Patch - - + + 0 - + 0 - + 0 - + 0 - + 0 - - + + 0 - + 0 - + 0 - + 0 - + 0 - - + + 6 - + 2 - + 2 - + 2 - + 2 - - + + Diff to: - + false - - - Qt::StrongFocus + + + Qt::FocusPolicy::StrongFocus - + Check to diff against parent - - P&arent + + Paren&t - + Alt+A - + true - - - Qt::ClickFocus + + + Qt::FocusPolicy::ClickFocus - + Check to diff against HEAD - + H&EAD - + Alt+E - - - Qt::ClickFocus + + + Qt::FocusPolicy::ClickFocus - + Use CTRL + right click to select a revision to diff against - + &SHA - + Alt+S - - Qt::Horizontal + + Qt::Orientation::Horizontal - + 20 0 @@ -137,24 +138,24 @@ - - - + + + 1 0 - + SHA value of selected revision. Use CTRL + right click to select. - - + + Toggle view of added and removed lines (CTRL+H) - + Ctrl+H @@ -162,55 +163,55 @@ - - - + + + 0 0 - - Qt::Horizontal + + Qt::Orientation::Horizontal - - - + + + 5 0 - - Qt::Vertical + + Qt::Orientation::Vertical - - - QTextEdit::NoWrap + + + QTextEdit::LineWrapMode::NoWrap - - + + false - - QTextEdit::NoWrap + + QTextEdit::LineWrapMode::NoWrap - + true - - Qt::TextSelectableByMouse + + Qt::TextInteractionFlag::TextSelectableByMouse - - - + + + 1 0 - - Qt::CustomContextMenu + + Qt::ContextMenuPolicy::CustomContextMenu @@ -219,7 +220,7 @@ - + FileList @@ -238,10 +239,10 @@ - revdesc.h + revdesc.h - + diff --git a/src/rangeselect.ui b/src/rangeselect.ui index 1905f9d..e9b798a 100644 --- a/src/rangeselect.ui +++ b/src/rangeselect.ui @@ -1,137 +1,136 @@ - + + RangeSelectBase - - + + 0 0 - 415 - 235 + 441 + 267 - + Range select - - :/icons/resources/join.svg + + + :/icons/resources/join.svg:/icons/resources/join.svg - + true - - + + 0 - + 4 - + 4 - + 4 - + 4 - - + + 6 - + 0 - + 0 - + 0 - + 0 - - + + 0 - + 0 - + 0 - + 0 - + 2 - - 2 - - - - - + + + + 0 0 - + Select a tag or paste/write a rev - + true - - QComboBox::NoInsert + + QComboBox::InsertPolicy::NoInsert - - - - Top: + + + + &Top: - + false - + comboBoxTo - - - + + + &Bottom: - + false - + comboBoxFrom - - - - + + + + 0 0 - + Select a tag or paste/write a rev - + true - - QComboBox::NoInsert + + QComboBox::InsertPolicy::NoInsert @@ -139,13 +138,13 @@ - - Qt::Vertical + + Qt::Orientation::Vertical - - QSizePolicy::Expanding + + QSizePolicy::Policy::Expanding - + 395 16 @@ -154,81 +153,81 @@ - - - QFrame::StyledPanel + + + QFrame::Shape::StyledPanel - - QFrame::Raised + + QFrame::Shadow::Raised - - + + 6 - + 9 - + 9 - + 9 - + 9 - - + + 6 - + 0 - + 0 - + 0 - + 0 - - + + Check to see git status. Necessary for committing. - + &Working dir - + Alt+W - - + + Check to enable '--all' option - + All branch&es - + Alt+E - - + + Check to view all the revisions - + Whole histor&y - + Alt+Y @@ -240,13 +239,13 @@ - - Qt::Vertical + + Qt::Orientation::Vertical - - QSizePolicy::Expanding + + QSizePolicy::Policy::Expanding - + 395 16 @@ -255,50 +254,50 @@ - - + + 6 - + 0 - + 0 - + 0 - + 0 - - - + + + 0 0 - - &Additional options: + + Additiona&l options: - + false - + lineEditOptions - - - + + + 0 0 - + Extra options to feed 'git log' @@ -306,50 +305,50 @@ - - + + 6 - + 0 - + 0 - + 0 - + 0 - - - + + + 0 0 - + You can always re-enable the dialog from settings. - + S&how this dialog when opening a repository - + Alt+H - - Qt::Horizontal + + Qt::Orientation::Horizontal - - QSizePolicy::Expanding + + QSizePolicy::Policy::Expanding - + 80 20 @@ -358,20 +357,20 @@ - - - + + + 0 0 - + O&k - + Alt+K - + true @@ -382,9 +381,9 @@ - + - + @@ -393,11 +392,11 @@ RangeSelectBase pushButtonOk_clicked() - + 20 20 - + 20 20 @@ -409,11 +408,11 @@ RangeSelectBase checkBoxShowDialog_toggled(bool) - + 20 20 - + 20 20 @@ -425,11 +424,11 @@ RangeSelectBase checkBoxDiffCache_toggled(bool) - + 78 98 - + 207 117 @@ -441,11 +440,11 @@ RangeSelectBase checkBoxShowAll_toggled(bool) - + 207 98 - + 207 117 @@ -457,15 +456,22 @@ RangeSelectBase checkBoxShowWholeHistory_toggled(bool) - + 336 98 - + 207 117 + + pushButtonOk_clicked() + checkBoxShowDialog_toggled(bool) + checkBoxDiffCache_toggled(bool) + checkBoxShowAll_toggled(bool) + checkBoxShowWholeHistory_toggled(bool) + diff --git a/src/revsview.ui b/src/revsview.ui index 14d10aa..65b0e8f 100644 --- a/src/revsview.ui +++ b/src/revsview.ui @@ -1,7 +1,8 @@ - + + TabRev - - + + 0 0 @@ -9,129 +10,105 @@ 523 - + Rev list - - + + 0 - + 0 - - - Qt::Vertical + + + Qt::Orientation::Vertical - - - Qt::CustomContextMenu + + + Qt::ContextMenuPolicy::CustomContextMenu - + true - + true - + false - + true - + false - + true - - - Qt::Horizontal + + + Qt::Orientation::Horizontal - - + + 0 - - - - 0 - 0 - 346 - 249 - + + + QTabWidget::TabPosition::East - - QTabWidget::East + + QTabWidget::TabShape::Triangular - - QTabWidget::Triangular - - + 0 - - - - 0 - 0 - 317 - 243 - - - + + Log - - + + 0 - + 0 - - - QTextEdit::WidgetWidth + + + QTextEdit::LineWrapMode::WidgetWidth - - - - 0 - 0 - 317 - 243 - - - + + Diff - - + + 0 - + 0 - - - test + + + test - + false - - QTextEdit::NoWrap + + QTextEdit::LineWrapMode::NoWrap - + true @@ -140,9 +117,9 @@ - - - Qt::CustomContextMenu + + + Qt::ContextMenuPolicy::CustomContextMenu @@ -150,7 +127,7 @@ - + ListView @@ -174,7 +151,7 @@ - revdesc.h + revdesc.h diff --git a/src/settings.ui b/src/settings.ui index ce09c76..06864a5 100644 --- a/src/settings.ui +++ b/src/settings.ui @@ -7,7 +7,7 @@ 0 0 513 - 377 + 504 @@ -75,10 +75,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -217,7 +217,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -383,7 +383,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -485,10 +485,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -584,7 +584,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -608,10 +608,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -680,7 +680,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -784,10 +784,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -824,7 +824,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -938,10 +938,10 @@ - QFrame::StyledPanel + QFrame::Shape::StyledPanel - QFrame::Raised + QFrame::Shadow::Raised @@ -1017,7 +1017,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -1093,7 +1093,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -1126,7 +1126,7 @@ Ms&g template - Qt::PlainText + Qt::TextFormat::PlainText false @@ -1181,7 +1181,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -1240,7 +1240,7 @@ - QDialogButtonBox::Ok + QDialogButtonBox::StandardButton::Ok @@ -1752,6 +1752,48 @@ toggled(bool) settingsBase checkBoxShowShortRef_toggled(bool) + + + 20 + 20 + + + 20 + 20 + + + + checkBoxNumbers_toggled(bool) + lineEditFormatPatchExtraOptions_textChanged(QString) + checkBoxDiffCache_toggled(bool) + lineEditExcludePerDir_textChanged(QString) + lineEditExcludeFile_textChanged(QString) + checkBoxSign_toggled(bool) + lineEditTemplate_textChanged(QString) + lineEditCommitExtraOptions_textChanged(QString) + checkBoxRelativeDate_toggled(bool) + checkBoxRangeSelectDialog_toggled(bool) + checkBoxReopenLastRepo_toggled(bool) + comboBoxDoubleClickAction_activated(int) + comboBoxCodecs_activated(int) + checkBoxCommitVerify_toggled(bool) + checkBoxCommitSign_toggled(bool) + checkBoxCommitUseDefMsg_toggled(bool) + lineEditExternalDiffViewer_textChanged(QString) + lineEditExternalEditor_textChanged(QString) + pushButtonExtDiff_clicked() + pushButtonExtEditor_clicked() + pushButtonFont_clicked() + comboBoxUserSrc_activated(int) + checkBoxMsgOnNewSHA_toggled(bool) + checkBoxLogDiffTab_toggled(bool) + checkBoxSmartLabels_toggled(bool) + lineEditApplyPatchExtraOptions_textChanged(QString) + comboBoxGitConfigSource_activated(int) + treeWidgetGitConfig_itemChanged(QTreeWidgetItem*, int) + checkBoxEnableDragnDrop_toggled(bool) + checkBoxShowShortRef_toggled(bool) + From a75ea1ad391649869d449eff82987befbbc30617 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 26 Apr 2025 17:59:04 -0400 Subject: [PATCH 04/23] Instruct CMake to require Qt6 --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4109cad..a2a0fa1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -set(QT_MIN_VERSION 5.15.0) -find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets) +set(QT_MIN_VERSION 6.6.0) +find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets) add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) include_directories( @@ -58,7 +58,7 @@ set(CPP_SOURCES ) # UIS_HDRS will be used later in add_executable -qt5_wrap_ui(UIS_HDRS +qt6_wrap_ui(UIS_HDRS src/commit.ui src/console.ui src/customaction.ui @@ -78,10 +78,10 @@ set(RESOURCE_FILES # this command will generate rules that will run rcc on all files from SAMPLE_RCS # in result SAMPLE_RC_SRCS variable will contain paths to files produced by rcc -qt5_add_resources(RC_SRCS ${RESOURCE_FILES}) +qt6_add_resources(RC_SRCS ${RESOURCE_FILES}) add_executable(qgit ${CPP_SOURCES} ${UIS_HDRS} ${RC_SRCS}) -target_link_libraries(qgit Qt5::Widgets) +target_link_libraries(qgit Qt6::Widgets) install(TARGETS qgit DESTINATION bin) From 501edd96d3502844be1b0e5dee3cff85cdb16f31 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 26 Apr 2025 18:00:33 -0400 Subject: [PATCH 05/23] toTime_t -> toSecsSinceEpoch --- src/FileHistory.cc | 2 +- src/git.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FileHistory.cc b/src/FileHistory.cc index 77ed4b0..d24014c 100644 --- a/src/FileHistory.cc +++ b/src/FileHistory.cc @@ -118,7 +118,7 @@ void FileHistory::clear(bool complete) { rowData.clear(); if (testFlag(REL_DATE_F)) { - secs = QDateTime::currentDateTime().toTime_t(); + secs = QDateTime::currentDateTime().toSecsSinceEpoch(); headerInfo[ColumnType::TIME_COL] = "Last Change"; } else { secs = 0; diff --git a/src/git.cpp b/src/git.cpp index e5f2a4d..5608e4c 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -1967,7 +1967,7 @@ const Rev* Git::fakeWorkDirRev(SCRef parent, SCRef log, SCRef longLog, int idx, if (!isMainHistory(fh)) patch = getWorkDirDiff(fh->fileNames().first()); - QString date(QString::number(QDateTime::currentDateTime().toTime_t())); + QString date(QString::number(QDateTime::currentDateTime().toSecsSinceEpoch())); QString author("-"); QStringList parents(parent); Rev* c = fakeRevData(ZERO_SHA, parents, author, date, log, longLog, patch, idx, fh); From 17a6611d3825f367da6bdd6c1b69c159e3cd48aa Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 26 Apr 2025 18:39:07 -0400 Subject: [PATCH 06/23] Remove conflicting declaration of QPair --- src/git.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/git.h b/src/git.h index 247a458..2cbb876 100644 --- a/src/git.h +++ b/src/git.h @@ -10,7 +10,6 @@ #include "exceptionmanager.h" #include "common.h" -template struct QPair; class QRegularExpression; class QTextCodec; class Annotate; From bbf4ebc5c2cf689b7cea1164a6ed1687de5ec997 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 26 Apr 2025 19:01:47 -0400 Subject: [PATCH 07/23] Remove redecl of QStringList --- src/lanes.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lanes.h b/src/lanes.h index 85e1f66..af3e6d4 100644 --- a/src/lanes.h +++ b/src/lanes.h @@ -10,8 +10,6 @@ #include #include -class QStringList; - // // At any given time, the Lanes class represents a single revision (row) of the history graph. From bcb84cffea2e866e7248734b629a4f73773548d2 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 26 Apr 2025 19:02:00 -0400 Subject: [PATCH 08/23] FIX type mismatch in std::min --- src/listview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/listview.cpp b/src/listview.cpp index 3bf330e..7e81be7 100644 --- a/src/listview.cpp +++ b/src/listview.cpp @@ -330,7 +330,7 @@ void ListView::mouseReleaseEvent(QMouseEvent* e) { QPixmap ListView::pixmapFromSelection(const QStringList &revs, const QString &ref) const { - const int maxRows = 10; + const qsizetype maxRows = 10; const int dotdotRow = 5; QStyleOptionViewItem opt; opt.initFrom(this); // ListViewDelegate *lvd = dynamic_cast(itemDelegate()); From 9ae01de25a698dafc4dfb7a4fbc03c9bc21fc2ed Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 26 Apr 2025 19:03:00 -0400 Subject: [PATCH 09/23] QPoint::pos() to QPoint.position().toPoint() --- src/listview.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/listview.cpp b/src/listview.cpp index 7e81be7..cdbb4fb 100644 --- a/src/listview.cpp +++ b/src/listview.cpp @@ -520,9 +520,9 @@ void ListView::dragEnterEvent(QDragEnterEvent* e) { void ListView::dragMoveEvent(QDragMoveEvent* e) { // When getting here, dragEnterEvent already accepted the drag in general - SCRef targetRef = refNameAt(e->pos()); + SCRef targetRef = refNameAt(e->position().toPoint()); uint targetRefType = refTypeFromName(targetRef); - QModelIndex idx = indexAt(e->pos()); + QModelIndex idx = indexAt(e->position().toPoint()); SCRef targetSHA = sha(idx.row()); uint accepted_actions = DropInfo::PatchAction; // applying patches is always allowed DropInfo::Action action, default_action = DropInfo::PatchAction; @@ -622,9 +622,9 @@ void ListView::dropEvent(QDropEvent *e) { return; } - SCRef targetRef = refNameAt(e->pos()); + SCRef targetRef = refNameAt(e->position().toPoint()); // uint targetRefType = refTypeFromName(targetRef); - SCRef targetSHA = sha(indexAt(e->pos()).row()); + SCRef targetSHA = sha(indexAt(e->position().toPoint()).row()); switch(dropInfo->action) { case DropInfo::PatchAction: emit applyRevisions(dropInfo->shas, dropInfo->sourceRepo); From a7f2fd4b00c089b2b814c548520c66bfe22afd53 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 26 Apr 2025 19:03:42 -0400 Subject: [PATCH 10/23] QEvent::keyboardModifiers -> QEvent::modifiers --- src/listview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/listview.cpp b/src/listview.cpp index cdbb4fb..1833e01 100644 --- a/src/listview.cpp +++ b/src/listview.cpp @@ -567,7 +567,7 @@ void ListView::dragMoveEvent(QDragMoveEvent* e) { e->accept(); // check whether modifier keys enforce an action - switch (e->keyboardModifiers()) { + switch (e->modifiers()) { case Qt::ControlModifier: action = DropInfo::PatchAction; break; case Qt::ShiftModifier: action = DropInfo::RebaseAction; break; case Qt::AltModifier: action = DropInfo::MergeAction; break; From 879df641ad08e51e6a563f06b38abd96f3c1011a Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 26 Apr 2025 19:06:23 -0400 Subject: [PATCH 11/23] FIX compile error from bad use of regex wildcard --- src/listview.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/listview.cpp b/src/listview.cpp index 1833e01..d590c2a 100644 --- a/src/listview.cpp +++ b/src/listview.cpp @@ -1272,7 +1272,7 @@ bool ListViewProxy::filterAcceptsRow(int source_row, const QModelIndex&) const { int ListViewProxy::setFilter(bool isOn, bool h, SCRef fl, int cn, ShaSet* s) { - filter = QRegularExpression(fl, Qt::CaseInsensitive, QRegularExpression::Wildcard); + filter = QRegularExpression::fromWildcard(fl, Qt::CaseInsensitive); colNum = cn; if (s) shaSet = *s; From 609a24982097fb9615c9e3adc551bf67341e4815 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 1 May 2025 16:53:46 +0200 Subject: [PATCH 12/23] Fix use of QRegularExpression Note that there are 3 (three) places where QRegExp::setMinimal(true) could not be translated over for lack of a proper equivalent with user-provided patterns. --- src/git.cpp | 22 +++++++++++----------- src/inputdialog.cpp | 13 +++++++------ src/mainimpl.cpp | 6 ++---- src/patchcontent.cpp | 22 ++++++---------------- src/patchcontent.h | 3 +-- src/rangeselectimpl.cpp | 5 +++-- src/revdesc.cpp | 2 +- src/settingsimpl.cpp | 2 +- 8 files changed, 32 insertions(+), 43 deletions(-) diff --git a/src/git.cpp b/src/git.cpp index 5608e4c..cf83ebe 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -420,8 +420,7 @@ const QString Git::getTagMsg(SCRef sha) { if (!rf.tagMsg.isEmpty()) return rf.tagMsg; - QRegularExpression pgp("-----BEGIN PGP SIGNATURE*END PGP SIGNATURE-----", - Qt::CaseSensitive, QRegularExpression::Wildcard); + QRegularExpression pgp("-----BEGIN PGP SIGNATURE.*END PGP SIGNATURE-----", QRegularExpression::DotMatchesEverythingOption); if (!rf.tagObj.isEmpty()) { QString ro; @@ -1022,15 +1021,16 @@ const QString Git::colorMatch(SCRef txt, QRegularExpression& regExp) { QString text = qt4and5escaping(txt); - if (regExp.isEmpty()) + if (regExp.pattern().isEmpty()) return text; SCRef startCol(QString::fromLatin1("")); SCRef endCol(QString::fromLatin1("")); int pos = 0; - while ((pos = text.indexOf(regExp, pos)) != -1) { + QRegularExpressionMatch regExpMatch; + while ((pos = text.indexOf(regExp, pos, ®ExpMatch)) != -1) { - SCRef match(regExp.cap(0)); + SCRef match(regExpMatch.captured(0)); const QString coloredText(startCol + match + endCol); text.replace(pos, match.length(), coloredText); pos += coloredText.length(); @@ -1116,12 +1116,12 @@ const QString Git::getDesc(SCRef sha, QRegularExpression& shortLogRE, QRegularEx // sha if there isn't a leading trailing space or an open parenthesis and, // in that case, before the space must not be a ':' character. // It's an ugly heuristic, but seems to work in most cases. - QRegularExpression reSHA("..[0-9a-f]{21,40}|[^:][\\s(][0-9a-f]{6,20}", Qt::CaseInsensitive); - reSHA.setMinimal(false); + QRegularExpression reSHA("..[0-9a-f]{21,40}|[^:][\\s(][0-9a-f]{6,20}", QRegularExpression::CaseInsensitiveOption); int pos = 0; - while ((pos = text.indexOf(reSHA, pos)) != -1) { + QRegularExpressionMatch match; + while ((pos = text.indexOf(reSHA, pos, &match)) != -1) { - SCRef ref = reSHA.cap(0).mid(2); + SCRef ref = match.captured(0).mid(2); const Rev* r = (ref.length() == 40 ? revLookup(ref) : revLookup(getRefSha(ref))); if (r && r->sha() != ZERO_SHA_RAW) { QString slog(r->shortLog()); @@ -1134,7 +1134,7 @@ const QString Git::getDesc(SCRef sha, QRegularExpression& shortLogRE, QRegularEx text.replace(pos + 2, ref.length(), link); pos += link.length(); } else - pos += reSHA.cap(0).length(); + pos += match.captured(0).length(); } return text; } @@ -1293,7 +1293,7 @@ const QString Git::getNewestFileName(SCList branches, SCRef fileName) { void Git::getFileFilter(SCRef path, ShaSet& shaSet) const { shaSet.clear(); - QRegularExpression rx(path, Qt::CaseInsensitive, QRegularExpression::Wildcard); + QRegularExpression rx = QRegularExpression::fromWildcard(path, Qt::CaseInsensitive); FOREACH (ShaVect, it, revData->revOrder) { if (!revsFiles.contains(*it)) diff --git a/src/inputdialog.cpp b/src/inputdialog.cpp index ec15379..fe71b47 100644 --- a/src/inputdialog.cpp +++ b/src/inputdialog.cpp @@ -92,11 +92,12 @@ InputDialog::InputDialog(const QString &cmd, const VariableMap &variables, QRegularExpression re("%(([a-z_]+)([[]([a-z ,]+)[]])?:)?([^%=]+)(=[^%]+)?%"); int start = 0; int row = 0; - while ((start = re.indexIn(cmd, start)) != -1) { - const QString type = re.cap(2); - const QStringList opts = re.cap(4).split(',', QGIT_SPLITBEHAVIOR(SkipEmptyParts)); - const QString name = re.cap(5); - const QString value = re.cap(6).mid(1); + QRegularExpressionMatch match; + while ((start = cmd.indexOf(re, start, &match)) != -1) { + const QString type = match.captured(2); + const QStringList opts = match.captured(4).split(',', QGIT_SPLITBEHAVIOR(SkipEmptyParts)); + const QString name = match.captured(5); + const QString value = match.captured(6).mid(1); if (widgets.count(name)) { // widget already created if (!type.isEmpty()) dbs("token must not be redefined: " + name); continue; @@ -104,7 +105,7 @@ InputDialog::InputDialog(const QString &cmd, const VariableMap &variables, WidgetItemPtr item (new WidgetItem()); item->start = start; - item->end = start = start + re.matchedLength(); + item->end = start = start + match.capturedLength(); if (type == "combobox") { QComboBox *w = new QComboBox(this); diff --git a/src/mainimpl.cpp b/src/mainimpl.cpp index d4f9881..3a9aa49 100644 --- a/src/mainimpl.cpp +++ b/src/mainimpl.cpp @@ -74,10 +74,8 @@ MainImpl::MainImpl(SCRef cd, QWidget* p) : QMainWindow(p) { setRepositoryBusy = false; // init filter match highlighters - shortLogRE.setMinimal(true); - shortLogRE.setCaseSensitivity(Qt::CaseInsensitive); - longLogRE.setMinimal(true); - longLogRE.setCaseSensitivity(Qt::CaseInsensitive); + shortLogRE.setPatternOptions(QRegularExpression::CaseInsensitiveOption); + longLogRE.setPatternOptions(QRegularExpression::CaseInsensitiveOption); // set-up standard revisions and files list font QSettings settings; diff --git a/src/patchcontent.cpp b/src/patchcontent.cpp index 831d950..3fab645 100644 --- a/src/patchcontent.cpp +++ b/src/patchcontent.cpp @@ -96,8 +96,7 @@ PatchContent::PatchContent(QWidget* parent) : QTextEdit(parent) { diffLoaded = seekTarget = false; curFilter = prevFilter = VIEW_ALL; - pickAxeRE.setMinimal(true); - pickAxeRE.setCaseSensitivity(Qt::CaseInsensitive); + pickAxeRE.setPatternOptions(QRegularExpression::CaseInsensitiveOption); setFont(QGit::TYPE_WRITER_FONT); diffHighlighter = new DiffHighlighter(this); @@ -316,25 +315,18 @@ void PatchContent::procFinished() { } } -int PatchContent::doSearch(SCRef txt, int pos) { - - if (isRegExp) - return txt.indexOf(pickAxeRE, pos); - - return txt.indexOf(pickAxeRE.pattern(), pos, Qt::CaseInsensitive); -} - bool PatchContent::computeMatches() { matches.clear(); - if (pickAxeRE.isEmpty()) + if (pickAxeRE.pattern().isEmpty()) return false; SCRef txt = toPlainText(); int pos, lastPos = 0, lastPara = 0; // must be at the end to catch patterns across more the one chunk - while ((pos = doSearch(txt, lastPos)) != -1) { + QRegularExpressionMatch match; + while ((pos = txt.indexOf(pickAxeRE, pos, &match)) != -1) { matches.append(MatchSelection()); MatchSelection& s = matches.last(); @@ -344,7 +336,7 @@ bool PatchContent::computeMatches() { s.indexFrom = pos - txt.lastIndexOf('\n', pos) - 1; // index starts from 0 lastPos = pos; - pos += (isRegExp ? pickAxeRE.matchedLength() : pickAxeRE.pattern().length()); + pos += match.capturedLength(); pos--; s.paraTo = s.paraFrom + txt.mid(lastPos, pos - lastPos).count('\n'); @@ -370,9 +362,7 @@ bool PatchContent::getMatch(int para, int* indexFrom, int* indexTo) { } void PatchContent::on_highlightPatch(const QString& exp, bool re) { - - pickAxeRE.setPattern(exp); - isRegExp = re; + pickAxeRE.setPattern(re ? exp : QRegularExpression::escape(exp)); if (diffLoaded) procFinished(); } diff --git a/src/patchcontent.h b/src/patchcontent.h index ed3522a..df9ff7d 100644 --- a/src/patchcontent.h +++ b/src/patchcontent.h @@ -8,6 +8,7 @@ #define PATCHCONTENT_H #include +#include #include #include #include "common.h" @@ -57,7 +58,6 @@ public slots: int positionToLineNum(int pos); int topToLineNum(); void saveRestoreSizes(bool startup = false); - int doSearch(const QString& txt, int pos); bool computeMatches(); bool getMatch(int para, int* indexFrom, int* indexTo); void centerMatch(int id = 0); @@ -70,7 +70,6 @@ public slots: bool diffLoaded; QByteArray patchRowData; QString halfLine; - bool isRegExp; QRegularExpression pickAxeRE; QString target; bool seekTarget; diff --git a/src/rangeselectimpl.cpp b/src/rangeselectimpl.cpp index 9fdfe0c..a60fccd 100644 --- a/src/rangeselectimpl.cpp +++ b/src/rangeselectimpl.cpp @@ -102,8 +102,9 @@ void RangeSelectImpl::orderRefs(const QStringList& src, QStringList& dst) { QString tmpStr(*it); - if (re.indexIn(tmpStr) != -1) - tmpStr.insert(re.pos(1), rcMark); + QRegularExpressionMatch match; + if (tmpStr.indexOf(re, 0, &match) != -1) + tmpStr.insert(match.capturedStart(1), rcMark); else tmpStr += noRcMark; diff --git a/src/revdesc.cpp b/src/revdesc.cpp index b99b59b..185d2dd 100644 --- a/src/revdesc.cpp +++ b/src/revdesc.cpp @@ -22,7 +22,7 @@ RevDesc::RevDesc(QWidget* p) : QTextBrowser(p), d(NULL) { void RevDesc::on_anchorClicked(const QUrl& link) { - QRegularExpression re("[0-9a-f]{40}", Qt::CaseInsensitive); + QRegularExpression re("[0-9a-f]{40}", QRegularExpression::CaseInsensitiveOption); if (re.match(link.toString()).hasMatch()) { setSource(QUrl()); // override default navigation behavior diff --git a/src/settingsimpl.cpp b/src/settingsimpl.cpp index 430c26a..6ed65d6 100644 --- a/src/settingsimpl.cpp +++ b/src/settingsimpl.cpp @@ -212,7 +212,7 @@ void SettingsImpl::setupCodecsCombo() { return; } const QString curCodec(tc != 0 ? tc->name() : "Latin1"); - QRegularExpression re("*" + curCodec + "*", Qt::CaseInsensitive, QRegularExpression::Wildcard); + QRegularExpression re("^.*" + QRegularExpression::escape(curCodec) + ".*$", QRegularExpression::CaseInsensitiveOption); int idx = codecs.indexOf(re); if (idx == -1) { dbp("ASSERT: codec <%1> not available, using local codec", curCodec); From 07decc2d722b84efdb3b820a90c24dff56042e38 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 1 May 2025 17:43:25 +0200 Subject: [PATCH 13/23] Resolve use of QDateTime::setTime_t for Qt 6 --- src/git.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/git.cpp b/src/git.cpp index cf83ebe..08d4972 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -1663,7 +1663,7 @@ const QString Git::getLocalDate(SCRef gitDate) { // cache miss if (localDate.isEmpty()) { static QDateTime d; - d.setTime_t(gitDate.toUInt()); + d.setSecsSinceEpoch(gitDate.toUInt()); localDate = QLocale::system().toString(d, QLocale::ShortFormat); // save to cache From a4e132fb81a5ff7e186deee51c324b0ee3525aa1 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 1 May 2025 17:56:21 +0200 Subject: [PATCH 14/23] build.yaml: Migrate CI from Qt 5 to Qt 6 --- .github/workflows/build.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e987cfd..ffd5950 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -32,7 +32,9 @@ jobs: sudo apt-get install --yes --no-install-recommends \ build-essential \ cmake \ - qtbase5-dev + libgl1-mesa-dev \ + libglx-dev \ + qt6-base-dev - name: 'Checkout Git branch' uses: actions/checkout@v2.0.0 From 4d40ad9412687a72f428a1b5aa0075fae82e5aed Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 1 May 2025 18:08:16 +0200 Subject: [PATCH 15/23] CMake: Lower minimum Qt version to 6.2.4 for Ubuntu 22.04 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2a0fa1..0dfd615 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -set(QT_MIN_VERSION 6.6.0) +set(QT_MIN_VERSION 6.2.4) find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets) add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) From 399d1ebd73521801aec93bc4578a30cb3d01d76c Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 1 May 2025 18:07:59 +0200 Subject: [PATCH 16/23] Add Core5Compat to allow use of QTextCodec with Qt 6 --- .github/workflows/build.yaml | 1 + CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ffd5950..82b1179 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -34,6 +34,7 @@ jobs: cmake \ libgl1-mesa-dev \ libglx-dev \ + libqt6core5compat6-dev \ qt6-base-dev - name: 'Checkout Git branch' diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dfd615..f28b45d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) set(QT_MIN_VERSION 6.2.4) -find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets) +find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets Core5Compat) add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) include_directories( @@ -81,7 +81,7 @@ set(RESOURCE_FILES qt6_add_resources(RC_SRCS ${RESOURCE_FILES}) add_executable(qgit ${CPP_SOURCES} ${UIS_HDRS} ${RC_SRCS}) -target_link_libraries(qgit Qt6::Widgets) +target_link_libraries(qgit Qt6::Widgets Qt6::Core5Compat) install(TARGETS qgit DESTINATION bin) From 42e55b7261bf3cbb919428a1274daa8817026ef1 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Fri, 2 May 2025 23:45:09 -0400 Subject: [PATCH 17/23] Use the new QMessageBox API --> avoids deprecation warnings at compilation --- src/consoleimpl.cpp | 15 ++++++++++----- src/mainimpl.cpp | 44 ++++++++++++++++++++++++++++++++------------ 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/consoleimpl.cpp b/src/consoleimpl.cpp index 7d1d7ea..c59f004 100644 --- a/src/consoleimpl.cpp +++ b/src/consoleimpl.cpp @@ -46,14 +46,19 @@ void ConsoleImpl::pushButtonTerminate_clicked() { void ConsoleImpl::closeEvent(QCloseEvent* ce) { - if (proc && proc->state() == QProcess::Running) - if (QMessageBox::question(this, "Action output window - QGit", - "Action is still running.\nAre you sure you want to close " - "the window and leave the action running in background?", - "&Yes", "&No", QString(), 1, 1) == 1) { + if (proc && proc->state() == QProcess::Running) { + QMessageBox q(QMessageBox::Question, + "Action output window - QGit", + "Action is still running.\nAre you sure you want to close " + "the window and leave the action running in background?", + QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, + this + ); + if (q.exec() == QMessageBox::StandardButton::No) { ce->ignore(); return; } + } if (QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); diff --git a/src/mainimpl.cpp b/src/mainimpl.cpp index 3a9aa49..4455c62 100644 --- a/src/mainimpl.cpp +++ b/src/mainimpl.cpp @@ -1615,16 +1615,30 @@ bool MainImpl::askApplyPatchParameters(bool* workDirOnly, bool* fold) { int ret = 0; if (!git->isStGITStack()) { - ret = QMessageBox::question(this, "Apply Patch", - "Do you want to commit or just to apply changes to " - "working directory?", "&Cancel", "&Working directory", "&Commit", 0, 0); - *workDirOnly = (ret == 1); + QMessageBox ret(QMessageBox::Question, + "Apply Patch", + "Do you want to commit or just to apply changes to " + "working directory?", + {}, this); + ret.addButton("&Cancel", QMessageBox::ButtonRole::RejectRole); + QAbstractButton* wdbtn = ret.addButton( + "&Working directory", QMessageBox::ButtonRole::AcceptRole); + ret.addButton("Commm&it", QMessageBox::ButtonRole::AcceptRole); + ret.exec(); + *workDirOnly = (ret.clickedButton() == wdbtn); *fold = false; } else { - ret = QMessageBox::question(this, "Apply Patch", "Do you want to " - "import or fold the patch?", "&Cancel", "&Fold", "&Import", 0, 0); + QMessageBox ret(QMessageBox::Question, + "Apply Patch", + "Do you want to import or fold the patch?", + {}, this); + ret.addButton("&Cancel", QMessageBox::ButtonRole::RejectRole); + QAbstractButton* fbtn = ret.addButton( + "&Fold", QMessageBox::ButtonRole::AcceptRole); + ret.addButton("&Import", QMessageBox::ButtonRole::AcceptRole); + ret.exec(); *workDirOnly = false; - *fold = (ret == 1); + *fold = (ret.clickedButton() == fbtn); } return (ret != 0); } @@ -2105,13 +2119,19 @@ void MainImpl::ActFindNext_activated() { return; if (endOfDocument) { - QMessageBox::warning(this, "Find text - QGit", "Text \"" + - textToFind + "\" not found!", QMessageBox::Ok, 0); + QMessageBox(QMessageBox::Warning, + "Find text - QGit", + "Text \"" + textToFind + "\" not found!", + QMessageBox::StandardButton::Ok, + this); return; } - if (QMessageBox::question(this, "Find text - QGit", "End of document " - "reached\n\nDo you want to continue from beginning?", QMessageBox::Yes, - QMessageBox::No | QMessageBox::Escape) == QMessageBox::No) + QMessageBox q(QMessageBox::Question, + "Find text - QGit", + "End of document reached\n\nDo you want to continue from beginning?", + QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No, + this); + if (q.exec() == QMessageBox::No) return; endOfDocument = true; From 22990c71d2dc86c12ff8cdad6141d5d296071ff6 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Fri, 2 May 2025 23:46:16 -0400 Subject: [PATCH 18/23] Avoid incorrect type conversion warnings the method in iterators is now a (new size of ) --- src/git.cpp | 2 +- src/mainimpl.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/git.cpp b/src/git.cpp index 08d4972..5c2bc14 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -2432,7 +2432,7 @@ void Git::on_loaded(FileHistory* fh, ulong byteSize, int loadTime, ulong kb = byteSize / 1024; double mbs = (double)byteSize / fh->loadTime / 1000; QString tmp; - tmp.asprintf("Loaded %i revisions (%li KB), " + tmp.asprintf("Loaded %lli revisions (%li KB), " "time elapsed: %i ms (%.2f MB/s)", fh->revs.count(), kb, fh->loadTime, mbs); diff --git a/src/mainimpl.cpp b/src/mainimpl.cpp index 4455c62..aed227b 100644 --- a/src/mainimpl.cpp +++ b/src/mainimpl.cpp @@ -758,7 +758,7 @@ void MainImpl::applyRevisions(SCList remoteRevs, SCRef remoteRepo) { dr.refresh(); if (dr.count() != 1) { - qDebug("ASSERT in on_droppedRevisions: found %i files " + qDebug("ASSERT in on_droppedRevisions: found %lli files " "in %s", dr.count(), qPrintable(dr.absolutePath())); break; } From 5d539e3b1913c1f9bd452e519312828899bc3ccb Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Fri, 2 May 2025 23:47:30 -0400 Subject: [PATCH 19/23] {QVariant}.type() -> {QVariant}.metaType().id() --- src/inputdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inputdialog.cpp b/src/inputdialog.cpp index fe71b47..5162d67 100644 --- a/src/inputdialog.cpp +++ b/src/inputdialog.cpp @@ -206,7 +206,7 @@ QString InputDialog::replace(const VariableMap &variables) const } for (VariableMap::const_iterator it=variables.begin(), end=variables.end(); it != end; ++it) { QString token = "$" + it.key(); - QString val = it.value().type() == QVariant::StringList ? it.value().toStringList().join(" ") + QString val = it.value().metaType().id() == QMetaType::QStringList ? it.value().toStringList().join(" ") : it.value().toString(); result.replace(token, val); } From 0e6240acf5bb7fd9b7b2bb62bf36927a62956674 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Fri, 2 May 2025 23:48:18 -0400 Subject: [PATCH 20/23] UseHighDpiPixmaps is now the default (remove line to to remove warning) --- src/qgit.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qgit.cpp b/src/qgit.cpp index 26c8d59..c8d3079 100644 --- a/src/qgit.cpp +++ b/src/qgit.cpp @@ -21,7 +21,6 @@ using namespace QGit; int main(int argc, char* argv[]) { QApplication app(argc, argv); - app.setAttribute(Qt::AA_UseHighDpiPixmaps, true); QCoreApplication::setOrganizationName(ORG_KEY); QCoreApplication::setApplicationName(APP_KEY); From 459998e70af413783da25e59e603ed8e5fa3cf00 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sat, 3 May 2025 00:04:05 -0400 Subject: [PATCH 21/23] Update Sebastian's copyright years --- src/mainimpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mainimpl.cpp b/src/mainimpl.cpp index fd12bb3..f862c64 100644 --- a/src/mainimpl.cpp +++ b/src/mainimpl.cpp @@ -2234,7 +2234,7 @@ void MainImpl::ActAbout_activated() { "2016-2018 Robert Haschke, " "2018-2024 Filipe Rinaldi, " "2018 Mateusz Balbus, " - "2019-2022 Sebastian Pipping, " + "2019-2025 Sebastian Pipping, " "2019-2020 Matthias von Faber, " "2019 Kevin Kofler, " "2020 Matthieu Muffato, " From c14304e904cba226ce871a5b410b3da817a5fce6 Mon Sep 17 00:00:00 2001 From: Cristian Tibirna Date: Sun, 4 May 2025 21:29:22 -0400 Subject: [PATCH 22/23] Restore ability to compile w/ Qt5 --- CMakeLists.txt | 54 +++++++++++++++++++++++++++++++++++++++------ src/git.cpp | 6 ++++- src/inputdialog.cpp | 10 +++++++-- src/listview.cpp | 44 ++++++++++++++++++++++++++++++++---- src/listview.h | 4 ++++ 5 files changed, 104 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f28b45d..1cf0ebb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,10 +17,51 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -set(QT_MIN_VERSION 6.2.4) -find_package(Qt6 ${QT_MIN_VERSION} REQUIRED COMPONENTS Core Gui Widgets Core5Compat) -add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) +# Select the Qt major version and its dependencies\ +set(QT_PACKAGE "Qt6" CACHE STRING "Major Qt version") +#set_property(CACHE QT_PACKAGE PROPERTY STRINGS "Qt6" "Qt5" "Qt4") +set_property(CACHE QT_PACKAGE PROPERTY STRINGS "Qt6" "Qt5") + + +find_package(QT NAMES ${QT_PACKAGE} REQUIRED) +set(QT Qt${QT_VERSION_MAJOR}) +message(STATUS "Using ${QT}") + +if (QT_VERSION_MAJOR EQUAL 6) + set(QT_MIN_VERSION 6.2.4) + set(QT_MODULES Core Gui Widgets Core5Compat) + set(QT_LIBRARIES Qt6::Widgets Qt6::Core5Compat) +elseif (QT_VERSION_MAJOR EQUAL 5) + set(QT_MIN_VERSION 5.11.0) + set(QT_MODULES Core Gui Widgets) + set(QT_LIBRARIES Qt5::Widgets) +elseif (QT_MAJOR_VERSION EQUAL 4) + set(QT_MODULES QtCore QtGui) + include(${QT_USE_FILE}) +endif() + +find_package(${QT} ${QT_MIN_VERSION} REQUIRED COMPONENTS ${QT_MODULES}) + +if (QT_VERSION VERSION_LESS 5.15) + if (QT_VERSION_MAJOR EQUAL 4) + macro(qt_wrap_ui) + qt4_wrap_ui(${ARGN}) + endmacro() + macro(qt_add_resources) + qt4_add_resources(${ARGN}) + endmacro() + elseif(QT_VERSION_MAJOR EQUAL 5) + macro(qt_wrap_ui) + qt5_wrap_ui(${ARGN}) + endmacro() + macro(qt_add_resources) + qt5_add_resources(${ARGN}) + endmacro() + endif() +endif() + +# Sources include_directories( ${CMAKE_SOURCE_DIR}/src ) @@ -58,7 +99,7 @@ set(CPP_SOURCES ) # UIS_HDRS will be used later in add_executable -qt6_wrap_ui(UIS_HDRS +qt_wrap_ui(UIS_HDRS src/commit.ui src/console.ui src/customaction.ui @@ -78,11 +119,10 @@ set(RESOURCE_FILES # this command will generate rules that will run rcc on all files from SAMPLE_RCS # in result SAMPLE_RC_SRCS variable will contain paths to files produced by rcc -qt6_add_resources(RC_SRCS ${RESOURCE_FILES}) +qt_add_resources(RC_SRCS ${RESOURCE_FILES}) add_executable(qgit ${CPP_SOURCES} ${UIS_HDRS} ${RC_SRCS}) -target_link_libraries(qgit Qt6::Widgets Qt6::Core5Compat) - +target_link_libraries(qgit ${QT_LIBRARIES}) install(TARGETS qgit DESTINATION bin) diff --git a/src/git.cpp b/src/git.cpp index 5c2bc14..5440e3d 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -1293,7 +1293,11 @@ const QString Git::getNewestFileName(SCList branches, SCRef fileName) { void Git::getFileFilter(SCRef path, ShaSet& shaSet) const { shaSet.clear(); - QRegularExpression rx = QRegularExpression::fromWildcard(path, Qt::CaseInsensitive); +#if QT_VERSION >= 0x060000 + QRegularExpression rx = QRegularExpression::fromWildcard(path, Qt::CaseInsensitive); +#else + QRegExp rx(path, Qt::CaseInsensitive, QRegExp::Wildcard); +#endif FOREACH (ShaVect, it, revData->revOrder) { if (!revsFiles.contains(*it)) diff --git a/src/inputdialog.cpp b/src/inputdialog.cpp index 5162d67..9b6e449 100644 --- a/src/inputdialog.cpp +++ b/src/inputdialog.cpp @@ -206,8 +206,14 @@ QString InputDialog::replace(const VariableMap &variables) const } for (VariableMap::const_iterator it=variables.begin(), end=variables.end(); it != end; ++it) { QString token = "$" + it.key(); - QString val = it.value().metaType().id() == QMetaType::QStringList ? it.value().toStringList().join(" ") - : it.value().toString(); + QString val = +#if QT_VERSION >= 0x060000 + it.value().metaType().id() == QMetaType::QStringList ? +#else + it.value().type() == QVariant::StringList ? +#endif + it.value().toStringList().join(" ") + : it.value().toString(); result.replace(token, val); } return result; diff --git a/src/listview.cpp b/src/listview.cpp index d590c2a..a090601 100644 --- a/src/listview.cpp +++ b/src/listview.cpp @@ -330,7 +330,11 @@ void ListView::mouseReleaseEvent(QMouseEvent* e) { QPixmap ListView::pixmapFromSelection(const QStringList &revs, const QString &ref) const { +#if QT_VERSION >= 0x060000 const qsizetype maxRows = 10; +#else + const int maxRows = 10; +#endif const int dotdotRow = 5; QStyleOptionViewItem opt; opt.initFrom(this); // ListViewDelegate *lvd = dynamic_cast(itemDelegate()); @@ -520,9 +524,21 @@ void ListView::dragEnterEvent(QDragEnterEvent* e) { void ListView::dragMoveEvent(QDragMoveEvent* e) { // When getting here, dragEnterEvent already accepted the drag in general - SCRef targetRef = refNameAt(e->position().toPoint()); + SCRef targetRef = refNameAt(e-> +#if QT_VERSION >= 0x060000 + position().toPoint() +#else + pos() +#endif + ); uint targetRefType = refTypeFromName(targetRef); - QModelIndex idx = indexAt(e->position().toPoint()); + QModelIndex idx = indexAt(e-> +#if QT_VERSION >= 0x060000 + position().toPoint() +#else + pos() +#endif + ); SCRef targetSHA = sha(idx.row()); uint accepted_actions = DropInfo::PatchAction; // applying patches is always allowed DropInfo::Action action, default_action = DropInfo::PatchAction; @@ -567,7 +583,11 @@ void ListView::dragMoveEvent(QDragMoveEvent* e) { e->accept(); // check whether modifier keys enforce an action +#if QT_VERSION >= 0x060000 switch (e->modifiers()) { +#else + switch (e->keyboardModifiers()) { +#endif case Qt::ControlModifier: action = DropInfo::PatchAction; break; case Qt::ShiftModifier: action = DropInfo::RebaseAction; break; case Qt::AltModifier: action = DropInfo::MergeAction; break; @@ -622,9 +642,21 @@ void ListView::dropEvent(QDropEvent *e) { return; } - SCRef targetRef = refNameAt(e->position().toPoint()); + SCRef targetRef = refNameAt(e-> +#if QT_VERSION >= 0x060000 + position().toPoint() +#else + pos() +#endif + ); // uint targetRefType = refTypeFromName(targetRef); - SCRef targetSHA = sha(indexAt(e->position().toPoint()).row()); + SCRef targetSHA = sha(indexAt(e-> +#if QT_VERSION >= 0x060000 + position().toPoint() +#else + pos() +#endif + ).row()); switch(dropInfo->action) { case DropInfo::PatchAction: emit applyRevisions(dropInfo->shas, dropInfo->sourceRepo); @@ -1272,7 +1304,11 @@ bool ListViewProxy::filterAcceptsRow(int source_row, const QModelIndex&) const { int ListViewProxy::setFilter(bool isOn, bool h, SCRef fl, int cn, ShaSet* s) { +#if QT_VERSION >= 0x060000 filter = QRegularExpression::fromWildcard(fl, Qt::CaseInsensitive); +#else + filter = QRegExp(fl, Qt::CaseInsensitive, QRegExp::Wildcard); +#endif colNum = cn; if (s) shaSet = *s; diff --git a/src/listview.h b/src/listview.h index 00a857a..2b8dd3f 100644 --- a/src/listview.h +++ b/src/listview.h @@ -139,7 +139,11 @@ Q_OBJECT Domain* d; Git* git; bool isHighLight; +#if QT_VERSION >= 0x060000 QRegularExpression filter; +#else + QRegExp filter; +#endif int colNum; ShaSet shaSet; }; From 20c8d013fac5a6de8edb32583945bcaabe058405 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Mon, 7 Jul 2025 11:58:09 +0200 Subject: [PATCH 23/23] build.yaml: Build with both Qt 5 and Qt 6 --- .github/workflows/build.yaml | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 82b1179..6193e2d 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -22,30 +22,39 @@ on: jobs: build: - name: Build (Linux, Ubuntu 22.04 LTS) + name: Build (Linux, Qt ${{ matrix.qt_major }}, Ubuntu 22.04 LTS) runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + include: + - qt_major: 5 + packages: qtbase5-dev + - qt_major: 6 + packages: libgl1-mesa-dev libglx-dev libqt6core5compat6-dev qt6-base-dev steps: - name: 'Install build dependencies' + env: + packages: ${{ matrix.packages }} run: |- set -e sudo apt-get update sudo apt-get install --yes --no-install-recommends \ build-essential \ cmake \ - libgl1-mesa-dev \ - libglx-dev \ - libqt6core5compat6-dev \ - qt6-base-dev + ${packages} - name: 'Checkout Git branch' uses: actions/checkout@v2.0.0 - name: 'Configure' + env: + qt_major: ${{ matrix.qt_major }} run: |- set -e mkdir build cd build - cmake .. + cmake -DQT_PACKAGE="Qt${qt_major}" .. - name: 'Build' run: |-