Added Picture View Dialog for open the picture in a external View

* Added Picture View Dialog for open the picture in a external View
* Added a clickable Label for Classic Views Thumbnail label to open Picture via one click
* Imroved the Classic & Card views dark stylesheets for better look and feel
This commit is contained in:
defnax 2020-01-10 19:27:58 +01:00
parent 42491f80e6
commit d0fcd90ccc
12 changed files with 665 additions and 53 deletions

View File

@ -0,0 +1,76 @@
/*******************************************************************************
* retroshare-gui/src/gui/Posted/PhotoView.cpp *
* *
* Copyright (C) 2020 by RetroShare Team <retroshare.project@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#include "PhotoView.h"
#include <QMenu>
#include <QFileDialog>
#include <QMessageBox>
#include "gui/gxs/GxsIdDetails.h"
#include <retroshare/rsidentity.h>
/** Constructor */
PhotoView::PhotoView(QWidget *parent)
: QDialog(parent),
ui(new Ui::PhotoView)
{
/* Invoke the Qt Designer generated object setup routine */
ui->setupUi(this);
ui->shareButton->hide();
}
/** Destructor */
PhotoView::~PhotoView()
{
delete ui;
}
void PhotoView::setPixmap(const QPixmap& pixmap)
{
ui->photoLabel->setPixmap(pixmap);
}
void PhotoView::setTitle(const QString& text)
{
ui->titleLabel->setText(text);
}
void PhotoView::setName(const RsGxsId& authorID)
{
ui->nameLabel->setId(authorID);
RsIdentityDetails idDetails ;
rsIdentity->getIdDetails(authorID,idDetails);
QPixmap pixmap ;
if(idDetails.mAvatar.mSize == 0 || !GxsIdDetails::loadPixmapFromData(idDetails.mAvatar.mData, idDetails.mAvatar.mSize, pixmap,GxsIdDetails::SMALL))
pixmap = GxsIdDetails::makeDefaultIcon(authorID,GxsIdDetails::SMALL);
ui->avatarWidget->setPixmap(pixmap);
}
void PhotoView::setTime(const QString& text)
{
ui->timeLabel->setText(text);
}

View File

@ -0,0 +1,62 @@
/*******************************************************************************
* retroshare-gui/src/gui/Posted/PhotoView.h *
* *
* Copyright (C) 2020 by RetroShare Team <retroshare.project@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#ifndef _PHOTO_VIEW_H
#define _PHOTO_VIEW_H
#include "ui_PhotoView.h"
#include <QDialog>
namespace Ui {
class PhotoView;
}
class PhotoView : public QDialog
{
Q_OBJECT
public:
/** Default Constructor */
PhotoView(QWidget *parent = 0);
/** Default Destructor */
~PhotoView();
public slots:
void setPixmap(const QPixmap& pixmap);
void setTitle (const QString &text);
void setName(const RsGxsId& authorID);
void setTime(const QString& text);
private slots:
private:
/** Qt Designer generated object */
Ui::PhotoView *ui;
};
#endif

View File

@ -0,0 +1,200 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PhotoView</class>
<widget class="QWidget" name="PhotoView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>565</width>
<height>464</height>
</rect>
</property>
<property name="windowTitle">
<string>Photo View</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="titleLabel">
<property name="font">
<font>
<family>MS Sans Serif</family>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item row="0" column="0">
<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="1">
<widget class="QLabel" name="photoLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_3">
<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>
</widget>
</item>
<item row="2" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<family>MS Sans Serif</family>
<pointsize>9</pointsize>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>Posted by</string>
</property>
</widget>
</item>
<item>
<widget class="AvatarWidget" name="avatarWidget" native="true">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="GxsIdLabel" name="nameLabel">
<property name="font">
<font>
<family>MS Sans Serif</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="timeLabel">
<property name="font">
<font>
<family>MS Sans Serif</family>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>398</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="shareButton">
<property name="text">
<string>Share</string>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
<normaloff>:/images/share.png</normaloff>:/images/share.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>GxsIdLabel</class>
<extends>QLabel</extends>
<header>gui/gxs/GxsIdLabel.h</header>
</customwidget>
<customwidget>
<class>AvatarWidget</class>
<extends>QWidget</extends>
<header>gui/common/AvatarWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../icons.qrc"/>
<include location="Posted_images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -180,7 +180,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="readButton">
<widget class="QToolButton" name="readButton">
<property name="maximumSize">
<size>
<width>24</width>
@ -203,7 +203,7 @@
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>

