Enabled ordered/bullet list for Message Composer

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8504 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2015-06-16 19:34:31 +00:00
parent ab95a6c865
commit 1e95534e41
3 changed files with 153 additions and 97 deletions

View File

@ -239,6 +239,26 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
actionAlignJustify = new QAction(QIcon(":/images/textedit/textjustify.png"), tr("&Justify"), grp);
actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J);
actionAlignJustify->setCheckable(true);
QActionGroup *grp2 = new QActionGroup(this);
connect(grp2, SIGNAL(triggered(QAction *)), this, SLOT(textStyle(QAction *)));
actionDisc = new QAction(QIcon(""), tr("Bullet List (Disc)"), grp2);
actionDisc->setCheckable(true);
actionCircle = new QAction(QIcon(""), tr("Bullet List (Circle)"), grp2);
actionCircle->setCheckable(true);
actionSquare = new QAction(QIcon(""), tr("Bullet List (Square)"), grp2);
actionSquare->setCheckable(true);
actionDecimal= new QAction(QIcon(""), tr("Ordered List (Decimal)"), grp2);
actionDecimal->setCheckable(true);
actionLowerAlpha = new QAction(QIcon(""), tr("Ordered List (Alpha lower)"), grp2);
actionLowerAlpha->setCheckable(true);
actionUpperAlpha = new QAction(QIcon(""), tr("Ordered List (Alpha upper)"), grp2);
actionUpperAlpha->setCheckable(true);
actionLowerRoman = new QAction(QIcon(""), tr("Ordered List (Roman lower"), grp2);
actionLowerRoman->setCheckable(true);
actionUpperRoman = new QAction(QIcon(""), tr("Ordered List (Roman upper)"), grp2);
actionUpperRoman->setCheckable(true);
setupFormatActions();
@ -250,15 +270,6 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
ui.filterComboBox->addItem(tr("Distant peer identities"));
ui.filterComboBox->setCurrentIndex(0);
/*ui.comboStyle->addItem("Standard");
ui.comboStyle->addItem("Bullet List (Disc)");
ui.comboStyle->addItem("Bullet List (Circle)");
ui.comboStyle->addItem("Bullet List (Square)");
ui.comboStyle->addItem("Ordered List (Decimal)");
ui.comboStyle->addItem("Ordered List (Alpha lower)");
ui.comboStyle->addItem("Ordered List (Alpha upper)");*/
//connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(textStyle(int)));
connect(ui.comboStyle, SIGNAL(activated(int)),this, SLOT(changeFormatType(int)));
connect(ui.comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &)));
@ -279,6 +290,17 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
alignmentmenu->addAction(actionAlignRight);
alignmentmenu->addAction(actionAlignJustify);
ui.textalignmentbtn->setMenu(alignmentmenu);
QMenu * formatlistmenu = new QMenu();
formatlistmenu->addAction(actionDisc);
formatlistmenu->addAction(actionCircle);
formatlistmenu->addAction(actionSquare);
formatlistmenu->addAction(actionDecimal);
formatlistmenu->addAction(actionLowerAlpha);
formatlistmenu->addAction(actionUpperAlpha);
formatlistmenu->addAction(actionLowerRoman);
formatlistmenu->addAction(actionUpperRoman);
ui.styleButton->setMenu(formatlistmenu);
QPixmap pxm(24,24);
pxm.fill(Qt::black);
@ -2081,34 +2103,28 @@ void MessageComposer::changeFormatType(int styleIndex )
cursor.endEditBlock();
}
void MessageComposer::textStyle(int styleIndex)
void MessageComposer::textStyle(QAction *a)
{
QTextCursor cursor = ui.msgText->textCursor();
if (styleIndex != 0) {
QTextListFormat::Style style = QTextListFormat::ListDisc;
switch (styleIndex) {
default:
case 1:
if (a == actionDisc)
style = QTextListFormat::ListDisc;
break;
case 2:
else if (a == actionCircle)
style = QTextListFormat::ListCircle;
break;
case 3:
else if (a == actionSquare)
style = QTextListFormat::ListSquare;
break;
case 4:
else if (a == actionDecimal)
style = QTextListFormat::ListDecimal;
break;
case 5:
else if (a == actionLowerAlpha)
style = QTextListFormat::ListLowerAlpha;
break;
case 6:
else if (a == actionUpperAlpha)
style = QTextListFormat::ListUpperAlpha;
break;
}
else if (a == actionLowerRoman)
style = QTextListFormat::ListLowerRoman;
else if (a == actionUpperRoman)
style = QTextListFormat::ListUpperRoman;
cursor.beginEditBlock();
@ -2129,12 +2145,12 @@ void MessageComposer::textStyle(int styleIndex)
cursor.createList(listFmt);
cursor.endEditBlock();
} else {
/*} else {
// ####
QTextBlockFormat bfmt;
bfmt.setObjectIndex(-1);
cursor.mergeBlockFormat(bfmt);
}
}*/
}
void MessageComposer::textColor()

View File

@ -122,7 +122,7 @@ private slots:
void textItalic();
void textFamily(const QString &f);
void textSize(const QString &p);
void textStyle(int styleIndex);
void textStyle(QAction *a);
void textColor();
void textbackgroundColor();
void textAlign(QAction *a);
@ -211,7 +211,15 @@ private:
*actionRedo,
*actionCut,
*actionCopy,
*actionPaste;
*actionPaste,
*actionDisc,
*actionCircle,
*actionSquare,
*actionDecimal,
*actionLowerAlpha,
*actionUpperAlpha,
*actionLowerRoman,
*actionUpperRoman;
QAction *contactSidebarAction;

View File

@ -220,6 +220,72 @@
<property name="horizontalSpacing">
<number>1</number>
</property>
<item row="0" column="0">
<widget class="QComboBox" name="comboStyle">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<item>
<property name="text">
<string>Paragraph</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 1</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 2</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 2</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 3</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 4</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 5</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 6</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QFontComboBox" name="comboFont">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="comboSize">
<property name="maximumSize">
@ -234,6 +300,12 @@
<property name="toolTip">
<string>Font size</string>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
</widget>
</item>
<item row="0" column="5">
@ -420,72 +492,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QComboBox" name="comboStyle">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<item>
<property name="text">
<string>Paragraph</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 1</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 2</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 2</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 3</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 4</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 5</string>
</property>
</item>
<item>
<property name="text">
<string>Heading 6</string>
</property>
</item>
</widget>
</item>
<item row="0" column="1">
<widget class="QFontComboBox" name="comboFont">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
</widget>
</item>
<item row="0" column="13">
<widget class="QToolButton" name="textalignmentbtn">
<property name="minimumSize">
@ -667,6 +673,32 @@
</property>
</widget>
</item>
<item row="0" column="11">
<widget class="QToolButton" name="styleButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/textedit/format-list-unordered.png</normaloff>:/images/textedit/format-list-unordered.png</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>