Browse Source

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
pull/1588/head
tux3 11 years ago
parent
commit
e79d40e356
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
  1. 52
      src/chatlog/chatline.cpp
  2. 148
      src/chatlog/chatlog.cpp
  3. 10
      src/chatlog/chatmessage.cpp
  4. 62
      src/chatlog/content/filetransferwidget.cpp
  5. 4
      src/chatlog/content/notificationicon.cpp
  6. 4
      src/chatlog/content/spinner.cpp
  7. 62
      src/chatlog/content/text.cpp
  8. 6
      src/chatlog/documentcache.cpp
  9. 2
      src/chatlog/pixmapcache.cpp
  10. 2
      src/core/coreencryption.cpp
  11. 11
      src/main.cpp
  12. 29
      src/misc/flowlayout.cpp
  13. 4
      src/misc/settings.cpp
  14. 5
      src/misc/smileypack.cpp
  15. 91
      src/platform/statusnotifier/enums.c
  16. 2
      src/video/cameraworker.cpp
  17. 12
      src/widget/form/chatform.cpp
  18. 8
      src/widget/form/genericchatform.cpp
  19. 7
      src/widget/widget.cpp
  20. 8
      tools/update-server/qtox-updater-genflist/main.cpp
  21. 7
      updater/widget.cpp

52
src/chatlog/chatline.cpp

@ -27,9 +27,9 @@ ChatLine::ChatLine() @@ -27,9 +27,9 @@ ChatLine::ChatLine()
ChatLine::~ChatLine()
{
for(ChatLineContent* c : content)
for (ChatLineContent* c : content)
{
if(c->scene())
if (c->scene())
c->scene()->removeItem(c);
delete c;
@ -40,15 +40,15 @@ void ChatLine::setRow(int idx) @@ -40,15 +40,15 @@ void ChatLine::setRow(int idx)
{
row = idx;
for(int c = 0; c < static_cast<int>(content.size()); ++c)
for (int c = 0; c < static_cast<int>(content.size()); ++c)
content[c]->setIndex(row, c);
}
void ChatLine::visibilityChanged(bool visible)
{
if(isVisible != visible)
if (isVisible != visible)
{
for(ChatLineContent* c : content)
for (ChatLineContent* c : content)
c->visibilityChanged(visible);
}
@ -62,7 +62,7 @@ int ChatLine::getRow() const @@ -62,7 +62,7 @@ int ChatLine::getRow() const
ChatLineContent *ChatLine::getContent(int col) const
{
if(col < static_cast<int>(content.size()) && col >= 0)
if (col < static_cast<int>(content.size()) && col >= 0)
return content[col];
return nullptr;
@ -70,9 +70,9 @@ ChatLineContent *ChatLine::getContent(int col) const @@ -70,9 +70,9 @@ ChatLineContent *ChatLine::getContent(int col) const
ChatLineContent *ChatLine::getContent(QPointF scenePos) const
{
for(ChatLineContent* c: content)
for (ChatLineContent* c: content)
{
if(c->sceneBoundingRect().contains(scenePos))
if (c->sceneBoundingRect().contains(scenePos))
return c;
}
@ -81,37 +81,37 @@ ChatLineContent *ChatLine::getContent(QPointF scenePos) const @@ -81,37 +81,37 @@ ChatLineContent *ChatLine::getContent(QPointF scenePos) const
void ChatLine::removeFromScene()
{
for(ChatLineContent* c : content)
for (ChatLineContent* c : content)
{
if(c->scene())
if (c->scene())
c->scene()->removeItem(c);
}
}
void ChatLine::addToScene(QGraphicsScene *scene)
{
if(!scene)
if (!scene)
return;
for(ChatLineContent* c : content)
for (ChatLineContent* c : content)
scene->addItem(c);
}
void ChatLine::setVisible(bool visible)
{
for(ChatLineContent* c : content)
for (ChatLineContent* c : content)
c->setVisible(visible);
}
void ChatLine::selectionCleared()
{
for(ChatLineContent* c : content)
for (ChatLineContent* c : content)
c->selectionCleared();
}
void ChatLine::selectionFocusChanged(bool focusIn)
{
for(ChatLineContent* c : content)
for (ChatLineContent* c : content)
c->selectionFocusChanged(focusIn);
}
@ -125,7 +125,7 @@ void ChatLine::updateBBox() @@ -125,7 +125,7 @@ void ChatLine::updateBBox()
bbox.setHeight(0);
bbox.setWidth(width);
for(ChatLineContent* c : content)
for (ChatLineContent* c : content)
bbox.setHeight(qMax(c->sceneBoundingRect().top() - bbox.top() + c->sceneBoundingRect().height(), bbox.height()));
}
@ -136,7 +136,7 @@ QRectF ChatLine::sceneBoundingRect() const @@ -136,7 +136,7 @@ QRectF ChatLine::sceneBoundingRect() const
void ChatLine::addColumn(ChatLineContent* item, ColumnFormat fmt)
{
if(!item)
if (!item)
return;
format.push_back(fmt);
@ -145,7 +145,7 @@ void ChatLine::addColumn(ChatLineContent* item, ColumnFormat fmt) @@ -145,7 +145,7 @@ void ChatLine::addColumn(ChatLineContent* item, ColumnFormat fmt)
void ChatLine::replaceContent(int col, ChatLineContent *lineContent)
{
if(col >= 0 && col < static_cast<int>(content.size()) && lineContent)
if (col >= 0 && col < static_cast<int>(content.size()) && lineContent)
{
QGraphicsScene* scene = content[col]->scene();
delete content[col];
@ -153,7 +153,7 @@ void ChatLine::replaceContent(int col, ChatLineContent *lineContent) @@ -153,7 +153,7 @@ void ChatLine::replaceContent(int col, ChatLineContent *lineContent)
content[col] = lineContent;
lineContent->setIndex(row, col);
if(scene)
if (scene)
scene->addItem(content[col]);
layout(width, bbox.topLeft());
@ -170,15 +170,15 @@ void ChatLine::layout(qreal w, QPointF scenePos) @@ -170,15 +170,15 @@ void ChatLine::layout(qreal w, QPointF scenePos)
qreal fixedWidth = (content.size()-1) * columnSpacing;
qreal varWidth = 0.0; // used for normalisation
for(int i = 0; i < static_cast<int>(format.size()); ++i)
for (int i = 0; i < static_cast<int>(format.size()); ++i)
{
if(format[i].policy == ColumnFormat::FixedSize)
if (format[i].policy == ColumnFormat::FixedSize)
fixedWidth += format[i].size;
else
varWidth += format[i].size;
}
if(varWidth == 0.0)
if (varWidth == 0.0)
varWidth = 1.0;
qreal leftover = qMax(0.0, width - fixedWidth);
@ -188,11 +188,11 @@ void ChatLine::layout(qreal w, QPointF scenePos) @@ -188,11 +188,11 @@ void ChatLine::layout(qreal w, QPointF scenePos)
qreal xPos[content.size()];
for(int i = 0; i < static_cast<int>(content.size()); ++i)
for (int i = 0; i < static_cast<int>(content.size()); ++i)
{
// calculate the effective width of the current column
qreal width;
if(format[i].policy == ColumnFormat::FixedSize)
if (format[i].policy == ColumnFormat::FixedSize)
width = format[i].size;
else
width = format[i].size / varWidth * leftover;
@ -222,7 +222,7 @@ void ChatLine::layout(qreal w, QPointF scenePos) @@ -222,7 +222,7 @@ void ChatLine::layout(qreal w, QPointF scenePos)
maxVOffset = qMax(maxVOffset, content[i]->getAscent());
}
for(int i = 0; i < static_cast<int>(content.size()); ++i)
for (int i = 0; i < static_cast<int>(content.size()); ++i)
{
// calculate vertical alignment
// vertical alignment may depend on width, so we do it in a second pass
@ -238,7 +238,7 @@ void ChatLine::layout(qreal w, QPointF scenePos) @@ -238,7 +238,7 @@ void ChatLine::layout(qreal w, QPointF scenePos)
void ChatLine::moveBy(qreal deltaY)
{
// reposition only
for(ChatLineContent* c : content)
for (ChatLineContent* c : content)
c->moveBy(0, deltaY);
bbox.moveTop(bbox.top() + deltaY);

148
src/chatlog/chatlog.cpp

@ -30,9 +30,9 @@ @@ -30,9 +30,9 @@
template<class T>
T clamp(T x, T min, T max)
{
if(x > max)
if (x > max)
return max;
if(x < min)
if (x < min)
return min;
return x;
}
@ -110,22 +110,22 @@ ChatLog::ChatLog(QWidget* parent) @@ -110,22 +110,22 @@ ChatLog::ChatLog(QWidget* parent)
ChatLog::~ChatLog()
{
// Remove chatlines from scene
for(ChatLine::Ptr l : lines)
for (ChatLine::Ptr l : lines)
l->removeFromScene();
if(busyNotification)
if (busyNotification)
busyNotification->removeFromScene();
if(typingNotification)
if (typingNotification)
typingNotification->removeFromScene();
}
void ChatLog::clearSelection()
{
if(selectionMode == None)
if (selectionMode == None)
return;
for(int i=selFirstRow; i<=selLastRow; ++i)
for (int i=selFirstRow; i<=selLastRow; ++i)
lines[i]->selectionCleared();
selFirstRow = -1;
@ -151,20 +151,20 @@ void ChatLog::updateSceneRect() @@ -151,20 +151,20 @@ void ChatLog::updateSceneRect()
void ChatLog::layout(int start, int end, qreal width)
{
if(lines.empty())
if (lines.empty())
return;
qreal h = 0.0;
// Line at start-1 is considered to have the correct position. All following lines are
// positioned in respect to this line.
if(start - 1 >= 0)
if (start - 1 >= 0)
h = lines[start - 1]->sceneBoundingRect().bottom() + lineSpacing;
start = clamp<int>(start, 0, lines.size());
end = clamp<int>(end + 1, 0, lines.size());
for(int i = start; i < end; ++i)
for (int i = start; i < end; ++i)
{
ChatLine* l = lines[i].get();
@ -177,7 +177,7 @@ void ChatLog::mousePressEvent(QMouseEvent* ev) @@ -177,7 +177,7 @@ void ChatLog::mousePressEvent(QMouseEvent* ev)
{
QGraphicsView::mousePressEvent(ev);
if(ev->button() == Qt::LeftButton)
if (ev->button() == Qt::LeftButton)
{
clickPos = ev->pos();
clearSelection();
@ -197,24 +197,24 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev) @@ -197,24 +197,24 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
QPointF scenePos = mapToScene(ev->pos());
if(ev->buttons() & Qt::LeftButton)
if (ev->buttons() & Qt::LeftButton)
{
//autoscroll
if(ev->pos().y() < 0)
if (ev->pos().y() < 0)
selectionScrollDir = Up;
else if(ev->pos().y() > height())
else if (ev->pos().y() > height())
selectionScrollDir = Down;
else
selectionScrollDir = NoDirection;
//select
if(selectionMode == None && (clickPos - ev->pos()).manhattanLength() > QApplication::startDragDistance())
if (selectionMode == None && (clickPos - ev->pos()).manhattanLength() > QApplication::startDragDistance())
{
QPointF sceneClickPos = mapToScene(clickPos.toPoint());
ChatLine::Ptr line = findLineByPosY(scenePos.y());
ChatLineContent* content = getContentFromPos(sceneClickPos);
if(content)
if (content)
{
selClickedRow = content->getRow();
selClickedCol = content->getColumn();
@ -226,10 +226,10 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev) @@ -226,10 +226,10 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
selectionMode = Precise;
// ungrab mouse grabber
if(scene->mouseGrabberItem())
if (scene->mouseGrabberItem())
scene->mouseGrabberItem()->ungrabMouse();
}
else if(line.get())
else if (line.get())
{
selClickedRow = line->getRow();
selFirstRow = selClickedRow;
@ -239,37 +239,37 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev) @@ -239,37 +239,37 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
}
}
if(selectionMode != None)
if (selectionMode != None)
{
ChatLineContent* content = getContentFromPos(scenePos);
ChatLine::Ptr line = findLineByPosY(scenePos.y());
int row;
if(content)
if (content)
{
row = content->getRow();
int col = content->getColumn();
if(row == selClickedRow && col == selClickedCol)
if (row == selClickedRow && col == selClickedCol)
{
selectionMode = Precise;
content->selectionMouseMove(scenePos);
selGraphItem->hide();
}
else if(col != selClickedCol)
else if (col != selClickedCol)
{
selectionMode = Multi;
lines[selClickedRow]->selectionCleared();
}
}
else if(line.get())
else if (line.get())
{
row = line->getRow();
if(row != selClickedRow)
if (row != selClickedRow)
{
selectionMode = Multi;
@ -280,10 +280,10 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev) @@ -280,10 +280,10 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
else
return;
if(row >= selClickedRow)
if (row >= selClickedRow)
selLastRow = row;
if(row <= selClickedRow)
if (row <= selClickedRow)
selFirstRow = row;
updateMultiSelectionRect();
@ -296,13 +296,13 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev) @@ -296,13 +296,13 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
//Much faster than QGraphicsScene::itemAt()!
ChatLineContent* ChatLog::getContentFromPos(QPointF scenePos) const
{
if(lines.empty())
if (lines.empty())
return nullptr;
auto itr = std::lower_bound(lines.cbegin(), lines.cend(), scenePos.y(), ChatLine::lessThanBSRectBottom);
//find content
if(itr != lines.cend() && (*itr)->sceneBoundingRect().contains(scenePos))
if (itr != lines.cend() && (*itr)->sceneBoundingRect().contains(scenePos))
return (*itr)->getContent(scenePos);
return nullptr;
@ -310,16 +310,16 @@ ChatLineContent* ChatLog::getContentFromPos(QPointF scenePos) const @@ -310,16 +310,16 @@ ChatLineContent* ChatLog::getContentFromPos(QPointF scenePos) const
bool ChatLog::isOverSelection(QPointF scenePos) const
{
if(selectionMode == Precise)
if (selectionMode == Precise)
{
ChatLineContent* content = getContentFromPos(scenePos);
if(content)
if (content)
return content->isOverSelection(scenePos);
}
else if(selectionMode == Multi)
else if (selectionMode == Multi)
{
if(selGraphItem->rect().contains(scenePos))
if (selGraphItem->rect().contains(scenePos))
return true;
}
@ -333,13 +333,13 @@ qreal ChatLog::useableWidth() const @@ -333,13 +333,13 @@ qreal ChatLog::useableWidth() const
void ChatLog::reposition(int start, int end, qreal deltaY)
{
if(lines.isEmpty())
if (lines.isEmpty())
return;
start = clamp<int>(start, 0, lines.size() - 1);
end = clamp<int>(end + 1, 0, lines.size());
for(int i = start; i < end; ++i)
for (int i = start; i < end; ++i)
{
ChatLine* l = lines[i].get();
l->moveBy(deltaY);
@ -348,7 +348,7 @@ void ChatLog::reposition(int start, int end, qreal deltaY) @@ -348,7 +348,7 @@ void ChatLog::reposition(int start, int end, qreal deltaY)
void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l)
{
if(!l.get())
if (!l.get())
return;
bool stickToBtm = stickToBottom();
@ -362,7 +362,7 @@ void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l) @@ -362,7 +362,7 @@ void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l)
layout(lines.last()->getRow(), lines.size(), useableWidth());
updateSceneRect();
if(stickToBtm)
if (stickToBtm)
scrollToBottom();
checkVisibility();
@ -371,7 +371,7 @@ void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l) @@ -371,7 +371,7 @@ void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l)
void ChatLog::insertChatlineOnTop(ChatLine::Ptr l)
{
if(!l.get())
if (!l.get())
return;
insertChatlineOnTop(QList<ChatLine::Ptr>() << l);
@ -379,7 +379,7 @@ void ChatLog::insertChatlineOnTop(ChatLine::Ptr l) @@ -379,7 +379,7 @@ void ChatLog::insertChatlineOnTop(ChatLine::Ptr l)
void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines)
{
if(newLines.isEmpty())
if (newLines.isEmpty())
return;
QGraphicsScene::ItemIndexMethod oldIndexMeth = scene->itemIndexMethod();
@ -391,7 +391,7 @@ void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines) @@ -391,7 +391,7 @@ void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines)
// add the new lines
int i = 0;
for(ChatLine::Ptr l : newLines)
for (ChatLine::Ptr l : newLines)
{
l->addToScene(scene);
l->visibilityChanged(false);
@ -400,7 +400,7 @@ void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines) @@ -400,7 +400,7 @@ void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines)
}
// add the old lines
for(ChatLine::Ptr l : lines)
for (ChatLine::Ptr l : lines)
{
l->setRow(i++);
combLines.push_back(l);
@ -427,16 +427,16 @@ void ChatLog::scrollToBottom() @@ -427,16 +427,16 @@ void ChatLog::scrollToBottom()
void ChatLog::startResizeWorker()
{
if(lines.empty())
if (lines.empty())
return;
// (re)start the worker
if(!workerTimer->isActive())
if (!workerTimer->isActive())
{
// these values must not be reevaluated while the worker is running
workerStb = stickToBottom();
if(!visibleLines.empty())
if (!visibleLines.empty())
workerAnchorLine = visibleLines.first();
}
@ -464,7 +464,7 @@ void ChatLog::mouseDoubleClickEvent(QMouseEvent *ev) @@ -464,7 +464,7 @@ void ChatLog::mouseDoubleClickEvent(QMouseEvent *ev)
QPointF scenePos = mapToScene(ev->pos());
ChatLineContent* content = getContentFromPos(scenePos);
if(content)
if (content)
{
content->selectionDoubleClick(scenePos);
selClickedCol = content->getColumn();
@ -479,18 +479,18 @@ void ChatLog::mouseDoubleClickEvent(QMouseEvent *ev) @@ -479,18 +479,18 @@ void ChatLog::mouseDoubleClickEvent(QMouseEvent *ev)
QString ChatLog::getSelectedText() const
{
if(selectionMode == Precise)
if (selectionMode == Precise)
{
return lines[selClickedRow]->content[selClickedCol]->getSelectedText();
}
else if(selectionMode == Multi)
else if (selectionMode == Multi)
{
// build a nicely formatted message
QString out;
for(int i=selFirstRow; i<=selLastRow; ++i)
for (int i=selFirstRow; i<=selLastRow; ++i)
{
if(lines[i]->content[1]->getText().isEmpty())
if (lines[i]->content[1]->getText().isEmpty())
continue;
QString timestamp = lines[i]->content[2]->getText().isEmpty() ? tr("pending") : lines[i]->content[2]->getText();
@ -530,7 +530,7 @@ void ChatLog::clear() @@ -530,7 +530,7 @@ void ChatLog::clear()
{
clearSelection();
for(ChatLine::Ptr l : lines)
for (ChatLine::Ptr l : lines)
l->removeFromScene();
lines.clear();
@ -544,13 +544,13 @@ void ChatLog::copySelectedText(bool toSelectionBuffer) const @@ -544,13 +544,13 @@ void ChatLog::copySelectedText(bool toSelectionBuffer) const
QString text = getSelectedText();
QClipboard* clipboard = QApplication::clipboard();
if(clipboard && !text.isNull())
if (clipboard && !text.isNull())
clipboard->setText(text, toSelectionBuffer ? QClipboard::Selection : QClipboard::Clipboard);
}
void ChatLog::setBusyNotification(ChatLine::Ptr notification)
{
if(!notification.get())
if (!notification.get())
return;
busyNotification = notification;
@ -569,7 +569,7 @@ void ChatLog::setTypingNotification(ChatLine::Ptr notification) @@ -569,7 +569,7 @@ void ChatLog::setTypingNotification(ChatLine::Ptr notification)
void ChatLog::setTypingNotificationVisible(bool visible)
{
if(typingNotification.get())
if (typingNotification.get())
{
typingNotification->setVisible(visible);
updateTypingNotification();
@ -578,7 +578,7 @@ void ChatLog::setTypingNotificationVisible(bool visible) @@ -578,7 +578,7 @@ void ChatLog::setTypingNotificationVisible(bool visible)
void ChatLog::scrollToLine(ChatLine::Ptr line)
{
if(!line.get())
if (!line.get())
return;
updateSceneRect();
@ -587,7 +587,7 @@ void ChatLog::scrollToLine(ChatLine::Ptr line) @@ -587,7 +587,7 @@ void ChatLog::scrollToLine(ChatLine::Ptr line)
void ChatLog::selectAll()
{
if(lines.empty())
if (lines.empty())
return;
clearSelection();
@ -607,7 +607,7 @@ void ChatLog::forceRelayout() @@ -607,7 +607,7 @@ void ChatLog::forceRelayout()
void ChatLog::checkVisibility()
{
if(lines.empty())
if (lines.empty())
return;
// find first visible line
@ -618,18 +618,18 @@ void ChatLog::checkVisibility() @@ -618,18 +618,18 @@ void ChatLog::checkVisibility()
// set visibilty
QList<ChatLine::Ptr> newVisibleLines;
for(auto itr = lowerBound; itr != upperBound; ++itr)
for (auto itr = lowerBound; itr != upperBound; ++itr)
{
newVisibleLines.append(*itr);
if(!visibleLines.contains(*itr))
if (!visibleLines.contains(*itr))
(*itr)->visibilityChanged(true);
visibleLines.removeOne(*itr);
}
// these lines are no longer visible
for(ChatLine::Ptr line : visibleLines)
for (ChatLine::Ptr line : visibleLines)
line->visibilityChanged(false);
visibleLines = newVisibleLines;
@ -637,7 +637,7 @@ void ChatLog::checkVisibility() @@ -637,7 +637,7 @@ void ChatLog::checkVisibility()
// enforce order
std::sort(visibleLines.begin(), visibleLines.end(), ChatLine::lessThanRowIndex);
//if(!visibleLines.empty())
//if (!visibleLines.empty())
// qDebug() << "visible from " << visibleLines.first()->getRow() << "to " << visibleLines.last()->getRow() << " total " << visibleLines.size();
}
@ -651,7 +651,7 @@ void ChatLog::resizeEvent(QResizeEvent* ev) @@ -651,7 +651,7 @@ void ChatLog::resizeEvent(QResizeEvent* ev)
{
bool stb = stickToBottom();
if(ev->size().width() != ev->oldSize().width())
if (ev->size().width() != ev->oldSize().width())
{
startResizeWorker();
stb = false; // let the resize worker handle it
@ -659,7 +659,7 @@ void ChatLog::resizeEvent(QResizeEvent* ev) @@ -659,7 +659,7 @@ void ChatLog::resizeEvent(QResizeEvent* ev)
QGraphicsView::resizeEvent(ev);
if(stb)
if (stb)
scrollToBottom();
updateBusyNotification();
@ -667,13 +667,13 @@ void ChatLog::resizeEvent(QResizeEvent* ev) @@ -667,13 +667,13 @@ void ChatLog::resizeEvent(QResizeEvent* ev)
void ChatLog::updateMultiSelectionRect()
{
if(selectionMode == Multi && selFirstRow >= 0 && selLastRow >= 0)
if (selectionMode == Multi && selFirstRow >= 0 && selLastRow >= 0)
{
QRectF selBBox;
selBBox = selBBox.united(lines[selFirstRow]->sceneBoundingRect());
selBBox = selBBox.united(lines[selLastRow]->sceneBoundingRect());
if(selGraphItem->rect() != selBBox)
if (selGraphItem->rect() != selBBox)
scene->invalidate(selGraphItem->rect());
selGraphItem->setRect(selBBox);
@ -688,12 +688,12 @@ void ChatLog::updateMultiSelectionRect() @@ -688,12 +688,12 @@ void ChatLog::updateMultiSelectionRect()
void ChatLog::updateTypingNotification()
{
ChatLine* notification = typingNotification.get();
if(!notification)
if (!notification)
return;
qreal posY = 0.0;
if(!lines.empty())
if (!lines.empty())
posY = lines.last()->sceneBoundingRect().bottom() + lineSpacing;
notification->layout(useableWidth(), QPointF(0.0, posY));
@ -701,7 +701,7 @@ void ChatLog::updateTypingNotification() @@ -701,7 +701,7 @@ void ChatLog::updateTypingNotification()
void ChatLog::updateBusyNotification()
{
if(busyNotification.get())
if (busyNotification.get())
{
//repoisition the busy notification (centered)
busyNotification->layout(useableWidth(), getVisibleRect().topLeft() + QPointF(0, getVisibleRect().height()/2.0));
@ -712,7 +712,7 @@ ChatLine::Ptr ChatLog::findLineByPosY(qreal yPos) const @@ -712,7 +712,7 @@ ChatLine::Ptr ChatLog::findLineByPosY(qreal yPos) const
{
auto itr = std::lower_bound(lines.cbegin(), lines.cend(), yPos, ChatLine::lessThanBSRectBottom);
if(itr != lines.cend())
if (itr != lines.cend())
return *itr;
return ChatLine::Ptr();
@ -722,7 +722,7 @@ QRectF ChatLog::calculateSceneRect() const @@ -722,7 +722,7 @@ QRectF ChatLog::calculateSceneRect() const
{
qreal bottom = (lines.empty() ? 0.0 : lines.last()->sceneBoundingRect().bottom());
if(typingNotification.get() != nullptr)
if (typingNotification.get() != nullptr)
bottom += typingNotification->sceneBoundingRect().height() + lineSpacing;
return QRectF(-margins.left(), -margins.top(), useableWidth(), bottom + margins.bottom() + margins.top());
@ -755,7 +755,7 @@ void ChatLog::onWorkerTimeout() @@ -755,7 +755,7 @@ void ChatLog::onWorkerTimeout()
workerLastIndex += stepSize;
// done?
if(workerLastIndex >= lines.size())
if (workerLastIndex >= lines.size())
{
workerTimer->stop();
@ -769,7 +769,7 @@ void ChatLog::onWorkerTimeout() @@ -769,7 +769,7 @@ void ChatLog::onWorkerTimeout()
updateMultiSelectionRect();
// scroll
if(workerStb)
if (workerStb)
scrollToBottom();
else
scrollToLine(workerAnchorLine);
@ -793,11 +793,11 @@ void ChatLog::focusInEvent(QFocusEvent* ev) @@ -793,11 +793,11 @@ void ChatLog::focusInEvent(QFocusEvent* ev)
{
QGraphicsView::focusInEvent(ev);
if(selectionMode != None)
if (selectionMode != None)
{
selGraphItem->setBrush(QBrush(selectionRectColor));
for(int i=selFirstRow; i<=selLastRow; ++i)
for (int i=selFirstRow; i<=selLastRow; ++i)
lines[i]->selectionFocusChanged(true);
}
}
@ -806,11 +806,11 @@ void ChatLog::focusOutEvent(QFocusEvent* ev) @@ -806,11 +806,11 @@ void ChatLog::focusOutEvent(QFocusEvent* ev)
{
QGraphicsView::focusOutEvent(ev);
if(selectionMode != None)
if (selectionMode != None)
{
selGraphItem->setBrush(QBrush(selectionRectColor.lighter(120)));
for(int i=selFirstRow; i<=selLastRow; ++i)
for (int i=selFirstRow; i<=selLastRow; ++i)
lines[i]->selectionFocusChanged(false);
}
}

10
src/chatlog/chatmessage.cpp

@ -45,7 +45,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt @@ -45,7 +45,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
const QColor actionColor = QColor("#1818FF"); // has to match the color in innerStyle.css (div.action)
//smileys
if(Settings::getInstance().getUseEmoticons())
if (Settings::getInstance().getUseEmoticons())
text = SmileyPack::getInstance().smileyfied(text);
//quotes (green text)
@ -70,7 +70,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt @@ -70,7 +70,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
msg->addColumn(new Text(text, Style::getFont(Style::Big), false, type == (ACTION && isMe) ? QString("%1 %2").arg(sender, rawMessage) : rawMessage), ColumnFormat(1.0, ColumnFormat::VariableSize));
msg->addColumn(new Spinner(":/ui/chatArea/spinner.svg", QSize(16, 16), 360.0/1.6), ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
if(!date.isNull())
if (!date.isNull())
msg->markAsSent(date);
return msg;
@ -137,7 +137,7 @@ void ChatMessage::markAsSent(const QDateTime &time) @@ -137,7 +137,7 @@ void ChatMessage::markAsSent(const QDateTime &time)
QString ChatMessage::toString() const
{
ChatLineContent* c = getContent(1);
if(c)
if (c)
return c->getText();
return QString();
@ -156,14 +156,14 @@ void ChatMessage::setAsAction() @@ -156,14 +156,14 @@ void ChatMessage::setAsAction()
void ChatMessage::hideSender()
{
ChatLineContent* c = getContent(0);
if(c)
if (c)
c->hide();
}
void ChatMessage::hideDate()
{
ChatLineContent* c = getContent(2);
if(c)
if (c)
c->hide();
}

62
src/chatlog/content/filetransferwidget.cpp

@ -83,7 +83,7 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file) @@ -83,7 +83,7 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
setupButtons();
//preview
if(fileInfo.direction == ToxFile::SENDING)
if (fileInfo.direction == ToxFile::SENDING)
{
showPreview(fileInfo.filePath);
ui->progressLabel->setText(tr("Waiting to send...", "file transfer widget"));
@ -114,7 +114,7 @@ void FileTransferWidget::autoAcceptTransfer(const QString &path) @@ -114,7 +114,7 @@ void FileTransferWidget::autoAcceptTransfer(const QString &path)
filepath = QString("%1/%2%3.%4").arg(path, base, number > 0 ? QString(" (%1)").arg(QString::number(number)) : QString(), suffix);
number++;
}
while(QFileInfo(filepath).exists());
while (QFileInfo(filepath).exists());
//Do not automatically accept the file-transfer if the path is not writable.
//The user can still accept it manually.
@ -126,11 +126,11 @@ void FileTransferWidget::autoAcceptTransfer(const QString &path) @@ -126,11 +126,11 @@ void FileTransferWidget::autoAcceptTransfer(const QString &path)
void FileTransferWidget::acceptTransfer(const QString &filepath)
{
if(filepath.isEmpty())
if (filepath.isEmpty())
return;
//test if writable
if(!Nexus::tryRemoveFile(filepath))
if (!Nexus::tryRemoveFile(filepath))
{
QMessageBox::warning(0,
tr("Location not writable","Title of permissions popup"),
@ -144,7 +144,7 @@ void FileTransferWidget::acceptTransfer(const QString &filepath) @@ -144,7 +144,7 @@ void FileTransferWidget::acceptTransfer(const QString &filepath)
void FileTransferWidget::setBackgroundColor(const QColor &c, bool whiteFont)
{
if(c != backgroundColor)
if (c != backgroundColor)
{
backgroundColorAnimation->setStartValue(backgroundColor);
backgroundColorAnimation->setEndValue(c);
@ -161,7 +161,7 @@ void FileTransferWidget::setBackgroundColor(const QColor &c, bool whiteFont) @@ -161,7 +161,7 @@ void FileTransferWidget::setBackgroundColor(const QColor &c, bool whiteFont)
void FileTransferWidget::setButtonColor(const QColor &c)
{
if(c != buttonColor)
if (c != buttonColor)
{
buttonColorAnimation->setStartValue(buttonColor);
buttonColorAnimation->setEndValue(c);
@ -188,13 +188,13 @@ void FileTransferWidget::paintEvent(QPaintEvent *) @@ -188,13 +188,13 @@ void FileTransferWidget::paintEvent(QPaintEvent *)
const int lineWidth = 1;
// draw background
if(drawButtonAreaNeeded())
if (drawButtonAreaNeeded())
painter.setClipRect(QRect(0,0,width()-buttonFieldWidth,height()));
painter.setBrush(QBrush(backgroundColor));
painter.drawRoundRect(geometry(), r * ratio, r);
if(drawButtonAreaNeeded())
if (drawButtonAreaNeeded())
{
// draw button background (top)
painter.setBrush(QBrush(buttonColor));
@ -213,12 +213,12 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file) @@ -213,12 +213,12 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
QTime now = QTime::currentTime();
qint64 dt = lastTick.msecsTo(now); //ms
if(fileInfo != file || dt < 1000)
if (fileInfo != file || dt < 1000)
return;
fileInfo = file;
if(fileInfo.status == ToxFile::TRANSMITTING)
if (fileInfo.status == ToxFile::TRANSMITTING)
{
// update progress
qreal progress = static_cast<qreal>(file.bytesSent) / static_cast<qreal>(file.filesize);
@ -238,13 +238,13 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file) @@ -238,13 +238,13 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
meanData[meanIndex++] = bytesPerSec;
qreal meanBytesPerSec = 0.0;
for(size_t i = 0; i < TRANSFER_ROLLING_AVG_COUNT; ++i)
for (size_t i = 0; i < TRANSFER_ROLLING_AVG_COUNT; ++i)
meanBytesPerSec += meanData[i];
meanBytesPerSec /= static_cast<qreal>(TRANSFER_ROLLING_AVG_COUNT);
// update UI
if(meanBytesPerSec > 0)
if (meanBytesPerSec > 0)
{
// ETA
QTime toGo = QTime(0,0).addSecs((file.filesize - file.bytesSent) / meanBytesPerSec);
@ -269,7 +269,7 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file) @@ -269,7 +269,7 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
void FileTransferWidget::onFileTransferAccepted(ToxFile file)
{
if(fileInfo != file)
if (fileInfo != file)
return;
fileInfo = file;
@ -281,7 +281,7 @@ void FileTransferWidget::onFileTransferAccepted(ToxFile file) @@ -281,7 +281,7 @@ void FileTransferWidget::onFileTransferAccepted(ToxFile file)
void FileTransferWidget::onFileTransferCancelled(ToxFile file)
{
if(fileInfo != file)
if (fileInfo != file)
return;
fileInfo = file;
@ -296,7 +296,7 @@ void FileTransferWidget::onFileTransferCancelled(ToxFile file) @@ -296,7 +296,7 @@ void FileTransferWidget::onFileTransferCancelled(ToxFile file)
void FileTransferWidget::onFileTransferPaused(ToxFile file)
{
if(fileInfo != file)
if (fileInfo != file)
return;
fileInfo = file;
@ -306,7 +306,7 @@ void FileTransferWidget::onFileTransferPaused(ToxFile file) @@ -306,7 +306,7 @@ void FileTransferWidget::onFileTransferPaused(ToxFile file)
// reset mean
meanIndex = 0;
for(size_t i=0; i<TRANSFER_ROLLING_AVG_COUNT; ++i)
for (size_t i=0; i<TRANSFER_ROLLING_AVG_COUNT; ++i)
meanData[i] = 0.0;
setBackgroundColor(Style::getColor(Style::LightGrey), false);
@ -316,7 +316,7 @@ void FileTransferWidget::onFileTransferPaused(ToxFile file) @@ -316,7 +316,7 @@ void FileTransferWidget::onFileTransferPaused(ToxFile file)
void FileTransferWidget::onFileTransferResumed(ToxFile file)
{
if(fileInfo != file)
if (fileInfo != file)
return;
fileInfo = file;
@ -326,7 +326,7 @@ void FileTransferWidget::onFileTransferResumed(ToxFile file) @@ -326,7 +326,7 @@ void FileTransferWidget::onFileTransferResumed(ToxFile file)
// reset mean
meanIndex = 0;
for(size_t i=0; i<TRANSFER_ROLLING_AVG_COUNT; ++i)
for (size_t i=0; i<TRANSFER_ROLLING_AVG_COUNT; ++i)
meanData[i] = 0.0;
setBackgroundColor(Style::getColor(Style::LightGrey), false);
@ -336,7 +336,7 @@ void FileTransferWidget::onFileTransferResumed(ToxFile file) @@ -336,7 +336,7 @@ void FileTransferWidget::onFileTransferResumed(ToxFile file)
void FileTransferWidget::onFileTransferFinished(ToxFile file)
{
if(fileInfo != file)
if (fileInfo != file)
return;
fileInfo = file;
@ -357,7 +357,7 @@ void FileTransferWidget::onFileTransferFinished(ToxFile file) @@ -357,7 +357,7 @@ void FileTransferWidget::onFileTransferFinished(ToxFile file)
ui->bottomButton->show();
// preview
if(fileInfo.direction == ToxFile::RECEIVING)
if (fileInfo.direction == ToxFile::RECEIVING)
showPreview(fileInfo.filePath);
disconnect(Core::getInstance(), 0, this, 0);
@ -432,7 +432,7 @@ void FileTransferWidget::setupButtons() @@ -432,7 +432,7 @@ void FileTransferWidget::setupButtons()
ui->topButton->setObjectName("cancel");
ui->topButton->setToolTip(tr("Cancel transfer"));
if(fileInfo.direction == ToxFile::SENDING)
if (fileInfo.direction == ToxFile::SENDING)
{
ui->bottomButton->setIcon(QIcon(":/ui/fileTransferInstance/pause.svg"));
ui->bottomButton->setObjectName("pause");
@ -450,31 +450,31 @@ void FileTransferWidget::setupButtons() @@ -450,31 +450,31 @@ void FileTransferWidget::setupButtons()
void FileTransferWidget::handleButton(QPushButton *btn)
{
if(fileInfo.direction == ToxFile::SENDING)
if (fileInfo.direction == ToxFile::SENDING)
{
if(btn->objectName() == "cancel")
if (btn->objectName() == "cancel")
Core::getInstance()->cancelFileSend(fileInfo.friendId, fileInfo.fileNum);
else if(btn->objectName() == "pause")
else if (btn->objectName() == "pause")
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
else if(btn->objectName() == "resume")
else if (btn->objectName() == "resume")
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
}
else
{
if(btn->objectName() == "cancel")
if (btn->objectName() == "cancel")
Core::getInstance()->cancelFileRecv(fileInfo.friendId, fileInfo.fileNum);
else if(btn->objectName() == "pause")
else if (btn->objectName() == "pause")
Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum);
else if(btn->objectName() == "resume")
else if (btn->objectName() == "resume")
Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum);
else if(btn->objectName() == "accept")
else if (btn->objectName() == "accept")
{
QString path = QFileDialog::getSaveFileName(0, tr("Save a file","Title of the file saving dialog"), QDir::home().filePath(fileInfo.fileName));
acceptTransfer(path);
}
}
if(btn->objectName() == "ok")
if (btn->objectName() == "ok")
{
Widget::confirmExecutableOpen(QFileInfo(fileInfo.filePath));
}
@ -490,7 +490,7 @@ void FileTransferWidget::showPreview(const QString &filename) @@ -490,7 +490,7 @@ void FileTransferWidget::showPreview(const QString &filename)
{
static const QStringList previewExtensions = { "png", "jpeg", "jpg", "gif" };
if(previewExtensions.contains(QFileInfo(filename).suffix()))
if (previewExtensions.contains(QFileInfo(filename).suffix()))
{
const int size = qMax(ui->previewLabel->width(), ui->previewLabel->height());
QPixmap pmap = QPixmap(filename).scaled(QSize(size, size), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);

4
src/chatlog/content/notificationicon.cpp

@ -68,7 +68,7 @@ void NotificationIcon::updateGradient() @@ -68,7 +68,7 @@ void NotificationIcon::updateGradient()
{
alpha += 0.01;
if(alpha + dotWidth >= 1.0)
if (alpha + dotWidth >= 1.0)
alpha = 0.0;
grad = QLinearGradient(QPointF(-0.5*size.width(),0), QPointF(3.0/2.0*size.width(),0));
@ -78,6 +78,6 @@ void NotificationIcon::updateGradient() @@ -78,6 +78,6 @@ void NotificationIcon::updateGradient()
grad.setColorAt(qMin(1.0, alpha + dotWidth), Qt::lightGray);
grad.setColorAt(1, Qt::lightGray);
if(scene() && isVisible())
if (scene() && isVisible())
scene()->invalidate(sceneBoundingRect());
}

4
src/chatlog/content/spinner.cpp

@ -70,7 +70,7 @@ void Spinner::setWidth(qreal width) @@ -70,7 +70,7 @@ void Spinner::setWidth(qreal width)
void Spinner::visibilityChanged(bool visible)
{
if(visible)
if (visible)
timer.start();
else
timer.stop();
@ -83,6 +83,6 @@ qreal Spinner::getAscent() const @@ -83,6 +83,6 @@ qreal Spinner::getAscent() const
void Spinner::timeout()
{
if(scene())
if (scene())
scene()->invalidate(sceneBoundingRect());
}

62
src/chatlog/content/text.cpp

@ -41,7 +41,7 @@ Text::Text(const QString& txt, QFont font, bool enableElide, const QString &rwTe @@ -41,7 +41,7 @@ Text::Text(const QString& txt, QFont font, bool enableElide, const QString &rwTe
Text::~Text()
{
if(doc)
if (doc)
DocumentCache::getInstance().push(doc);
}
@ -56,7 +56,7 @@ void Text::setWidth(qreal w) @@ -56,7 +56,7 @@ void Text::setWidth(qreal w)
width = w;
dirty = true;
if(elide)
if (elide)
{
QFontMetrics metrics = QFontMetrics(defFont);
elidedText = metrics.elidedText(text, Qt::ElideRight, width);
@ -67,11 +67,11 @@ void Text::setWidth(qreal w) @@ -67,11 +67,11 @@ void Text::setWidth(qreal w)
void Text::selectionMouseMove(QPointF scenePos)
{
if(!doc)
if (!doc)
return;
int cur = cursorFromPos(scenePos);
if(cur >= 0)
if (cur >= 0)
{
selectionEnd = cur;
selectedText = extractSanitizedText(getSelectionStart(), getSelectionEnd());
@ -83,7 +83,7 @@ void Text::selectionMouseMove(QPointF scenePos) @@ -83,7 +83,7 @@ void Text::selectionMouseMove(QPointF scenePos)
void Text::selectionStarted(QPointF scenePos)
{
int cur = cursorFromPos(scenePos);
if(cur >= 0)
if (cur >= 0)
{
selectionEnd = cur;
selectionAnchor = cur;
@ -103,12 +103,12 @@ void Text::selectionCleared() @@ -103,12 +103,12 @@ void Text::selectionCleared()
void Text::selectionDoubleClick(QPointF scenePos)
{
if(!doc)
if (!doc)
return;
int cur = cursorFromPos(scenePos);
if(cur >= 0)
if (cur >= 0)
{
QTextCursor cursor(doc);
cursor.setPosition(cur);
@ -132,7 +132,7 @@ void Text::selectionFocusChanged(bool focusIn) @@ -132,7 +132,7 @@ void Text::selectionFocusChanged(bool focusIn)
bool Text::isOverSelection(QPointF scenePos) const
{
int cur = cursorFromPos(scenePos);
if(getSelectionStart() < cur && getSelectionEnd() >= cur)
if (getSelectionStart() < cur && getSelectionEnd() >= cur)
return true;
return false;
@ -150,7 +150,7 @@ QRectF Text::boundingRect() const @@ -150,7 +150,7 @@ QRectF Text::boundingRect() const
void Text::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
if(doc)
if (doc)
{
painter->setClipRect(boundingRect());
@ -158,7 +158,7 @@ void Text::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWid @@ -158,7 +158,7 @@ void Text::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWid
QAbstractTextDocumentLayout::PaintContext ctx;
QAbstractTextDocumentLayout::Selection sel;
if(hasSelection())
if (hasSelection())
{
sel.cursor = QTextCursor(doc);
sel.cursor.setPosition(getSelectionStart());
@ -194,30 +194,30 @@ qreal Text::getAscent() const @@ -194,30 +194,30 @@ qreal Text::getAscent() const
void Text::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
if (event->button() == Qt::LeftButton)
event->accept(); // grabber
}
void Text::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if(!doc)
if (!doc)
return;
QString anchor = doc->documentLayout()->anchorAt(event->pos());
// open anchor in browser
if(!anchor.isEmpty())
if (!anchor.isEmpty())
QDesktopServices::openUrl(anchor);
}
void Text::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
{
if(!doc)
if (!doc)
return;
QString anchor = doc->documentLayout()->anchorAt(event->pos());
if(!anchor.isEmpty())
if (!anchor.isEmpty())
setCursor(QCursor(Qt::PointingHandCursor));
else
setCursor(QCursor());
@ -233,17 +233,17 @@ QString Text::getText() const @@ -233,17 +233,17 @@ QString Text::getText() const
void Text::regenerate()
{
if(!doc)
if (!doc)
{
doc = DocumentCache::getInstance().pop();
dirty = true;
}
if(dirty)
if (dirty)
{
doc->setDefaultFont(defFont);
if(!elide)
if (!elide)
doc->setHtml(text);
else
doc->setPlainText(elidedText);
@ -258,11 +258,11 @@ void Text::regenerate() @@ -258,11 +258,11 @@ void Text::regenerate()
doc->documentLayout()->update();
// update ascent
if(doc->firstBlock().layout()->lineCount() > 0)
if (doc->firstBlock().layout()->lineCount() > 0)
ascent = doc->firstBlock().layout()->lineAt(0).ascent();
// let the scene know about our change in size
if(size != idealSize())
if (size != idealSize())
prepareGeometryChange();
// get the new width and height
@ -272,7 +272,7 @@ void Text::regenerate() @@ -272,7 +272,7 @@ void Text::regenerate()
}
// if we are not visible -> free mem
if(!keepInMemory)
if (!keepInMemory)
freeResources();
}
@ -284,7 +284,7 @@ void Text::freeResources() @@ -284,7 +284,7 @@ void Text::freeResources()
QSizeF Text::idealSize()
{
if(doc)
if (doc)
return QSizeF(qMin(doc->idealWidth(), width), doc->size().height());
return size;
@ -292,7 +292,7 @@ QSizeF Text::idealSize() @@ -292,7 +292,7 @@ QSizeF Text::idealSize()
int Text::cursorFromPos(QPointF scenePos, bool fuzzy) const
{
if(doc)
if (doc)
return doc->documentLayout()->hitTest(mapFromScene(scenePos), fuzzy ? Qt::FuzzyHit : Qt::ExactHit);
return -1;
@ -315,23 +315,23 @@ bool Text::hasSelection() const @@ -315,23 +315,23 @@ bool Text::hasSelection() const
QString Text::extractSanitizedText(int from, int to) const
{
if(!doc)
if (!doc)
return "";
QString txt;
QTextBlock block = doc->firstBlock();
for(QTextBlock::Iterator itr = block.begin(); itr!=block.end(); ++itr)
for (QTextBlock::Iterator itr = block.begin(); itr!=block.end(); ++itr)
{
int pos = itr.fragment().position(); //fragment position -> position of the first character in the fragment
if(itr.fragment().charFormat().isImageFormat())
if (itr.fragment().charFormat().isImageFormat())
{
QTextImageFormat imgFmt = itr.fragment().charFormat().toImageFormat();
QString key = imgFmt.name(); //img key (eg. key::D for :D)
QString rune = key.mid(4);
if(pos >= from && pos < to)
if (pos >= from && pos < to)
{
txt += rune;
pos++;
@ -339,9 +339,9 @@ QString Text::extractSanitizedText(int from, int to) const @@ -339,9 +339,9 @@ QString Text::extractSanitizedText(int from, int to) const
}
else
{
for(QChar c : itr.fragment().text())
for (QChar c : itr.fragment().text())
{
if(pos >= from && pos < to)
if (pos >= from && pos < to)
txt += c;
pos++;
@ -354,9 +354,9 @@ QString Text::extractSanitizedText(int from, int to) const @@ -354,9 +354,9 @@ QString Text::extractSanitizedText(int from, int to) const
QString Text::extractImgTooltip(int pos) const
{
for(QTextBlock::Iterator itr = doc->firstBlock().begin(); itr!=doc->firstBlock().end(); ++itr)
for (QTextBlock::Iterator itr = doc->firstBlock().begin(); itr!=doc->firstBlock().end(); ++itr)
{
if(itr.fragment().contains(pos) && itr.fragment().charFormat().isImageFormat())
if (itr.fragment().contains(pos) && itr.fragment().charFormat().isImageFormat())
{
QTextImageFormat imgFmt = itr.fragment().charFormat().toImageFormat();
return imgFmt.toolTip();

6
src/chatlog/documentcache.cpp

@ -19,13 +19,13 @@ @@ -19,13 +19,13 @@
DocumentCache::~DocumentCache()
{
while(!documents.isEmpty())
while (!documents.isEmpty())
delete documents.pop();
}
QTextDocument* DocumentCache::pop()
{
if(documents.empty())
if (documents.empty())
documents.push(new CustomTextDocument);
return documents.pop();
@ -33,7 +33,7 @@ QTextDocument* DocumentCache::pop() @@ -33,7 +33,7 @@ QTextDocument* DocumentCache::pop()
void DocumentCache::push(QTextDocument *doc)
{
if(doc)
if (doc)
{
doc->clear();
documents.push(doc);

2
src/chatlog/pixmapcache.cpp

@ -20,7 +20,7 @@ QPixmap PixmapCache::get(const QString &filename, QSize size) @@ -20,7 +20,7 @@ QPixmap PixmapCache::get(const QString &filename, QSize size)
{
auto itr = cache.find(filename);
if(itr == cache.end())
if (itr == cache.end())
{
QIcon icon;
icon.addFile(filename);

2
src/core/coreencryption.cpp

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

11
src/main.cpp

@ -182,15 +182,17 @@ int main(int argc, char *argv[]) @@ -182,15 +182,17 @@ int main(int argc, char *argv[])
sudoprocess->start(sudo); //Where the magic actually happens, safety checks ^
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";
} else {
}
else
{
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;
}
qtoxprocess->start(qtox);
@ -269,6 +271,7 @@ int main(int argc, char *argv[]) @@ -269,6 +271,7 @@ int main(int argc, char *argv[])
uint32_t dest = 0;
if (parser.isSet("p"))
dest = Settings::getInstance().getCurrentProfileId();
time_t event = ipc.postEvent("activate", QByteArray(), dest);
if (ipc.waitUntilAccepted(event, 2))
{

29
src/misc/flowlayout.cpp

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

4
src/misc/settings.cpp

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

5
src/misc/smileypack.cpp

@ -136,7 +136,7 @@ bool SmileyPack::load(const QString& filename) @@ -136,7 +136,7 @@ bool SmileyPack::load(const QString& filename)
cacheSmiley(file); // preload all smileys
if(!getCachedSmiley(emoticon).isNull())
if (!getCachedSmiley(emoticon).isNull())
emoticonSet.push_back(emoticon);
stringElement = stringElement.nextSibling().toElement();
@ -206,9 +206,8 @@ QIcon SmileyPack::getCachedSmiley(const QString &key) @@ -206,9 +206,8 @@ QIcon SmileyPack::getCachedSmiley(const QString &key)
// cache it if needed
QString file = filenameTable.value(key);
if (!iconCache.contains(file)) {
if (!iconCache.contains(file))
cacheSmiley(file);
}
return iconCache.value(file);
}

91
src/platform/statusnotifier/enums.c

@ -1,4 +1,18 @@ @@ -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"
@ -6,13 +20,14 @@ GType @@ -6,13 +20,14 @@ GType
status_notifier_error_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
if (etype == 0)
{
static const GEnumValue values[] = {
{ 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_WATCHER, "STATUS_NOTIFIER_ERROR_NO_WATCHER", "watcher" },
{ STATUS_NOTIFIER_ERROR_NO_HOST, "STATUS_NOTIFIER_ERROR_NO_HOST", "host" },
{ 0, NULL, NULL }
{ 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_WATCHER, "STATUS_NOTIFIER_ERROR_NO_WATCHER", "watcher" },
{ STATUS_NOTIFIER_ERROR_NO_HOST, "STATUS_NOTIFIER_ERROR_NO_HOST", "host" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("StatusNotifierError", values);
}
@ -22,13 +37,14 @@ GType @@ -22,13 +37,14 @@ GType
status_notifier_state_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
if (etype == 0)
{
static const GEnumValue values[] = {
{ STATUS_NOTIFIER_STATE_NOT_REGISTERED, "STATUS_NOTIFIER_STATE_NOT_REGISTERED", "not-registered" },
{ STATUS_NOTIFIER_STATE_REGISTERING, "STATUS_NOTIFIER_STATE_REGISTERING", "registering" },
{ STATUS_NOTIFIER_STATE_REGISTERED, "STATUS_NOTIFIER_STATE_REGISTERED", "registered" },
{ STATUS_NOTIFIER_STATE_FAILED, "STATUS_NOTIFIER_STATE_FAILED", "failed" },
{ 0, NULL, NULL }
{ STATUS_NOTIFIER_STATE_NOT_REGISTERED, "STATUS_NOTIFIER_STATE_NOT_REGISTERED", "not-registered" },
{ STATUS_NOTIFIER_STATE_REGISTERING, "STATUS_NOTIFIER_STATE_REGISTERING", "registering" },
{ STATUS_NOTIFIER_STATE_REGISTERED, "STATUS_NOTIFIER_STATE_REGISTERED", "registered" },
{ STATUS_NOTIFIER_STATE_FAILED, "STATUS_NOTIFIER_STATE_FAILED", "failed" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("StatusNotifierState", values);
}
@ -38,14 +54,15 @@ GType @@ -38,14 +54,15 @@ GType
status_notifier_icon_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
if (etype == 0)
{
static const GEnumValue values[] = {
{ STATUS_NOTIFIER_ICON, "STATUS_NOTIFIER_ICON", "status-notifier-icon" },
{ STATUS_NOTIFIER_ATTENTION_ICON, "STATUS_NOTIFIER_ATTENTION_ICON", "status-notifier-attention-icon" },
{ STATUS_NOTIFIER_OVERLAY_ICON, "STATUS_NOTIFIER_OVERLAY_ICON", "status-notifier-overlay-icon" },
{ STATUS_NOTIFIER_TOOLTIP_ICON, "STATUS_NOTIFIER_TOOLTIP_ICON", "status-notifier-tooltip-icon" },
{ _NB_STATUS_NOTIFIER_ICONS, "_NB_STATUS_NOTIFIER_ICONS", "-nb-status-notifier-icons" },
{ 0, NULL, NULL }
{ STATUS_NOTIFIER_ICON, "STATUS_NOTIFIER_ICON", "status-notifier-icon" },
{ STATUS_NOTIFIER_ATTENTION_ICON, "STATUS_NOTIFIER_ATTENTION_ICON", "status-notifier-attention-icon" },
{ STATUS_NOTIFIER_OVERLAY_ICON, "STATUS_NOTIFIER_OVERLAY_ICON", "status-notifier-overlay-icon" },
{ STATUS_NOTIFIER_TOOLTIP_ICON, "STATUS_NOTIFIER_TOOLTIP_ICON", "status-notifier-tooltip-icon" },
{ _NB_STATUS_NOTIFIER_ICONS, "_NB_STATUS_NOTIFIER_ICONS", "-nb-status-notifier-icons" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("StatusNotifierIcon", values);
}
@ -55,13 +72,14 @@ GType @@ -55,13 +72,14 @@ GType
status_notifier_category_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
if (etype == 0)
{
static const GEnumValue values[] = {
{ STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS, "STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS", "application-status" },
{ STATUS_NOTIFIER_CATEGORY_COMMUNICATIONS, "STATUS_NOTIFIER_CATEGORY_COMMUNICATIONS", "communications" },
{ STATUS_NOTIFIER_CATEGORY_SYSTEM_SERVICES, "STATUS_NOTIFIER_CATEGORY_SYSTEM_SERVICES", "system-services" },
{ STATUS_NOTIFIER_CATEGORY_HARDWARE, "STATUS_NOTIFIER_CATEGORY_HARDWARE", "hardware" },
{ 0, NULL, NULL }
{ STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS, "STATUS_NOTIFIER_CATEGORY_APPLICATION_STATUS", "application-status" },
{ STATUS_NOTIFIER_CATEGORY_COMMUNICATIONS, "STATUS_NOTIFIER_CATEGORY_COMMUNICATIONS", "communications" },
{ STATUS_NOTIFIER_CATEGORY_SYSTEM_SERVICES, "STATUS_NOTIFIER_CATEGORY_SYSTEM_SERVICES", "system-services" },
{ STATUS_NOTIFIER_CATEGORY_HARDWARE, "STATUS_NOTIFIER_CATEGORY_HARDWARE", "hardware" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("StatusNotifierCategory", values);
}
@ -71,12 +89,13 @@ GType @@ -71,12 +89,13 @@ GType
status_notifier_status_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
if (etype == 0)
{
static const GEnumValue values[] = {
{ STATUS_NOTIFIER_STATUS_PASSIVE, "STATUS_NOTIFIER_STATUS_PASSIVE", "passive" },
{ STATUS_NOTIFIER_STATUS_ACTIVE, "STATUS_NOTIFIER_STATUS_ACTIVE", "active" },
{ STATUS_NOTIFIER_STATUS_NEEDS_ATTENTION, "STATUS_NOTIFIER_STATUS_NEEDS_ATTENTION", "needs-attention" },
{ 0, NULL, NULL }
{ STATUS_NOTIFIER_STATUS_PASSIVE, "STATUS_NOTIFIER_STATUS_PASSIVE", "passive" },
{ STATUS_NOTIFIER_STATUS_ACTIVE, "STATUS_NOTIFIER_STATUS_ACTIVE", "active" },
{ STATUS_NOTIFIER_STATUS_NEEDS_ATTENTION, "STATUS_NOTIFIER_STATUS_NEEDS_ATTENTION", "needs-attention" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("StatusNotifierStatus", values);
}
@ -86,16 +105,14 @@ GType @@ -86,16 +105,14 @@ GType
status_notifier_scroll_orientation_get_type (void)
{
static GType etype = 0;
if (etype == 0) {
if (etype == 0)
{
static const GEnumValue values[] = {
{ STATUS_NOTIFIER_SCROLL_ORIENTATION_HORIZONTAL, "STATUS_NOTIFIER_SCROLL_ORIENTATION_HORIZONTAL", "horizontal" },
{ STATUS_NOTIFIER_SCROLL_ORIENTATION_VERTICAL, "STATUS_NOTIFIER_SCROLL_ORIENTATION_VERTICAL", "vertical" },
{ 0, NULL, NULL }
{ STATUS_NOTIFIER_SCROLL_ORIENTATION_HORIZONTAL, "STATUS_NOTIFIER_SCROLL_ORIENTATION_HORIZONTAL", "horizontal" },
{ STATUS_NOTIFIER_SCROLL_ORIENTATION_VERTICAL, "STATUS_NOTIFIER_SCROLL_ORIENTATION_VERTICAL", "vertical" },
{ 0, NULL, NULL }
};
etype = g_enum_register_static ("StatusNotifierScrollOrientation", values);
}
return etype;
}

2
src/video/cameraworker.cpp

@ -159,7 +159,7 @@ void CameraWorker::subscribe() @@ -159,7 +159,7 @@ void CameraWorker::subscribe()
qDebug() << "CameraWorker:" << "OpenCV exception caught: " << e.what();
}
if(!bSuccess)
if (!bSuccess)
{
qDebug() << "CameraWorker: Could not open camera";
}

12
src/widget/form/chatform.cpp

@ -221,11 +221,11 @@ void ChatForm::onFileRecvRequest(ToxFile file) @@ -221,11 +221,11 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|| Settings::getInstance().getAutoSaveEnabled())
{
ChatLineContentProxy* proxy = dynamic_cast<ChatLineContentProxy*>(msg->getContent(1));
if(proxy)
if (proxy)
{
FileTransferWidget* tfWidget = dynamic_cast<FileTransferWidget*>(proxy->getWidget());
if(tfWidget)
if (tfWidget)
tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxID()));
}
}
@ -538,7 +538,7 @@ void ChatForm::onHangupCallTriggered() @@ -538,7 +538,7 @@ void ChatForm::onHangupCallTriggered()
qDebug() << "onHangupCallTriggered";
//Fixes an OS X bug with ending a call while in full screen
if(netcam->isFullScreen())
if (netcam->isFullScreen())
netcam->showNormal();
audioInputFlag = false;
@ -635,7 +635,7 @@ void ChatForm::enableCallButtons() @@ -635,7 +635,7 @@ void ChatForm::enableCallButtons()
videoButton->setToolTip("");
videoButton->disconnect();
if(disableCallButtonsTimer == nullptr)
if (disableCallButtonsTimer == nullptr)
{
disableCallButtonsTimer = new QTimer();
connect(disableCallButtonsTimer, SIGNAL(timeout()),
@ -827,7 +827,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered) @@ -827,7 +827,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
authorId.isMine(),
QDateTime());
if(!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) )
if (!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) )
msg->hideSender();
prevId = authorId;
@ -973,7 +973,7 @@ void ChatForm::setFriendTyping(bool isTyping) @@ -973,7 +973,7 @@ void ChatForm::setFriendTyping(bool isTyping)
Text* text = dynamic_cast<Text*>(chatWidget->getTypingNotification()->getContent(1));
if(text)
if (text)
text->setText("<div class=typing>" + QString("%1 is typing").arg(f->getDisplayedName()) + "</div>");
}

8
src/widget/form/genericchatform.cpp

@ -253,7 +253,7 @@ ChatMessage::Ptr GenericChatForm::addMessage(const ToxID& author, const QString @@ -253,7 +253,7 @@ ChatMessage::Ptr GenericChatForm::addMessage(const ToxID& author, const QString
QString authorStr = author.isMine() ? Core::getInstance()->getUsername() : resolveToxID(author);
ChatMessage::Ptr msg;
if(isAction)
if (isAction)
{
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::ACTION, false);
previousId.clear();
@ -270,7 +270,7 @@ ChatMessage::Ptr GenericChatForm::addMessage(const ToxID& author, const QString @@ -270,7 +270,7 @@ ChatMessage::Ptr GenericChatForm::addMessage(const ToxID& author, const QString
insertChatMessage(msg);
if(isSent)
if (isSent)
msg->markAsSent(datetime);
return msg;
@ -287,7 +287,7 @@ void GenericChatForm::addAlertMessage(const ToxID &author, QString message, QDat @@ -287,7 +287,7 @@ void GenericChatForm::addAlertMessage(const ToxID &author, QString message, QDat
ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::ALERT, author.isMine(), datetime);
insertChatMessage(msg);
if( (author == previousId) && (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter) )
if ((author == previousId) && (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter))
msg->hideSender();
previousId = author;
@ -333,7 +333,7 @@ void GenericChatForm::onSaveLogClicked() @@ -333,7 +333,7 @@ void GenericChatForm::onSaveLogClicked()
QString plainText;
auto lines = chatWidget->getLines();
for(ChatLine::Ptr l : lines)
for (ChatLine::Ptr l : lines)
{
Timestamp* rightCol = dynamic_cast<Timestamp*>(l->getContent(2));
ChatLineContent* middleCol = l->getContent(1);

7
src/widget/widget.cpp

@ -468,9 +468,7 @@ void Widget::confirmExecutableOpen(const QFileInfo file) @@ -468,9 +468,7 @@ void Widget::confirmExecutableOpen(const QFileInfo file)
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))
{
return;
}
// 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);
@ -695,7 +693,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status) @@ -695,7 +693,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status)
&& Settings::getInstance().getStatusChangeNotificationEnabled())
{
QString fStatus = "";
switch(f->getStatus())
switch (f->getStatus())
{
case Status::Away:
fStatus = tr("away", "contact status"); break;
@ -1075,7 +1073,7 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f) @@ -1075,7 +1073,7 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
bool Widget::event(QEvent * e)
{
switch(e->type())
switch (e->type())
{
case QEvent::WindowActivate:
if (activeChatroomWidget != nullptr)
@ -1292,6 +1290,7 @@ void Widget::clearAllReceipts() @@ -1292,6 +1290,7 @@ void Widget::clearAllReceipts()
for (Friend *f : frnds)
f->getChatForm()->getOfflineMsgEngine()->removeAllReciepts();
}
void Widget::reloadTheme()
{
QString statusPanelStyle = Style::getStylesheet(":/ui/window/statusPanel.css");

8
tools/update-server/qtox-updater-genflist/main.cpp

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

7
updater/widget.cpp

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

Loading…
Cancel
Save