View File

@ -29,7 +29,7 @@
#include "gui/gxs/GxsIdDetails.h"
#include "util/misc.h"
#include "util/HandleRichText.h"
#include "PhotoView.h"
#include "ui_PostedItem.h"
#include <retroshare/rsposted.h>
@ -110,6 +110,7 @@ void PostedItem::setup()
connect(ui->notesButton, SIGNAL(clicked()), this, SLOT( toggleNotes()));
connect(ui->readButton, SIGNAL(toggled(bool)), this, SLOT(readToggled(bool)));
connect(ui->thumbnailLabel, SIGNAL(clicked()), this, SLOT(viewPicture()));
QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this);
connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(copyMessageLink()));
@ -319,6 +320,7 @@ void PostedItem::fill()
QPixmap sqpixmap = pixmap.scaled(desired_width,desired_height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
ui->thumbnailLabel->setPixmap(sqpixmap);
ui->pictureLabel->setPixmap(pixmap);
ui->thumbnailLabel->setToolTip(tr("Click to view Picture"));
}
else if (urlOkay && (mPost.mImage.mData == NULL))
{
@ -578,3 +580,26 @@ void PostedItem::toggleNotes()
}
}
void PostedItem::viewPicture()
{
if(mPost.mImage.mData == NULL) {
return;
}
QString timestamp = misc::timeRelativeToNow(mPost.mMeta.mPublishTs);
QPixmap pixmap;
GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL);
RsGxsId authorID = mPost.mMeta.mAuthorId;
PhotoView *PView = new PhotoView(this);
PView->setPixmap(pixmap);
PView->setTitle(messageName());
PView->setName(authorID);
PView->setTime(timestamp);
PView->show();
/* window will destroy itself! */
}

View File

