mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge branch 'pr462'
This commit is contained in:
commit
b0b5e5872c
12
src/core.cpp
12
src/core.cpp
|
@ -259,10 +259,6 @@ void Core::start()
|
|||
toxav_register_audio_recv_callback(toxav, playCallAudio, this);
|
||||
toxav_register_video_recv_callback(toxav, playCallVideo, this);
|
||||
|
||||
uint8_t friendAddress[TOX_FRIEND_ADDRESS_SIZE];
|
||||
tox_get_address(tox, friendAddress);
|
||||
emit friendAddressGenerated(CFriendAddress::toString(friendAddress));
|
||||
|
||||
QPixmap pic = Settings::getInstance().getSavedAvatar(getSelfId().toString());
|
||||
if (!pic.isNull() && !pic.size().isEmpty())
|
||||
{
|
||||
|
@ -1116,13 +1112,17 @@ bool Core::loadConfiguration(QString path)
|
|||
|
||||
// set GUI with user and statusmsg
|
||||
QString name = getUsername();
|
||||
if (name != "")
|
||||
if (!name.isEmpty())
|
||||
emit usernameSet(name);
|
||||
|
||||
QString msg = getStatusMessage();
|
||||
if (msg != "")
|
||||
if (!msg.isEmpty())
|
||||
emit statusMessageSet(msg);
|
||||
|
||||
QString id = getSelfId().toString();
|
||||
if (!id.isEmpty())
|
||||
emit idSet(id);
|
||||
|
||||
loadFriends();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -123,8 +123,6 @@ signals:
|
|||
void friendAvatarChanged(int friendId, const QPixmap& pic);
|
||||
void friendAvatarRemoved(int friendId);
|
||||
|
||||
void friendAddressGenerated(const QString& friendAddress);
|
||||
|
||||
void friendRemoved(int friendId);
|
||||
|
||||
void friendLastSeenChanged(int friendId, const QDateTime& dateTime);
|
||||
|
@ -137,6 +135,7 @@ signals:
|
|||
void usernameSet(const QString& username);
|
||||
void statusMessageSet(const QString& message);
|
||||
void statusSet(Status status);
|
||||
void idSet(const QString& id);
|
||||
void selfAvatarChanged(const QPixmap& pic);
|
||||
|
||||
void messageSentResult(int friendId, const QString& message, int messageId);
|
||||
|
|
|
@ -84,11 +84,11 @@ void FileTransferInstance::onFileTransferInfo(int FriendId, int FileNum, int64_t
|
|||
if (lastUpdateTime.secsTo(now) < 1) //update every 1s
|
||||
return;
|
||||
|
||||
int timediff = startTime.secsTo(now);
|
||||
int timediff = effStartTime.secsTo(now);
|
||||
if (timediff <= 0)
|
||||
return;
|
||||
|
||||
long rawspeed = BytesSent / timediff;
|
||||
long rawspeed = (BytesSent - previousBytesSent) / timediff;
|
||||
|
||||
speed = getHumanReadableSize(rawspeed)+"/s";
|
||||
size = getHumanReadableSize(Filesize);
|
||||
|
@ -146,7 +146,7 @@ void FileTransferInstance::onFileTransferAccepted(ToxFile File)
|
|||
|
||||
remotePaused = false;
|
||||
state = tsProcessing;
|
||||
startTime = QDateTime::currentDateTime();
|
||||
effStartTime = QDateTime::currentDateTime();
|
||||
|
||||
emit stateUpdated();
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ void FileTransferInstance::acceptRecvRequest()
|
|||
Core::getInstance()->acceptFileRecvRequest(friendId, fileNum, path);
|
||||
state = tsProcessing;
|
||||
|
||||
startTime = QDateTime::currentDateTime();
|
||||
effStartTime = QDateTime::currentDateTime();
|
||||
|
||||
emit stateUpdated();
|
||||
}
|
||||
|
@ -243,6 +243,11 @@ void FileTransferInstance::pauseResumeRecv()
|
|||
// if (state == tsProcessing)
|
||||
// state = tsPaused;
|
||||
// else state = tsProcessing;
|
||||
if (state == tsPaused)
|
||||
{
|
||||
effStartTime = QDateTime::currentDateTime();
|
||||
previousBytesSent = lastBytesSent;
|
||||
}
|
||||
|
||||
emit stateUpdated();
|
||||
}
|
||||
|
@ -259,6 +264,11 @@ void FileTransferInstance::pauseResumeSend()
|
|||
// if (state == tsProcessing)
|
||||
// state = tsPaused;
|
||||
// else state = tsProcessing;
|
||||
if (state == tsPaused)
|
||||
{
|
||||
effStartTime = QDateTime::currentDateTime();
|
||||
previousBytesSent = lastBytesSent;
|
||||
}
|
||||
|
||||
emit stateUpdated();
|
||||
}
|
||||
|
|
|
@ -74,8 +74,8 @@ private:
|
|||
QImage pic;
|
||||
QString filename, size, speed, eta;
|
||||
QString filenameElided;
|
||||
QDateTime startTime, lastUpdateTime;
|
||||
long long lastBytesSent, totalBytes;
|
||||
QDateTime effStartTime, lastUpdateTime;
|
||||
long long lastBytesSent, totalBytes, previousBytesSent = 0; // last var used for eta on resumes
|
||||
int fileNum;
|
||||
int friendId;
|
||||
int contentPrefWidth;
|
||||
|
|
13
src/main.cpp
13
src/main.cpp
|
@ -18,7 +18,6 @@
|
|||
#include "misc/settings.h"
|
||||
#include <QApplication>
|
||||
#include <QFontDatabase>
|
||||
#include <QTranslator>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QDebug>
|
||||
|
||||
|
@ -32,18 +31,6 @@ int main(int argc, char *argv[])
|
|||
QCoreApplication::addLibraryPath(QCoreApplication::applicationDirPath());
|
||||
a.addLibraryPath("platforms");
|
||||
|
||||
// Load translations
|
||||
QTranslator translator;
|
||||
if (Settings::getInstance().getUseTranslations())
|
||||
{
|
||||
QString locale = QLocale::system().name().section('_', 0, 0);
|
||||
if (locale=="en" || translator.load(locale,":translations/"))
|
||||
qDebug() << "Loaded translation "+locale;
|
||||
else
|
||||
qDebug() << "Error loading translation "+locale;
|
||||
a.installTranslator(&translator);
|
||||
}
|
||||
|
||||
// Install Unicode 6.1 supporting font
|
||||
QFontDatabase::addApplicationFont("://DejaVuSans.ttf");
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ void Settings::load()
|
|||
|
||||
s.beginGroup("General");
|
||||
enableIPv6 = s.value("enableIPv6", true).toBool();
|
||||
useTranslations = s.value("useTranslations", true).toBool();
|
||||
translation = s.value("translation", "").toString();
|
||||
makeToxPortable = s.value("makeToxPortable", false).toBool();
|
||||
autostartInTray = s.value("autostartInTray", false).toBool();
|
||||
forceTCP = s.value("forceTCP", false).toBool();
|
||||
|
@ -216,7 +216,7 @@ void Settings::save(QString path)
|
|||
|
||||
s.beginGroup("General");
|
||||
s.setValue("enableIPv6", enableIPv6);
|
||||
s.setValue("useTranslations",useTranslations);
|
||||
s.setValue("translation",translation);
|
||||
s.setValue("makeToxPortable",makeToxPortable);
|
||||
s.setValue("autostartInTray",autostartInTray);
|
||||
s.setValue("useProxy", useProxy);
|
||||
|
@ -389,14 +389,14 @@ void Settings::setStatusChangeNotificationEnabled(bool newValue)
|
|||
statusChangeNotificationEnabled = newValue;
|
||||
}
|
||||
|
||||
bool Settings::getUseTranslations() const
|
||||
QString Settings::getTranslation() const
|
||||
{
|
||||
return useTranslations;
|
||||
return translation;
|
||||
}
|
||||
|
||||
void Settings::setUseTranslations(bool newValue)
|
||||
void Settings::setTranslation(QString newValue)
|
||||
{
|
||||
useTranslations = newValue;
|
||||
translation = newValue;
|
||||
}
|
||||
|
||||
bool Settings::getForceTCP() const
|
||||
|
|
|
@ -58,8 +58,8 @@ public:
|
|||
QString getCurrentProfile() const;
|
||||
void setCurrentProfile(QString profile);
|
||||
|
||||
bool getUseTranslations() const;
|
||||
void setUseTranslations(bool newValue);
|
||||
QString getTranslation() const;
|
||||
void setTranslation(QString newValue);
|
||||
|
||||
bool getForceTCP() const;
|
||||
void setForceTCP(bool newValue);
|
||||
|
@ -179,7 +179,7 @@ private:
|
|||
bool dontShowDhtDialog;
|
||||
|
||||
bool enableIPv6;
|
||||
bool useTranslations;
|
||||
QString translation;
|
||||
static bool makeToxPortable;
|
||||
bool autostartInTray;
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
#include <QMessageBox>
|
||||
#include <QStyleFactory>
|
||||
|
||||
static QStringList locales = {"de", "en", "fr", "it", "mannol", "pirate", "pl", "ru", "fi", "uk"};
|
||||
static QStringList langs = {"Deustch", "English", "Français", "Italiano", "mannol", "Pirate", "Polski", "Русский", "Suomi", "Українська"};
|
||||
|
||||
GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
||||
GenericForm(tr("General"), QPixmap(":/img/settings/general.png"))
|
||||
{
|
||||
|
@ -32,7 +35,9 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
|||
bodyUI->setupUi(this);
|
||||
|
||||
bodyUI->cbEnableIPv6->setChecked(Settings::getInstance().getEnableIPv6());
|
||||
bodyUI->cbUseTranslations->setChecked(Settings::getInstance().getUseTranslations());
|
||||
for (int i = 0; i < langs.size(); i++)
|
||||
bodyUI->transComboBox->insertItem(i, langs[i]);
|
||||
bodyUI->transComboBox->setCurrentIndex(locales.indexOf(Settings::getInstance().getTranslation()));
|
||||
bodyUI->cbMakeToxPortable->setChecked(Settings::getInstance().getMakeToxPortable());
|
||||
bodyUI->startInTray->setChecked(Settings::getInstance().getAutostartInTray());
|
||||
bodyUI->statusChangesCheckbox->setChecked(Settings::getInstance().getStatusChangeNotificationEnabled());
|
||||
|
@ -64,7 +69,7 @@ GeneralForm::GeneralForm(SettingsWidget *myParent) :
|
|||
onUseProxyUpdated();
|
||||
|
||||
connect(bodyUI->cbEnableIPv6, &QCheckBox::stateChanged, this, &GeneralForm::onEnableIPv6Updated);
|
||||
connect(bodyUI->cbUseTranslations, &QCheckBox::stateChanged, this, &GeneralForm::onUseTranslationUpdated);
|
||||
connect(bodyUI->transComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(onTranslationUpdated()));
|
||||
connect(bodyUI->cbMakeToxPortable, &QCheckBox::stateChanged, this, &GeneralForm::onMakeToxPortableUpdated);
|
||||
connect(bodyUI->startInTray, &QCheckBox::stateChanged, this, &GeneralForm::onSetAutostartInTray);
|
||||
connect(bodyUI->statusChangesCheckbox, &QCheckBox::stateChanged, this, &GeneralForm::onSetStatusChange);
|
||||
|
@ -88,9 +93,10 @@ void GeneralForm::onEnableIPv6Updated()
|
|||
Settings::getInstance().setEnableIPv6(bodyUI->cbEnableIPv6->isChecked());
|
||||
}
|
||||
|
||||
void GeneralForm::onUseTranslationUpdated()
|
||||
void GeneralForm::onTranslationUpdated()
|
||||
{
|
||||
Settings::getInstance().setUseTranslations(bodyUI->cbUseTranslations->isChecked());
|
||||
Settings::getInstance().setTranslation(locales[bodyUI->transComboBox->currentIndex()]);
|
||||
Widget::getInstance()->setTranslation();
|
||||
}
|
||||
|
||||
void GeneralForm::onMakeToxPortableUpdated()
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
private slots:
|
||||
void onEnableIPv6Updated();
|
||||
void onUseTranslationUpdated();
|
||||
void onTranslationUpdated();
|
||||
void onMakeToxPortableUpdated();
|
||||
void onSetAutostartInTray();
|
||||
void onSmileyBrowserIndexChanged(int index);
|
||||
|
|
|
@ -30,11 +30,31 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbUseTranslations">
|
||||
<property name="text">
|
||||
<string extracomment="Text on a checkbox to enable translations">Use translations</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="transLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="transLabel">
|
||||
<property name="toolTip">
|
||||
<string>The translation may not load until qTox restarts.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Translation:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="transComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>The translation may not load until qTox restarts.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cbMakeToxPortable">
|
||||
|
|
|
@ -46,6 +46,7 @@ IdentityForm::IdentityForm() :
|
|||
|
||||
connect(bodyUI->toxIdLabel, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
||||
connect(toxId, SIGNAL(clicked()), this, SLOT(copyIdClicked()));
|
||||
connect(Core::getInstance(), &Core::idSet, this, &IdentityForm::setToxId);
|
||||
connect(bodyUI->userName, SIGNAL(editingFinished()), this, SLOT(onUserNameEdited()));
|
||||
connect(bodyUI->statusMessage, SIGNAL(editingFinished()), this, SLOT(onStatusMessageEdited()));
|
||||
connect(bodyUI->loadButton, &QPushButton::clicked, this, &IdentityForm::onLoadClicked);
|
||||
|
@ -96,14 +97,10 @@ void IdentityForm::present()
|
|||
bodyUI->statusMessage->setText(Core::getInstance()->getStatusMessage());
|
||||
}
|
||||
|
||||
void IdentityForm::setUserName(const QString &name)
|
||||
void IdentityForm::setToxId(const QString& id)
|
||||
{
|
||||
bodyUI->userName->setText(name);
|
||||
}
|
||||
|
||||
void IdentityForm::setStatusMessage(const QString &msg)
|
||||
{
|
||||
bodyUI->statusMessage->setText(msg);
|
||||
toxId->setText(id);
|
||||
toxId->setCursorPosition(0);
|
||||
}
|
||||
|
||||
void IdentityForm::onLoadClicked()
|
||||
|
|
|
@ -47,9 +47,6 @@ public:
|
|||
IdentityForm();
|
||||
~IdentityForm();
|
||||
|
||||
void setUserName(const QString &name);
|
||||
void setStatusMessage(const QString &msg);
|
||||
|
||||
virtual void present();
|
||||
|
||||
signals:
|
||||
|
@ -57,6 +54,7 @@ signals:
|
|||
void statusMessageChanged(QString);
|
||||
|
||||
private slots:
|
||||
void setToxId(const QString& id);
|
||||
void copyIdClicked();
|
||||
void onUserNameEdited();
|
||||
void onStatusMessageEdited();
|
||||
|
|
|
@ -43,8 +43,10 @@
|
|||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QTimer>
|
||||
#include <tox/tox.h>
|
||||
#include <QStyleFactory>
|
||||
#include <QTranslator>
|
||||
#include <tox/tox.h>
|
||||
|
||||
|
||||
Widget *Widget::instance{nullptr};
|
||||
|
||||
|
@ -53,7 +55,8 @@ Widget::Widget(QWidget *parent)
|
|||
ui(new Ui::MainWindow),
|
||||
activeChatroomWidget{nullptr}
|
||||
{
|
||||
|
||||
translator = new QTranslator;
|
||||
setTranslation();
|
||||
}
|
||||
|
||||
void Widget::init()
|
||||
|
@ -312,7 +315,7 @@ QString Widget::getUsername()
|
|||
void Widget::onAvatarClicked()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName(this, tr("Choose a profile picture"), QDir::homePath());
|
||||
if (filename == "")
|
||||
if (filename.isEmpty())
|
||||
return;
|
||||
QFile file(filename);
|
||||
file.open(QIODevice::ReadOnly);
|
||||
|
@ -546,22 +549,24 @@ void Widget::onFriendStatusChanged(int friendId, Status status)
|
|||
f->friendStatus = status;
|
||||
f->widget->updateStatusLight();
|
||||
|
||||
QString fStatus = "";
|
||||
switch(f->friendStatus){
|
||||
case Status::Away:
|
||||
fStatus = tr("away", "contact status"); break;
|
||||
case Status::Busy:
|
||||
fStatus = tr("busy", "contact status"); break;
|
||||
case Status::Offline:
|
||||
fStatus = tr("offline", "contact status"); break;
|
||||
default:
|
||||
fStatus = tr("online", "contact status"); break;
|
||||
}
|
||||
|
||||
//won't print the message if there were no messages before
|
||||
//won't print the message if there were no messages before
|
||||
if(f->chatForm->getNumberOfMessages() != 0
|
||||
&& Settings::getInstance().getStatusChangeNotificationEnabled() == true)
|
||||
f->chatForm->addSystemInfoMessage(tr("%1 is now %2", "e.g. \"Dubslow is now online\"").arg(f->getName()).arg(fStatus), "white");
|
||||
{
|
||||
QString fStatus = "";
|
||||
switch(f->friendStatus){
|
||||
case Status::Away:
|
||||
fStatus = tr("away", "contact status"); break;
|
||||
case Status::Busy:
|
||||
fStatus = tr("busy", "contact status"); break;
|
||||
case Status::Offline:
|
||||
fStatus = tr("offline", "contact status"); break;
|
||||
default:
|
||||
fStatus = tr("online", "contact status"); break;
|
||||
}
|
||||
f->chatForm->addSystemInfoMessage(tr("%1 is now %2", "e.g. \"Dubslow is now online\"").arg(f->getName()).arg(fStatus),
|
||||
"white", QDateTime::currentDateTime());
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::onFriendStatusMessageChanged(int friendId, const QString& message)
|
||||
|
@ -902,3 +907,17 @@ void Widget::onGroupSendResult(int groupId, const QString& message, int result)
|
|||
if (result == -1)
|
||||
g->chatForm->addSystemInfoMessage("Message failed to send", "red");
|
||||
}
|
||||
|
||||
void Widget::setTranslation()
|
||||
{
|
||||
// Load translations
|
||||
QCoreApplication::removeTranslator(translator);
|
||||
QString locale;
|
||||
if ((locale = Settings::getInstance().getTranslation()) == "")
|
||||
locale = QLocale::system().name().section('_', 0, 0);
|
||||
if (translator->load(locale,":translations/"))
|
||||
qDebug() << "Loaded translation" << locale;
|
||||
else
|
||||
qDebug() << "Error loading translation" << locale;
|
||||
QCoreApplication::installTranslator(translator);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ class Camera;
|
|||
class FriendListWidget;
|
||||
class MaskablePixmapWidget;
|
||||
class QTimer;
|
||||
class QTranslator;
|
||||
|
||||
class Widget : public QMainWindow
|
||||
{
|
||||
|
@ -59,7 +60,8 @@ public:
|
|||
bool getIsWindowMinimized();
|
||||
static QList<QString> searchProfiles();
|
||||
void clearContactsList();
|
||||
void setIdleTimer(int minutes);
|
||||
void setIdleTimer(int minutes);
|
||||
void setTranslation();
|
||||
~Widget();
|
||||
|
||||
virtual void closeEvent(QCloseEvent *event);
|
||||
|
@ -138,6 +140,7 @@ private:
|
|||
bool notify(QObject *receiver, QEvent *event);
|
||||
bool autoAwayActive = false;
|
||||
QTimer* idleTimer;
|
||||
QTranslator* translator;
|
||||
};
|
||||
|
||||
#endif // WIDGET_H
|
||||
|
|
Loading…
Reference in New Issue
Block a user