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:
|
||||
self._do_update_config()
|
||||
|
||||
if Modules.STUDY in keys:
|
||||
self._tab_widget_info.update()
|
||||
|
||||
logger.debug(f"Propagation of {keys}")
|
||||
for _, window in self.sub_win_list:
|
||||
window._propagated_update(key=keys)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
|
||||
from Modules import Modules
|
||||
from Model.Study import Study
|
||||
from View.Tools.PamhyrWindow import PamhyrDialog
|
||||
|
||||
|
|
@ -27,11 +30,14 @@ from PyQt5.QtGui import (
|
|||
|
||||
from PyQt5.QtWidgets import (
|
||||
QRadioButton, QLabel, QDateTimeEdit,
|
||||
QTextEdit, QPushButton,
|
||||
QTextEdit, QPlainTextEdit, QTextBrowser,
|
||||
QPushButton,
|
||||
)
|
||||
|
||||
_translate = QCoreApplication.translate
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
class NewStudyWindow(PamhyrDialog):
|
||||
_pamhyr_ui = "NewStudy"
|
||||
|
|
@ -56,8 +62,11 @@ class NewStudyWindow(PamhyrDialog):
|
|||
|
||||
if self._study is not None:
|
||||
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(
|
||||
"textEdit_description", self._study.description
|
||||
"textBrowser_description", self._study.description
|
||||
)
|
||||
self.set_datetime_edit("dateTimeEdit_date", self._study.date)
|
||||
|
||||
|
|
@ -82,22 +91,14 @@ class NewStudyWindow(PamhyrDialog):
|
|||
time.toggled.connect(self.set_time)
|
||||
date.toggled.connect(self.set_date)
|
||||
|
||||
self._desc = self.find(QTextEdit, "textEdit_description")
|
||||
self._bold = self.find(QPushButton, "pushButton_bold")
|
||||
self._italic = self.find(QPushButton, "pushButton_italic")
|
||||
self._underline = self.find(QPushButton, "pushButton_underline")
|
||||
self._highlight = self.find(QPushButton, "pushButton_highlight")
|
||||
|
||||
self._bold.clicked.connect(
|
||||
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")
|
||||
md_edit = self.find(QPlainTextEdit, "plainTextEdit_description")
|
||||
#md_previou = self.find(QTextBrowser, "textBrowser_description")
|
||||
md_edit.textChanged.connect(
|
||||
lambda: self.set_text_edit_text(
|
||||
"textBrowser_description",
|
||||
self.get_plaintext_edit_text(
|
||||
"plainTextEdit_description"
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
|
@ -113,7 +114,8 @@ class NewStudyWindow(PamhyrDialog):
|
|||
|
||||
def accept(self):
|
||||
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:
|
||||
study = Study.new(name, description)
|
||||
|
|
@ -132,4 +134,5 @@ class NewStudyWindow(PamhyrDialog):
|
|||
else:
|
||||
self._study.use_time()
|
||||
|
||||
self._propagate_update(key=Modules.STUDY)
|
||||
self.done(True)
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ class ASubWindowFeatures(object):
|
|||
Returns:
|
||||
Nothing
|
||||
"""
|
||||
self.find(QTextEdit, name).setText(text)
|
||||
self.find(QTextEdit, name).setMarkdown(text)
|
||||
|
||||
def get_text_edit_text(self, name: str):
|
||||
"""Get text of text edit component
|
||||
|
|
@ -229,7 +229,7 @@ class ASubWindowFeatures(object):
|
|||
Returns:
|
||||
Text
|
||||
"""
|
||||
return self.find(QTextEdit, name).toHtml()
|
||||
return self.find(QTextEdit, name).toMarkdown()
|
||||
|
||||
def set_plaintext_edit_text(self, name: str, text: str):
|
||||
"""Set text of text edit component
|
||||
|
|
|
|||
|
|
@ -48,117 +48,34 @@
|
|||
<item row="2" column="1">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_bold">
|
||||
<property name="maximumSize">
|
||||
<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">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="tabChangesFocus">
|
||||
<bool>false</bool>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Markdown</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit_description">
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
|||
Loading…
Reference in New Issue