1+ from AnyQt .QtCore import Qt
2+ from AnyQt .QtWidgets import (
3+ QFormLayout , QCheckBox , QLineEdit , QWidget , QVBoxLayout ,
4+ )
5+ from orangecanvas .application .settings import UserSettingsDialog
16from orangewidget .workflow .mainwindow import OWCanvasMainWindow
7+
28from Orange .canvas .utils .overlay import NotificationOverlay
39
410
11+ class OUserSettingsDialog (UserSettingsDialog ):
12+ def __init__ (self , * args , ** kwargs ):
13+ super ().__init__ (* args , ** kwargs )
14+ w = self .widget (0 ) # 'General' tab
15+ layout = w .layout ()
16+ assert isinstance (layout , QFormLayout )
17+ cb = QCheckBox (self .tr ("Automatically check for updates" ))
18+ cb .setAttribute (Qt .WA_LayoutUsesWidgetRect )
19+
20+ layout .addRow ("Updates" , cb )
21+ self .bind (cb , "checked" , "startup/check-updates" )
22+
23+ # Error Reporting Tab
24+ tab = QWidget ()
25+ self .addTab (tab , self .tr ("Error Reporting" ),
26+ toolTip = "Settings related to error reporting" )
27+
28+ form = QFormLayout ()
29+ line_edit_mid = QLineEdit ()
30+ self .bind (line_edit_mid , "text" , "error-reporting/machine-id" )
31+ form .addRow ("Machine ID:" , line_edit_mid )
32+
33+ box = QWidget ()
34+ layout = QVBoxLayout ()
35+ layout .setContentsMargins (0 , 0 , 0 , 0 )
36+ cb1 = QCheckBox (
37+ self .tr ("" ),
38+ toolTip = self .tr (
39+ "Share anonymous usage statistics to improve Orange" )
40+ )
41+ self .bind (cb1 , "checked" , "error-reporting/send-statistics" )
42+ layout .addWidget (cb1 )
43+ box .setLayout (layout )
44+ form .addRow (self .tr ("Share Anonymous Statistics" ), box )
45+
46+ tab .setLayout (form )
47+
48+
549class MainWindow (OWCanvasMainWindow ):
650 def __init__ (self , * args , ** kwargs ):
751 super ().__init__ (* args , ** kwargs )
@@ -11,3 +55,12 @@ def closeEvent(self, event):
1155 super ().closeEvent (event )
1256 if event .isAccepted ():
1357 self .notification_overlay .close ()
58+
59+ def open_canvas_settings (self ):
60+ # type: () -> None
61+ """Reimplemented."""
62+ dlg = OUserSettingsDialog (self , windowTitle = self .tr ("Preferences" ))
63+ dlg .show ()
64+ status = dlg .exec_ ()
65+ if status == 0 :
66+ self .user_preferences_changed_notify_all ()
0 commit comments