diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 3c6941865e..787d59e725 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -903,7 +903,11 @@ std::string Document::getTransientDirectoryName(const std::string& uuid, const s // Create a directory name of the form: {ExeName}_Doc_{UUID}_{HASH}_{PID} std::stringstream s; QCryptographicHash hash(QCryptographicHash::Sha1); +#if QT_VERSION < QT_VERSION_CHECK(6,3,0) hash.addData(filename.c_str(), filename.size()); +#else + hash.addData(QByteArrayView(filename.c_str(), filename.size())); +#endif s << App::Application::getUserCachePath() << App::Application::getExecutableName() << "_Doc_" << uuid << "_" << hash.result().toHex().left(6).constData() diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp index 8907d05a47..02cbcf0704 100644 --- a/src/Gui/Action.cpp +++ b/src/Gui/Action.cpp @@ -1050,7 +1050,7 @@ void RecentMacrosAction::setFiles(const QStringList& files) // Raise a single warning no matter how many conflicts if (!existingCommands.isEmpty()) { auto msgMain = QStringLiteral("Recent macros : keyboard shortcut(s)"); - for (int index = 0; index < accel_col.count(); index++) { + for (int index = 0; index < accel_col.size(); index++) { msgMain += QStringLiteral(" %1").arg(accel_col[index]); } msgMain += QStringLiteral(" disabled because of conflicts with"); diff --git a/src/Gui/CallTips.cpp b/src/Gui/CallTips.cpp index 40e11c2ace..45fe10a281 100644 --- a/src/Gui/CallTips.cpp +++ b/src/Gui/CallTips.cpp @@ -688,7 +688,7 @@ void CallTipsList::callTipItemActivated(QListWidgetItem *item) if (!sel.isEmpty()) { // in case the cursor moved too far on the right side const QChar underscore = QLatin1Char('_'); - const QChar ch = sel.at(sel.count()-1); + const QChar ch = sel.at(sel.size()-1); if (!ch.isLetterOrNumber() && ch != underscore) cursor.movePosition(QTextCursor::Left, QTextCursor::KeepAnchor); } @@ -734,16 +734,16 @@ QString CallTipsList::stripWhiteSpace(const QString& str) const int minspace=INT_MAX; int line=0; for (QStringList::iterator it = lines.begin(); it != lines.end(); ++it, ++line) { - if (it->count() > 0 && line > 0) { + if (it->size() > 0 && line > 0) { int space = 0; - for (int i=0; icount(); i++) { + for (int i=0; isize(); i++) { if ((*it)[i] == QLatin1Char('\t')) space++; else break; } - if (it->count() > space) + if (it->size() > space) minspace = std::min(minspace, space); } } @@ -756,7 +756,7 @@ QString CallTipsList::stripWhiteSpace(const QString& str) const if (line == 0 && !it->isEmpty()) { strippedlines << *it; } - else if (it->count() > 0 && line > 0) { + else if (it->size() > 0 && line > 0) { strippedlines << it->mid(minspace); } } diff --git a/src/Gui/DlgToolbarsImp.cpp b/src/Gui/DlgToolbarsImp.cpp index 15a4634b05..b597af5a97 100644 --- a/src/Gui/DlgToolbarsImp.cpp +++ b/src/Gui/DlgToolbarsImp.cpp @@ -625,7 +625,11 @@ void DlgCustomToolbarsImp::renameCustomToolbar(const QString& old_name, const QS QList DlgCustomToolbarsImp::getActionGroup(QAction* action) { QList group; +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QList widgets = action->associatedWidgets(); +#else + QList widgets = action->associatedObjects(); +#endif for (const auto & widget : widgets) { auto tb = qobject_cast(widget); if (tb) { @@ -642,7 +646,11 @@ QList DlgCustomToolbarsImp::getActionGroup(QAction* action) void DlgCustomToolbarsImp::setActionGroup(QAction* action, const QList& group) { // See also ActionGroup::addTo() +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QList widgets = action->associatedWidgets(); +#else + QList widgets = action->associatedObjects(); +#endif for (const auto & widget : widgets) { auto tb = qobject_cast(widget); if (tb) { diff --git a/src/Gui/PythonConsole.cpp b/src/Gui/PythonConsole.cpp index 42c053fa01..8a7e73cee9 100644 --- a/src/Gui/PythonConsole.cpp +++ b/src/Gui/PythonConsole.cpp @@ -992,7 +992,13 @@ void PythonConsole::mouseReleaseEvent( QMouseEvent *e ) // Now we must amend the received event and pass forward. As e->setLocalPos() is only // available in Qt>=5.8, let's stop the original event propagation and generate a fake event // with corrected pointer position (inside the prompt line of the widget) - QMouseEvent newEv(e->type(), QPoint(newPos.x(),newPos.y()), e->button(), e->buttons(), e->modifiers()); +#if QT_VERSION < QT_VERSION_CHECK(6,4,0) + QMouseEvent newEv(e->type(), QPoint(newPos.x(),newPos.y()), + e->button(), e->buttons(), e->modifiers()); +#else + QMouseEvent newEv(e->type(), QPoint(newPos.x(),newPos.y()), e->globalPosition(), + e->button(), e->buttons(), e->modifiers()); +#endif e->accept(); QCoreApplication::sendEvent(this->viewport(), &newEv); return; @@ -1318,7 +1324,8 @@ void PythonConsole::contextMenuEvent ( QContextMenuEvent * e ) QAction *a; bool mayPasteHere = cursorBeyond( this->textCursor(), this->inputBegin() ); - a = menu.addAction(tr("&Copy"), this, &PythonConsole::copy, QKeySequence(QString::fromLatin1("CTRL+C"))); + a = menu.addAction(tr("&Copy"), this, &PythonConsole::copy); + a->setShortcut(QKeySequence(QString::fromLatin1("CTRL+C"))); a->setEnabled(textCursor().hasSelection()); a = menu.addAction(tr("&Copy command"), this, &PythonConsole::onCopyCommand); @@ -1337,11 +1344,13 @@ void PythonConsole::contextMenuEvent ( QContextMenuEvent * e ) menu.addSeparator(); - a = menu.addAction(tr("&Paste"), this, &PythonConsole::paste, QKeySequence(QString::fromLatin1("CTRL+V"))); + a = menu.addAction(tr("&Paste"), this, &PythonConsole::paste); + a->setShortcut(QKeySequence(QString::fromLatin1("CTRL+V"))); const QMimeData *md = QApplication::clipboard()->mimeData(); a->setEnabled( mayPasteHere && md && canInsertFromMimeData(md)); - a = menu.addAction(tr("Select All"), this, &PythonConsole::selectAll, QKeySequence(QString::fromLatin1("CTRL+A"))); + a = menu.addAction(tr("Select All"), this, &PythonConsole::selectAll); + a->setShortcut(QKeySequence(QString::fromLatin1("CTRL+A"))); a->setEnabled(!document()->isEmpty()); a = menu.addAction(tr("Clear console"), this, &PythonConsole::onClearConsole); diff --git a/src/Gui/PythonEditor.cpp b/src/Gui/PythonEditor.cpp index fd63da8ef2..de015145aa 100644 --- a/src/Gui/PythonEditor.cpp +++ b/src/Gui/PythonEditor.cpp @@ -150,8 +150,10 @@ void PythonEditor::contextMenuEvent ( QContextMenuEvent * e ) QMenu* menu = createStandardContextMenu(); if (!isReadOnly()) { menu->addSeparator(); - menu->addAction( tr("Comment"), this, &PythonEditor::onComment, QKeySequence(QString::fromLatin1("ALT+C"))); - menu->addAction( tr("Uncomment"), this, &PythonEditor::onUncomment, QKeySequence(QString::fromLatin1("ALT+U"))); + QAction* comment = menu->addAction( tr("Comment"), this, &PythonEditor::onComment); + comment->setShortcut(QKeySequence(QString::fromLatin1("ALT+C"))); + QAction* uncomment = menu->addAction( tr("Uncomment"), this, &PythonEditor::onUncomment); + uncomment->setShortcut(QKeySequence(QString::fromLatin1("ALT+U"))); } menu->exec(e->globalPos()); diff --git a/src/Gui/ReportView.cpp b/src/Gui/ReportView.cpp index 27947f2a5f..e5d349b717 100644 --- a/src/Gui/ReportView.cpp +++ b/src/Gui/ReportView.cpp @@ -653,7 +653,8 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e ) // Use Qt's internal translation of the Copy & Select All commands const char* context = "QWidgetTextControl"; QString copyStr = QCoreApplication::translate(context, "&Copy"); - QAction* copy = menu->addAction(copyStr, this, &ReportOutput::copy, QKeySequence(QKeySequence::Copy)); + QAction* copy = menu->addAction(copyStr, this, &ReportOutput::copy); + copy->setShortcut(QKeySequence(QKeySequence::Copy)); copy->setEnabled(textCursor().hasSelection()); QIcon icon = QIcon::fromTheme(QString::fromLatin1("edit-copy")); if (!icon.isNull()) @@ -661,7 +662,8 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e ) menu->addSeparator(); QString selectStr = QCoreApplication::translate(context, "Select All"); - menu->addAction(selectStr, this, &ReportOutput::selectAll, QKeySequence(QKeySequence::SelectAll)); + QAction* select = menu->addAction(selectStr, this, &ReportOutput::selectAll); + select->setShortcut(QKeySequence(QKeySequence::SelectAll)); menu->addAction(tr("Clear"), this, &ReportOutput::clear); menu->addSeparator(); diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp index 3460a30833..cb5e1e31a7 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp @@ -73,13 +73,9 @@ QT_TRANSLATE_NOOP("SketcherGui::ConstraintView", "Select Elements"); /// ACTSONSELECTION is a true/false value to activate the command only if a selection is made #define CONTEXT_ITEM(ICONSTR, NAMESTR, CMDSTR, FUNC, ACTSONSELECTION) \ QIcon icon_##FUNC(Gui::BitmapFactory().pixmap(ICONSTR)); \ - QAction* constr_##FUNC = menu.addAction( \ - icon_##FUNC, \ - tr(NAMESTR), \ - this, \ - SLOT(FUNC()), \ - QKeySequence(QString::fromUtf8( \ - Gui::Application::Instance->commandManager().getCommandByName(CMDSTR)->getAccel()))); \ + QAction* constr_##FUNC = menu.addAction(icon_##FUNC, tr(NAMESTR), this, SLOT(FUNC())); \ + constr_##FUNC->setShortcut(QKeySequence(QString::fromUtf8( \ + Gui::Application::Instance->commandManager().getCommandByName(CMDSTR)->getAccel()))); \ if (ACTSONSELECTION) \ constr_##FUNC->setEnabled(!items.isEmpty()); \ else \ @@ -586,24 +582,18 @@ void ConstraintView::contextMenuEvent(QContextMenuEvent* event) doSelectConstraints, true) - QAction* rename = menu.addAction(tr("Rename"), - this, - &ConstraintView::renameCurrentItem + QAction* rename = menu.addAction(tr("Rename"), this, &ConstraintView::renameCurrentItem); #ifndef Q_OS_MAC// on Mac F2 doesn't seem to trigger an edit signal - , - QKeySequence(Qt::Key_F2) + rename->setShortcut(QKeySequence(Qt::Key_F2)); #endif - ); rename->setEnabled(item != nullptr); QAction* center = menu.addAction(tr("Center sketch"), this, &ConstraintView::centerSelectedItems); center->setEnabled(item != nullptr); - QAction* remove = menu.addAction(tr("Delete"), - this, - &ConstraintView::deleteSelectedItems, - QKeySequence(QKeySequence::Delete)); + QAction* remove = menu.addAction(tr("Delete"), this, &ConstraintView::deleteSelectedItems); + remove->setShortcut(QKeySequence(QKeySequence::Delete)); remove->setEnabled(!items.isEmpty()); QAction* swap = menu.addAction( diff --git a/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp b/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp index 378f25f6dc..22c994f5c0 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherElements.cpp @@ -91,13 +91,9 @@ QT_TRANSLATE_NOOP("SketcherGui::ElementView", "Select Vertical Axis"); /// ACTSONSELECTION is a true/false value to activate the command only if a selection is made #define CONTEXT_ITEM(ICONSTR, NAMESTR, CMDSTR, FUNC, ACTSONSELECTION) \ QIcon icon_##FUNC(Gui::BitmapFactory().pixmap(ICONSTR)); \ - QAction* constr_##FUNC = menu.addAction( \ - icon_##FUNC, \ - tr(NAMESTR), \ - this, \ - SLOT(FUNC()), \ - QKeySequence(QString::fromUtf8( \ - Gui::Application::Instance->commandManager().getCommandByName(CMDSTR)->getAccel()))); \ + QAction* constr_##FUNC = menu.addAction(icon_##FUNC, tr(NAMESTR), this, SLOT(FUNC())); \ + constr_##FUNC->setShortcut(QKeySequence(QString::fromUtf8( \ + Gui::Application::Instance->commandManager().getCommandByName(CMDSTR)->getAccel()))); \ if (ACTSONSELECTION) \ constr_##FUNC->setEnabled(!items.isEmpty()); \ else \ @@ -686,8 +682,8 @@ void ElementView::contextMenuEvent(QContextMenuEvent* event) menu.addSeparator(); - QAction* remove = menu.addAction( - tr("Delete"), this, &ElementView::deleteSelectedItems, QKeySequence(QKeySequence::Delete)); + QAction* remove = menu.addAction(tr("Delete"), this, &ElementView::deleteSelectedItems); + remove->setShortcut(QKeySequence(QKeySequence::Delete)); remove->setEnabled(!items.isEmpty()); menu.menuAction()->setIconVisibleInMenu(true);