Removed Italic text support from the view, its proposed bytecode conflicts with tab-spaces.

master
Tomatix 5 years ago
parent 70819f20e1
commit cfc1635ce8
  1. 16
      Widgets/IIRCView.cpp
  2. 3
      Widgets/IIRCView.h
  3. 6
      Widgets/ILineEdit.cpp

@ -98,7 +98,6 @@ bool isCtrlCode(char c)
case CtrlBold:
case CtrlUnderline:
case CtrlColor:
case CtrlItalic:
case CtrlReverse:
case CtrlStriketrhough:
case CtrlReset:
@ -314,6 +313,7 @@ void IIRCView::resetView()
void IIRCView::formatSpaces(QString& text)
{
text.replace("\t", " ");
if (text.length() < 3)
return;
@ -333,19 +333,16 @@ void IIRCView::ctrlFormat(QString& text)
struct {
bool bold{ false };
bool underline{ false };
bool italic{ false };
bool reverse{ false };
bool strikethrough{ false };
std::optional<QColor> fgColor;
std::optional<QColor> bgColor;
bool has() {
return bold || underline || strikethrough || italic
|| fgColor.has_value() || bgColor.has_value();
return bold || underline || strikethrough || fgColor.has_value() || bgColor.has_value();
}
void reset() {
bold = false;
underline = false;
italic = false;
reverse = false;
strikethrough = false;
fgColor.reset();
@ -409,9 +406,6 @@ void IIRCView::ctrlFormat(QString& text)
case CtrlColor:
parseColor(i);
break;
case CtrlItalic:
state.italic = !state.italic;
break;
case CtrlReverse:
state.reverse = !state.reverse;
break;
@ -454,16 +448,14 @@ void IIRCView::ctrlFormat(QString& text)
textDecoration << "underline";
if (state.strikethrough)
textDecoration << "line-through";
if (state.italic)
style += "font-style:italic;";
if (state.fgColor)
fgColor = QStringLiteral("color: %1;").arg(state.fgColor->name());
if (state.bgColor)
bgColor = QStringLiteral("background-color: %1;").arg(state.bgColor->name());
if (state.reverse) {
ConfigMgr& conf = ConfigMgr::instance();
fgColor = conf.color("TextviewBackground");
bgColor = conf.color("Normal");
fgColor = QStringLiteral("color: %1;").arg( conf.color("TextviewBackground") );
bgColor = QStringLiteral("background-color: %1;").arg( conf.color("Normal") );
}
if (!textDecoration.isEmpty())

@ -70,7 +70,6 @@ enum CtrlCode : char {
CtrlBold = 0x02,
CtrlUnderline = 0x1F,
CtrlColor = 0x03,
CtrlItalic = 0x09,
CtrlReverse = 0x16,
CtrlStriketrhough = 0x13,
CtrlReset = 0x0F
@ -84,7 +83,7 @@ class IIRCView : public QTextBrowser
public:
IIRCView();
void print(const PrintType ptype, const QString& text);
void print(PrintType ptype, const QString& text);
void resetView();
static QString stripTags(const QString& text);
static QString formatType(PrintType ptype, const QString& text);

@ -4,7 +4,7 @@
#include <IWin/IWin.h>
enum CtrlModifierCode : uint16_t {
CMC_Invert = 0x25E9,
CMC_Reverse = 0x25E9,
CMC_Bold = 0x25A0,
CMC_Underline = 0x25BD,
CMC_Color = 0x25A9,
@ -165,7 +165,7 @@ bool KeyEventFilter::eventFilter(QObject* obj, QEvent* evt)
for (auto line : linelist) {
input->prevLines.push_front(line);
if (!Ctrl) {
line.replace(QChar(CMC_Invert), QChar(CtrlReverse));
line.replace(QChar(CMC_Reverse), QChar(CtrlReverse));
line.replace(QChar(CMC_Bold), QChar(CtrlBold));
line.replace(QChar(CMC_Underline), QChar(CtrlUnderline));
line.replace(QChar(CMC_Color), QChar(CtrlColor));
@ -177,7 +177,7 @@ bool KeyEventFilter::eventFilter(QObject* obj, QEvent* evt)
}
}
else if (Ctrl && kevt->key() == Qt::Key_I) {
input->insert(QChar(CMC_Invert));
input->insert(QChar(CMC_Reverse));
return true;
}
else if (Ctrl && kevt->key() == Qt::Key_B) {

Loading…
Cancel
Save