forked from qt-creator/qt-creator
Adapt to key sequence changes in Qt6
Use operator| instead of operator+ which was removed. Individual keys in QKeySequence are now QKeyCombinations instead of ints. Task-number: QTCREATORBUG-24098 Change-Id: I43a6122cf660e6a6de7edbf3ac9954e0a39cec06 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -1008,8 +1008,8 @@ void ObjectItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
|
||||
menu.addSeparator();
|
||||
menu.addAction(new ContextMenuAction(tr("Remove"), "remove",
|
||||
QKeySequence(QKeySequence::Delete), &menu));
|
||||
menu.addAction(new ContextMenuAction(tr("Delete"), "delete",
|
||||
QKeySequence(Qt::CTRL + Qt::Key_D), &menu));
|
||||
menu.addAction(
|
||||
new ContextMenuAction(tr("Delete"), "delete", QKeySequence(Qt::CTRL | Qt::Key_D), &menu));
|
||||
//menu.addAction(new ContextMenuAction(tr("Select in Model Tree"), "selectInModelTree", &menu));
|
||||
QMenu alignMenu;
|
||||
alignMenu.setTitle(tr("Align Objects"));
|
||||
|
@@ -260,8 +260,10 @@ void ModelTreeView::contextMenuEvent(QContextMenuEvent *event)
|
||||
if (melement->owner()) {
|
||||
if (addSeparator)
|
||||
menu.addSeparator();
|
||||
menu.addAction(new ContextMenuAction(tr("Delete"), "delete",
|
||||
QKeySequence(Qt::CTRL + Qt::Key_D), &menu));
|
||||
menu.addAction(new ContextMenuAction(tr("Delete"),
|
||||
"delete",
|
||||
QKeySequence(Qt::CTRL | Qt::Key_D),
|
||||
&menu));
|
||||
}
|
||||
QAction *selectedAction = menu.exec(event->globalPos());
|
||||
if (selectedAction) {
|
||||
|
@@ -117,12 +117,18 @@ static QKeySequence keySequenceFromEditString(const QString &editString)
|
||||
return QKeySequence::fromString(text, QKeySequence::PortableText);
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
|
||||
using KeyCombination = int;
|
||||
#else
|
||||
using KeyCombination = QKeyCombination;
|
||||
#endif
|
||||
|
||||
static bool keySequenceIsValid(const QKeySequence &sequence)
|
||||
{
|
||||
if (sequence.isEmpty())
|
||||
return false;
|
||||
for (int i = 0; i < sequence.count(); ++i) {
|
||||
if (sequence[i] == Qt::Key_unknown)
|
||||
if (sequence[i] == KeyCombination(Qt::Key_unknown))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@@ -175,7 +175,7 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view) :
|
||||
28, 28, textColorNormal);
|
||||
|
||||
m_zoomInAction = new QAction(zoomInIcon, tr("Zoom in"), this);
|
||||
m_zoomInAction->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Plus));
|
||||
m_zoomInAction->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Plus));
|
||||
connect(m_zoomInAction.data(), &QAction::triggered, this, [this] {
|
||||
if (!m_formEditorView)
|
||||
return;
|
||||
@@ -187,7 +187,7 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view) :
|
||||
m_toolBox->addRightSideAction(m_zoomInAction.data());
|
||||
|
||||
m_zoomOutAction = new QAction(zoomOutIcon, tr("Zoom out"), this);
|
||||
m_zoomOutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Minus));
|
||||
m_zoomOutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Minus));
|
||||
connect(m_zoomOutAction.data(), &QAction::triggered, this, [this] {
|
||||
if (!m_formEditorView)
|
||||
return;
|
||||
@@ -206,7 +206,7 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view) :
|
||||
m_toolBox->addRightSideAction(m_zoomAction.data());
|
||||
|
||||
m_zoomAllAction = new QAction(zoomAllIcon, tr("Zoom screen to fit all content"), this);
|
||||
m_zoomAllAction->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_0));
|
||||
m_zoomAllAction->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_0));
|
||||
connect(m_zoomAllAction.data(), &QAction::triggered, this, [this] {
|
||||
if (!m_formEditorView)
|
||||
return;
|
||||
@@ -218,7 +218,7 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view) :
|
||||
m_toolBox->addRightSideAction(m_zoomAllAction.data());
|
||||
|
||||
m_zoomSelectionAction = new QAction(zoomSelectionIcon, tr("Zoom screen to fit current selection"), this);
|
||||
m_zoomSelectionAction->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_I));
|
||||
m_zoomSelectionAction->setShortcut(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_I));
|
||||
connect(m_zoomSelectionAction.data(), &QAction::triggered, this, [this] {
|
||||
if (!m_formEditorView)
|
||||
return;
|
||||
|
@@ -185,11 +185,11 @@ bool TextEditorWidget::eventFilter( QObject *, QEvent *event)
|
||||
static std::vector<QKeySequence> overrideSequences = { QKeySequence::SelectAll, QKeySequence::Cut,
|
||||
QKeySequence::Copy, QKeySequence::Delete,
|
||||
QKeySequence::Paste, QKeySequence::Undo,
|
||||
QKeySequence::Redo, QKeySequence(Qt::CTRL + Qt::ALT),
|
||||
QKeySequence(Qt::Key_Left + Qt::CTRL),
|
||||
QKeySequence(Qt::Key_Right + Qt::CTRL),
|
||||
QKeySequence(Qt::Key_Up + Qt::CTRL),
|
||||
QKeySequence(Qt::Key_Down + Qt::CTRL)
|
||||
QKeySequence::Redo, QKeySequence(Qt::CTRL | Qt::ALT),
|
||||
QKeySequence(Qt::Key_Left | Qt::CTRL),
|
||||
QKeySequence(Qt::Key_Right | Qt::CTRL),
|
||||
QKeySequence(Qt::Key_Up | Qt::CTRL),
|
||||
QKeySequence(Qt::Key_Down | Qt::CTRL)
|
||||
};
|
||||
if (event->type() == QEvent::ShortcutOverride) {
|
||||
auto keyEvent = static_cast<QKeyEvent *>(event);
|
||||
|
@@ -191,8 +191,8 @@ QmlJSEditorPluginPrivate::QmlJSEditorPluginPrivate()
|
||||
|
||||
QAction *showQuickToolbar = new QAction(QmlJSEditorPlugin::tr("Show Qt Quick Toolbar"), this);
|
||||
cmd = ActionManager::registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context);
|
||||
cmd->setDefaultKeySequence(useMacShortcuts ? QKeySequence(Qt::META + Qt::ALT + Qt::Key_Space)
|
||||
: QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Space));
|
||||
cmd->setDefaultKeySequence(useMacShortcuts ? QKeySequence(Qt::META | Qt::ALT | Qt::Key_Space)
|
||||
: QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Space));
|
||||
connect(showQuickToolbar, &QAction::triggered, this, &QmlJSEditorPluginPrivate::showContextPane);
|
||||
contextMenu->addAction(cmd);
|
||||
qmlToolsMenu->addAction(cmd);
|
||||
|
Reference in New Issue
Block a user