Browse Source

feat(toxid): Show NoSpam and checksum parts of ToxID in colors.

Also added the explanation to the ToxID tooltip message.
reviewable/pr4467/r2
Yuri 8 years ago
parent
commit
c0951a5675
  1. 17
      src/widget/form/profileform.cpp
  2. 2
      src/widget/form/profileform.h
  3. 6
      src/widget/form/profileform.ui

17
src/widget/form/profileform.cpp

@ -62,8 +62,6 @@ ProfileForm::ProfileForm(QWidget* parent)
// tox // tox
toxId = new ClickableTE(); toxId = new ClickableTE();
toxId->setReadOnly(true);
toxId->setFrame(false);
toxId->setFont(Style::getFont(Style::Small)); toxId->setFont(Style::getFont(Style::Small));
toxId->setToolTip(bodyUI->toxId->toolTip()); toxId->setToolTip(bodyUI->toxId->toolTip());
@ -213,13 +211,11 @@ void ProfileForm::showProfilePictureContextMenu(const QPoint& point)
void ProfileForm::copyIdClicked() void ProfileForm::copyIdClicked()
{ {
toxId->selectAll();
QString txt = toxId->text(); QString txt = toxId->text();
txt.replace('\n', ""); txt.remove(QRegularExpression("<[^>]*>"));
QApplication::clipboard()->setText(txt, QClipboard::Clipboard); QApplication::clipboard()->setText(txt, QClipboard::Clipboard);
if (QApplication::clipboard()->supportsSelection()) if (QApplication::clipboard()->supportsSelection())
QApplication::clipboard()->setText(txt, QClipboard::Selection); QApplication::clipboard()->setText(txt, QClipboard::Selection);
toxId->setCursorPosition(0);
if (!hasCheck) { if (!hasCheck) {
bodyUI->toxIdLabel->setText(bodyUI->toxIdLabel->text() + ""); bodyUI->toxIdLabel->setText(bodyUI->toxIdLabel->text() + "");
@ -245,8 +241,12 @@ void ProfileForm::onSelfAvatarLoaded(const QPixmap& pic)
void ProfileForm::setToxId(const ToxId& id) void ProfileForm::setToxId(const ToxId& id)
{ {
toxId->setText(id.toString()); auto idString = id.toString();
toxId->setCursorPosition(0); static const QString ToxIdColor = QStringLiteral("%1<span style='color:blue'>%2</span><span style='color:gray'>%3</span>");
toxId->setText(ToxIdColor
.arg(idString.mid(0, 64))
.arg(idString.mid(64, 8))
.arg(idString.mid(72, 4)));
delete qr; delete qr;
qr = new QRWidget(); qr = new QRWidget();
@ -466,7 +466,8 @@ void ProfileForm::retranslateUi()
// We have to add the toxId tooltip here and not in the .ui or Qt won't know how to translate it // We have to add the toxId tooltip here and not in the .ui or Qt won't know how to translate it
// dynamically // dynamically
toxId->setToolTip(tr("This bunch of characters tells other Tox clients how to contact " toxId->setToolTip(tr("This bunch of characters tells other Tox clients how to contact "
"you.\nShare it with your friends to communicate.")); "you.\nShare it with your friends to communicate.\n\n"
"This ID includes the NoSpam code (in blue), and the checksum (in gray)."));
} }
void ProfileForm::showRegisterToxme() void ProfileForm::showRegisterToxme()

2
src/widget/form/profileform.h

@ -36,7 +36,7 @@ namespace Ui {
class IdentitySettings; class IdentitySettings;
} }
class ClickableTE : public QLineEdit class ClickableTE : public QLabel
{ {
Q_OBJECT Q_OBJECT
public: public:

6
src/widget/form/profileform.ui

@ -206,12 +206,12 @@ Share it with your friends to communicate.</string>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="toxId"> <widget class="QLabel" name="toxId">
<property name="accessibleDescription"> <property name="accessibleDescription">
<string>Your Tox ID</string> <string>Your Tox ID</string>
</property> </property>
<property name="frame"> <property name="textFormat">
<bool>true</bool> <enum>Qt::RichText</enum>
</property> </property>
</widget> </widget>
</item> </item>

Loading…
Cancel
Save