Skip to content

Commit

Permalink
mainwindow: Extend preferences dialog
Browse files Browse the repository at this point in the history
Add back setting controls lost in the refactoring canvas (biolabgh-3772)

Bump orange-canvas-core requirement to >=0.1.3
  • Loading branch information
ales-erjavec committed Jul 4, 2019
1 parent 92899cb commit ff17e09
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Orange/canvas/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from AnyQt.QtGui import QPainter, QFont, QFontMetrics, QColor, QPixmap, QIcon
from AnyQt.QtCore import Qt, QPoint, QRect

from orangecanvas import config as occonfig
from orangewidget.workflow import widgetsscheme, discovery, config

import Orange
Expand All @@ -24,6 +25,13 @@

WIDGETS_ENTRY = "orange.widgets"

spec = [
("startup/check-updates", bool, False, "Check for updates"),
("error-reporting/machine-id", str, "", ""),
("error-reporting/send-statistics", bool, False, ""),
("error-reporting/permission-requested", bool, False, ""),
]


class Config(config.Config):
"""
Expand All @@ -33,6 +41,11 @@ class Config(config.Config):
ApplicationName = "Orange Canvas"
ApplicationVersion = Orange.__version__

def init(self):
super().init()
for t in spec:
occonfig.register_setting(*t)

@staticmethod
def application_icon():
"""
Expand Down
53 changes: 53 additions & 0 deletions Orange/canvas/mainwindow.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,51 @@
from AnyQt.QtCore import Qt
from AnyQt.QtWidgets import (
QFormLayout, QCheckBox, QLineEdit, QWidget, QVBoxLayout,
)
from orangecanvas.application.settings import UserSettingsDialog
from orangewidget.workflow.mainwindow import OWCanvasMainWindow

from Orange.canvas.utils.overlay import NotificationOverlay


class OUserSettingsDialog(UserSettingsDialog):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
w = self.widget(0) # 'General' tab
layout = w.layout()
assert isinstance(layout, QFormLayout)
cb = QCheckBox(self.tr("Automatically check for updates"))
cb.setAttribute(Qt.WA_LayoutUsesWidgetRect)

layout.addRow("Updates", cb)
self.bind(cb, "checked", "startup/check-updates")

# Error Reporting Tab
tab = QWidget()
self.addTab(tab, self.tr("Error Reporting"),
toolTip="Settings related to error reporting")

form = QFormLayout()
line_edit_mid = QLineEdit()
self.bind(line_edit_mid, "text", "error-reporting/machine-id")
form.addRow("Machine ID:", line_edit_mid)

box = QWidget()
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
cb1 = QCheckBox(
self.tr(""),
toolTip=self.tr(
"Share anonymous usage statistics to improve Orange")
)
self.bind(cb1, "checked", "error-reporting/send-statistics")
layout.addWidget(cb1)
box.setLayout(layout)
form.addRow(self.tr("Share Anonymous Statistics"), box)

tab.setLayout(form)


class MainWindow(OWCanvasMainWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand All @@ -11,3 +55,12 @@ def closeEvent(self, event):
super().closeEvent(event)
if event.isAccepted():
self.notification_overlay.close()

def open_canvas_settings(self):
# type: () -> None
"""Reimplemented."""
dlg = OUserSettingsDialog(self, windowTitle=self.tr("Preferences"))
dlg.show()
status = dlg.exec_()
if status == 0:
self.user_preferences_changed_notify_all()
2 changes: 1 addition & 1 deletion requirements-gui.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
orange-canvas-core>=0.1a,<0.2a
orange-canvas-core>=0.1.3,<0.2a
orange-widget-base>=4.0a,<4.1a

# PyQt4/PyQt5 compatibility
Expand Down

0 comments on commit ff17e09

Please sign in to comment.