Skip to content

Commit ff17e09

Browse files
committed
mainwindow: Extend preferences dialog
Add back setting controls lost in the refactoring canvas (biolabgh-3772) Bump orange-canvas-core requirement to >=0.1.3
1 parent 92899cb commit ff17e09

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

Orange/canvas/config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from AnyQt.QtGui import QPainter, QFont, QFontMetrics, QColor, QPixmap, QIcon
1616
from AnyQt.QtCore import Qt, QPoint, QRect
1717

18+
from orangecanvas import config as occonfig
1819
from orangewidget.workflow import widgetsscheme, discovery, config
1920

2021
import Orange
@@ -24,6 +25,13 @@
2425

2526
WIDGETS_ENTRY = "orange.widgets"
2627

28+
spec = [
29+
("startup/check-updates", bool, False, "Check for updates"),
30+
("error-reporting/machine-id", str, "", ""),
31+
("error-reporting/send-statistics", bool, False, ""),
32+
("error-reporting/permission-requested", bool, False, ""),
33+
]
34+
2735

2836
class Config(config.Config):
2937
"""
@@ -33,6 +41,11 @@ class Config(config.Config):
3341
ApplicationName = "Orange Canvas"
3442
ApplicationVersion = Orange.__version__
3543

44+
def init(self):
45+
super().init()
46+
for t in spec:
47+
occonfig.register_setting(*t)
48+
3649
@staticmethod
3750
def application_icon():
3851
"""

Orange/canvas/mainwindow.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,51 @@
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
16
from orangewidget.workflow.mainwindow import OWCanvasMainWindow
7+
28
from 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+
549
class 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()

requirements-gui.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
orange-canvas-core>=0.1a,<0.2a
1+
orange-canvas-core>=0.1.3,<0.2a
22
orange-widget-base>=4.0a,<4.1a
33

44
# PyQt4/PyQt5 compatibility

0 commit comments

Comments
 (0)