Browse Source

Merge branch 'pr1661'

pull/1675/head
tux3 10 years ago committed by marcel
parent
commit
a9ce1adf4d
  1. 6
      qtox.pro
  2. 59
      src/core/toxid.cpp
  3. 26
      src/core/toxid.h
  4. 2
      src/widget/form/chatform.cpp
  5. 2
      src/widget/tool/screengrabberoverlayitem.cpp

6
qtox.pro

@ -436,7 +436,8 @@ SOURCES += \ @@ -436,7 +436,8 @@ SOURCES += \
src/widget/tool/screengrabberoverlayitem.cpp \
src/widget/tool/toolboxgraphicsitem.cpp \
src/widget/tool/flyoutoverlaywidget.cpp \
src/widget/form/settings/verticalonlyscroller.cpp
src/widget/form/settings/verticalonlyscroller.cpp \
src/core/toxid.cpp
HEADERS += \
@ -468,4 +469,5 @@ HEADERS += \ @@ -468,4 +469,5 @@ HEADERS += \
src/widget/tool/screengrabberoverlayitem.h \
src/widget/tool/toolboxgraphicsitem.h \
src/widget/tool/flyoutoverlaywidget.h \
src/widget/form/settings/verticalonlyscroller.h
src/widget/form/settings/verticalonlyscroller.h \
src/core/toxid.h

59
src/core/toxid.cpp

@ -0,0 +1,59 @@ @@ -0,0 +1,59 @@
#include "toxid.h"
#include <tox/tox.h>
#include <qregularexpression.h>
#define TOX_ID_PUBLIC_KEY_LENGTH 64
#define TOX_ID_NO_SPAM_LENGTH 8
#define TOX_ID_CHECKSUM_LENGTH 4
#define TOX_HEX_ID_LENGTH 2*TOX_ADDRESS_SIZE
ToxId::ToxId()
: publicKey(), noSpam(), checkSum()
{}
ToxId::ToxId(const ToxId &other)
: publicKey(other.publicKey), noSpam(other.noSpam), checkSum(other.checkSum)
{}
ToxId::ToxId(const QString &id)
{
if (isToxId(id))
{
publicKey = id.left(TOX_ID_PUBLIC_KEY_LENGTH);
noSpam = id.mid(TOX_ID_PUBLIC_KEY_LENGTH, TOX_ID_NO_SPAM_LENGTH);
checkSum = id.mid(TOX_ID_PUBLIC_KEY_LENGTH + TOX_ID_NO_SPAM_LENGTH, TOX_ID_CHECKSUM_LENGTH);
}
else
{
publicKey = id;
}
}
bool ToxId::operator==(const ToxId& other) const
{
return publicKey == other.publicKey;
}
bool ToxId::operator!=(const ToxId &other) const
{
return publicKey != other.publicKey;
}
QString ToxId::toString() const
{
return publicKey + noSpam + checkSum;
}
void ToxId::clear()
{
publicKey.clear();
noSpam.clear();
checkSum.clear();
}
bool ToxId::isToxId(const QString &id)
{
const QRegularExpression hexRegExp("^[A-Fa-f0-9]+$");
return id.length() == TOX_HEX_ID_LENGTH && id.contains(hexRegExp);
}

26
src/core/toxid.h

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
#ifndef TOXID_H
#define TOXID_H
#include <QString>
class ToxId
{
public:
ToxId();
ToxId(const ToxId& other);
ToxId(const QString& id);
bool operator==(const ToxId& other) const;
bool operator!=(const ToxId& other) const;
QString toString() const;
void clear();
static bool isToxId(const QString& id);
public:
QString publicKey;
QString noSpam;
QString checkSum;
};
#endif // TOXID_H

2
src/widget/form/chatform.cpp

@ -401,7 +401,7 @@ void ChatForm::onAvRinging(uint32_t FriendId, int CallId, bool video) @@ -401,7 +401,7 @@ void ChatForm::onAvRinging(uint32_t FriendId, int CallId, bool video)
addSystemInfoMessage(tr("Calling to %1").arg(f->getDisplayedName()), ChatMessage::INFO, QDateTime::currentDateTime());
}
void ChatForm::onAvStarting(uint32_t FriendId, int CallId, bool video)
void ChatForm::onAvStarting(uint32_t FriendId, int, bool video)
{
if (FriendId != f->getFriendID())
return;

2
src/widget/tool/screengrabberoverlayitem.cpp

@ -52,7 +52,7 @@ void ScreenGrabberOverlayItem::mousePressEvent(QGraphicsSceneMouseEvent* event) @@ -52,7 +52,7 @@ void ScreenGrabberOverlayItem::mousePressEvent(QGraphicsSceneMouseEvent* event)
}
void ScreenGrabberOverlayItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
void ScreenGrabberOverlayItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
{
painter->setBrush(brush());
painter->setPen(pen());

Loading…
Cancel
Save