Salome HOME
[bos #35160][EDF](2023-T1) Keyboard shortcuts.
authordish <Dmitrii.SHVYDKOI@opencascade.com>
Wed, 6 Dec 2023 05:09:39 +0000 (05:09 +0000)
committerdish <dmitrii.shvydkoi@opencascade.com>
Thu, 25 Jan 2024 10:50:35 +0000 (10:50 +0000)
Make column widths of shortcut editor resizable.

src/Qtx/QtxShortcutEdit.cxx
src/Qtx/QtxShortcutEdit.h
src/Qtx/resources/Qtx_msg_fr.ts
src/Qtx/resources/Qtx_msg_ja.ts

index aa78dfafdd3263efeb7a9fe0ea1343c58a8743e2..eb7431d8eafea66fc637e2fe983d49f5881cbbb4 100644 (file)
@@ -22,6 +22,7 @@
 #include <QWidget>
 #include <QLayout>
 #include <QList>
+#include <QMap>
 
 #include <QToolButton>
 #include <QLineEdit>
@@ -32,6 +33,7 @@
 #include <QPushButton>
 #include <QBrush>
 #include <QColor>
+#include <QHeaderView>
 
 #include <QKeyEvent>
 #include <QKeySequence>
@@ -359,10 +361,15 @@ myShortcutContainer(theContainer ? theContainer : std::shared_ptr<SUIT_ShortcutC
   setSelectionMode(QAbstractItemView::SingleSelection);
   setColumnWidth(0, COLUMN_SIZE);
   setSortingEnabled(false); // Items are sorted in the same way, as in ShortcutContainer.
-  headerItem()->setHidden(true);
+  header()->setSectionResizeMode(QHeaderView::Interactive);
+  {
+    QMap<int, QString> 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
index 065959ea11027fde1e860ef340ce849913e5218d..71e0d9d938b9727959f834289796c858d0a4b101 100644 (file)
@@ -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<SUIT_ShortcutContainer> theContainer = std::shared_ptr<SUIT_ShortcutContainer>(),
     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);
index 6c47b40b045e9facca8ccc89724810409bb4b36d..2ea62824ee145c9d24c536a9b8c6d00140f5b8cc 100644 (file)
 </context>
 <context>
     <name>QtxShortcutTree</name>
+    <message>
+        <source>Action</source>
+        <translation>Action</translation>
+    </message>
+    <message>
+        <source>Key sequence</source>
+        <translation>Séquence de touches</translation>
+    </message>
     <message>
         <source>Double click to edit key sequence.</source>
         <translation>Double-cliquez pour modifier la séquence de touches.</translation>
index 06d53157c1dce3fe31a2eb29daf6d6e500701f22..36900402a7cc12635914783b079578f185c3f9b7 100644 (file)
   </context>
   <context>
       <name>QtxShortcutTree</name>
+      <message>
+        <source>Action</source>
+        <translation>アクション</translation>
+      </message>
+      <message>
+          <source>Key sequence</source>
+          <translation>キーシーケンス</translation>
+      </message>
       <message>
           <source>Double click to edit key sequence.</source>
           <translation>ダブルクリックしてキー シーケンスを編集します。</translation>