mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-03 14:45:12 -04:00
* Added two new Services to RS GUI.
- The Wire, this is not at all functional yet - just a gui shell. - Identity, Basics of the GUI complete. talks via rsIdentity to the backend. * Fixed the Photo Drag and Drop under Linux. * Resurrected the Application Window - for Unfinished Service. * Moved Photos, Wire, Identity & Wiki to the Unfinished Window. * Added "Experimental Services" option in Settings -> though this is not yet saved / used. * changed #ifdef UNFINISHED -> #ifdef UNFINISHED_FD for bits in FriendList, which didn't compile. * removed old Unfinished Applications from Window. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@4933 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
459b51e814
commit
1eb82bd676
22 changed files with 3653 additions and 46 deletions
255
retroshare-gui/src/gui/TheWire/PulseItem.cpp
Normal file
255
retroshare-gui/src/gui/TheWire/PulseItem.cpp
Normal file
|
@ -0,0 +1,255 @@
|
|||
/*
|
||||
* Retroshare Photo Plugin.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
#include <QMouseEvent>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "PulseItem.h"
|
||||
|
||||
#include <retroshare/rsphoto.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
/****
|
||||
* #define DEBUG_ITEM 1
|
||||
****/
|
||||
|
||||
/** Constructor */
|
||||
PulseItem::PulseItem(PulseHolder *parent, const RsPhotoAlbum &album, const RsPhotoThumbnail &thumbnail)
|
||||
:QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_ALBUM)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
mDetails = *( (RsPhotoPhoto *) &(album));
|
||||
updateAlbumText(album);
|
||||
updateImage(thumbnail);
|
||||
|
||||
setSelected(false);
|
||||
}
|
||||
|
||||
|
||||
PulseItem::PulseItem(PulseHolder *parent, const RsPhotoPhoto &photo, const RsPhotoThumbnail &thumbnail)
|
||||
:QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_PHOTO)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
mDetails = *( (RsPhotoPhoto *) &(photo));
|
||||
|
||||
updatePhotoText(photo);
|
||||
updateImage(thumbnail);
|
||||
|
||||
setSelected(false);
|
||||
}
|
||||
|
||||
|
||||
PulseItem::PulseItem(PulseHolder *parent, std::string path) // for new photos.
|
||||
:QWidget(NULL), mParent(parent), mType(PHOTO_ITEM_TYPE_NEW)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||
|
||||
#if 0
|
||||
QString dummyString("dummytext");
|
||||
titleLabel->setText(QString("NEW PHOTO"));
|
||||
|
||||
fromBoldLabel->setText(QString("From:"));
|
||||
fromLabel->setText(QString("Ourselves"));
|
||||
|
||||
statusBoldLabel->setText(QString("Status:"));
|
||||
statusLabel->setText(QString("new photo"));
|
||||
|
||||
dateBoldLabel->setText(QString("Date:"));
|
||||
dateLabel->setText(QString("now"));
|
||||
|
||||
int width = 120;
|
||||
int height = 120;
|
||||
|
||||
//QPixmap qtn = QPixmap(QString::fromStdString(path)).scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
QPixmap qtn = QPixmap(QString::fromStdString(path)).scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
imgLabel->setPixmap(qtn);
|
||||
setSelected(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PulseItem::updateAlbumText(const RsPhotoAlbum &album)
|
||||
{
|
||||
#if 0
|
||||
QString dummyString("dummytext");
|
||||
titleLabel->setText(QString("TITLE"));
|
||||
|
||||
fromBoldLabel->setText(QString("From:"));
|
||||
fromLabel->setText(QString("Unknown"));
|
||||
|
||||
statusBoldLabel->setText(QString("Status:"));
|
||||
statusLabel->setText(QString("new photo"));
|
||||
|
||||
dateBoldLabel->setText(QString("Date:"));
|
||||
dateLabel->setText(QString("now"));
|
||||
|
||||
//QDateTime qtime;
|
||||
//qtime.setTime_t(msg.ts);
|
||||
//QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");
|
||||
//timestamplabel->setText(timestamp);
|
||||
|
||||
dateBoldLabel->setText(dummyString);
|
||||
dateLabel->setText(dummyString);
|
||||
#endif
|
||||
}
|
||||
|
||||
void PulseItem::updatePhotoText(const RsPhotoPhoto &photo)
|
||||
{
|
||||
#if 0
|
||||
QString dummyString("dummytext");
|
||||
titleLabel->setText(QString("TITLE"));
|
||||
|
||||
fromBoldLabel->setText(QString("From:"));
|
||||
fromLabel->setText(QString("Unknown"));
|
||||
|
||||
statusBoldLabel->setText(QString("Status:"));
|
||||
statusLabel->setText(QString("new photo"));
|
||||
|
||||
dateBoldLabel->setText(QString("Date:"));
|
||||
dateLabel->setText(QString("now"));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void PulseItem::updateImage(const RsPhotoThumbnail &thumbnail)
|
||||
{
|
||||
#if 0
|
||||
if (thumbnail.data != NULL)
|
||||
{
|
||||
QPixmap qtn;
|
||||
qtn.loadFromData(thumbnail.data, thumbnail.size, thumbnail.type.c_str());
|
||||
imgLabel->setPixmap(qtn);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PulseItem::getPhotoThumbnail(RsPhotoThumbnail &nail)
|
||||
{
|
||||
#if 0
|
||||
const QPixmap *tmppix = imgLabel->pixmap();
|
||||
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
|
||||
if(!tmppix->isNull())
|
||||
{
|
||||
// send chan image
|
||||
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
tmppix->save(&buffer, "PNG"); // writes image into ba in PNG format
|
||||
|
||||
RsPhotoThumbnail tmpnail;
|
||||
tmpnail.data = (uint8_t *) ba.data();
|
||||
tmpnail.size = ba.size();
|
||||
|
||||
nail.copyFrom(tmpnail);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
nail.data = NULL;
|
||||
nail.size = 0;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void PulseItem::removeItem()
|
||||
{
|
||||
#if 0
|
||||
#ifdef DEBUG_ITEM
|
||||
std::cerr << "PulseItem::removeItem()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
hide();
|
||||
if (mParent)
|
||||
{
|
||||
mParent->deletePulseItem(this, mType);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void PulseItem::setSelected(bool on)
|
||||
{
|
||||
#if 0
|
||||
mSelected = on;
|
||||
if (mSelected)
|
||||
{
|
||||
mParent->notifySelection(this, mType);
|
||||
frame->setStyleSheet("QFrame#frame{border: 2px solid #55CC55;\nbackground: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #55EE55, stop: 1 #CCCCCC);\nborder-radius: 10px}");
|
||||
}
|
||||
else
|
||||
{
|
||||
frame->setStyleSheet("QFrame#frame{border: 2px solid #CCCCCC;\nbackground: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #EEEEEE, stop: 1 #CCCCCC);\nborder-radius: 10px}");
|
||||
}
|
||||
update();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PulseItem::isSelected()
|
||||
{
|
||||
return mSelected;
|
||||
}
|
||||
|
||||
|
||||
void PulseItem::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
/* We can be very cunning here?
|
||||
* grab out position.
|
||||
* flag ourselves as selected.
|
||||
* then pass the mousePressEvent up for handling by the parent
|
||||
*/
|
||||
|
||||
QPoint pos = event->pos();
|
||||
|
||||
std::cerr << "PulseItem::mousePressEvent(" << pos.x() << ", " << pos.y() << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
setSelected(true);
|
||||
|
||||
QWidget::mousePressEvent(event);
|
||||
}
|
||||
|
||||
|
||||
const QPixmap *PulseItem::getPixmap()
|
||||
{
|
||||
#if 0
|
||||
return imgLabel->pixmap();
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue