mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-22 07:41:20 -04:00
Merge pull request #2237 from defnax/avatar-dialog-improvements
Added to load stickers in Avatars dialog to use as Avatar
This commit is contained in:
commit
85afe64086
6 changed files with 387 additions and 99 deletions
|
@ -19,12 +19,35 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QHash>
|
||||||
|
#include <QIcon>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QTabWidget>
|
||||||
|
#include <QToolTip>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "AvatarDialog.h"
|
#include "AvatarDialog.h"
|
||||||
#include "ui_AvatarDialog.h"
|
#include "ui_AvatarDialog.h"
|
||||||
#include "AvatarDefs.h"
|
#include "AvatarDefs.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
#include "gui/common/FilesDefs.h"
|
#include "gui/common/FilesDefs.h"
|
||||||
|
#include "util/HandleRichText.h"
|
||||||
|
#include "retroshare/rsinit.h"
|
||||||
|
|
||||||
|
#define ICONNAME "groupicon.png"
|
||||||
|
|
||||||
|
static QStringList filters;
|
||||||
|
static QStringList stickerFolders;
|
||||||
|
static QHash<QString, QString> tooltipcache;
|
||||||
|
static QHash<QString, QPixmap> iconcache;
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
AvatarDialog::AvatarDialog(QWidget *parent) :
|
AvatarDialog::AvatarDialog(QWidget *parent) :
|
||||||
|
@ -44,6 +67,8 @@ AvatarDialog::AvatarDialog(QWidget *parent) :
|
||||||
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
|
||||||
updateInterface();
|
updateInterface();
|
||||||
|
|
||||||
|
loadAvatarWidget();
|
||||||
}
|
}
|
||||||
|
|
||||||
const int AvatarDialog::RS_AVATAR_DEFAULT_IMAGE_W = 96;
|
const int AvatarDialog::RS_AVATAR_DEFAULT_IMAGE_W = 96;
|
||||||
|
@ -56,18 +81,25 @@ AvatarDialog::~AvatarDialog()
|
||||||
|
|
||||||
void AvatarDialog::changeAvatar()
|
void AvatarDialog::changeAvatar()
|
||||||
{
|
{
|
||||||
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Avatar"), RS_AVATAR_DEFAULT_IMAGE_W,RS_AVATAR_DEFAULT_IMAGE_H);
|
QString image_filename ;
|
||||||
|
|
||||||
if (img.isNull())
|
if(!misc::getOpenFileName(this,RshareSettings::LASTDIR_IMAGES,tr("Import image"), tr("Image files (*.jpg *.png);;All files (*)"),image_filename))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ui->avatarLabel->setPixmap(img);
|
QImage img(image_filename);
|
||||||
|
|
||||||
|
ui->avatarLabel->setPicture(QPixmap::fromImage(img));
|
||||||
|
ui->avatarLabel->setEnableZoom(true);
|
||||||
|
ui->avatarLabel->setToolTip(tr("Use the mouse to zoom and adjust the image for your avatar."));
|
||||||
|
|
||||||
|
// shows the tooltip for a while
|
||||||
|
QToolTip::showText( ui->avatarLabel->mapToGlobal( QPoint( 0, 0 ) ), ui->avatarLabel->toolTip() );
|
||||||
updateInterface();
|
updateInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarDialog::removeAvatar()
|
void AvatarDialog::removeAvatar()
|
||||||
{
|
{
|
||||||
ui->avatarLabel->setPixmap(QPixmap());
|
ui->avatarLabel->setPicture(QPixmap());
|
||||||
updateInterface();
|
updateInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +115,7 @@ void AvatarDialog::updateInterface()
|
||||||
|
|
||||||
void AvatarDialog::setAvatar(const QPixmap &avatar)
|
void AvatarDialog::setAvatar(const QPixmap &avatar)
|
||||||
{
|
{
|
||||||
ui->avatarLabel->setPixmap(avatar);
|
ui->avatarLabel->setPicture(avatar);
|
||||||
updateInterface();
|
updateInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,3 +143,194 @@ void AvatarDialog::getAvatar(QByteArray &avatar)
|
||||||
buffer.open(QIODevice::WriteOnly);
|
buffer.open(QIODevice::WriteOnly);
|
||||||
pixmap->save(&buffer, "PNG"); // writes image into ba in PNG format
|
pixmap->save(&buffer, "PNG"); // writes image into ba in PNG format
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AvatarDialog::load()
|
||||||
|
{
|
||||||
|
filters << "*.png" << "*.jpg" << "*.gif";
|
||||||
|
stickerFolders << (QString::fromStdString(RsAccounts::AccountDirectory()) + "/stickers"); //under account, unique for user
|
||||||
|
stickerFolders << (QString::fromStdString(RsAccounts::ConfigDirectory()) + "/stickers"); //under .retroshare, shared between users
|
||||||
|
stickerFolders << (QString::fromStdString(RsAccounts::systemDataDirectory()) + "/stickers"); //exe's folder, shipped with RS
|
||||||
|
|
||||||
|
QDir dir(QString::fromStdString(RsAccounts::AccountDirectory()));
|
||||||
|
dir.mkpath("stickers/imported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AvatarDialog::loadAvatarWidget()
|
||||||
|
{
|
||||||
|
QVector<QString> stickerTabs;
|
||||||
|
refreshStickerTabs(stickerTabs);
|
||||||
|
|
||||||
|
if(stickerTabs.count() == 0) {
|
||||||
|
ui->nostickersLabel->setText("");
|
||||||
|
QString message = "No stickers installed.\nYou can install them by putting images into one of these folders:\n" /*+ stickerFolders.join('\n')*/;
|
||||||
|
message += "RetroShare/stickers\n RetroShare/Data/stickers\n RetroShare/Data/Location/stickers";
|
||||||
|
ui->nostickersLabel->setText(message);
|
||||||
|
} else {
|
||||||
|
ui->infoframe->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bOnlyOneGroup = (stickerTabs.count() == 1);
|
||||||
|
|
||||||
|
QTabWidget *avatarTab = nullptr;
|
||||||
|
if (! bOnlyOneGroup)
|
||||||
|
{
|
||||||
|
avatarTab = new QTabWidget(ui->avatarWidget);
|
||||||
|
QGridLayout *avatarGLayout = new QGridLayout(ui->avatarWidget);
|
||||||
|
avatarGLayout->setContentsMargins(0,0,0,0);
|
||||||
|
avatarGLayout->addWidget(avatarTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int buttonWidth = QFontMetricsF(ui->avatarWidget->font()).height()*5;
|
||||||
|
const int buttonHeight = QFontMetricsF(ui->avatarWidget->font()).height()*5;
|
||||||
|
int maxRowCount = 0;
|
||||||
|
int maxCountPerLine = 0;
|
||||||
|
|
||||||
|
QVectorIterator<QString> grp(stickerTabs);
|
||||||
|
while(grp.hasNext())
|
||||||
|
{
|
||||||
|
QDir groupDir = QDir(grp.next());
|
||||||
|
QString groupName = groupDir.dirName();
|
||||||
|
groupDir.setNameFilters(filters);
|
||||||
|
|
||||||
|
QWidget *tabGrpWidget = nullptr;
|
||||||
|
if (! bOnlyOneGroup)
|
||||||
|
{
|
||||||
|
//Lazy load tooltips for the current tab
|
||||||
|
QObject::connect(avatarTab, &QTabWidget::currentChanged, [=](int index){
|
||||||
|
QWidget* current = avatarTab->widget(index);
|
||||||
|
loadToolTips(current);
|
||||||
|
});
|
||||||
|
|
||||||
|
tabGrpWidget = new QWidget(avatarTab);
|
||||||
|
|
||||||
|
// (Cyril) Never use an absolute size. It needs to be scaled to the actual font size on the screen.
|
||||||
|
//
|
||||||
|
QFontMetricsF fm(font()) ;
|
||||||
|
avatarTab->setIconSize(QSize(28*fm.height()/14.0,28*fm.height()/14.0));
|
||||||
|
avatarTab->setMinimumWidth(200);
|
||||||
|
//avatarTab->setTabPosition(QTabWidget::West);
|
||||||
|
avatarTab->setStyleSheet("QTabBar::tab { height: 44px; width: 44px; }");
|
||||||
|
|
||||||
|
int index;
|
||||||
|
if (groupDir.exists(ICONNAME)) //use groupicon.png if exists, else the first png as a group icon
|
||||||
|
index = avatarTab->addTab( tabGrpWidget, FilesDefs::getIconFromQtResourcePath(groupDir.absoluteFilePath(ICONNAME)), "");
|
||||||
|
else
|
||||||
|
index = avatarTab->addTab( tabGrpWidget, FilesDefs::getIconFromQtResourcePath(groupDir.entryInfoList(QDir::Files)[0].canonicalFilePath()), "");
|
||||||
|
avatarTab->setTabToolTip(index, groupName);
|
||||||
|
} else {
|
||||||
|
tabGrpWidget = ui->avatarWidget;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGridLayout *tabGLayout = new QGridLayout(tabGrpWidget);
|
||||||
|
tabGLayout->setContentsMargins(0,0,0,0);
|
||||||
|
tabGLayout->setSpacing(0);
|
||||||
|
|
||||||
|
QFileInfoList group = groupDir.entryInfoList(QDir::Files, QDir::Name);
|
||||||
|
int rowCount = (int)sqrt((double)group.size());
|
||||||
|
int countPerLine = (group.size()/rowCount) + ((group.size() % rowCount) ? 1 : 0);
|
||||||
|
maxRowCount = qMax(maxRowCount, rowCount);
|
||||||
|
maxCountPerLine = qMax(maxCountPerLine, countPerLine);
|
||||||
|
|
||||||
|
int lin = 0;
|
||||||
|
int col = 0;
|
||||||
|
for(int i = 0; i < group.length(); ++i)
|
||||||
|
{
|
||||||
|
QFileInfo fi = group[i];
|
||||||
|
if(fi.fileName().compare(ICONNAME, Qt::CaseInsensitive) == 0)
|
||||||
|
continue;
|
||||||
|
QPushButton *button = new QPushButton("", tabGrpWidget);
|
||||||
|
button->setIconSize(QSize(buttonWidth, buttonHeight));
|
||||||
|
button->setFixedSize(QSize(buttonWidth, buttonHeight));
|
||||||
|
if(!iconcache.contains(fi.absoluteFilePath()))
|
||||||
|
{
|
||||||
|
iconcache.insert(fi.absoluteFilePath(), FilesDefs::getPixmapFromQtResourcePath(fi.absoluteFilePath()).scaled(buttonWidth, buttonHeight, Qt::KeepAspectRatio));
|
||||||
|
}
|
||||||
|
button->setIcon(iconcache[fi.absoluteFilePath()]);
|
||||||
|
button->setToolTip(fi.fileName());
|
||||||
|
button->setStatusTip(fi.absoluteFilePath());
|
||||||
|
button->setStyleSheet("QPushButton:hover {border: 3px solid #0099cc; border-radius: 3px;}");
|
||||||
|
button->setFlat(true);
|
||||||
|
tabGLayout->addWidget(button,col,lin);
|
||||||
|
++lin;
|
||||||
|
if(lin >= countPerLine)
|
||||||
|
{
|
||||||
|
lin = 0;
|
||||||
|
++col;
|
||||||
|
}
|
||||||
|
QObject::connect(button, SIGNAL(clicked()), this, SLOT(addAvatar()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//Load tooltips for the first page
|
||||||
|
QWidget * firstpage;
|
||||||
|
if(bOnlyOneGroup) {
|
||||||
|
firstpage = ui->avatarWidget;
|
||||||
|
} else {
|
||||||
|
firstpage = avatarTab->currentWidget();
|
||||||
|
}
|
||||||
|
loadToolTips(firstpage);
|
||||||
|
|
||||||
|
//Get widget's size
|
||||||
|
QSize sizeWidget = ui->avatarWidget->sizeHint();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString AvatarDialog::importedStickerPath()
|
||||||
|
{
|
||||||
|
QDir dir(stickerFolders[0]);
|
||||||
|
return dir.absoluteFilePath("imported");
|
||||||
|
}
|
||||||
|
|
||||||
|
void AvatarDialog::loadToolTips(QWidget *container)
|
||||||
|
{
|
||||||
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
|
QList<QPushButton *> children = container->findChildren<QPushButton *>();
|
||||||
|
for(int i = 0; i < children.length(); ++i) {
|
||||||
|
if(!children[i]->toolTip().contains('<')) {
|
||||||
|
if(tooltipcache.contains(children[i]->statusTip())) {
|
||||||
|
children[i]->setToolTip(tooltipcache[children[i]->statusTip()]);
|
||||||
|
} else {
|
||||||
|
QString tooltip;
|
||||||
|
if(RsHtml::makeEmbeddedImage(children[i]->statusTip(), tooltip, 300*300)) {
|
||||||
|
tooltipcache.insert(children[i]->statusTip(), tooltip);
|
||||||
|
children[i]->setToolTip(tooltip);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QApplication::restoreOverrideCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AvatarDialog::refreshStickerTabs(QVector<QString>& stickerTabs)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < stickerFolders.count(); ++i)
|
||||||
|
refreshStickerTabs(stickerTabs, stickerFolders[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AvatarDialog::refreshStickerTabs(QVector<QString>& stickerTabs, QString foldername)
|
||||||
|
{
|
||||||
|
QDir dir(foldername);
|
||||||
|
if(!dir.exists()) return;
|
||||||
|
|
||||||
|
//If it contains at a least one png then add it as a group
|
||||||
|
QStringList files = dir.entryList(filters, QDir::Files);
|
||||||
|
if(files.count() > 0)
|
||||||
|
stickerTabs.append(foldername);
|
||||||
|
|
||||||
|
//Check subfolders
|
||||||
|
QFileInfoList subfolders = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||||
|
for(int i = 0; i<subfolders.length(); i++)
|
||||||
|
refreshStickerTabs(stickerTabs, subfolders[i].filePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AvatarDialog::addAvatar()
|
||||||
|
{
|
||||||
|
QString sticker = qobject_cast<QPushButton*>(sender())->statusTip();
|
||||||
|
QPixmap pixmap(sticker);
|
||||||
|
|
||||||
|
ui->avatarLabel->setPixmap(pixmap);
|
||||||
|
updateInterface();
|
||||||
|
}
|
||||||
|
|
|
@ -46,9 +46,19 @@ public:
|
||||||
void getAvatar(QPixmap &avatar);
|
void getAvatar(QPixmap &avatar);
|
||||||
void getAvatar(QByteArray &avatar);
|
void getAvatar(QByteArray &avatar);
|
||||||
|
|
||||||
|
static QString importedStickerPath();
|
||||||
|
static void load();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void changeAvatar();
|
void changeAvatar();
|
||||||
void removeAvatar();
|
void removeAvatar();
|
||||||
|
void addAvatar();
|
||||||
|
|
||||||
|
void loadAvatarWidget();
|
||||||
|
|
||||||
|
void loadToolTips(QWidget *container);
|
||||||
|
void refreshStickerTabs(QVector<QString>& stickerTabs, QString foldername);
|
||||||
|
void refreshStickerTabs(QVector<QString>& stickerTabs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateInterface();
|
void updateInterface();
|
||||||
|
|
|
@ -6,31 +6,37 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>374</width>
|
<width>589</width>
|
||||||
<height>252</height>
|
<height>468</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Change Avatar</string>
|
<string>Change Avatar</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<property name="spacing">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="topMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
<widget class="HeaderFrame" name="headerFrame">
|
<widget class="HeaderFrame" name="headerFrame">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="0">
|
||||||
<widget class="QFrame" name="frame">
|
<widget class="QFrame" name="frame">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
@ -38,11 +44,39 @@
|
||||||
<property name="frameShadow">
|
<property name="frameShadow">
|
||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="1">
|
<property name="topMargin">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<number>3</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QFrame" name="infoframe">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="nostickersLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" rowspan="2">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="avatarLabel">
|
<widget class="ZoomableLabel" name="avatarLabel">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>128</width>
|
<width>128</width>
|
||||||
|
@ -70,73 +104,93 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<widget class="QPushButton" name="avatarButton">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QPushButton" name="avatarButton">
|
<string>Browse...</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Add Avatar</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item>
|
||||||
</item>
|
<widget class="QPushButton" name="removeButton">
|
||||||
<item>
|
<property name="enabled">
|
||||||
<widget class="QPushButton" name="removeButton">
|
<bool>false</bool>
|
||||||
<property name="enabled">
|
</property>
|
||||||
<bool>false</bool>
|
<property name="text">
|
||||||
</property>
|
<string>Remove</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Remove</string>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item>
|
||||||
</item>
|
<spacer name="verticalSpacer_2">
|
||||||
<item>
|
<property name="orientation">
|
||||||
<spacer name="verticalSpacer_2">
|
<enum>Qt::Vertical</enum>
|
||||||
<property name="orientation">
|
</property>
|
||||||
<enum>Qt::Vertical</enum>
|
<property name="sizeHint" stdset="0">
|
||||||
</property>
|
<size>
|
||||||
<property name="sizeHint" stdset="0">
|
<width>20</width>
|
||||||
<size>
|
<height>40</height>
|
||||||
<width>20</width>
|
</size>
|
||||||
<height>40</height>
|
</property>
|
||||||
</size>
|
</spacer>
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
<item row="1" column="0">
|
||||||
<spacer name="horizontalSpacer_3">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
<property name="orientation">
|
<property name="widgetResizable">
|
||||||
<enum>Qt::Horizontal</enum>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||||
<size>
|
<property name="geometry">
|
||||||
<width>61</width>
|
<rect>
|
||||||
<height>98</height>
|
<x>0</x>
|
||||||
</size>
|
<y>0</y>
|
||||||
</property>
|
<width>431</width>
|
||||||
</spacer>
|
<height>359</height>
|
||||||
</item>
|
</rect>
|
||||||
<item row="1" column="0" colspan="3">
|
</property>
|
||||||
<spacer name="verticalSpacer">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="orientation">
|
<property name="leftMargin">
|
||||||
<enum>Qt::Vertical</enum>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="topMargin">
|
||||||
<size>
|
<number>0</number>
|
||||||
<width>218</width>
|
</property>
|
||||||
<height>88</height>
|
<property name="rightMargin">
|
||||||
</size>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QWidget" name="avatarWidget" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="2" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="margin">
|
<property name="leftMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>9</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
@ -175,6 +229,11 @@
|
||||||
<header>gui/common/HeaderFrame.h</header>
|
<header>gui/common/HeaderFrame.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>ZoomableLabel</class>
|
||||||
|
<extends>QLabel</extends>
|
||||||
|
<header>gui/gxschannels/GxsChannelPostThumbnail.h</header>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
|
|
|
@ -88,33 +88,19 @@ void AvatarWidget::mouseReleaseEvent(QMouseEvent */*event*/)
|
||||||
if (!mFlag.isOwnId) {
|
if (!mFlag.isOwnId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Choose avatar"), AvatarDialog::RS_AVATAR_DEFAULT_IMAGE_W,AvatarDialog::RS_AVATAR_DEFAULT_IMAGE_H);
|
|
||||||
|
|
||||||
if (img.isNull())
|
AvatarDialog dialog(this);
|
||||||
return;
|
|
||||||
|
|
||||||
setPixmap(img);
|
QPixmap avatar;
|
||||||
|
AvatarDefs::getOwnAvatar(avatar, "");
|
||||||
|
|
||||||
QByteArray data;
|
dialog.setAvatar(avatar);
|
||||||
QBuffer buffer(&data);
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
QByteArray newAvatar;
|
||||||
|
dialog.getAvatar(newAvatar);
|
||||||
|
|
||||||
buffer.open(QIODevice::WriteOnly);
|
rsMsgs->setOwnAvatarData((unsigned char *)(newAvatar.data()), newAvatar.size()) ; // last char 0 included.
|
||||||
img.save(&buffer, "PNG"); // writes image into a in PNG format
|
}
|
||||||
|
|
||||||
rsMsgs->setOwnAvatarData((unsigned char *)(data.data()), data.size()) ; // last char 0 included.
|
|
||||||
|
|
||||||
// AvatarDialog dialog(this);
|
|
||||||
//
|
|
||||||
// QPixmap avatar;
|
|
||||||
// AvatarDefs::getOwnAvatar(avatar, "");
|
|
||||||
//
|
|
||||||
// dialog.setAvatar(avatar);
|
|
||||||
// if (dialog.exec() == QDialog::Accepted) {
|
|
||||||
// QByteArray newAvatar;
|
|
||||||
// dialog.getAvatar(newAvatar);
|
|
||||||
//
|
|
||||||
// rsMsgs->setOwnAvatarData((unsigned char *)(newAvatar.data()), newAvatar.size()) ; // last char 0 included.
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarWidget::setFrameType(FrameType type)
|
void AvatarWidget::setFrameType(FrameType type)
|
||||||
|
|
|
@ -18,6 +18,14 @@ HeaderFrame > QFrame#frame > QLabel#headerLabel {
|
||||||
color: rgb(255, 255, 255);
|
color: rgb(255, 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AvatarDialog QFrame#infoframe
|
||||||
|
{
|
||||||
|
border: 1px solid #DCDC41;
|
||||||
|
border-radius: 6px;
|
||||||
|
background: #FFFFD7;
|
||||||
|
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2);
|
||||||
|
}
|
||||||
|
|
||||||
/* GenCertDialog */
|
/* GenCertDialog */
|
||||||
|
|
||||||
GenCertDialog QLabel#genprofileinfo_label, QLabel#header_label, QLabel#entropy_label
|
GenCertDialog QLabel#genprofileinfo_label, QLabel#header_label, QLabel#entropy_label
|
||||||
|
|
|
@ -42,6 +42,7 @@ CrashStackTrace gCrashStackTrace;
|
||||||
#include "gui/StartDialog.h"
|
#include "gui/StartDialog.h"
|
||||||
#include "gui/chat/ChatDialog.h"
|
#include "gui/chat/ChatDialog.h"
|
||||||
#include "gui/connect/ConfCertDialog.h"
|
#include "gui/connect/ConfCertDialog.h"
|
||||||
|
#include "gui/common/AvatarDialog.h"
|
||||||
#include "gui/common/Emoticons.h"
|
#include "gui/common/Emoticons.h"
|
||||||
#include "gui/FileTransfer/SearchDialog.h"
|
#include "gui/FileTransfer/SearchDialog.h"
|
||||||
#include "gui/FileTransfer/TransfersDialog.h"
|
#include "gui/FileTransfer/TransfersDialog.h"
|
||||||
|
@ -493,6 +494,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
||||||
RsharePeerSettings::Create();
|
RsharePeerSettings::Create();
|
||||||
|
|
||||||
Emoticons::load();
|
Emoticons::load();
|
||||||
|
AvatarDialog::load();
|
||||||
|
|
||||||
if (Settings->value(QString::fromUtf8("FirstRun"), true).toBool()) {
|
if (Settings->value(QString::fromUtf8("FirstRun"), true).toBool()) {
|
||||||
splashScreen.hide();
|
splashScreen.hide();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue