improved layout

This commit is contained in:
csoler 2020-06-04 19:50:34 +02:00
parent a38d5aba14
commit e0cf9768fc
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
2 changed files with 295 additions and 274 deletions

View file

@ -49,6 +49,10 @@
* #define DEBUG_CHANNEL * #define DEBUG_CHANNEL
***/ ***/
static const int mTokenTypeGroupData = 1;
static const int CHANNEL_TABS_DETAILS= 0;
static const int CHANNEL_TABS_POSTS = 1;
/* View mode */ /* View mode */
#define VIEW_MODE_FEEDS 1 #define VIEW_MODE_FEEDS 1
#define VIEW_MODE_FILES 2 #define VIEW_MODE_FILES 2
@ -255,9 +259,18 @@ void GxsChannelPostsWidgetWithModel::handleEvent_main_thread(std::shared_ptr<con
void GxsChannelPostsWidgetWithModel::showPostDetails() void GxsChannelPostsWidgetWithModel::showPostDetails()
{ {
QModelIndex selected_index = ui->postsTree->selectionModel()->currentIndex(); QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
std::cerr << "Showing details about selected index : "<< selected_index.row() << "," << selected_index.column() << std::endl; if(!index.isValid())
{
ui->postDetails_TE->clear();
return;
}
RsGxsChannelPost post = index.data(Qt::UserRole).value<RsGxsChannelPost>() ;
std::cerr << "Showing details about selected index : "<< index.row() << "," << index.column() << std::endl;
ui->postDetails_TE->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
} }
void GxsChannelPostsWidgetWithModel::updateGroupData() void GxsChannelPostsWidgetWithModel::updateGroupData()
@ -285,6 +298,7 @@ void GxsChannelPostsWidgetWithModel::updateGroupData()
{ {
mGroup = groups[0]; mGroup = groups[0];
mThreadModel->updateChannel(groupId()); mThreadModel->updateChannel(groupId());
insertChannelDetails(mGroup);
} ); } );
}); });
} }
@ -427,105 +441,99 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
} else { } else {
chanImage = QPixmap(CHAN_DEFAULT_IMAGE); chanImage = QPixmap(CHAN_DEFAULT_IMAGE);
} }
//ui->logoLabel->setPixmap(chanImage); ui->logoLabel->setPixmap(chanImage);
ui->logoLabel->setFixedSize(QSize(ui->logoLabel->height()*chanImage.width()/(float)chanImage.height(),ui->logoLabel->height())); // make the logo have the same aspect ratio than the original image
if (group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH) ui->postButton->setEnabled(bool(group.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_PUBLISH));
{
mStateHelper->setWidgetEnabled(ui->postButton, true);
}
else
{
mStateHelper->setWidgetEnabled(ui->postButton, false);
}
ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)); ui->subscribeToolButton->setSubscribed(IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags));
mStateHelper->setWidgetEnabled(ui->subscribeToolButton, true); ui->subscribeToolButton->setEnabled(true);
bool autoDownload ; bool autoDownload ;
rsGxsChannels->getChannelAutoDownload(group.mMeta.mGroupId,autoDownload); rsGxsChannels->getChannelAutoDownload(group.mMeta.mGroupId,autoDownload);
setAutoDownload(autoDownload); setAutoDownload(autoDownload);
RetroShareLink link; RetroShareLink link;
if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) { if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags))
ui->feedToolButton->setEnabled(true); {
ui->fileToolButton->setEnabled(true);
//ui->infoWidget->hide();
setViewMode(viewMode());
ui->subscribeToolButton->setText(tr("Subscribed") + " " + QString::number(group.mMeta.mPop) ); ui->subscribeToolButton->setText(tr("Subscribed") + " " + QString::number(group.mMeta.mPop) );
ui->feedToolButton->setEnabled(true);
ui->fileToolButton->setEnabled(true);
ui->channel_TW->setTabEnabled(CHANNEL_TABS_POSTS,true);
ui->details_TW->setEnabled(true);
}
else
{
ui->details_TW->setEnabled(false);
ui->channel_TW->setTabEnabled(CHANNEL_TABS_POSTS,false);
}
ui->infoPosts->clear(); ui->infoPosts->setText(QString::number(group.mMeta.mVisibleMsgCount));
ui->infoDescription->clear(); if(group.mMeta.mLastPost==0)
} else { ui->infoLastPost->setText(tr("Never"));
ui->infoPosts->setText(QString::number(group.mMeta.mVisibleMsgCount)); else
if(group.mMeta.mLastPost==0) ui->infoLastPost->setText(DateTime::formatLongDateTime(group.mMeta.mLastPost));
ui->infoLastPost->setText(tr("Never")); QString formatDescription = QString::fromUtf8(group.mDescription.c_str());
else
ui->infoLastPost->setText(DateTime::formatLongDateTime(group.mMeta.mLastPost));
QString formatDescription = QString::fromUtf8(group.mDescription.c_str());
unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS; unsigned int formatFlag = RSHTML_FORMATTEXT_EMBED_LINKS;
// embed smileys ? // embed smileys ?
if (Settings->valueFromGroup(QString("ChannelPostsWidget"), QString::fromUtf8("Emoteicons_ChannelDecription"), true).toBool()) { if (Settings->valueFromGroup(QString("ChannelPostsWidget"), QString::fromUtf8("Emoteicons_ChannelDecription"), true).toBool()) {
formatFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS; formatFlag |= RSHTML_FORMATTEXT_EMBED_SMILEYS;
} }
formatDescription = RsHtml().formatText(NULL, formatDescription, formatFlag); formatDescription = RsHtml().formatText(NULL, formatDescription, formatFlag);
ui->infoDescription->setText(formatDescription); ui->infoDescription->setText(formatDescription);
ui->infoAdministrator->setId(group.mMeta.mAuthorId) ; ui->infoAdministrator->setId(group.mMeta.mAuthorId) ;
link = RetroShareLink::createMessage(group.mMeta.mAuthorId, ""); link = RetroShareLink::createMessage(group.mMeta.mAuthorId, "");
ui->infoAdministrator->setText(link.toHtml()); ui->infoAdministrator->setText(link.toHtml());
ui->infoCreated->setText(DateTime::formatLongDateTime(group.mMeta.mPublishTs)); ui->infoCreated->setText(DateTime::formatLongDateTime(group.mMeta.mPublishTs));
QString distrib_string ( "[unknown]" ); QString distrib_string ( "[unknown]" );
switch(group.mMeta.mCircleType) switch(group.mMeta.mCircleType)
{ {
case GXS_CIRCLE_TYPE_PUBLIC: distrib_string = tr("Public") ; case GXS_CIRCLE_TYPE_PUBLIC: distrib_string = tr("Public") ;
break ; break ;
case GXS_CIRCLE_TYPE_EXTERNAL: case GXS_CIRCLE_TYPE_EXTERNAL:
{ {
RsGxsCircleDetails det ; RsGxsCircleDetails det ;
// !! What we need here is some sort of CircleLabel, which loads the circle and updates the label when done. // !! What we need here is some sort of CircleLabel, which loads the circle and updates the label when done.
if(rsGxsCircles->getCircleDetails(group.mMeta.mCircleId,det)) if(rsGxsCircles->getCircleDetails(group.mMeta.mCircleId,det))
distrib_string = tr("Restricted to members of circle \"")+QString::fromUtf8(det.mCircleName.c_str()) +"\""; distrib_string = tr("Restricted to members of circle \"")+QString::fromUtf8(det.mCircleName.c_str()) +"\"";
else else
distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ; distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ;
} }
break ; break ;
case GXS_CIRCLE_TYPE_YOUR_EYES_ONLY: distrib_string = tr("Your eyes only"); case GXS_CIRCLE_TYPE_YOUR_EYES_ONLY: distrib_string = tr("Your eyes only");
break ; break ;
case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("You and your friend nodes"); case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("You and your friend nodes");
break ; break ;
default: default:
std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl; std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl;
} }
ui->infoDistribution->setText(distrib_string); ui->infoDistribution->setText(distrib_string);
#ifdef TODO #ifdef TODO
ui->infoWidget->show(); ui->infoWidget->show();
ui->feedWidget->hide(); ui->feedWidget->hide();
ui->fileWidget->hide(); ui->fileWidget->hide();
#endif #endif
ui->feedToolButton->setEnabled(false); ui->feedToolButton->setEnabled(false);
ui->fileToolButton->setEnabled(false); ui->fileToolButton->setEnabled(false);
ui->subscribeToolButton->setText(tr("Subscribe ") + " " + QString::number(group.mMeta.mPop) ); ui->subscribeToolButton->setText(tr("Subscribe ") + " " + QString::number(group.mMeta.mPop) );
}
} }
int GxsChannelPostsWidgetWithModel::viewMode() int GxsChannelPostsWidgetWithModel::viewMode()
@ -870,8 +878,8 @@ void GxsChannelPostsWidget::clearPosts()
void GxsChannelPostsWidgetWithModel::blank() void GxsChannelPostsWidgetWithModel::blank()
{ {
//mStateHelper->setWidgetEnabled(ui->postButton, false); mStateHelper->setWidgetEnabled(ui->postButton, false);
//mStateHelper->setWidgetEnabled(ui->subscribeToolButton, false); mStateHelper->setWidgetEnabled(ui->subscribeToolButton, false);
mThreadModel->clear(); mThreadModel->clear();
groupNameChanged(QString()); groupNameChanged(QString());

View file

@ -222,182 +222,182 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="channel_TW">
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="tab_3"> <widget class="QWidget" name="tab_3">
<attribute name="title"> <attribute name="title">
<string>Channel details</string> <string>Channel details</string>
</attribute> </attribute>
<layout class="QHBoxLayout" name="horizontalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QGroupBox" name="groupBox"> <layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="title"> <item>
<string>Channel details</string> <widget class="QLabel" name="logoLabel">
</property> <property name="text">
<layout class="QGridLayout" name="gridLayout"> <string>TextLabel</string>
<property name="leftMargin"> </property>
<number>9</number> <property name="scaledContents">
</property> <bool>true</bool>
<property name="topMargin"> </property>
<number>9</number> <property name="alignment">
</property> <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<property name="rightMargin"> </property>
<number>9</number> </widget>
</property> </item>
<property name="bottomMargin"> <item>
<number>9</number> <layout class="QGridLayout" name="gridLayout">
</property> <item row="2" column="3">
<item row="1" column="0"> <widget class="GxsIdLabel" name="infoAdministrator">
<widget class="QLabel" name="infoLastPostLabel"> <property name="text">
<property name="sizePolicy"> <string>unknown</string>
<sizepolicy hsizetype="Maximum" vsizetype="Preferred"> </property>
<horstretch>0</horstretch> <property name="openExternalLinks">
<verstretch>0</verstretch> <bool>true</bool>
</sizepolicy> </property>
</property> </widget>
<property name="font"> </item>
<font> <item row="3" column="3">
<weight>75</weight> <widget class="QLabel" name="infoDistribution">
<bold>true</bold> <property name="text">
</font> <string>unknown</string>
</property> </property>
<property name="text"> </widget>
<string>Last Post:</string> </item>
</property> <item row="4" column="1" colspan="2">
</widget> <widget class="QLabel" name="label_2">
</item> <property name="font">
<item row="6" column="0" colspan="3"> <font>
<widget class="QTextBrowser" name="infoDescription"> <weight>75</weight>
<property name="html"> <bold>true</bold>
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; </font>
</property>
<property name="text">
<string>Created:</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QLabel" name="infoCreated">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="infoPostsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Posts:</string>
</property>
</widget>
</item>
<item row="1" column="4">
<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 row="0" column="3">
<widget class="QLabel" name="infoPosts">
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLabel" name="infoLastPostLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Last Post:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLabel" name="infoLastPost">
<property name="text">
<string notr="true">unknown</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Administrator:</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Distribution:</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QTextBrowser" name="infoDescription">
<property name="html">
<string notr="true">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt; &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set> <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property> </property>
<property name="openExternalLinks"> <property name="openExternalLinks">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="openLinks"> <property name="openLinks">
<bool>true</bool> <bool>true</bool>
</property> </property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="infoDescriptionLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Description:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Created:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Administrator:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="infoPostsLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Posts:</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Distribution:</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="infoCreated">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QLabel" name="infoDistribution">
<property name="text">
<string>unknown</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="GxsIdLabel" name="infoAdministrator">
<property name="text">
<string>unknown</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLabel" name="infoLastPost">
<property name="text">
<string notr="true">unknown</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QLabel" name="infoPosts">
<property name="text">
<string notr="true">0</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -406,43 +406,56 @@ p, li { white-space: pre-wrap; }
<attribute name="title"> <attribute name="title">
<string>Posts</string> <string>Posts</string>
</attribute> </attribute>
<layout class="QHBoxLayout" name="horizontalLayout_4"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QTreeView" name="postsTree"> <widget class="QSplitter" name="splitter">
<property name="selectionBehavior"> <property name="orientation">
<enum>QAbstractItemView::SelectItems</enum> <enum>Qt::Vertical</enum>
</property> </property>
<attribute name="headerStretchLastSection"> <widget class="QTreeView" name="postsTree">
<bool>false</bool> <property name="selectionBehavior">
</attribute> <enum>QAbstractItemView::SelectItems</enum>
</property>
<attribute name="headerStretchLastSection">
<bool>false</bool>
</attribute>
</widget>
<widget class="QTabWidget" name="details_TW">
<property name="currentIndex">
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Details</string>
</attribute>
<widget class="QTextEdit" name="postDetails_TE">
<property name="geometry">
<rect>
<x>9</x>
<y>9</y>
<width>955</width>
<height>181</height>
</rect>
</property>
</widget>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Files</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Comments</string>
</attribute>
</widget>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
</widget> </widget>
</item> </item>
<item>
<widget class="QTabWidget" name="details_TW">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Details</string>
</attribute>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QTextEdit" name="textEdit"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Comments</string>
</attribute>
</widget>
</widget>
</item>
</layout> </layout>
<action name="actionFeeds"> <action name="actionFeeds">
<property name="text"> <property name="text">