-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMenuUnderline.cpp
More file actions
56 lines (46 loc) · 1.77 KB
/
Copy pathMenuUnderline.cpp
File metadata and controls
56 lines (46 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "common_headers.h"
#include "ComboBoxColor.h"
#include "MenuUnderline.h"
QMenuUnderline::QMenuUnderline(QWidget* parent)
: QMenu(parent)
{
m_pCmbColor = new QComboBoxColor(this);
m_pCmbColor->setCurrentColor(QColor(Qt::black));
QObject::connect(m_pCmbColor, SIGNAL(colorChose(QColor)), this, SLOT(onColorChose(QColor)));
m_pCmbLineStyle = new QComboBox(this);
{
_CPairVector<QString, QTextCharFormat::UnderlineStyle> vStyles;
vStyles["Single"] = QTextCharFormat::SingleUnderline;
vStyles["Dash"] = QTextCharFormat::DashUnderline;
vStyles["Dot"] = QTextCharFormat::DotLine;
vStyles["Dash Dot"] = QTextCharFormat::DashDotLine;
vStyles["Dash Dot Dot"] = QTextCharFormat::DashDotDotLine;
vStyles["Wave"] = QTextCharFormat::WaveUnderline;
vStyles["Spell Check"] = QTextCharFormat::SpellCheckUnderline;
_CPairVector<QString, QTextCharFormat::UnderlineStyle>::const_iterator it;
__EACH(it, vStyles){
m_pCmbLineStyle->addItem(it->first, QVariant(it->second));
}
QObject::connect(m_pCmbLineStyle, SIGNAL(currentIndexChanged(int)), this, SLOT(onStyleChose(int)));
}
QFormLayout* pLayoutMain = new QFormLayout;
pLayoutMain->addRow("Color", m_pCmbColor);
pLayoutMain->addRow("Style", m_pCmbLineStyle);
QMenu::setLayout(pLayoutMain);
}
QColor QMenuUnderline::underlineColor() const
{
return m_pCmbColor->currentColor();
}
QTextCharFormat::UnderlineStyle QMenuUnderline::underlineStyle() const
{
return (QTextCharFormat::UnderlineStyle)m_pCmbLineStyle->itemData(m_pCmbLineStyle->currentIndex(), Qt::UserRole).toInt();
}
void QMenuUnderline::onColorChose(const QColor& clColor)
{
emit colorChose(clColor);
}
void QMenuUnderline::onStyleChose(int nIndex)
{
emit styleChose((QTextCharFormat::UnderlineStyle)m_pCmbLineStyle->itemData(nIndex, Qt::UserRole).toInt());
}