Skip to content

Commit c98c834

Browse files
authored
Merge pull request #282 from nxt-dev/dev
Release editor-v4.0.0
2 parents 5527907 + 6567e1c commit c98c834

28 files changed

Lines changed: 171 additions & 131 deletions

CONTRIBUTING.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,9 @@ Conda is best installed via [miniconda](https://docs.conda.io/en/latest/minicond
8585
```
8686

8787
## Dependencies
88-
- Python 2.7
88+
- [Python 3.9](https://www.python.org/downloads/release/python-390/)
8989
- [Qt.py](https://github.com/mottosso/Qt.py)
90-
- [PySide2](https://wiki.qt.io/Qt_for_Python) 5.6 (Python 2)
91-
- `pip install -e <path to nxt core clone>`
92-
93-
- Python 3.7
94-
- [Qt.py](https://github.com/mottosso/Qt.py)
95-
- [PySide2](https://wiki.qt.io/Qt_for_Python) 5.11.1 (Python 3)
90+
- [PySide6](https://doc.qt.io/qtforpython-6/gettingstarted.html)
9691
- `pip install -e <path to nxt core clone>`
9792

9893
## Changelog syntax

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2020 The nxt Authors
3+
Copyright (c) 2015-2025 The nxt Authors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
66
and associated documentation files (the "Software"), to deal in the Software without restriction,

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Only clone this repo if you're [contributing](CONTRIBUTING.md) to the NXT codeba
1717
<br>
1818

1919
#### Requirements
20-
- Python >= [2.7.*](https://www.python.org/download/releases/2.7) <= [3.7.*](https://www.python.org/download/releases/3.7)
21-
- We strongly recommend using a Python [virtual environment](https://docs.python.org/3.7/tutorial/venv.html)
20+
- Python >= [3.9.*](https://www.python.org/downloads/release/python-390/)
21+
- We strongly recommend using a Python [virtual environment](https://docs.python.org/3/library/venv.html)
2222

2323
*[Requirements for contributors](CONTRIBUTING.md#python-environment)*
2424

build/release_footer.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ This release includes backwards compatibility for graph versions as old as `0.45
66
# Installation Types
77
Each described installation is self contained, and produces a working nxt.
88
## Pip Installation
9-
From a Python(2 or 3) environment run the following command:
9+
From a Python 3 environment run the following command:
1010
`pip install nxt-editor`
1111
**Python Dependancies**
1212
- [nxt-core](https://github.com/nxt-dev/nxt)
1313
- [Qt.py](https://github.com/mottosso/Qt.py)
14-
- [pyside2](https://doc.qt.io/qtforpython/index.html)
15-
- **Windows Only** Note that pyside2 is not available for python2.7 by default on windows([details](https://wiki.qt.io/Qt_for_Python/Considerations#Missing_Windows_.2F_Python_2.7_release)). For instructions on using conda to build an environment to satifsy these dependencies please see [CONTRIBUTING.md](https://github.com/nxt-dev/nxt/blob/release/CONTRIBUTING.md#python-environment)
14+
- [PySide6](https://doc.qt.io/qtforpython-6/gettingstarted.html)
15+
1616

1717
## Blender (2.8 and newer) Installation
1818
1. Download Blender addon (nxt_blender.zip)
@@ -23,6 +23,6 @@ From a Python(2 or 3) environment run the following command:
2323
- By Hand: `/path/to/python.exe -m pip install -U nxt-editor`
2424

2525

26-
## Maya(2019-2020) Installation/Update
26+
## Maya(2019-2025) Installation/Update
2727
1. Download Maya module(nxt_maya.zip)
2828
2. Extract and follow `README.md` inside

nxt_editor/__init__.py

Lines changed: 13 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -36,48 +36,21 @@ class StringSignaler(QtCore.QObject):
3636

3737

3838
def make_resources(qrc_path=None, result_path=None):
39-
import PySide2
40-
pyside_dir = os.path.dirname(PySide2.__file__)
41-
full_pyside2rcc_path = os.path.join(pyside_dir, 'pyside2-rcc')
42-
full_rcc_path = os.path.join(pyside_dir, 'rcc')
39+
import subprocess
4340
this_dir = os.path.dirname(os.path.realpath(__file__))
4441
if not qrc_path:
4542
qrc_path = os.path.join(this_dir, 'resources/resources.qrc')
4643
if not result_path:
4744
result_path = os.path.join(this_dir, 'qresources.py')
4845
msg = 'First launch nxt resource generation from {} to {}'
4946
logger.info(msg.format(qrc_path, result_path))
50-
import subprocess
51-
ver = ['-py2']
52-
if sys.version_info[0] == 3:
53-
ver += ['-py3']
54-
args = [qrc_path] + ver + ['-o', result_path]
55-
try:
56-
subprocess.check_call(['pyside2-rcc'] + args)
57-
except:
58-
pass
59-
else:
60-
return
6147

48+
args = [qrc_path, '-o', result_path, '-g', 'python']
6249
try:
63-
subprocess.check_call([full_pyside2rcc_path] + args)
50+
subprocess.call(['pyside6-rcc'] + args)
6451
except:
65-
pass
66-
else:
67-
return
68-
try:
69-
subprocess.check_call([full_rcc_path, '-g', 'python', qrc_path,
70-
'-o', result_path], cwd=pyside_dir)
71-
except:
72-
pass
73-
else:
74-
return
75-
try:
76-
subprocess.check_call(['rcc', '-g', 'python', qrc_path,
77-
'-o', result_path], cwd=pyside_dir)
78-
except:
79-
raise Exception("Failed to generate UI resources using pyside2 rcc!"
80-
" Reinstalling pyside2 may fix the problem. If you "
52+
raise Exception("Failed to generate UI resources using PySide rcc!"
53+
" Reinstalling PySide6 may fix the problem. If you "
8154
"know how to use rcc please build from: \"{}\" and "
8255
"output to \"{}\"".format(qrc_path, result_path))
8356
else:
@@ -111,7 +84,7 @@ def _new_qapp():
11184
return app
11285

11386

114-
def launch_editor(paths=None, start_rpc=True):
87+
def launch_editor(paths=None, start_rpc=False):
11588
"""Launch an instance of the editor. Will attach to existing QApp if found,
11689
otherwise will create and open one.
11790
"""
@@ -120,18 +93,23 @@ def launch_editor(paths=None, start_rpc=True):
12093
app = existing
12194
else:
12295
app = _new_qapp()
96+
from nxt_editor.dialogs import UpgradePrefsDialogue
97+
UpgradePrefsDialogue.confirm_upgrade_if_possible()
12398
instance = show_new_editor(paths, start_rpc)
12499
app.setActiveWindow(instance)
125100
if not existing:
126101
app.exec_()
127102
return instance
128103

129104

130-
def show_new_editor(paths=None, start_rpc=True):
105+
def show_new_editor(paths=None, start_rpc=False):
131106
path = None
132-
if paths is not None:
107+
if paths and isinstance(paths, list):
133108
path = paths[0]
134109
paths.pop(0)
110+
elif isinstance(paths, str):
111+
path = paths
112+
paths = []
135113
else:
136114
paths = []
137115
# Deferred import since main window relies on us

nxt_editor/constants.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ class EDITOR_VERSION(object):
2222

2323

2424
class FONTS(object):
25-
DEFAULT_FAMILY = 'RobotoMono-Regular'
25+
DEFAULT_FAMILY = 'Roboto Mono'
2626
DEFAULT_SIZE = 10
2727

2828

29-
_pref_dir_name = str(EDITOR_VERSION.MAJOR)
30-
PREF_DIR = os.path.join(USER_DIR, 'prefs', _pref_dir_name)
29+
PREF_DIR_INT = EDITOR_VERSION.MAJOR
30+
PREF_DIR_NAME = 'prefs'
31+
_pref_dir_num = str(PREF_DIR_INT)
32+
PREF_DIR = os.path.join(USER_DIR, PREF_DIR_NAME, _pref_dir_num)
3133

3234
NXT_WEBSITE = 'https://nxt-dev.github.io/'

nxt_editor/dialogs.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def build_widgets(self):
297297
self.save_details_button.released.connect(self.on_save_details)
298298

299299
self.detail_buttons_layout = QtWidgets.QHBoxLayout()
300-
self.detail_buttons_layout.addStretch(streth=1)
300+
self.detail_buttons_layout.addStretch(1)
301301
self.detail_buttons_layout.addWidget(self.save_details_button)
302302
self.detail_buttons_layout.addWidget(self.copy_details_button)
303303

@@ -314,7 +314,7 @@ def build_widgets(self):
314314
self.top_right_layout = QtWidgets.QVBoxLayout()
315315
self.top_right_layout.addWidget(self.text_label)
316316
self.top_right_layout.addWidget(self.info_label)
317-
self.top_right_layout.addStretch(streth=1)
317+
self.top_right_layout.addStretch(1)
318318
self.top_right_layout.addLayout(self.buttons_layout)
319319
self.top_layout = QtWidgets.QHBoxLayout()
320320
self.top_layout.addWidget(self.icon)
@@ -373,14 +373,16 @@ def show_message(cls, text, info, details=None):
373373

374374

375375
class NxtConfirmDialog(QtWidgets.QMessageBox):
376+
Ok = QtWidgets.QMessageBox.StandardButton.Ok
377+
Cancel = QtWidgets.QMessageBox.StandardButton.Cancel
376378
def __init__(self, text='Title', info='Confirm something!',
377379
button_text=None, icon=QtWidgets.QMessageBox.Icon.Question):
378380
"""Simple message box used for user confirmation
379381
:param text: Title text
380382
:param info: Main info text
381383
:param button_text: Custom button text dict:
382-
{QtWidgets.QMessageBox.Ok: 'Custom Ok Text',
383-
QtWidgets.QMessageBox.Cancel: 'Custom Cancel Text'}
384+
{QtWidgets.QMessageBox.StandardButton.Ok: 'Custom Ok Text',
385+
QtWidgets.QMessageBox.StandardButton.Cancel: 'Custom Cancel Text'}
384386
"""
385387
super(NxtConfirmDialog, self).__init__()
386388
self.setText(text)
@@ -389,6 +391,7 @@ def __init__(self, text='Title', info='Confirm something!',
389391
self.setIcon(icon)
390392
self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
391393
self.setStandardButtons(self.Ok | self.Cancel)
394+
self.setWindowTitle(text)
392395
if button_text:
393396
self.setButtonText(self.Ok, button_text.get(self.Ok, 'Ok'))
394397
self.setButtonText(self.Cancel, button_text.get(self.Cancel,
@@ -408,6 +411,31 @@ def show_message(cls, *args, **kwargs):
408411
return False
409412

410413

414+
class UpgradePrefsDialogue(NxtConfirmDialog):
415+
def __int__(self, title_text, info, button_text):
416+
super(UpgradePrefsDialogue, self).__init__(text=title_text,
417+
info=info,
418+
button_text=button_text)
419+
420+
@classmethod
421+
def confirm_upgrade_if_possible(cls):
422+
423+
if not user_dir.UPGRADABLE_PREFS:
424+
return
425+
from_version = user_dir.UPGRADE_PREFS_FROM_VERSION
426+
title_text = f'Copy version {from_version} Preferences?'
427+
button_text = {
428+
NxtConfirmDialog.Ok: f'Copy v{from_version} prefs',
429+
NxtConfirmDialog.Cancel: 'Use default preferences'
430+
}
431+
i = ('Would you like to copy preferences from an older version of NXT?'
432+
'\nSome things like the window layout may not be preserved.')
433+
do_upgrade = super().show_message(text=title_text, info=i,
434+
button_text=button_text)
435+
if do_upgrade:
436+
user_dir.upgrade_prefs(user_dir.UPGRADABLE_PREFS)
437+
438+
411439
class UnsavedLayersDialogue(QtWidgets.QDialog):
412440
@classmethod
413441
def save_before_exit(cls, stage_models, main_window):

nxt_editor/dockwidgets/build_view.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class BuildTable(QtWidgets.QTableView):
315315
"""
316316
def __init__(self):
317317
super(BuildTable, self).__init__()
318-
self.setSelectionMode(self.NoSelection)
318+
self.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection)
319319
self.horizontalHeader().hide()
320320
self.verticalHeader().hide()
321321
self.break_delegate = LetterCheckboxDelegeate('B')
@@ -342,7 +342,7 @@ def setModel(self, model):
342342
header = self.horizontalHeader()
343343
header.setStretchLastSection(False)
344344
header.setDefaultSectionSize(28)
345-
header.setSectionResizeMode(header.Fixed)
345+
header.setSectionResizeMode(QtWidgets.QHeaderView.Fixed)
346346
if header.count():
347347
column = BuildModel.PATH_COLUMN
348348
header.setSectionResizeMode(column, QtWidgets.QHeaderView.Stretch)

nxt_editor/dockwidgets/code_editor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ def focusOutEvent(self, event):
778778
return QtWidgets.QPlainTextEdit.focusOutEvent(self, event)
779779

780780
def wheelEvent(self, event):
781-
delta = event.delta()
781+
delta = event.angleDelta().y() / 8
782782
if event.modifiers() == QtCore.Qt.ControlModifier:
783783
if delta > 0:
784784
self.set_font_size(delta=0.5)
@@ -1271,7 +1271,7 @@ def paintEvent(self, event):
12711271

12721272
def get_width(self):
12731273
count = self.editor.blockCount()
1274-
width = self.fontMetrics().width(str(count)) + 10
1274+
width = self.fontMetrics().horizontalAdvance(str(count)) + 10
12751275
return width
12761276

12771277
def update_width(self):

nxt_editor/dockwidgets/find_rep.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def setModel(self, model):
196196
super(SearchResultsTree, self).setModel(model)
197197
header = self.header()
198198
header.setStretchLastSection(False)
199-
header.setSectionResizeMode(header.ResizeToContents)
199+
header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
200200
if self.model():
201201
self.model().modelReset.connect(self.expandAll)
202202

0 commit comments

Comments
 (0)