@ -63,6 +63,7 @@ private slots:
void toggle();
void copyMessageLink();
void toggleNotes();
void viewPicture();
signals:
void vote(const RsGxsGrpMsgIdPair& msgId, bool up);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>825</width>
<height>339</height>
<height>337</height>
</rect>
</property>
<property name="windowTitle">
@ -109,6 +109,9 @@
<property name="toolTip">
<string>Vote up</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
@ -148,8 +151,8 @@
<property name="toolTip">
<string>Vote down</string>
</property>
<property name="text">
<string>\/</string>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="icon">
<iconset resource="Posted_images.qrc">
@ -185,7 +188,7 @@
<number>6</number>
</property>
<item>
<widget class="QLabel" name="thumbnailLabel">
<widget class="ClickableLabel" name="thumbnailLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -267,6 +270,9 @@
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
@ -415,6 +421,9 @@
</property>
<item>
<widget class="QToolButton" name="expandButton">
<property name="toolTip">
<string>Expand</string>
</property>
<property name="text">
<string/>
</property>
@ -428,7 +437,7 @@
</widget>
</item>
<item>
<widget class="QPushButton" name="readButton">
<widget class="QToolButton" name="readButton">
<property name="maximumSize">
<size>
<width>24</width>
@ -451,7 +460,7 @@
<property name="checked">
<bool>false</bool>
</property>
<property name="flat">
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
@ -482,6 +491,18 @@
</item>
<item>
<widget class="QPushButton" name="shareButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="text">
<string>Share</string>
</property>
@ -489,6 +510,9 @@
<iconset resource="Posted_images.qrc">
<normaloff>:/images/share.png</normaloff>:/images/share.png</iconset>
</property>
<property name="default">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
@ -529,24 +553,6 @@
</item>
<item>
<widget class="QPushButton" name="readAndClearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>44</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>44</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
@ -561,24 +567,6 @@
</item>
<item>
<widget class="QPushButton" name="clearButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>50</width>
<height>44</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>50</width>
<height>44</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
@ -634,6 +622,9 @@
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
@ -714,11 +705,16 @@
<extends>QLabel</extends>
<header>gui/gxs/GxsIdLabel.h</header>
</customwidget>
<customwidget>
<class>ClickableLabel</class>
<extends>QLabel</extends>
<header>util/ClickableLabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../icons.qrc"/>
<include location="../images.qrc"/>
<include location="Posted_images.qrc"/>
<include location="../images.qrc"/>
<include location="../icons.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -934,6 +934,7 @@ QPushButton::menu-indicator {
subcontrol-origin: padding;
subcontrol-position: bottom right;
bottom: 4px;
}
QPushButton:pressed {
@ -1836,6 +1837,7 @@ QToolBox QScrollArea QWidget QWidget {
QFrame {
border-radius: 4px;
border: 1px solid #32414B;
}
QFrame[frameShape="0"] {
@ -2046,3 +2048,90 @@ GxsChannelPostsWidget QToolButton#subscribeToolButton::menu-button {
image: none;
}
QTabBar#smTab::tab{
height: 32px;
width: 32px;
}
PostedCreatePostDialog QPushButton#submitButton {
font: bold;
font-size: 15px;
color: white;
background: #0099cc;
border-radius: 4px;
min-width: 2em;
}
PostedCreatePostDialog QPushButton#submitButton:hover {
background: #03b1f3;
border-radius: 4px;
min-width: 2em;
}
PostedItem QFrame#mainFrame {
border-radius: 4px;
border: 1px solid #32414B;
background-color: #19232D;
}
GxsChannelPostItem QFrame#mainFrame {
border-radius: 4px;
border: 1px solid #32414B;
background-color: #19232D;
}
PostedItem QPushButton#shareButton
{
background-color: transparent;
min-width: 80px;
max-height: 22px;
}
PostedItem QLabel#scoreLabel
{
background-color: transparent;
}
PostedItem QFrame#voteFrame {
background: #141415;
}
PostedItem QToolButton#voteDownButton, QToolButton#voteUpButton
{
border: none;
}
PostedCardView QPushButton#shareButton
{
background-color: transparent;
min-width: 80px;
max-height: 22px;
}
PostedCardView QFrame#voteFrame {
background: #141415;
}
PostedCardView QFrame#mainFrame {
background-color: #19232D;
}
PostedCardView QFrame#mainFrame [new=false]{
background: #19232D;
}
PostedCardView > QFrame#mainFrame[new=true] {
background-color: #005000;
}

View File

@ -996,7 +996,7 @@ QToolButton::menu-arrow:open {
QPushButton::menu-indicator {
subcontrol-origin: padding;
subcontrol-position: bottom right;
left: 8px;
}
QTableView
@ -1209,3 +1209,80 @@ GxsChannelPostsWidget QToolButton#subscribeToolButton::menu-button {
image: none;
}
QTabBar#smTab::tab{
height: 32px;
width: 32px;
}
PostedCreatePostDialog QPushButton#submitButton {
font: bold;
font-size: 15px;
color: white;
background: #0099cc;
border-radius: 4px;
min-width: 2em;
}
PostedCreatePostDialog QPushButton#submitButton:hover {
background: #03b1f3;
border-radius: 4px;
min-width: 2em;
}
GxsForumThreadWidget QLabel#forumName
{
qproperty-fontSizeFactor: 140;
color: #0099cc;
font-size: 15px;
font: bold;
}
PostedItem QPushButton#shareButton
{
background-color: transparent;
border: none;
min-width: 75px;
max-height: 22px;
}
PostedCardView QPushButton#shareButton
{
background-color: transparent;
border: none;
min-width: 75px;
}
PostedItem QFrame#voteFrame {
background: #141415;
}
PostedCardView QFrame#voteFrame {
background: #141415;
}
QPushButton#shareButton:hover, QPushButton#shareButton::menu-button:hover {
background-color: #4A4949;
border: 1px solid gray;
}
PostedItem QToolButton#voteDownButton, QToolButton#voteUpButton, QToolButton#expandButton, QToolButton#readButton,
QToolButton#commentButton, QToolButton#notesButton
{
border: none;
}
PostedCardView QToolButton#voteDownButton, QToolButton#voteUpButton
{
border: none;
}
PostedCardView QFrame#mainFrame [new=false]{
background: #302F2F;
}
PostedCardView > QFrame#mainFrame[new=true] {
background-color: #005000;
}

View File

@ -469,6 +469,7 @@ HEADERS += rshare.h \
util/QtVersion.h \
util/RsFile.h \
util/qtthreadsutils.h \
util/ClickableLabel.h \
gui/profile/ProfileWidget.h \
gui/profile/ProfileManager.h \
gui/profile/StatusMessage.h \
@ -828,6 +829,7 @@ SOURCES += main.cpp \
util/ObjectPainter.cpp \
util/RsFile.cpp \
util/RichTextEdit.cpp \
util/ClickableLabel.cpp \
gui/profile/ProfileWidget.cpp \
gui/profile/StatusMessage.cpp \
gui/profile/ProfileManager.cpp \
@ -1348,6 +1350,7 @@ posted {
gui/Posted/PostedGroupDialog.h \
gui/feeds/PostedGroupItem.h \
gui/Posted/PostedCreatePostDialog.h \
gui/Posted/PhotoView.h \
gui/Posted/PostedUserNotify.h
#gui/Posted/PostedCreateCommentDialog.h \
@ -1358,7 +1361,7 @@ posted {
gui/Posted/PostedItem.ui \
gui/Posted/PostedCardView.ui \
gui/Posted/PostedCreatePostDialog.ui \
gui/Posted/PhotoView.ui
#gui/Posted/PostedDialog.ui \
#gui/Posted/PostedComments.ui \
#gui/Posted/PostedCreateCommentDialog.ui
@ -1370,6 +1373,7 @@ posted {
gui/Posted/PostedCardView.cpp \
gui/Posted/PostedGroupDialog.cpp \
gui/Posted/PostedCreatePostDialog.cpp \
gui/Posted/PhotoView.cpp \
gui/Posted/PostedUserNotify.cpp
#gui/Posted/PostedDialog.cpp \

View File

@ -0,0 +1,35 @@
/*******************************************************************************
* retroshare-gui/src/util/ClickableLabel.cpp *
* *
* Copyright (C) 2020 by RetroShare Team <retroshare.project@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#include "ClickableLabel.h"
/** Constructor */
ClickableLabel::ClickableLabel(QWidget* parent, Qt::WindowFlags f)
: QLabel(parent) {
}
ClickableLabel::~ClickableLabel() {
}
void ClickableLabel::mousePressEvent(QMouseEvent* event) {
emit clicked();
}

View File

@ -0,0 +1,47 @@
/*******************************************************************************
* retroshare-gui/src/util/ClickableLabel.h *
* *
* Copyright (C) 2020 by RetroShare Team <retroshare.project@gmail.com> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#ifndef CLICKABLELABEL_H
#define CLICKABLELABEL_H
#include <QLabel>
#include <QWidget>
#include <Qt>
class ClickableLabel : public QLabel {
Q_OBJECT
public:
explicit ClickableLabel(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags());
~ClickableLabel();
signals:
void clicked();
protected:
void mousePressEvent(QMouseEvent* event);
void enterEvent(QEvent *ev) override { setStyleSheet("QLabel { border: 1px solid #3A3939; }");}
void leaveEvent(QEvent *ev) override { setStyleSheet("QLabel { border: none; }");}
};
#endif // CLICKABLELABEL_H