From: dish Date: Wed, 6 Dec 2023 05:09:39 +0000 (+0000) Subject: [bos #35160][EDF](2023-T1) Keyboard shortcuts. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f9c0ac4c06e914b83656aea59f1f9826adbb6a75;p=modules%2Fgui.git [bos #35160][EDF](2023-T1) Keyboard shortcuts. Make column widths of shortcut editor resizable. --- diff --git a/src/Qtx/QtxShortcutEdit.cxx b/src/Qtx/QtxShortcutEdit.cxx index aa78dfafd..eb7431d8e 100644 --- a/src/Qtx/QtxShortcutEdit.cxx +++ b/src/Qtx/QtxShortcutEdit.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -32,6 +33,7 @@ #include #include #include +#include #include #include @@ -359,10 +361,15 @@ myShortcutContainer(theContainer ? theContainer : std::shared_ptrsetHidden(true); + header()->setSectionResizeMode(QHeaderView::Interactive); + { + QMap labelMap; + labelMap[QtxShortcutTree::ElementIdx::Name] = tr("Action"); + labelMap[QtxShortcutTree::ElementIdx::KeySequence] = tr("Key sequence"); + setHeaderLabels(labelMap.values()); + } setExpandsOnDoubleClick(false); // Open shortcut editor on double click instead. setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); - setToolTip(tr("Double click to edit key sequence.")); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); myEditDialog = new QtxEditKeySequenceDialog(this); @@ -637,9 +644,9 @@ QtxShortcutTreeItem::QtxShortcutTreeItem(const QString& theModuleID, const QStri { auto item = new QtxShortcutTreeItem(theModuleID, QString()); - QFont font = item->font(ElementIdx::Name); + QFont font = item->font(QtxShortcutTree::ElementIdx::Name); font.setBold(true); - item->setFont(ElementIdx::Name, font); + item->setFont(QtxShortcutTree::ElementIdx::Name, font); return item; } @@ -652,7 +659,9 @@ QtxShortcutTreeItem::QtxShortcutTreeItem(const QString& theModuleID, const QStri return nullptr; } - return new QtxShortcutTreeItem(theModuleID, theInModuleActionID); + auto item = new QtxShortcutTreeItem(theModuleID, theInModuleActionID); + item->setToolTip(QtxShortcutTree::ElementIdx::KeySequence, QtxShortcutTree::tr("Double click to edit key sequence.")); + return item; } bool QtxShortcutTreeItem::isFolder() const @@ -667,26 +676,29 @@ void QtxShortcutTreeItem::highlightKeySequenceAsModified(bool theHighlight) static const QBrush fgHighlitingBrush = QBrush(Qt::white); static const QBrush noBrush = QBrush(); - setBackground(ElementIdx::KeySequence, theHighlight ? bgHighlitingBrush : noBrush); - setForeground(ElementIdx::KeySequence, theHighlight ? fgHighlitingBrush : noBrush); + setBackground(QtxShortcutTree::ElementIdx::KeySequence, theHighlight ? bgHighlitingBrush : noBrush); + setForeground(QtxShortcutTree::ElementIdx::KeySequence, theHighlight ? fgHighlitingBrush : noBrush); } void QtxShortcutTreeItem::setName(const QString& theName) { - setText(ElementIdx::Name, theName); + const QString& name = theName.isEmpty() ? myInModuleActionID : theName; + setText(QtxShortcutTree::ElementIdx::Name, name); + if (!isFolder()) + setToolTip(QtxShortcutTree::ElementIdx::Name, name + (name.at(name.length()-1) == "." ? "\n" : ".\n") + QtxShortcutTree::tr("Double click to edit key sequence.")); } QString QtxShortcutTreeItem::name() const { - return text(ElementIdx::Name); + return text(QtxShortcutTree::ElementIdx::Name); } void QtxShortcutTreeItem::setKeySequence(const QString& theKeySequence) { - setText(ElementIdx::KeySequence, theKeySequence); + setText(QtxShortcutTree::ElementIdx::KeySequence, theKeySequence); } QString QtxShortcutTreeItem::keySequence() const { - return text(ElementIdx::KeySequence); + return text(QtxShortcutTree::ElementIdx::KeySequence); } \ No newline at end of file diff --git a/src/Qtx/QtxShortcutEdit.h b/src/Qtx/QtxShortcutEdit.h index 065959ea1..71e0d9d93 100644 --- a/src/Qtx/QtxShortcutEdit.h +++ b/src/Qtx/QtxShortcutEdit.h @@ -123,6 +123,11 @@ class QTX_EXPORT QtxShortcutTree : public QTreeWidget Q_OBJECT public: + enum ElementIdx { + Name = 0, + KeySequence = 1, // Empty, if item is used as folder. + }; + QtxShortcutTree( std::shared_ptr theContainer = std::shared_ptr(), QWidget* theParent = nullptr @@ -172,11 +177,6 @@ class QtxShortcutTreeItem : public QTreeWidgetItem private: QtxShortcutTreeItem(const QString& theModuleID, const QString& theInModuleActionID); - enum ElementIdx { - Name = 0, - KeySequence = 1, // Empty, if item is used as folder. - }; - public: static QtxShortcutTreeItem* createFolderItem(const QString& theModuleID); static QtxShortcutTreeItem* createShortcutItem(const QString& theModuleID, const QString& theInModuleActionID); diff --git a/src/Qtx/resources/Qtx_msg_fr.ts b/src/Qtx/resources/Qtx_msg_fr.ts index 6c47b40b0..2ea62824e 100644 --- a/src/Qtx/resources/Qtx_msg_fr.ts +++ b/src/Qtx/resources/Qtx_msg_fr.ts @@ -531,6 +531,14 @@ QtxShortcutTree + + Action + Action + + + Key sequence + Séquence de touches + Double click to edit key sequence. Double-cliquez pour modifier la séquence de touches. diff --git a/src/Qtx/resources/Qtx_msg_ja.ts b/src/Qtx/resources/Qtx_msg_ja.ts index 06d53157c..36900402a 100644 --- a/src/Qtx/resources/Qtx_msg_ja.ts +++ b/src/Qtx/resources/Qtx_msg_ja.ts @@ -531,6 +531,14 @@ QtxShortcutTree + + Action + アクション + + + Key sequence + キーシーケンス + Double click to edit key sequence. ダブルクリックしてキー シーケンスを編集します。