used a more compact layout for comment button in order to align everything in compact view

This commit is contained in:
csoler 2020-09-28 22:27:44 +02:00
parent 819035472d
commit 6e33c65334
3 changed files with 59 additions and 48 deletions

View File

@ -58,13 +58,29 @@ BoardPostDisplayWidgetBase::BoardPostDisplayWidgetBase(const RsPostedPost& post,
void BoardPostDisplayWidgetBase::setCommentsSize(int comNb)
{
QString sComButText = tr("Comment");
if (comNb == 1)
sComButText = sComButText.append("(1)");
else if(comNb > 1)
sComButText = tr("Comments ").append("(%1)").arg(comNb);
QString sComButText ;
commentButton()->setText(sComButText);
if (comNb == 1)
sComButText = tr("1 comment");
else if(comNb > 1)
sComButText = tr("%1 comments").arg(comNb);
else
sComButText = tr("No comments yet. Click to add one.");
commentButton()->setToolTip(sComButText);
if(comNb > 0)
commentButton()->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/comments_blue.png"));
else
commentButton()->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/comments.png"));
// QString sComButText = tr("Comment");
// if (comNb == 1)
// sComButText = sComButText.append("(1)");
// else if(comNb > 1)
// sComButText = tr("Comments ").append("(%1)").arg(comNb);
//
// commentButton()->setText(sComButText);
}
void BoardPostDisplayWidgetBase::makeDownVote()
@ -270,13 +286,7 @@ void BoardPostDisplayWidgetBase::setup()
//frame_comment->show();
commentButton()->show();
if (mPost.mComments)
{
QString commentText = tr("Comments (%1)").arg(QString::number(mPost.mComments));
commentButton()->setText(commentText);
}
else
commentButton()->setText(tr("Comment"));
setCommentsSize(mPost.mComments);
setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus));

View File

@ -311,6 +311,26 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="newLabel">
<property name="text">
<string>New</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="readButton">
<property name="maximumSize">
@ -341,9 +361,22 @@
</widget>
</item>
<item>
<widget class="QLabel" name="newLabel">
<widget class="QToolButton" name="commentButton">
<property name="text">
<string>New</string>
<string/>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/comments.png</normaloff>:/images/comments.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
@ -367,26 +400,6 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="commentButton">
<property name="text">
<string>Comments</string>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/comments.png</normaloff>:/images/comments.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="shareButton">
<property name="text">
@ -401,19 +414,6 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>

View File

@ -5,6 +5,7 @@
<file>images/down-arrow.png</file>
<file>images/up-arrow.png</file>
<file>images/comments.png</file>
<file>images/comments_blue.png</file>
<file>images/thumb-default.png</file>
<file>images/thumb-link.png</file>
<file>images/share.png</file>