tried to implement a toggle menu feature with alt key, but it does not work :(
This commit is contained in:
@@ -16,7 +16,10 @@ import os, re
|
|||||||
from PyQt5 import QtCore
|
from PyQt5 import QtCore
|
||||||
from PyQt5.QtCore import QUrl, QSettings, QSizeF, Qt
|
from PyQt5.QtCore import QUrl, QSettings, QSizeF, Qt
|
||||||
from PyQt5.QtGui import QKeySequence, QFont
|
from PyQt5.QtGui import QKeySequence, QFont
|
||||||
from PyQt5.QtWidgets import QWidget, QTabWidget, QVBoxLayout, QHBoxLayout, QSplitter, QPlainTextEdit, QShortcut, QPushButton, QCheckBox, QSpinBox, QLabel
|
from PyQt5.QtWidgets import (QWidget, QTabWidget,
|
||||||
|
QVBoxLayout, QHBoxLayout, QSplitter,
|
||||||
|
QPlainTextEdit, QShortcut,
|
||||||
|
QPushButton, QCheckBox, QSpinBox, QLabel)
|
||||||
from PyQt5.QtWebKit import QWebSettings
|
from PyQt5.QtWebKit import QWebSettings
|
||||||
from PyQt5.QtWebKitWidgets import QWebView, QWebInspector
|
from PyQt5.QtWebKitWidgets import QWebView, QWebInspector
|
||||||
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrinter
|
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrinter
|
||||||
@@ -316,6 +319,7 @@ class CodeEditor(QPlainTextEdit):
|
|||||||
self.tabs = tabs
|
self.tabs = tabs
|
||||||
self.file = file
|
self.file = file
|
||||||
self.hl= highlighter.Highlighter(self.document(),mode)
|
self.hl= highlighter.Highlighter(self.document(),mode)
|
||||||
|
# TODO: set code editor background color to dark
|
||||||
self.setText()
|
self.setText()
|
||||||
self.setTabStopWidth(15)
|
self.setTabStopWidth(15)
|
||||||
|
|
||||||
|
|||||||
@@ -10,15 +10,17 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import, print_function, division, unicode_literals
|
from __future__ import absolute_import, print_function, division, unicode_literals
|
||||||
|
|
||||||
import os
|
import os, asyncio
|
||||||
|
|
||||||
from PyQt5.QtGui import QIcon
|
|
||||||
from PyQt5.QtWidgets import QMainWindow, QAction, QWidget, QLabel, QStackedWidget, QFileDialog, QMessageBox
|
|
||||||
|
|
||||||
|
from PyQt5.QtCore import Qt
|
||||||
|
from PyQt5.QtGui import QIcon, QKeySequence
|
||||||
|
from PyQt5.QtWidgets import (QMainWindow, QAction, QWidget,
|
||||||
|
QLabel, QStackedWidget,
|
||||||
|
QFileDialog, QMessageBox,
|
||||||
|
QShortcut)
|
||||||
from . import design, content, docsetdialog
|
from . import design, content, docsetdialog
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MainWindow(QMainWindow):
|
class MainWindow(QMainWindow):
|
||||||
def __init__(self, core):
|
def __init__(self, core):
|
||||||
super(MainWindow, self).__init__()
|
super(MainWindow, self).__init__()
|
||||||
@@ -251,6 +253,45 @@ class MainWindow(QMainWindow):
|
|||||||
elif q.text() == "&Version":
|
elif q.text() == "&Version":
|
||||||
self.mainstack.setCurrentIndex(2)
|
self.mainstack.setCurrentIndex(2)
|
||||||
|
|
||||||
|
# __ ____ ______ __
|
||||||
|
# / /_____ __ __/ __ \________ __________/ ____/ _____ ____ / /_
|
||||||
|
# / //_/ _ \/ / / / /_/ / ___/ _ \/ ___/ ___/ __/ | | / / _ \/ __ \/ __/
|
||||||
|
# / ,< / __/ /_/ / ____/ / / __(__ |__ ) /___ | |/ / __/ / / / /_
|
||||||
|
# /_/|_|\___/\__, /_/ /_/ \___/____/____/_____/ |___/\___/_/ /_/\__/
|
||||||
|
# /____/
|
||||||
|
# def keyPressEvent(self, e):
|
||||||
|
# print('keyPressEvent', e.key())
|
||||||
|
# # print('Qt.Key_Alt', Qt.Key_Alt)
|
||||||
|
# super(MainWindow, self).keyPressEvent(e)
|
||||||
|
# self.checkToggleMenu('pressed', e.key() == Qt.Key_Alt)
|
||||||
|
#
|
||||||
|
# def keyReleaseEvent(self, e):
|
||||||
|
# print('keyReleaseEvent', e.key())
|
||||||
|
# # print('Qt.Key_Alt', Qt.Key_Alt)
|
||||||
|
# super(MainWindow, self).keyReleaseEvent(e)
|
||||||
|
# self.checkToggleMenu('released', e.key() == Qt.Key_Alt)
|
||||||
|
|
||||||
|
# def checkToggleMenu(self, act='released', alt=True):
|
||||||
|
# print("-- -- checkToggleMenu : "+act+" | alt :"+str(alt))
|
||||||
|
# # if alt is pressed, other key pressevent is not fired, only release :(
|
||||||
|
# # keyPressEvent is waiting for toggleMenu o_O which is supposed to be asynchro ...
|
||||||
|
# if not alt:
|
||||||
|
# self.key_pressed_after_alt = True
|
||||||
|
# if alt and act=="pressed":
|
||||||
|
# self.key_pressed_after_alt = False
|
||||||
|
# if act == 'released' and alt:
|
||||||
|
# loop = asyncio.get_event_loop()
|
||||||
|
# loop.run_until_complete(self.toggleMenu())
|
||||||
|
# # loop.close()
|
||||||
|
|
||||||
|
# async def toggleMenu(self):
|
||||||
|
# print('toggleMenu')
|
||||||
|
# await asyncio.sleep(2)
|
||||||
|
# if not self.key_pressed_after_alt:
|
||||||
|
# print('!! !! TOGGLE !! !!')
|
||||||
|
# # self.menuBar().setVisible(not self.menuBar().isVisible())
|
||||||
|
|
||||||
|
|
||||||
# __ ___ _ _____ __ __
|
# __ ___ _ _____ __ __
|
||||||
# / |/ /___ _(_)___ / ___// /_____ ______/ /__
|
# / |/ /___ _(_)___ / ___// /_____ ______/ /__
|
||||||
# / /|_/ / __ `/ / __ \\__ \/ __/ __ `/ ___/ //_/
|
# / /|_/ / __ `/ / __ \\__ \/ __/ __ `/ ___/ //_/
|
||||||
|
|||||||
Reference in New Issue
Block a user