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

@ -240,6 +240,26 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J); actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J);
actionAlignJustify->setCheckable(true); 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(); setupFormatActions();
ui.respond_to_CB->setFlags(IDCHOOSER_ID_REQUIRED) ; ui.respond_to_CB->setFlags(IDCHOOSER_ID_REQUIRED) ;
@ -250,15 +270,6 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
ui.filterComboBox->addItem(tr("Distant peer identities")); ui.filterComboBox->addItem(tr("Distant peer identities"));
ui.filterComboBox->setCurrentIndex(0); 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.comboStyle, SIGNAL(activated(int)),this, SLOT(changeFormatType(int)));
connect(ui.comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &))); connect(ui.comboFont, SIGNAL(activated(const QString &)), this, SLOT(textFamily(const QString &)));
@ -280,6 +291,17 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
alignmentmenu->addAction(actionAlignJustify); alignmentmenu->addAction(actionAlignJustify);
ui.textalignmentbtn->setMenu(alignmentmenu); 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); QPixmap pxm(24,24);
pxm.fill(Qt::black); pxm.fill(Qt::black);
ui.colorbtn->setIcon(pxm); ui.colorbtn->setIcon(pxm);
@ -2081,34 +2103,28 @@ void MessageComposer::changeFormatType(int styleIndex )
cursor.endEditBlock(); cursor.endEditBlock();
} }
void MessageComposer::textStyle(int styleIndex) void MessageComposer::textStyle(QAction *a)
{ {
QTextCursor cursor = ui.msgText->textCursor(); QTextCursor cursor = ui.msgText->textCursor();
if (styleIndex != 0) {
QTextListFormat::Style style = QTextListFormat::ListDisc; QTextListFormat::Style style = QTextListFormat::ListDisc;
switch (styleIndex) { if (a == actionDisc)
default:
case 1:
style = QTextListFormat::ListDisc; style = QTextListFormat::ListDisc;
break; else if (a == actionCircle)
case 2:
style = QTextListFormat::ListCircle; style = QTextListFormat::ListCircle;
break; else if (a == actionSquare)
case 3:
style = QTextListFormat::ListSquare; style = QTextListFormat::ListSquare;
break; else if (a == actionDecimal)
case 4:
style = QTextListFormat::ListDecimal; style = QTextListFormat::ListDecimal;
break; else if (a == actionLowerAlpha)
case 5:
style = QTextListFormat::ListLowerAlpha; style = QTextListFormat::ListLowerAlpha;
break; else if (a == actionUpperAlpha)
case 6:
style = QTextListFormat::ListUpperAlpha; style = QTextListFormat::ListUpperAlpha;
break; else if (a == actionLowerRoman)
} style = QTextListFormat::ListLowerRoman;
else if (a == actionUpperRoman)
style = QTextListFormat::ListUpperRoman;
cursor.beginEditBlock(); cursor.beginEditBlock();
@ -2129,12 +2145,12 @@ void MessageComposer::textStyle(int styleIndex)
cursor.createList(listFmt); cursor.createList(listFmt);
cursor.endEditBlock(); cursor.endEditBlock();
} else { /*} else {
// #### // ####
QTextBlockFormat bfmt; QTextBlockFormat bfmt;
bfmt.setObjectIndex(-1); bfmt.setObjectIndex(-1);
cursor.mergeBlockFormat(bfmt); cursor.mergeBlockFormat(bfmt);
} }*/
} }
void MessageComposer::textColor() void MessageComposer::textColor()

View File

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

View File

@ -220,6 +220,72 @@
<property name="horizontalSpacing"> <property name="horizontalSpacing">
<number>1</number> <number>1</number>
</property> </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"> <item row="0" column="2">
<widget class="QComboBox" name="comboSize"> <widget class="QComboBox" name="comboSize">
<property name="maximumSize"> <property name="maximumSize">
@ -234,6 +300,12 @@
<property name="toolTip"> <property name="toolTip">
<string>Font size</string> <string>Font size</string>
</property> </property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="5"> <item row="0" column="5">
@ -420,72 +492,6 @@
</property> </property>
</widget> </widget>
</item> </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"> <item row="0" column="13">
<widget class="QToolButton" name="textalignmentbtn"> <widget class="QToolButton" name="textalignmentbtn">
<property name="minimumSize"> <property name="minimumSize">
@ -667,6 +673,32 @@
</property> </property>
</widget> </widget>
</item> </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> </layout>
</item> </item>
</layout> </layout>