mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
use single view mode button system, similar to channels
This commit is contained in:
parent
395435b5f3
commit
364e9ffdd2
@ -67,6 +67,10 @@ Q_DECLARE_METATYPE(RsPostedPost);
|
||||
|
||||
// Delegate used to paint into the table of thumbnails
|
||||
|
||||
//===================================================================================================================================
|
||||
//== PostedPostDelegate ==
|
||||
//===================================================================================================================================
|
||||
|
||||
std::ostream& operator<<(std::ostream& o,const QSize& s) { return o << s.width() << " x " << s.height() ; }
|
||||
|
||||
void PostedPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
|
||||
@ -189,6 +193,10 @@ void PostedPostDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptio
|
||||
editor->setGeometry(option.rect);
|
||||
}
|
||||
|
||||
//===================================================================================================================================
|
||||
//== PostedListWidgetWithModel ==
|
||||
//===================================================================================================================================
|
||||
|
||||
/** Constructor */
|
||||
PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedId, QWidget *parent) :
|
||||
GxsMessageFrameWidget(rsPosted, parent),
|
||||
@ -214,8 +222,7 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
||||
connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prev10Posts()));
|
||||
|
||||
connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&)));
|
||||
connect(ui->cardViewButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode()));
|
||||
connect(ui->classicViewButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode()));
|
||||
connect(ui->viewModeButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode()));
|
||||
|
||||
connect(mPostedPostsModel,SIGNAL(boardPostsLoaded()),this,SLOT(postPostLoad()));
|
||||
|
||||
@ -251,9 +258,8 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
||||
settingsChanged();
|
||||
setGroupId(postedId);
|
||||
|
||||
ui->classicViewButton->setChecked(true); // inits both button checking consistency and delegate display mode variables.
|
||||
|
||||
mPostedPostsModel->updateBoard(postedId);
|
||||
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW);
|
||||
switchDisplayMode(); // makes everything consistent and chooses classic view as default
|
||||
|
||||
mEventHandlerId = 0;
|
||||
// Needs to be asynced because this function is called by another thread!
|
||||
@ -265,18 +271,21 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
||||
|
||||
void PostedListWidgetWithModel::switchDisplayMode()
|
||||
{
|
||||
if(sender() == ui->classicViewButton)
|
||||
if(mPostedPostsDelegate->getDisplayMode() == BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW)
|
||||
{
|
||||
whileBlocking(ui->cardViewButton)->setChecked(false);
|
||||
ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/classic.png"));
|
||||
ui->viewModeButton->setToolTip(tr("Click to switch to card view"));
|
||||
|
||||
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_COMPACT);
|
||||
}
|
||||
else
|
||||
{
|
||||
whileBlocking(ui->classicViewButton)->setChecked(false);
|
||||
ui->viewModeButton->setIcon(FilesDefs::getIconFromQtResourcePath(":images/card.png"));
|
||||
ui->viewModeButton->setToolTip(tr("Click to switch to compact view"));
|
||||
|
||||
mPostedPostsDelegate->setDisplayMode(BoardPostDisplayWidget::DISPLAY_MODE_CARD_VIEW);
|
||||
}
|
||||
|
||||
forceRedraw();
|
||||
mPostedPostsModel->triggerRedraw();
|
||||
}
|
||||
|
||||
void PostedListWidgetWithModel::updateSorting(int s)
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
|
||||
void setCellWidth(int pix) { mCellWidthPix = pix; }
|
||||
void setDisplayMode(BoardPostDisplayWidget::DisplayMode dm) { mDisplayMode = dm; }
|
||||
BoardPostDisplayWidget::DisplayMode getDisplayMode() const { return mDisplayMode; }
|
||||
|
||||
public slots:
|
||||
void expandItem(RsGxsMessageId msgId,bool expanded);
|
||||
|
@ -350,6 +350,9 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
@ -411,7 +414,7 @@ p, li { white-space: pre-wrap; }
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="classicViewButton">
|
||||
<widget class="QPushButton" name="viewModeButton">
|
||||
<property name="font">
|
||||
<font>
|
||||
<kerning>true</kerning>
|
||||
@ -438,29 +441,6 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cardViewButton">
|
||||
<property name="toolTip">
|
||||
<string>Card View</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="Posted_images.qrc">
|
||||
<normaloff>:/images/card.png</normaloff>:/images/card.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@ -561,8 +541,8 @@ p, li { white-space: pre-wrap; }
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="Posted_images.qrc"/>
|
||||
<include location="../icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user