From 42b6f0a01b3364b9f5c709c2073044cb33c1e3c7 Mon Sep 17 00:00:00 2001 From: Hanjin Liu Date: Mon, 8 Jul 2024 23:49:11 +0900 Subject: [PATCH] update style --- tabulous/_qt/_table/_base/_enhanced_table.py | 10 ++++++++++ tabulous/style/_style.qss | 4 ++++ tabulous/widgets/_mainwindow.py | 1 + 3 files changed, 15 insertions(+) diff --git a/tabulous/_qt/_table/_base/_enhanced_table.py b/tabulous/_qt/_table/_base/_enhanced_table.py index 6936380e..4b95a4a4 100644 --- a/tabulous/_qt/_table/_base/_enhanced_table.py +++ b/tabulous/_qt/_table/_base/_enhanced_table.py @@ -276,6 +276,11 @@ def _on_moved(self, src: Index, dst: Index) -> None: self._update_all(rect) return None + def _close_editor(self): + if isinstance(line := self._focused_widget, (QCellLiteralEdit, QCellLabelEdit)): + cast("QCellLiteralEdit | QCellLabelEdit", line)._hide_and_delete() + return None + def copy(self, link: bool = True) -> _QTableViewEnhanced: """Make a copy of the table.""" new = _QTableViewEnhanced(self.parentTable()) @@ -284,6 +289,7 @@ def copy(self, link: bool = True) -> _QTableViewEnhanced: new._selection_model = self._selection_model new._selection_model.moving.connect(new._on_moving) new._selection_model.moved.connect(new._on_moved) + new.rightClickedSignal.connect(self.parentTable().showContextMenu) new._table_map = self._table_map new.setZoom(self.zoom()) new._selection_model.current_index = self._selection_model.current_index @@ -400,6 +406,10 @@ def mouseDoubleClickEvent(self, e: QtGui.QMouseEvent) -> None: index = self.indexAt(e.pos()) if not index.isValid(): return None + + if e.buttons() != Qt.MouseButton.LeftButton: + return None + from ._table_base import QMutableTable table = self.parentTable() diff --git a/tabulous/style/_style.qss b/tabulous/style/_style.qss index 94eed1e5..7a30bfc6 100644 --- a/tabulous/style/_style.qss +++ b/tabulous/style/_style.qss @@ -622,3 +622,7 @@ QCircularProgressBar { qproperty-color: #[highlight0]; qproperty-grooveColor: #[background0]; } + +QtDockWidget { + border: 1px solid #[highlight0]; +} diff --git a/tabulous/widgets/_mainwindow.py b/tabulous/widgets/_mainwindow.py index c0a89cf6..56ef0450 100644 --- a/tabulous/widgets/_mainwindow.py +++ b/tabulous/widgets/_mainwindow.py @@ -352,6 +352,7 @@ def add_layer(self, input: TableBase, *, update: bool = False): table_has_focus = table.native._qtable_view.hasFocus() else: table_has_focus = False + self.current_table._qwidget._qtable_view._close_editor() if ( update and (table := self.tables.get(input.name, None))