mirror of https://gitlab.com/pamhyr/pamhyr2
Study: Switch rich text to markdown.
parent
16a0e03d1d
commit
48c98cddba
|
|
@ -436,6 +436,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit):
|
||||||
if Modules.CONFIG in keys:
|
if Modules.CONFIG in keys:
|
||||||
self._do_update_config()
|
self._do_update_config()
|
||||||
|
|
||||||
|
if Modules.STUDY in keys:
|
||||||
|
self._tab_widget_info.update()
|
||||||
|
|
||||||
logger.debug(f"Propagation of {keys}")
|
logger.debug(f"Propagation of {keys}")
|
||||||
for _, window in self.sub_win_list:
|
for _, window in self.sub_win_list:
|
||||||
window._propagated_update(key=keys)
|
window._propagated_update(key=keys)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from Modules import Modules
|
||||||
from Model.Study import Study
|
from Model.Study import Study
|
||||||
from View.Tools.PamhyrWindow import PamhyrDialog
|
from View.Tools.PamhyrWindow import PamhyrDialog
|
||||||
|
|
||||||
|
|
@ -27,11 +30,14 @@ from PyQt5.QtGui import (
|
||||||
|
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
QRadioButton, QLabel, QDateTimeEdit,
|
QRadioButton, QLabel, QDateTimeEdit,
|
||||||
QTextEdit, QPushButton,
|
QTextEdit, QPlainTextEdit, QTextBrowser,
|
||||||
|
QPushButton,
|
||||||
)
|
)
|
||||||
|
|
||||||
_translate = QCoreApplication.translate
|
_translate = QCoreApplication.translate
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
class NewStudyWindow(PamhyrDialog):
|
class NewStudyWindow(PamhyrDialog):
|
||||||
_pamhyr_ui = "NewStudy"
|
_pamhyr_ui = "NewStudy"
|
||||||
|
|
@ -56,8 +62,11 @@ class NewStudyWindow(PamhyrDialog):
|
||||||
|
|
||||||
if self._study is not None:
|
if self._study is not None:
|
||||||
self.set_line_edit_text("lineEdit_name", self._study.name)
|
self.set_line_edit_text("lineEdit_name", self._study.name)
|
||||||
|
self.set_plaintext_edit_text(
|
||||||
|
"plainTextEdit_description", self._study.description
|
||||||
|
)
|
||||||
self.set_text_edit_text(
|
self.set_text_edit_text(
|
||||||
"textEdit_description", self._study.description
|
"textBrowser_description", self._study.description
|
||||||
)
|
)
|
||||||
self.set_datetime_edit("dateTimeEdit_date", self._study.date)
|
self.set_datetime_edit("dateTimeEdit_date", self._study.date)
|
||||||
|
|
||||||
|
|
@ -82,23 +91,15 @@ class NewStudyWindow(PamhyrDialog):
|
||||||
time.toggled.connect(self.set_time)
|
time.toggled.connect(self.set_time)
|
||||||
date.toggled.connect(self.set_date)
|
date.toggled.connect(self.set_date)
|
||||||
|
|
||||||
self._desc = self.find(QTextEdit, "textEdit_description")
|
md_edit = self.find(QPlainTextEdit, "plainTextEdit_description")
|
||||||
self._bold = self.find(QPushButton, "pushButton_bold")
|
#md_previou = self.find(QTextBrowser, "textBrowser_description")
|
||||||
self._italic = self.find(QPushButton, "pushButton_italic")
|
md_edit.textChanged.connect(
|
||||||
self._underline = self.find(QPushButton, "pushButton_underline")
|
lambda: self.set_text_edit_text(
|
||||||
self._highlight = self.find(QPushButton, "pushButton_highlight")
|
"textBrowser_description",
|
||||||
|
self.get_plaintext_edit_text(
|
||||||
self._bold.clicked.connect(
|
"plainTextEdit_description"
|
||||||
lambda x: self._desc.setFontWeight(
|
|
||||||
QFont.Bold if x else QFont.Normal
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self._italic.clicked.connect(self._desc.setFontItalic)
|
|
||||||
self._underline.clicked.connect(self._desc.setFontUnderline)
|
|
||||||
self._highlight.clicked.connect(
|
|
||||||
lambda x: self._desc.setTextBackgroundColor(
|
|
||||||
QColor("yellow") if x else QColor("white")
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_time(self):
|
def set_time(self):
|
||||||
|
|
@ -113,7 +114,8 @@ class NewStudyWindow(PamhyrDialog):
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
name = self.get_line_edit_text("lineEdit_name")
|
name = self.get_line_edit_text("lineEdit_name")
|
||||||
description = self.get_text_edit_text("textEdit_description")
|
description = self.get_plaintext_edit_text("plainTextEdit_description")
|
||||||
|
logger.info(description)
|
||||||
|
|
||||||
if self._study is None:
|
if self._study is None:
|
||||||
study = Study.new(name, description)
|
study = Study.new(name, description)
|
||||||
|
|
@ -132,4 +134,5 @@ class NewStudyWindow(PamhyrDialog):
|
||||||
else:
|
else:
|
||||||
self._study.use_time()
|
self._study.use_time()
|
||||||
|
|
||||||
|
self._propagate_update(key=Modules.STUDY)
|
||||||
self.done(True)
|
self.done(True)
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ class ASubWindowFeatures(object):
|
||||||
Returns:
|
Returns:
|
||||||
Nothing
|
Nothing
|
||||||
"""
|
"""
|
||||||
self.find(QTextEdit, name).setText(text)
|
self.find(QTextEdit, name).setMarkdown(text)
|
||||||
|
|
||||||
def get_text_edit_text(self, name: str):
|
def get_text_edit_text(self, name: str):
|
||||||
"""Get text of text edit component
|
"""Get text of text edit component
|
||||||
|
|
@ -229,7 +229,7 @@ class ASubWindowFeatures(object):
|
||||||
Returns:
|
Returns:
|
||||||
Text
|
Text
|
||||||
"""
|
"""
|
||||||
return self.find(QTextEdit, name).toHtml()
|
return self.find(QTextEdit, name).toMarkdown()
|
||||||
|
|
||||||
def set_plaintext_edit_text(self, name: str, text: str):
|
def set_plaintext_edit_text(self, name: str, text: str):
|
||||||
"""Set text of text edit component
|
"""Set text of text edit component
|
||||||
|
|
|
||||||
|
|
@ -48,117 +48,34 @@
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="Line" name="line_2">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="orientation">
|
<property name="currentIndex">
|
||||||
<enum>Qt::Horizontal</enum>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<widget class="QWidget" name="tab">
|
||||||
</item>
|
<attribute name="title">
|
||||||
<item>
|
<string>Markdown</string>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
</attribute>
|
||||||
<item>
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<widget class="QPushButton" name="pushButton_bold">
|
<item row="0" column="0">
|
||||||
<property name="maximumSize">
|
<widget class="QPlainTextEdit" name="plainTextEdit_description">
|
||||||
<size>
|
|
||||||
<width>32</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>B</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_italic">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>32</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<italic>true</italic>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>I</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_underline">
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>32</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<underline>true</underline>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>U</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_highlight">
|
|
||||||
<property name="text">
|
|
||||||
<string>Highlight</string>
|
|
||||||
</property>
|
|
||||||
<property name="checkable">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="autoDefault">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="flat">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTextEdit" name="textEdit_description">
|
|
||||||
<property name="autoFillBackground">
|
<property name="autoFillBackground">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="tabChangesFocus">
|
</widget>
|
||||||
<bool>false</bool>
|
</item>
|
||||||
</property>
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_2">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Preview</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QTextBrowser" name="textBrowser_description"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue