1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge branch 'pr1446'

Conflicts:
	src/chatlog/chatlog.cpp
	src/chatlog/content/filetransferwidget.cpp
	src/core.cpp
	src/core/coreencryption.cpp
	src/toxdns.cpp
	src/widget/form/chatform.cpp
	src/widget/form/genericchatform.cpp
	src/widget/friendwidget.cpp
	src/widget/widget.cpp
This commit is contained in:
tux3 2015-05-07 22:00:40 +02:00
commit e79d40e356
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
21 changed files with 283 additions and 253 deletions

View File

@ -283,7 +283,9 @@ void Core::checkEncryptedHistory()
return; return;
} }
else else
{
setPassword(pw, ptHistory, reinterpret_cast<uint8_t*>(salt.data())); setPassword(pw, ptHistory, reinterpret_cast<uint8_t*>(salt.data()));
}
error = exists && !HistoryKeeper::checkPassword(); error = exists && !HistoryKeeper::checkPassword();
dialogtxt = a + "\n" + c + "\n" + b; dialogtxt = a + "\n" + c + "\n" + b;

View File

@ -182,15 +182,17 @@ int main(int argc, char *argv[])
sudoprocess->start(sudo); //Where the magic actually happens, safety checks ^ sudoprocess->start(sudo); //Where the magic actually happens, safety checks ^
sudoprocess->waitForFinished(); sudoprocess->waitForFinished();
if (old_app.removeRecursively()) { //We've just deleted the running program if (old_app.removeRecursively()) //We've just deleted the running program
{
qDebug() << "OS X: Cleaned up old directory"; qDebug() << "OS X: Cleaned up old directory";
} else { }
else
{
qDebug() << "OS X: This should never happen, the directory failed to delete"; qDebug() << "OS X: This should never happen, the directory failed to delete";
} }
if (fork() != 0) { //Forking is required otherwise it won't actually cleanly launch if (fork() != 0) //Forking is required otherwise it won't actually cleanly launch
return EXIT_UPDATE_MACX; return EXIT_UPDATE_MACX;
}
qtoxprocess->start(qtox); qtoxprocess->start(qtox);
@ -269,6 +271,7 @@ int main(int argc, char *argv[])
uint32_t dest = 0; uint32_t dest = 0;
if (parser.isSet("p")) if (parser.isSet("p"))
dest = Settings::getInstance().getCurrentProfileId(); dest = Settings::getInstance().getCurrentProfileId();
time_t event = ipc.postEvent("activate", QByteArray(), dest); time_t event = ipc.postEvent("activate", QByteArray(), dest);
if (ipc.waitUntilAccepted(event, 2)) if (ipc.waitUntilAccepted(event, 2))
{ {

View File

@ -67,21 +67,19 @@ void FlowLayout::addItem(QLayoutItem *item)
int FlowLayout::horizontalSpacing() const int FlowLayout::horizontalSpacing() const
{ {
if (m_hSpace >= 0) { if (m_hSpace >= 0)
return m_hSpace; return m_hSpace;
} else { else
return smartSpacing(QStyle::PM_LayoutHorizontalSpacing); return smartSpacing(QStyle::PM_LayoutHorizontalSpacing);
} }
}
int FlowLayout::verticalSpacing() const int FlowLayout::verticalSpacing() const
{ {
if (m_vSpace >= 0) { if (m_vSpace >= 0)
return m_vSpace; return m_vSpace;
} else { else
return smartSpacing(QStyle::PM_LayoutVerticalSpacing); return smartSpacing(QStyle::PM_LayoutVerticalSpacing);
} }
}
int FlowLayout::count() const int FlowLayout::count() const
{ {
@ -149,18 +147,22 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
int lineHeight = 0; int lineHeight = 0;
QLayoutItem *item; QLayoutItem *item;
foreach (item, itemList) { foreach (item, itemList)
{
QWidget *wid = item->widget(); QWidget *wid = item->widget();
int spaceX = horizontalSpacing(); int spaceX = horizontalSpacing();
if (spaceX == -1) if (spaceX == -1)
spaceX = wid->style()->layoutSpacing( spaceX = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal); QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal);
int spaceY = verticalSpacing(); int spaceY = verticalSpacing();
if (spaceY == -1) if (spaceY == -1)
spaceY = wid->style()->layoutSpacing( spaceY = wid->style()->layoutSpacing(
QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical); QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Vertical);
int nextX = x + item->sizeHint().width() + spaceX; int nextX = x + item->sizeHint().width() + spaceX;
if (nextX - spaceX > effectiveRect.right() && lineHeight > 0) { if (nextX - spaceX > effectiveRect.right() && lineHeight > 0)
{
x = effectiveRect.x(); x = effectiveRect.x();
y = y + lineHeight + spaceY; y = y + lineHeight + spaceY;
nextX = x + item->sizeHint().width() + spaceX; nextX = x + item->sizeHint().width() + spaceX;
@ -178,12 +180,17 @@ int FlowLayout::doLayout(const QRect &rect, bool testOnly) const
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
{ {
QObject *parent = this->parent(); QObject *parent = this->parent();
if (!parent) { if (!parent)
{
return -1; return -1;
} else if (parent->isWidgetType()) { }
else if (parent->isWidgetType())
{
QWidget *pw = static_cast<QWidget *>(parent); QWidget *pw = static_cast<QWidget *>(parent);
return pw->style()->pixelMetric(pm, 0, pw); return pw->style()->pixelMetric(pm, 0, pw);
} else { }
else
{
return static_cast<QLayout *>(parent)->spacing(); return static_cast<QLayout *>(parent)->spacing();
} }
} }

View File

@ -911,7 +911,9 @@ void Settings::setAutoAcceptDir(const ToxID &id, const QString& dir)
if (it != friendLst.end()) if (it != friendLst.end())
{ {
it->autoAcceptDir = dir; it->autoAcceptDir = dir;
} else { }
else
{
updateFriendAdress(id.toString()); updateFriendAdress(id.toString());
setAutoAcceptDir(id, dir); setAutoAcceptDir(id, dir);
} }

View File

@ -206,9 +206,8 @@ QIcon SmileyPack::getCachedSmiley(const QString &key)
// cache it if needed // cache it if needed
QString file = filenameTable.value(key); QString file = filenameTable.value(key);
if (!iconCache.contains(file)) { if (!iconCache.contains(file))
cacheSmiley(file); cacheSmiley(file);
}
return iconCache.value(file); return iconCache.value(file);
} }

View File

@ -1,4 +1,18 @@
/*
Copyright (C) 2015 by Project Tox <https://tox.im>
This file is part of qTox, a Qt-based graphical interface for Tox.
This program is libre software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the COPYING file for more details.
*/
#include "enums.h" #include "enums.h"
@ -6,7 +20,8 @@ GType
status_notifier_error_get_type (void) status_notifier_error_get_type (void)
{ {
static GType etype = 0; static GType etype = 0;
if (etype == 0) { if (etype == 0)
{
static const GEnumValue values[] = { static const GEnumValue values[] = {
{ STATUS_NOTIFIER_ERROR_NO_CONNECTION, "STATUS_NOTIFIER_ERROR_NO_CONNECTION", "connection" }, { STATUS_NOTIFIER_ERROR_NO_CONNECTION, "STATUS_NOTIFIER_ERROR_NO_CONNECTION", "connection" },
{ STATUS_NOTIFIER_ERROR_NO_NAME, "STATUS_NOTIFIER_ERROR_NO_NAME", "name" }, { STATUS_NOTIFIER_ERROR_NO_NAME, "STATUS_NOTIFIER_ERROR_NO_NAME", "name" },
@ -22,7 +37,8 @@ GType
status_notifier_state_get_type (void) status_notifier_state_get_type (void)
{ {
static GType etype = 0; static GType etype = 0;
if (etype == 0) { if (etype == 0)
{
static const GEnumValue values[] = { static const GEnumValue values[] = {
{ STATUS_NOTIFIER_STATE_NOT_REGISTERED, "STATUS_NOTIFIER_STATE_NOT_REGISTERED", "not-registered" }, { STATUS_NOTIFIER_STATE_NOT_REGISTERED, "STATUS_NOTIFIER_STATE_NOT_REGISTERED", "not-registered" },
{ STATUS_NOTIFIER_STATE_REGISTERING, "STATUS_NOTIFIER_STATE_REGISTERING", "registering" }, { STATUS_NOTIFIER_STATE_REGISTERING, "STATUS_NOTIFIER_STATE_REGISTERING", "registering" },
@ -38,7 +54,8 @@ GType
status_notifier_icon_get_type (void) status_notifier_icon_get_type (void)
{ {
static GType etype = 0; static GType etype = 0;
if (etype == 0) { if (etype == 0)
{
static const GEnumValue values[] = { static const GEnumValue values[] = {
{ STATUS_NOTIFIER_ICON, "STATUS_NOTIFIER_ICON", "status-notifier-icon" }, { STATUS_NOTIFIER_ICON, "STATUS_NOTIFIER_ICON", "status-notifier-icon" },
{ STATUS_NOTIFIER_ATTENTION_ICON, "STATUS_NOTIFIER_ATTENTION_ICON", "status-notifier-attention-icon" }, { STATUS_NOTIFIER_ATTENTION_ICON, "STATUS_NOTIFIER_ATTENTION_ICON", "status-notifier-attention-icon" },
@ -55,7 +72,8 @@ GType
status_notifier_category_get_type (void) status_notifier_category_get_type (void)
{ {
static GType etype = 0; static GType etype = 0;
if (etype == 0) { if (etype == 0)
{
static const GEnumValue values[] = { static const GEnumValue values[] = {
{ STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS, "STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS", "application-status" }, { STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS, "STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS", "application-status" },
{ STATUS_NOTIFIER_CATEGORY_COMMUNICATIONS, "STATUS_NOTIFIER_CATEGORY_COMMUNICATIONS", "communications" }, { STATUS_NOTIFIER_CATEGORY_COMMUNICATIONS, "STATUS_NOTIFIER_CATEGORY_COMMUNICATIONS", "communications" },
@ -71,7 +89,8 @@ GType
status_notifier_status_get_type (void) status_notifier_status_get_type (void)
{ {
static GType etype = 0; static GType etype = 0;
if (etype == 0) { if (etype == 0)
{
static const GEnumValue values[] = { static const GEnumValue values[] = {
{ STATUS_NOTIFIER_STATUS_PASSIVE, "STATUS_NOTIFIER_STATUS_PASSIVE", "passive" }, { STATUS_NOTIFIER_STATUS_PASSIVE, "STATUS_NOTIFIER_STATUS_PASSIVE", "passive" },
{ STATUS_NOTIFIER_STATUS_ACTIVE, "STATUS_NOTIFIER_STATUS_ACTIVE", "active" }, { STATUS_NOTIFIER_STATUS_ACTIVE, "STATUS_NOTIFIER_STATUS_ACTIVE", "active" },
@ -86,7 +105,8 @@ GType
status_notifier_scroll_orientation_get_type (void) status_notifier_scroll_orientation_get_type (void)
{ {
static GType etype = 0; static GType etype = 0;
if (etype == 0) { if (etype == 0)
{
static const GEnumValue values[] = { static const GEnumValue values[] = {
{ STATUS_NOTIFIER_SCROLL_ORIENTATION_HORIZONTAL, "STATUS_NOTIFIER_SCROLL_ORIENTATION_HORIZONTAL", "horizontal" }, { STATUS_NOTIFIER_SCROLL_ORIENTATION_HORIZONTAL, "STATUS_NOTIFIER_SCROLL_ORIENTATION_HORIZONTAL", "horizontal" },
{ STATUS_NOTIFIER_SCROLL_ORIENTATION_VERTICAL, "STATUS_NOTIFIER_SCROLL_ORIENTATION_VERTICAL", "vertical" }, { STATUS_NOTIFIER_SCROLL_ORIENTATION_VERTICAL, "STATUS_NOTIFIER_SCROLL_ORIENTATION_VERTICAL", "vertical" },
@ -96,6 +116,3 @@ status_notifier_scroll_orientation_get_type (void)
} }
return etype; return etype;
} }

View File

@ -468,9 +468,7 @@ void Widget::confirmExecutableOpen(const QFileInfo file)
if (dangerousExtensions.contains(file.suffix())) if (dangerousExtensions.contains(file.suffix()))
{ {
if (!GUI::askQuestion(tr("Executable file", "popup title"), tr("You have asked qTox to open an executable file. Executable files can potentially damage your computer. Are you sure want to open this file?", "popup text"), false, true)) if (!GUI::askQuestion(tr("Executable file", "popup title"), tr("You have asked qTox to open an executable file. Executable files can potentially damage your computer. Are you sure want to open this file?", "popup text"), false, true))
{
return; return;
}
// The user wants to run this file, so make it executable and run it // The user wants to run this file, so make it executable and run it
QFile(file.filePath()).setPermissions(file.permissions() | QFile::ExeOwner | QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther); QFile(file.filePath()).setPermissions(file.permissions() | QFile::ExeOwner | QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther);
@ -1292,6 +1290,7 @@ void Widget::clearAllReceipts()
for (Friend *f : frnds) for (Friend *f : frnds)
f->getChatForm()->getOfflineMsgEngine()->removeAllReciepts(); f->getChatForm()->getOfflineMsgEngine()->removeAllReciepts();
} }
void Widget::reloadTheme() void Widget::reloadTheme()
{ {
QString statusPanelStyle = Style::getStylesheet(":/ui/window/statusPanel.css"); QString statusPanelStyle = Style::getStylesheet(":/ui/window/statusPanel.css");

View File

@ -21,7 +21,8 @@ QList<QString> scanDir(QDir dir)
QList<QString> files; QList<QString> files;
QStack<QString> stack; QStack<QString> stack;
stack.push(dir.absolutePath()); stack.push(dir.absolutePath());
while (!stack.isEmpty()) { while (!stack.isEmpty())
{
QString sSubdir = stack.pop(); QString sSubdir = stack.pop();
QDir subdir(sSubdir); QDir subdir(sSubdir);
@ -29,11 +30,13 @@ QList<QString> scanDir(QDir dir)
QList<QString> sublist = subdir.entryList(QDir::Files); QList<QString> sublist = subdir.entryList(QDir::Files);
for (QString& file : sublist) for (QString& file : sublist)
file = dir.relativeFilePath(sSubdir + '/' + file); file = dir.relativeFilePath(sSubdir + '/' + file);
files += sublist; files += sublist;
QFileInfoList infoEntries = subdir.entryInfoList(QStringList(), QFileInfoList infoEntries = subdir.entryInfoList(QStringList(),
QDir::AllDirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); QDir::AllDirs | QDir::NoSymLinks | QDir::NoDotAndDotDot);
for (int i = 0; i < infoEntries.size(); i++) { for (int i = 0; i < infoEntries.size(); i++)
{
QFileInfo& item = infoEntries[i]; QFileInfo& item = infoEntries[i];
stack.push(item.absoluteFilePath()); stack.push(item.absoluteFilePath());
} }
@ -131,4 +134,3 @@ int main(int argc, char* argv[])
flistFile.close(); flistFile.close();
return 0; return 0;
} }

View File

@ -43,9 +43,7 @@ Widget::Widget(QWidget *parent) :
// Updates only for supported platforms // Updates only for supported platforms
if (!supported) if (!supported)
{
fatalError(tr("The qTox updater is not supported on this platform.")); fatalError(tr("The qTox updater is not supported on this platform."));
}
QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "update", Qt::QueuedConnection);
} }
@ -107,6 +105,7 @@ void Widget::update()
QFile updateFlistFile(updateDirStr+"flist"); QFile updateFlistFile(updateDirStr+"flist");
if (!updateFlistFile.open(QIODevice::ReadOnly)) if (!updateFlistFile.open(QIODevice::ReadOnly))
fatalError(tr("The update is incomplete.")); fatalError(tr("The update is incomplete."));
QByteArray updateFlistData = updateFlistFile.readAll(); QByteArray updateFlistData = updateFlistFile.readAll();
updateFlistFile.close(); updateFlistFile.close();
@ -120,9 +119,8 @@ void Widget::update()
if (!QFile::exists(updateDirStr+fileMeta.installpath)) if (!QFile::exists(updateDirStr+fileMeta.installpath))
fatalError(tr("The update is incomplete.")); fatalError(tr("The update is incomplete."));
if (diff.size() == 0){ if (diff.size() == 0)
fatalError(tr("The diff list is empty.")); fatalError(tr("The diff list is empty."));
}
setProgress(5); setProgress(5);
@ -137,6 +135,7 @@ void Widget::update()
QFile fileFile(updateDirStr+fileMeta.installpath); QFile fileFile(updateDirStr+fileMeta.installpath);
if (!fileFile.open(QIODevice::ReadOnly)) if (!fileFile.open(QIODevice::ReadOnly))
fatalError(tr("Update files are unreadable.")); fatalError(tr("Update files are unreadable."));
file.data = fileFile.readAll(); file.data = fileFile.readAll();
fileFile.close(); fileFile.close();