Skip to content

Commit

Permalink
Continuization: Delay before showing default behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Feb 11, 2023
1 parent 0063152 commit 3592756
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Orange/widgets/data/owcontinuize.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import scipy.sparse as sp

from AnyQt.QtCore import Qt, QSize, QAbstractListModel, QObject, \
QItemSelectionModel
QItemSelectionModel, QTimer
from AnyQt.QtGui import QColor
from AnyQt.QtWidgets import QButtonGroup, QRadioButton, QListView

Expand Down Expand Up @@ -126,6 +126,8 @@ def __init__(self, valid_type):
valid_types=(valid_type, ), strict_type=True)

def data(self, index, role=Qt.DisplayRole):
if role == Qt.ToolTipRole:
return None
if role == self.FilterRole:
name = super().data(index, Qt.DisplayRole)
if not isinstance(name, str):
Expand Down Expand Up @@ -214,7 +216,12 @@ def __init__(self, *args, **kwargs):
self.default_view = None
super().__init__(preferred_size=QSize(350, -1), *args, **kwargs)
self.setItemDelegate(self.Delegate(self))

self.force_hints = False
self.update_timer = QTimer()
self.update_timer.setInterval(500)
self.update_timer.setSingleShot(True)
self.update_timer.timeout.connect(self.viewport().update)

def select_default(self):
"""Select the item representing default settings"""
Expand Down Expand Up @@ -261,10 +268,12 @@ def __layout(self):

def enterEvent(self, _):
self.itemDelegate().set_default_hints(True)
self.viewport().update()
self.update_timer.start()

def leaveEvent(self, _):
self.itemDelegate().set_default_hints(False)
if self.update_timer.isActive():
self.update_timer.stop()
self.viewport().update()


Expand Down

0 comments on commit 3592756

Please sign in to comment.