mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
qrcode always visible, button to save
This commit is contained in:
parent
a501620d92
commit
9d99007e2c
|
@ -27,8 +27,6 @@
|
||||||
#include "src/widget/gui.h"
|
#include "src/widget/gui.h"
|
||||||
#include "src/historykeeper.h"
|
#include "src/historykeeper.h"
|
||||||
#include "src/misc/style.h"
|
#include "src/misc/style.h"
|
||||||
#include "src/misc/qrwidget.h"
|
|
||||||
#include "qrencode.h"
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
@ -38,7 +36,6 @@
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
|
||||||
|
|
||||||
void ProfileForm::refreshProfiles()
|
void ProfileForm::refreshProfiles()
|
||||||
{
|
{
|
||||||
bodyUI->profiles->clear();
|
bodyUI->profiles->clear();
|
||||||
|
@ -78,9 +75,11 @@ ProfileForm::ProfileForm(QWidget *parent) :
|
||||||
toxId->setReadOnly(true);
|
toxId->setReadOnly(true);
|
||||||
toxId->setFrame(false);
|
toxId->setFrame(false);
|
||||||
toxId->setFont(Style::getFont(Style::Small));
|
toxId->setFont(Style::getFont(Style::Small));
|
||||||
|
|
||||||
|
QVBoxLayout *toxIdGroup = qobject_cast<QVBoxLayout*>(bodyUI->toxGroup->layout());
|
||||||
|
toxIdGroup->replaceWidget(bodyUI->toxId, toxId);
|
||||||
|
bodyUI->toxId->hide();
|
||||||
|
|
||||||
bodyUI->toxGroup->layout()->addWidget(toxId);
|
|
||||||
|
|
||||||
profilePicture = new MaskablePixmapWidget(this, QSize(64, 64), ":/img/avatar_mask.png");
|
profilePicture = new MaskablePixmapWidget(this, QSize(64, 64), ":/img/avatar_mask.png");
|
||||||
profilePicture->setPixmap(QPixmap(":/img/contact_dark.png"));
|
profilePicture->setPixmap(QPixmap(":/img/contact_dark.png"));
|
||||||
profilePicture->setClickable(true);
|
profilePicture->setClickable(true);
|
||||||
|
@ -172,10 +171,10 @@ void ProfileForm::setToxId(const QString& id)
|
||||||
toxId->setText(id);
|
toxId->setText(id);
|
||||||
toxId->setCursorPosition(0);
|
toxId->setCursorPosition(0);
|
||||||
|
|
||||||
QRWidget *qrcode = new QRWidget();
|
qr = new QRWidget();
|
||||||
qrcode->setQRData(id);
|
qr->setQRData(id);
|
||||||
|
bodyUI->qrCode->setPixmap(QPixmap::fromImage(qr->getImage()->scaledToWidth(150)));
|
||||||
toxId->setToolTip(qrcode->getImageAsText());
|
bodyUI->qrCode->setToolTip(qr->getImageAsText());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileForm::onAvatarClicked()
|
void ProfileForm::onAvatarClicked()
|
||||||
|
@ -376,3 +375,32 @@ void ProfileForm::showEvent(QShowEvent *event)
|
||||||
refreshProfiles();
|
refreshProfiles();
|
||||||
QWidget::showEvent(event);
|
QWidget::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProfileForm::on_copyQr_clicked()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProfileForm::on_saveQr_clicked()
|
||||||
|
{
|
||||||
|
QString current = bodyUI->profiles->currentText() + ".png";
|
||||||
|
QString path = QFileDialog::getSaveFileName(0, tr("Save", "save qr image"),
|
||||||
|
QDir::home().filePath(current),
|
||||||
|
tr("Save QrCode (*.png)", "save dialog filter"));
|
||||||
|
if (!path.isEmpty())
|
||||||
|
{
|
||||||
|
bool success;
|
||||||
|
if (QFile::exists(path))
|
||||||
|
{
|
||||||
|
success = QFile::remove(path);
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
QMessageBox::warning(this, tr("Failed to remove file"), tr("The file you chose to overwrite could not be removed first."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
success = qr->saveImage(path);
|
||||||
|
if (!success)
|
||||||
|
QMessageBox::warning(this, tr("Failed to copy file"), tr("The file you chose could not be written to."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include "src/core.h"
|
#include "src/core.h"
|
||||||
|
#include "src/misc/qrwidget.h"
|
||||||
|
|
||||||
class CroppingLabel;
|
class CroppingLabel;
|
||||||
class Core;
|
class Core;
|
||||||
|
@ -36,7 +37,7 @@ class ClickableTE : public QLineEdit
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked();
|
void clicked();
|
||||||
protected:
|
protected:
|
||||||
|
@ -73,7 +74,10 @@ private slots:
|
||||||
void onNewClicked();
|
void onNewClicked();
|
||||||
void disableSwitching();
|
void disableSwitching();
|
||||||
void enableSwitching();
|
void enableSwitching();
|
||||||
|
void on_copyQr_clicked();
|
||||||
|
|
||||||
|
void on_saveQr_clicked();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void showEvent(QShowEvent *);
|
virtual void showEvent(QShowEvent *);
|
||||||
|
|
||||||
|
@ -85,6 +89,7 @@ private:
|
||||||
Core* core;
|
Core* core;
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
bool hasCheck = false;
|
bool hasCheck = false;
|
||||||
|
QRWidget *qr;
|
||||||
|
|
||||||
ClickableTE* toxId;
|
ClickableTE* toxId;
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>439</width>
|
<width>442</width>
|
||||||
<height>472</height>
|
<height>659</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -39,8 +39,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>419</width>
|
<width>422</width>
|
||||||
<height>452</height>
|
<height>639</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
|
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,1">
|
||||||
|
@ -97,6 +97,52 @@ Share it with your friends to communicate.</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="toxId"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="verticalFrame">
|
||||||
|
<layout class="QHBoxLayout" name="qrGroup">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="qrCode">
|
||||||
|
<property name="text">
|
||||||
|
<string>QRCODE</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="horizontalFrame">
|
||||||
|
<layout class="QVBoxLayout" name="qrButtons">
|
||||||
|
<item alignment="Qt::AlignTop">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Share this code, so friends can add you</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignVCenter">
|
||||||
|
<widget class="QPushButton" name="saveQr">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignVCenter">
|
||||||
|
<widget class="QPushButton" name="copyQr">
|
||||||
|
<property name="text">
|
||||||
|
<string>Copy</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -212,7 +258,7 @@ Profile does not contain your history.</string>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>CroppingLabel</class>
|
<class>CroppingLabel</class>
|
||||||
<extends>QLabel</extends>
|
<extends>QLabel</extends>
|
||||||
<header>src/widget/croppinglabel.h</header>
|
<header location="global">src/widget/croppinglabel.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user