Qt6 port:
Fix deprecation warnings with version 6.3 or 6.4
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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; i<it->count(); i++) {
|
||||
for (int i=0; i<it->size(); i++) {
|
||||
if ((*it)[i] == QLatin1Char('\t'))
|
||||
space++;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (it->count() > space)
|
||||
if (it->size() > space)
|
||||
minspace = std::min<int>(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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,7 +625,11 @@ void DlgCustomToolbarsImp::renameCustomToolbar(const QString& old_name, const QS
|
||||
QList<QAction*> DlgCustomToolbarsImp::getActionGroup(QAction* action)
|
||||
{
|
||||
QList<QAction*> group;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
QList<QWidget*> widgets = action->associatedWidgets();
|
||||
#else
|
||||
QList<QObject*> widgets = action->associatedObjects();
|
||||
#endif
|
||||
for (const auto & widget : widgets) {
|
||||
auto tb = qobject_cast<QToolButton*>(widget);
|
||||
if (tb) {
|
||||
@@ -642,7 +646,11 @@ QList<QAction*> DlgCustomToolbarsImp::getActionGroup(QAction* action)
|
||||
void DlgCustomToolbarsImp::setActionGroup(QAction* action, const QList<QAction*>& group)
|
||||
{
|
||||
// See also ActionGroup::addTo()
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
|
||||
QList<QWidget*> widgets = action->associatedWidgets();
|
||||
#else
|
||||
QList<QObject*> widgets = action->associatedObjects();
|
||||
#endif
|
||||
for (const auto & widget : widgets) {
|
||||
auto tb = qobject_cast<QToolButton*>(widget);
|
||||
if (tb) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user