Skip to content

Commit c5f8021

Browse files
committed
oweditdomain: Rename the 'merge selected' to 'rename selected'
1 parent 9696fe9 commit c5f8021

File tree

1 file changed

+32
-16
lines changed

1 file changed

+32
-16
lines changed

Orange/widgets/data/oweditdomain.py

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
QStyledItemDelegate, QStyleOptionViewItem, QStyle, QSizePolicy, QToolTip,
2525
QDialogButtonBox, QPushButton, QCheckBox, QComboBox, QStackedLayout,
2626
QDialog, QRadioButton, QGridLayout, QLabel, QSpinBox, QDoubleSpinBox,
27-
QShortcut, QAbstractItemView
27+
QAbstractItemView, QMenu
2828
)
2929
from AnyQt.QtGui import QStandardItemModel, QStandardItem, QKeySequence, QIcon
3030
from AnyQt.QtCore import (
3131
Qt, QEvent, QSize, QModelIndex, QAbstractItemModel, QPersistentModelIndex,
32-
QRect
32+
QRect, QPoint
3333
)
3434
from AnyQt.QtCore import pyqtSignal as Signal, pyqtSlot as Slot
3535

@@ -1170,7 +1170,8 @@ def __init__(self, *args, **kwargs):
11701170
self, objectName="action-group-categories", enabled=False
11711171
)
11721172
self.move_value_up = QAction(
1173-
"\N{UPWARDS ARROW}", group,
1173+
"Move up", group,
1174+
iconText="\N{UPWARDS ARROW}",
11741175
toolTip="Move the selected item up.",
11751176
shortcut=QKeySequence(Qt.ControlModifier | Qt.AltModifier |
11761177
Qt.Key_BracketLeft),
@@ -1179,7 +1180,8 @@ def __init__(self, *args, **kwargs):
11791180
self.move_value_up.triggered.connect(self.move_up)
11801181

11811182
self.move_value_down = QAction(
1182-
"\N{DOWNWARDS ARROW}", group,
1183+
"Move down", group,
1184+
iconText="\N{DOWNWARDS ARROW}",
11831185
toolTip="Move the selected item down.",
11841186
shortcut=QKeySequence(Qt.ControlModifier | Qt.AltModifier |
11851187
Qt.Key_BracketRight),
@@ -1188,28 +1190,32 @@ def __init__(self, *args, **kwargs):
11881190
self.move_value_down.triggered.connect(self.move_down)
11891191

11901192
self.add_new_item = QAction(
1191-
"+", group,
1193+
"Add", group,
1194+
iconText="+",
11921195
objectName="action-add-item",
11931196
toolTip="Append a new item.",
11941197
shortcut=QKeySequence(QKeySequence.New),
11951198
shortcutContext=Qt.WidgetShortcut,
11961199
)
11971200
self.remove_item = QAction(
1198-
"\N{MINUS SIGN}", group,
1201+
"Remove item", group,
1202+
iconText="\N{MINUS SIGN}",
11991203
objectName="action-remove-item",
12001204
toolTip="Delete the selected item.",
12011205
shortcut=QKeySequence(QKeySequence.Delete),
12021206
shortcutContext=Qt.WidgetShortcut,
12031207
)
1204-
self.merge_selected_items = QAction(
1205-
"=", group,
1206-
objectName="action-merge-selected-items",
1207-
toolTip="Merge selected items.",
1208+
self.rename_selected_items = QAction(
1209+
"Rename selected items", group,
1210+
iconText="=",
1211+
objectName="action-rename-selected-items",
1212+
toolTip="Rename selected items.",
12081213
shortcut=QKeySequence(Qt.ControlModifier | Qt.Key_Equal),
12091214
shortcutContext=Qt.WidgetShortcut,
12101215
)
12111216
self.merge_items = QAction(
1212-
"ƒM", group,
1217+
"Merge", group,
1218+
iconText="M",
12131219
objectName="action-activate-merge-dialog",
12141220
toolTip="Merge infrequent items.",
12151221
shortcut=QKeySequence(Qt.ControlModifier | Qt.MetaModifier | Qt.Key_Equal),
@@ -1218,7 +1224,7 @@ def __init__(self, *args, **kwargs):
12181224

12191225
self.add_new_item.triggered.connect(self._add_category)
12201226
self.remove_item.triggered.connect(self._remove_category)
1221-
self.merge_selected_items.triggered.connect(self._merge_selected_categories)
1227+
self.rename_selected_items.triggered.connect(self._rename_selected_categories)
12221228
self.merge_items.triggered.connect(self._merge_categories)
12231229

12241230
button1 = FixedSizeButton(
@@ -1238,7 +1244,7 @@ def __init__(self, *args, **kwargs):
12381244
accessibleName="Remove"
12391245
)
12401246
button5 = FixedSizeButton(
1241-
self, defaultAction=self.merge_selected_items,
1247+
self, defaultAction=self.rename_selected_items,
12421248
accessibleName="Merge selected items"
12431249
)
12441250
button6 = FixedSizeButton(
@@ -1248,8 +1254,18 @@ def __init__(self, *args, **kwargs):
12481254

12491255
self.values_edit.addActions([
12501256
self.move_value_up, self.move_value_down,
1251-
self.add_new_item, self.remove_item, self.merge_selected_items
1257+
self.add_new_item, self.remove_item, self.rename_selected_items
12521258
])
1259+
self.values_edit.setContextMenuPolicy(Qt.CustomContextMenu)
1260+
1261+
@self.values_edit.customContextMenuRequested.connect
1262+
def context_menu(pos: QPoint):
1263+
viewport = self.values_edit.viewport()
1264+
menu = QMenu(self.values_edit)
1265+
menu.setAttribute(Qt.WA_DeleteOnClose)
1266+
menu.addActions([self.rename_selected_items, self.remove_item])
1267+
menu.popup(viewport.mapToGlobal(pos))
1268+
12531269
hlayout.addWidget(button1)
12541270
hlayout.addWidget(button2)
12551271
hlayout.addSpacing(3)
@@ -1535,9 +1551,9 @@ def complete_merge(text, merge_attributes):
15351551
dlg.get_merged_value_name(), dlg.get_merge_attributes()
15361552
)
15371553

1538-
def _merge_selected_categories(self):
1554+
def _rename_selected_categories(self):
15391555
"""
1540-
Merge selected categories into one.
1556+
Rename selected categories and merging them.
15411557
15421558
Popup an editable combo box for selection/edit of a new value.
15431559
"""

0 commit comments

Comments
 (0)