Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
python-version: "3.11"

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion preditor/excepthooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def ask_to_show_logger(self, *exc_info):

# logger is visible and check if it was minimized on windows
if instance.isVisible() and not instance.isMinimized():
if instance.uiAutoPromptACT.isChecked():
if instance.uiAutoPromptCHK.isChecked():
instance.console().startInputLine()
return

Expand Down
21 changes: 20 additions & 1 deletion preditor/gui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import absolute_import

import re
from functools import partial

from Qt.QtCore import Property
from Qt.QtWidgets import QStackedWidget
from Qt.QtGui import QCursor
from Qt.QtWidgets import QStackedWidget, QToolTip

from .dialog import Dialog # noqa: F401
from .window import Window # noqa: F401
Expand Down Expand Up @@ -61,6 +63,23 @@ def _setattrCallback(callback, attrName, self, value):
return Property(typ, fget=(lambda s: ga(s, name)), fset=(lambda s, v: sa(s, v)))


def handleMenuHovered(action):
"""Actions in QMenus which are not descendants of a QToolBar will not show
their toolTips, because... Reasons?
"""
# Don't show if it's just the text of the action
text = re.sub(r"(?<!&)&(?!&)", "", action.text())
text = text.replace('...', '')

if text == action.toolTip():
text = ''
else:
text = action.toolTip()

menu = action.parent()
QToolTip.showText(QCursor.pos(), text, menu)


def loadUi(filename, widget, uiname=''):
"""use's Qt's uic loader to load dynamic interafces onto the inputed widget

Expand Down
44 changes: 20 additions & 24 deletions preditor/gui/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def __init__(self, parent):
self.addSepNewline = False

# When executing code, that takes longer than this seconds, flash the window
self.flash_time = 1.0
self.flash_window = None

# Store previous commands to retrieve easily
Expand Down Expand Up @@ -165,6 +164,11 @@ def codeHighlighter(self):
"""
return self._uiCodeHighlighter

def contextMenuEvent(self, event):
menu = self.createStandardContextMenu()
menu.setFont(self.window().font())
menu.exec(self.mapToGlobal(event.pos()))

def doubleSingleShotSetScrollValue(self, origPercent):
"""This double QTimer.singleShot monkey business seems to be the only way
to get scroll.maximum() to update properly so that we calc newValue
Expand Down Expand Up @@ -241,17 +245,6 @@ def mouseReleaseEvent(self, event):
QApplication.restoreOverrideCursor()
return super(ConsolePrEdit, self).mouseReleaseEvent(event)

def wheelEvent(self, event):
"""Override of wheelEvent to allow for font resizing by holding ctrl while"""
# scrolling. If used in LoggerWindow, use that wheel event
# May not want to import LoggerWindow, so perhaps
# check by str(type())
ctrlPressed = event.modifiers() == Qt.KeyboardModifier.ControlModifier
if ctrlPressed and "LoggerWindow" in str(type(self.window())):
self.window().wheelEvent(event)
else:
QTextEdit.wheelEvent(self, event)

def keyReleaseEvent(self, event):
"""Override of keyReleaseEvent to determine when to end navigation of
previous commands
Expand All @@ -272,8 +265,8 @@ def errorHyperlink(self):

# Bail if Error Hyperlinks setting is not turned on or we don't have an anchor.
doHyperlink = (
hasattr(window, 'uiErrorHyperlinksACT')
and window.uiErrorHyperlinksACT.isChecked()
hasattr(window, 'uiErrorHyperlinksCHK')
and window.uiErrorHyperlinksCHK.isChecked()
and self.anchor
)
if not doHyperlink:
Expand All @@ -293,7 +286,7 @@ def errorHyperlink(self):
cmdTempl = window.textEditorCmdTempl

# Bail if not setup properly
if workboxName is None:
if not workboxName:
msg = (
"Cannot use traceback hyperlink (Correct the path with Options "
"> Set Preferred Text Editor Path).\n"
Expand Down Expand Up @@ -340,7 +333,7 @@ def errorHyperlink(self):
)
subprocess.Popen(command)
except (ValueError, OSError):
msg = "The provided text editor command template is not valid:\n {}"
msg = "The provided text editor command is not valid:\n {}"
msg = msg.format(cmdTempl)
print(msg)
elif workboxName is not None:
Expand Down Expand Up @@ -433,9 +426,11 @@ def getWorkboxLine(self, name, lineNum):
workbox = self.window().workbox_for_name(name)
if not workbox:
return None
if lineNum > workbox.lines():

num_lines = workbox.__num_lines__()
if lineNum > num_lines:
return None
txt = workbox.text(lineNum).strip() + "\n"
txt = workbox.__text_part__(lineNum=lineNum).strip() + "\n"
return txt

def executeString(
Expand Down Expand Up @@ -484,7 +479,8 @@ def executeString(
self.reportExecutionTime((delta, commandText))

# Provide user feedback when running long code execution.
if self.flash_window and self.flash_time and delta >= self.flash_time:
flash_time = self.window().uiFlashTimeSPIN.value()
if self.flash_window and flash_time and delta >= flash_time:
if settings.OS_TYPE == "Windows":
try:
from casement import utils
Expand Down Expand Up @@ -729,7 +725,7 @@ def keyPressEvent(self, event):
# If option chosen, if the exact prefix exists in the
# possible completions, highlight it, even if it's not the
# topmost completion.
if self.window().uiHighlightExactCompletionACT.isChecked():
if self.window().uiHighlightExactCompletionCHK.isChecked():
for i in range(completer.completionCount()):
completer.setCurrentRow(i)
curCompletion = completer.currentCompletion()
Expand Down Expand Up @@ -934,12 +930,12 @@ def write(self, msg, error=False):
if QtCompat.isValid(self):
window = self.window()
doHyperlink = (
hasattr(window, 'uiErrorHyperlinksACT')
and window.uiErrorHyperlinksACT.isChecked()
hasattr(window, 'uiErrorHyperlinksCHK')
and window.uiErrorHyperlinksCHK.isChecked()
)
sepPreditorTrace = (
hasattr(window, 'uiSeparateTracebackACT')
and window.uiSeparateTracebackACT.isChecked()
hasattr(window, 'uiSeparateTracebackCHK')
and window.uiSeparateTracebackCHK.isChecked()
)
self.moveCursor(QTextCursor.MoveOperation.End)

Expand Down
Loading