Added a second color button to Message Composer, for set text background color.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8480 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2015-06-15 22:23:35 +00:00
parent fb8ec988b2
commit ec6f6ea009
3 changed files with 203 additions and 196 deletions

View File

@ -151,6 +151,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
connect(ui.underlinebtn, SIGNAL(clicked()), this, SLOT(textUnderline()));
connect(ui.italicbtn, SIGNAL(clicked()), this, SLOT(textItalic()));
connect(ui.colorbtn, SIGNAL(clicked()), this, SLOT(textColor()));
connect(ui.color2btn, SIGNAL(clicked()), this, SLOT(textbackgroundColor()));
connect(ui.imagebtn, SIGNAL(clicked()), this, SLOT(addImage()));
connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidget()));
//connect(ui.linkbtn, SIGNAL(clicked()), this, SLOT(insertLink()));
@ -282,6 +284,10 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
pxm.fill(Qt::black);
ui.colorbtn->setIcon(pxm);
QPixmap pxm2(24,24);
pxm2.fill(Qt::white);
ui.color2btn->setIcon(pxm2);
/* Set header resize modes and initial section sizes */
QHeaderView * _smheader = ui.msgFileList->header () ;
@ -2142,6 +2148,17 @@ void MessageComposer::textColor()
colorChanged(col);
}
void MessageComposer::textbackgroundColor()
{
QColor col2 = QColorDialog::getColor(ui.msgText->textBackgroundColor(), this);
if (!col2.isValid())
return;
QTextCharFormat fmt;
fmt.setBackground(col2);
mergeFormatOnWordOrSelection(fmt);
colorChanged2(col2);
}
void MessageComposer::textAlign(QAction *a)
{
if (a == actionAlignLeft)
@ -2168,6 +2185,7 @@ void MessageComposer::currentCharFormatChanged(const QTextCharFormat &format)
{
fontChanged(format.font());
colorChanged(format.foreground().color());
colorChanged2(format.background().color());
}
void MessageComposer::cursorPositionChanged()
@ -2200,6 +2218,13 @@ void MessageComposer::colorChanged(const QColor &c)
ui.colorbtn->setIcon(pix);
}
void MessageComposer::colorChanged2(const QColor &c)
{
QPixmap pix(16, 16);
pix.fill(c);
ui.color2btn->setIcon(pix);
}
void MessageComposer::alignmentChanged(Qt::Alignment a)
{
if (a & Qt::AlignLeft) {

View File

@ -124,6 +124,7 @@ private slots:
void textSize(const QString &p);
void textStyle(int styleIndex);
void textColor();
void textbackgroundColor();
void textAlign(QAction *a);
void smileyWidget();
void addSmileys();
@ -187,6 +188,7 @@ private:
void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
void fontChanged(const QFont &f);
void colorChanged(const QColor &c);
void colorChanged2(const QColor &c);
void alignmentChanged(Qt::Alignment a);
bool sendMessage_internal(bool bDraftbox);

View File

@ -60,16 +60,7 @@
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>1</number>
</property>
<item row="1" column="0">
@ -221,16 +212,7 @@
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
@ -238,7 +220,128 @@
<property name="horizontalSpacing">
<number>1</number>
</property>
<item row="0" column="8">
<item row="0" column="2">
<widget class="QComboBox" name="comboSize">
<property name="maximumSize">
<size>
<width>45</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="toolTip">
<string>Font size</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QToolButton" name="sizeincreaseButton">
<property name="maximumSize">
<size>
<width>1677</width>
<height>1677</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Increase font size</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/textedit/format_font_size_more.png</normaloff>:/images/textedit/format_font_size_more.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QToolButton" name="sizedecreaseButton">
<property name="maximumSize">
<size>
<width>167</width>
<height>167</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Decrease font size</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/textedit/format_font_size_less.png</normaloff>:/images/textedit/format_font_size_less.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QToolButton" name="boldbtn">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1677</width>
<height>1677</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Bold</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/textedit/textbold.png</normaloff>:/images/textedit/textbold.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QToolButton" name="italicbtn">
<property name="minimumSize">
<size>
@ -279,7 +382,7 @@
</property>
</widget>
</item>
<item row="0" column="12">
<item row="0" column="14">
<widget class="QToolButton" name="imagebtn">
<property name="minimumSize">
<size>
@ -383,156 +486,7 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="comboSize">
<property name="maximumSize">
<size>
<width>45</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="toolTip">
<string>Font size</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="sizeincreaseButton">
<property name="maximumSize">
<size>
<width>1677</width>
<height>1677</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Increase font size</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/textedit/format_font_size_more.png</normaloff>:/images/textedit/format_font_size_more.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QToolButton" name="sizedecreaseButton">
<property name="maximumSize">
<size>
<width>167</width>
<height>167</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Decrease font size</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/textedit/format_font_size_less.png</normaloff>:/images/textedit/format_font_size_less.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QToolButton" name="boldbtn">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1677</width>
<height>1677</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Bold</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/textedit/textbold.png</normaloff>:/images/textedit/textbold.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="10">
<widget class="QToolButton" name="colorbtn">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>167</width>
<height>167</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Select Color</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="11">
<item row="0" column="13">
<widget class="QToolButton" name="textalignmentbtn">
<property name="minimumSize">
<size>
@ -569,7 +523,7 @@
</property>
</widget>
</item>
<item row="0" column="9">
<item row="0" column="10">
<widget class="QToolButton" name="codeButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
@ -595,7 +549,7 @@
</property>
</widget>
</item>
<item row="0" column="15">
<item row="0" column="17">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -608,7 +562,7 @@
</property>
</spacer>
</item>
<item row="0" column="7">
<item row="0" column="8">
<widget class="QToolButton" name="underlinebtn">
<property name="minimumSize">
<size>
@ -649,7 +603,7 @@
</property>
</widget>
</item>
<item row="0" column="13">
<item row="0" column="15">
<widget class="QToolButton" name="emoticonButton">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
@ -669,6 +623,50 @@
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="colorbtn">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>167</width>
<height>167</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Set Text color</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="color2btn">
<property name="toolTip">
<string>Set Text background color</string>
</property>
<property name="text">
<string/>
</property>
<property name="autoRepeat">
<bool>false</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@ -763,16 +761,7 @@
<enum>QFrame::Box</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>6</number>
</property>
<item>
@ -1009,16 +998,7 @@ border-image: url(:/images/closepressed.png)
</widget>
<widget class="QWidget" name="layoutWidget_1">
<layout class="QGridLayout" name="layoutrecommended">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">