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:
commit
e79d40e356
|
@ -27,9 +27,9 @@ ChatLine::ChatLine()
|
||||||
|
|
||||||
ChatLine::~ChatLine()
|
ChatLine::~ChatLine()
|
||||||
{
|
{
|
||||||
for(ChatLineContent* c : content)
|
for (ChatLineContent* c : content)
|
||||||
{
|
{
|
||||||
if(c->scene())
|
if (c->scene())
|
||||||
c->scene()->removeItem(c);
|
c->scene()->removeItem(c);
|
||||||
|
|
||||||
delete c;
|
delete c;
|
||||||
|
@ -40,15 +40,15 @@ void ChatLine::setRow(int idx)
|
||||||
{
|
{
|
||||||
row = 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);
|
content[c]->setIndex(row, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLine::visibilityChanged(bool visible)
|
void ChatLine::visibilityChanged(bool visible)
|
||||||
{
|
{
|
||||||
if(isVisible != visible)
|
if (isVisible != visible)
|
||||||
{
|
{
|
||||||
for(ChatLineContent* c : content)
|
for (ChatLineContent* c : content)
|
||||||
c->visibilityChanged(visible);
|
c->visibilityChanged(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ int ChatLine::getRow() const
|
||||||
|
|
||||||
ChatLineContent *ChatLine::getContent(int col) 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 content[col];
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -70,9 +70,9 @@ ChatLineContent *ChatLine::getContent(int col) const
|
||||||
|
|
||||||
ChatLineContent *ChatLine::getContent(QPointF scenePos) 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;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,37 +81,37 @@ ChatLineContent *ChatLine::getContent(QPointF scenePos) const
|
||||||
|
|
||||||
void ChatLine::removeFromScene()
|
void ChatLine::removeFromScene()
|
||||||
{
|
{
|
||||||
for(ChatLineContent* c : content)
|
for (ChatLineContent* c : content)
|
||||||
{
|
{
|
||||||
if(c->scene())
|
if (c->scene())
|
||||||
c->scene()->removeItem(c);
|
c->scene()->removeItem(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLine::addToScene(QGraphicsScene *scene)
|
void ChatLine::addToScene(QGraphicsScene *scene)
|
||||||
{
|
{
|
||||||
if(!scene)
|
if (!scene)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(ChatLineContent* c : content)
|
for (ChatLineContent* c : content)
|
||||||
scene->addItem(c);
|
scene->addItem(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLine::setVisible(bool visible)
|
void ChatLine::setVisible(bool visible)
|
||||||
{
|
{
|
||||||
for(ChatLineContent* c : content)
|
for (ChatLineContent* c : content)
|
||||||
c->setVisible(visible);
|
c->setVisible(visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLine::selectionCleared()
|
void ChatLine::selectionCleared()
|
||||||
{
|
{
|
||||||
for(ChatLineContent* c : content)
|
for (ChatLineContent* c : content)
|
||||||
c->selectionCleared();
|
c->selectionCleared();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLine::selectionFocusChanged(bool focusIn)
|
void ChatLine::selectionFocusChanged(bool focusIn)
|
||||||
{
|
{
|
||||||
for(ChatLineContent* c : content)
|
for (ChatLineContent* c : content)
|
||||||
c->selectionFocusChanged(focusIn);
|
c->selectionFocusChanged(focusIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ void ChatLine::updateBBox()
|
||||||
bbox.setHeight(0);
|
bbox.setHeight(0);
|
||||||
bbox.setWidth(width);
|
bbox.setWidth(width);
|
||||||
|
|
||||||
for(ChatLineContent* c : content)
|
for (ChatLineContent* c : content)
|
||||||
bbox.setHeight(qMax(c->sceneBoundingRect().top() - bbox.top() + c->sceneBoundingRect().height(), bbox.height()));
|
bbox.setHeight(qMax(c->sceneBoundingRect().top() - bbox.top() + c->sceneBoundingRect().height(), bbox.height()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ QRectF ChatLine::sceneBoundingRect() const
|
||||||
|
|
||||||
void ChatLine::addColumn(ChatLineContent* item, ColumnFormat fmt)
|
void ChatLine::addColumn(ChatLineContent* item, ColumnFormat fmt)
|
||||||
{
|
{
|
||||||
if(!item)
|
if (!item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
format.push_back(fmt);
|
format.push_back(fmt);
|
||||||
|
@ -145,7 +145,7 @@ void ChatLine::addColumn(ChatLineContent* item, ColumnFormat fmt)
|
||||||
|
|
||||||
void ChatLine::replaceContent(int col, ChatLineContent *lineContent)
|
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();
|
QGraphicsScene* scene = content[col]->scene();
|
||||||
delete content[col];
|
delete content[col];
|
||||||
|
@ -153,7 +153,7 @@ void ChatLine::replaceContent(int col, ChatLineContent *lineContent)
|
||||||
content[col] = lineContent;
|
content[col] = lineContent;
|
||||||
lineContent->setIndex(row, col);
|
lineContent->setIndex(row, col);
|
||||||
|
|
||||||
if(scene)
|
if (scene)
|
||||||
scene->addItem(content[col]);
|
scene->addItem(content[col]);
|
||||||
|
|
||||||
layout(width, bbox.topLeft());
|
layout(width, bbox.topLeft());
|
||||||
|
@ -170,15 +170,15 @@ void ChatLine::layout(qreal w, QPointF scenePos)
|
||||||
qreal fixedWidth = (content.size()-1) * columnSpacing;
|
qreal fixedWidth = (content.size()-1) * columnSpacing;
|
||||||
qreal varWidth = 0.0; // used for normalisation
|
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;
|
fixedWidth += format[i].size;
|
||||||
else
|
else
|
||||||
varWidth += format[i].size;
|
varWidth += format[i].size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(varWidth == 0.0)
|
if (varWidth == 0.0)
|
||||||
varWidth = 1.0;
|
varWidth = 1.0;
|
||||||
|
|
||||||
qreal leftover = qMax(0.0, width - fixedWidth);
|
qreal leftover = qMax(0.0, width - fixedWidth);
|
||||||
|
@ -188,11 +188,11 @@ void ChatLine::layout(qreal w, QPointF scenePos)
|
||||||
qreal xPos[content.size()];
|
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
|
// calculate the effective width of the current column
|
||||||
qreal width;
|
qreal width;
|
||||||
if(format[i].policy == ColumnFormat::FixedSize)
|
if (format[i].policy == ColumnFormat::FixedSize)
|
||||||
width = format[i].size;
|
width = format[i].size;
|
||||||
else
|
else
|
||||||
width = format[i].size / varWidth * leftover;
|
width = format[i].size / varWidth * leftover;
|
||||||
|
@ -222,7 +222,7 @@ void ChatLine::layout(qreal w, QPointF scenePos)
|
||||||
maxVOffset = qMax(maxVOffset, content[i]->getAscent());
|
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
|
// calculate vertical alignment
|
||||||
// vertical alignment may depend on width, so we do it in a second pass
|
// 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)
|
||||||
void ChatLine::moveBy(qreal deltaY)
|
void ChatLine::moveBy(qreal deltaY)
|
||||||
{
|
{
|
||||||
// reposition only
|
// reposition only
|
||||||
for(ChatLineContent* c : content)
|
for (ChatLineContent* c : content)
|
||||||
c->moveBy(0, deltaY);
|
c->moveBy(0, deltaY);
|
||||||
|
|
||||||
bbox.moveTop(bbox.top() + deltaY);
|
bbox.moveTop(bbox.top() + deltaY);
|
||||||
|
|
|
@ -30,9 +30,9 @@
|
||||||
template<class T>
|
template<class T>
|
||||||
T clamp(T x, T min, T max)
|
T clamp(T x, T min, T max)
|
||||||
{
|
{
|
||||||
if(x > max)
|
if (x > max)
|
||||||
return max;
|
return max;
|
||||||
if(x < min)
|
if (x < min)
|
||||||
return min;
|
return min;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
@ -110,22 +110,22 @@ ChatLog::ChatLog(QWidget* parent)
|
||||||
ChatLog::~ChatLog()
|
ChatLog::~ChatLog()
|
||||||
{
|
{
|
||||||
// Remove chatlines from scene
|
// Remove chatlines from scene
|
||||||
for(ChatLine::Ptr l : lines)
|
for (ChatLine::Ptr l : lines)
|
||||||
l->removeFromScene();
|
l->removeFromScene();
|
||||||
|
|
||||||
if(busyNotification)
|
if (busyNotification)
|
||||||
busyNotification->removeFromScene();
|
busyNotification->removeFromScene();
|
||||||
|
|
||||||
if(typingNotification)
|
if (typingNotification)
|
||||||
typingNotification->removeFromScene();
|
typingNotification->removeFromScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLog::clearSelection()
|
void ChatLog::clearSelection()
|
||||||
{
|
{
|
||||||
if(selectionMode == None)
|
if (selectionMode == None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(int i=selFirstRow; i<=selLastRow; ++i)
|
for (int i=selFirstRow; i<=selLastRow; ++i)
|
||||||
lines[i]->selectionCleared();
|
lines[i]->selectionCleared();
|
||||||
|
|
||||||
selFirstRow = -1;
|
selFirstRow = -1;
|
||||||
|
@ -151,20 +151,20 @@ void ChatLog::updateSceneRect()
|
||||||
|
|
||||||
void ChatLog::layout(int start, int end, qreal width)
|
void ChatLog::layout(int start, int end, qreal width)
|
||||||
{
|
{
|
||||||
if(lines.empty())
|
if (lines.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qreal h = 0.0;
|
qreal h = 0.0;
|
||||||
|
|
||||||
// Line at start-1 is considered to have the correct position. All following lines are
|
// Line at start-1 is considered to have the correct position. All following lines are
|
||||||
// positioned in respect to this line.
|
// positioned in respect to this line.
|
||||||
if(start - 1 >= 0)
|
if (start - 1 >= 0)
|
||||||
h = lines[start - 1]->sceneBoundingRect().bottom() + lineSpacing;
|
h = lines[start - 1]->sceneBoundingRect().bottom() + lineSpacing;
|
||||||
|
|
||||||
start = clamp<int>(start, 0, lines.size());
|
start = clamp<int>(start, 0, lines.size());
|
||||||
end = clamp<int>(end + 1, 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();
|
ChatLine* l = lines[i].get();
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ void ChatLog::mousePressEvent(QMouseEvent* ev)
|
||||||
{
|
{
|
||||||
QGraphicsView::mousePressEvent(ev);
|
QGraphicsView::mousePressEvent(ev);
|
||||||
|
|
||||||
if(ev->button() == Qt::LeftButton)
|
if (ev->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
clickPos = ev->pos();
|
clickPos = ev->pos();
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
@ -197,24 +197,24 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
|
||||||
|
|
||||||
QPointF scenePos = mapToScene(ev->pos());
|
QPointF scenePos = mapToScene(ev->pos());
|
||||||
|
|
||||||
if(ev->buttons() & Qt::LeftButton)
|
if (ev->buttons() & Qt::LeftButton)
|
||||||
{
|
{
|
||||||
//autoscroll
|
//autoscroll
|
||||||
if(ev->pos().y() < 0)
|
if (ev->pos().y() < 0)
|
||||||
selectionScrollDir = Up;
|
selectionScrollDir = Up;
|
||||||
else if(ev->pos().y() > height())
|
else if (ev->pos().y() > height())
|
||||||
selectionScrollDir = Down;
|
selectionScrollDir = Down;
|
||||||
else
|
else
|
||||||
selectionScrollDir = NoDirection;
|
selectionScrollDir = NoDirection;
|
||||||
|
|
||||||
//select
|
//select
|
||||||
if(selectionMode == None && (clickPos - ev->pos()).manhattanLength() > QApplication::startDragDistance())
|
if (selectionMode == None && (clickPos - ev->pos()).manhattanLength() > QApplication::startDragDistance())
|
||||||
{
|
{
|
||||||
QPointF sceneClickPos = mapToScene(clickPos.toPoint());
|
QPointF sceneClickPos = mapToScene(clickPos.toPoint());
|
||||||
ChatLine::Ptr line = findLineByPosY(scenePos.y());
|
ChatLine::Ptr line = findLineByPosY(scenePos.y());
|
||||||
|
|
||||||
ChatLineContent* content = getContentFromPos(sceneClickPos);
|
ChatLineContent* content = getContentFromPos(sceneClickPos);
|
||||||
if(content)
|
if (content)
|
||||||
{
|
{
|
||||||
selClickedRow = content->getRow();
|
selClickedRow = content->getRow();
|
||||||
selClickedCol = content->getColumn();
|
selClickedCol = content->getColumn();
|
||||||
|
@ -226,10 +226,10 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
|
||||||
selectionMode = Precise;
|
selectionMode = Precise;
|
||||||
|
|
||||||
// ungrab mouse grabber
|
// ungrab mouse grabber
|
||||||
if(scene->mouseGrabberItem())
|
if (scene->mouseGrabberItem())
|
||||||
scene->mouseGrabberItem()->ungrabMouse();
|
scene->mouseGrabberItem()->ungrabMouse();
|
||||||
}
|
}
|
||||||
else if(line.get())
|
else if (line.get())
|
||||||
{
|
{
|
||||||
selClickedRow = line->getRow();
|
selClickedRow = line->getRow();
|
||||||
selFirstRow = selClickedRow;
|
selFirstRow = selClickedRow;
|
||||||
|
@ -239,37 +239,37 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(selectionMode != None)
|
if (selectionMode != None)
|
||||||
{
|
{
|
||||||
ChatLineContent* content = getContentFromPos(scenePos);
|
ChatLineContent* content = getContentFromPos(scenePos);
|
||||||
ChatLine::Ptr line = findLineByPosY(scenePos.y());
|
ChatLine::Ptr line = findLineByPosY(scenePos.y());
|
||||||
|
|
||||||
int row;
|
int row;
|
||||||
|
|
||||||
if(content)
|
if (content)
|
||||||
{
|
{
|
||||||
row = content->getRow();
|
row = content->getRow();
|
||||||
int col = content->getColumn();
|
int col = content->getColumn();
|
||||||
|
|
||||||
if(row == selClickedRow && col == selClickedCol)
|
if (row == selClickedRow && col == selClickedCol)
|
||||||
{
|
{
|
||||||
selectionMode = Precise;
|
selectionMode = Precise;
|
||||||
|
|
||||||
content->selectionMouseMove(scenePos);
|
content->selectionMouseMove(scenePos);
|
||||||
selGraphItem->hide();
|
selGraphItem->hide();
|
||||||
}
|
}
|
||||||
else if(col != selClickedCol)
|
else if (col != selClickedCol)
|
||||||
{
|
{
|
||||||
selectionMode = Multi;
|
selectionMode = Multi;
|
||||||
|
|
||||||
lines[selClickedRow]->selectionCleared();
|
lines[selClickedRow]->selectionCleared();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(line.get())
|
else if (line.get())
|
||||||
{
|
{
|
||||||
row = line->getRow();
|
row = line->getRow();
|
||||||
|
|
||||||
if(row != selClickedRow)
|
if (row != selClickedRow)
|
||||||
{
|
{
|
||||||
selectionMode = Multi;
|
selectionMode = Multi;
|
||||||
|
|
||||||
|
@ -280,10 +280,10 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(row >= selClickedRow)
|
if (row >= selClickedRow)
|
||||||
selLastRow = row;
|
selLastRow = row;
|
||||||
|
|
||||||
if(row <= selClickedRow)
|
if (row <= selClickedRow)
|
||||||
selFirstRow = row;
|
selFirstRow = row;
|
||||||
|
|
||||||
updateMultiSelectionRect();
|
updateMultiSelectionRect();
|
||||||
|
@ -296,13 +296,13 @@ void ChatLog::mouseMoveEvent(QMouseEvent* ev)
|
||||||
//Much faster than QGraphicsScene::itemAt()!
|
//Much faster than QGraphicsScene::itemAt()!
|
||||||
ChatLineContent* ChatLog::getContentFromPos(QPointF scenePos) const
|
ChatLineContent* ChatLog::getContentFromPos(QPointF scenePos) const
|
||||||
{
|
{
|
||||||
if(lines.empty())
|
if (lines.empty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto itr = std::lower_bound(lines.cbegin(), lines.cend(), scenePos.y(), ChatLine::lessThanBSRectBottom);
|
auto itr = std::lower_bound(lines.cbegin(), lines.cend(), scenePos.y(), ChatLine::lessThanBSRectBottom);
|
||||||
|
|
||||||
//find content
|
//find content
|
||||||
if(itr != lines.cend() && (*itr)->sceneBoundingRect().contains(scenePos))
|
if (itr != lines.cend() && (*itr)->sceneBoundingRect().contains(scenePos))
|
||||||
return (*itr)->getContent(scenePos);
|
return (*itr)->getContent(scenePos);
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -310,16 +310,16 @@ ChatLineContent* ChatLog::getContentFromPos(QPointF scenePos) const
|
||||||
|
|
||||||
bool ChatLog::isOverSelection(QPointF scenePos) const
|
bool ChatLog::isOverSelection(QPointF scenePos) const
|
||||||
{
|
{
|
||||||
if(selectionMode == Precise)
|
if (selectionMode == Precise)
|
||||||
{
|
{
|
||||||
ChatLineContent* content = getContentFromPos(scenePos);
|
ChatLineContent* content = getContentFromPos(scenePos);
|
||||||
|
|
||||||
if(content)
|
if (content)
|
||||||
return content->isOverSelection(scenePos);
|
return content->isOverSelection(scenePos);
|
||||||
}
|
}
|
||||||
else if(selectionMode == Multi)
|
else if (selectionMode == Multi)
|
||||||
{
|
{
|
||||||
if(selGraphItem->rect().contains(scenePos))
|
if (selGraphItem->rect().contains(scenePos))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,13 +333,13 @@ qreal ChatLog::useableWidth() const
|
||||||
|
|
||||||
void ChatLog::reposition(int start, int end, qreal deltaY)
|
void ChatLog::reposition(int start, int end, qreal deltaY)
|
||||||
{
|
{
|
||||||
if(lines.isEmpty())
|
if (lines.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
start = clamp<int>(start, 0, lines.size() - 1);
|
start = clamp<int>(start, 0, lines.size() - 1);
|
||||||
end = clamp<int>(end + 1, 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();
|
ChatLine* l = lines[i].get();
|
||||||
l->moveBy(deltaY);
|
l->moveBy(deltaY);
|
||||||
|
@ -348,7 +348,7 @@ void ChatLog::reposition(int start, int end, qreal deltaY)
|
||||||
|
|
||||||
void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l)
|
void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l)
|
||||||
{
|
{
|
||||||
if(!l.get())
|
if (!l.get())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool stickToBtm = stickToBottom();
|
bool stickToBtm = stickToBottom();
|
||||||
|
@ -362,7 +362,7 @@ void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l)
|
||||||
layout(lines.last()->getRow(), lines.size(), useableWidth());
|
layout(lines.last()->getRow(), lines.size(), useableWidth());
|
||||||
updateSceneRect();
|
updateSceneRect();
|
||||||
|
|
||||||
if(stickToBtm)
|
if (stickToBtm)
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
|
|
||||||
checkVisibility();
|
checkVisibility();
|
||||||
|
@ -371,7 +371,7 @@ void ChatLog::insertChatlineAtBottom(ChatLine::Ptr l)
|
||||||
|
|
||||||
void ChatLog::insertChatlineOnTop(ChatLine::Ptr l)
|
void ChatLog::insertChatlineOnTop(ChatLine::Ptr l)
|
||||||
{
|
{
|
||||||
if(!l.get())
|
if (!l.get())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
insertChatlineOnTop(QList<ChatLine::Ptr>() << l);
|
insertChatlineOnTop(QList<ChatLine::Ptr>() << l);
|
||||||
|
@ -379,7 +379,7 @@ void ChatLog::insertChatlineOnTop(ChatLine::Ptr l)
|
||||||
|
|
||||||
void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines)
|
void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines)
|
||||||
{
|
{
|
||||||
if(newLines.isEmpty())
|
if (newLines.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QGraphicsScene::ItemIndexMethod oldIndexMeth = scene->itemIndexMethod();
|
QGraphicsScene::ItemIndexMethod oldIndexMeth = scene->itemIndexMethod();
|
||||||
|
@ -391,7 +391,7 @@ void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines)
|
||||||
|
|
||||||
// add the new lines
|
// add the new lines
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(ChatLine::Ptr l : newLines)
|
for (ChatLine::Ptr l : newLines)
|
||||||
{
|
{
|
||||||
l->addToScene(scene);
|
l->addToScene(scene);
|
||||||
l->visibilityChanged(false);
|
l->visibilityChanged(false);
|
||||||
|
@ -400,7 +400,7 @@ void ChatLog::insertChatlineOnTop(const QList<ChatLine::Ptr>& newLines)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the old lines
|
// add the old lines
|
||||||
for(ChatLine::Ptr l : lines)
|
for (ChatLine::Ptr l : lines)
|
||||||
{
|
{
|
||||||
l->setRow(i++);
|
l->setRow(i++);
|
||||||
combLines.push_back(l);
|
combLines.push_back(l);
|
||||||
|
@ -427,16 +427,16 @@ void ChatLog::scrollToBottom()
|
||||||
|
|
||||||
void ChatLog::startResizeWorker()
|
void ChatLog::startResizeWorker()
|
||||||
{
|
{
|
||||||
if(lines.empty())
|
if (lines.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// (re)start the worker
|
// (re)start the worker
|
||||||
if(!workerTimer->isActive())
|
if (!workerTimer->isActive())
|
||||||
{
|
{
|
||||||
// these values must not be reevaluated while the worker is running
|
// these values must not be reevaluated while the worker is running
|
||||||
workerStb = stickToBottom();
|
workerStb = stickToBottom();
|
||||||
|
|
||||||
if(!visibleLines.empty())
|
if (!visibleLines.empty())
|
||||||
workerAnchorLine = visibleLines.first();
|
workerAnchorLine = visibleLines.first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ void ChatLog::mouseDoubleClickEvent(QMouseEvent *ev)
|
||||||
QPointF scenePos = mapToScene(ev->pos());
|
QPointF scenePos = mapToScene(ev->pos());
|
||||||
ChatLineContent* content = getContentFromPos(scenePos);
|
ChatLineContent* content = getContentFromPos(scenePos);
|
||||||
|
|
||||||
if(content)
|
if (content)
|
||||||
{
|
{
|
||||||
content->selectionDoubleClick(scenePos);
|
content->selectionDoubleClick(scenePos);
|
||||||
selClickedCol = content->getColumn();
|
selClickedCol = content->getColumn();
|
||||||
|
@ -479,18 +479,18 @@ void ChatLog::mouseDoubleClickEvent(QMouseEvent *ev)
|
||||||
|
|
||||||
QString ChatLog::getSelectedText() const
|
QString ChatLog::getSelectedText() const
|
||||||
{
|
{
|
||||||
if(selectionMode == Precise)
|
if (selectionMode == Precise)
|
||||||
{
|
{
|
||||||
return lines[selClickedRow]->content[selClickedCol]->getSelectedText();
|
return lines[selClickedRow]->content[selClickedCol]->getSelectedText();
|
||||||
}
|
}
|
||||||
else if(selectionMode == Multi)
|
else if (selectionMode == Multi)
|
||||||
{
|
{
|
||||||
// build a nicely formatted message
|
// build a nicely formatted message
|
||||||
QString out;
|
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;
|
continue;
|
||||||
|
|
||||||
QString timestamp = lines[i]->content[2]->getText().isEmpty() ? tr("pending") : lines[i]->content[2]->getText();
|
QString timestamp = lines[i]->content[2]->getText().isEmpty() ? tr("pending") : lines[i]->content[2]->getText();
|
||||||
|
@ -530,7 +530,7 @@ void ChatLog::clear()
|
||||||
{
|
{
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
|
||||||
for(ChatLine::Ptr l : lines)
|
for (ChatLine::Ptr l : lines)
|
||||||
l->removeFromScene();
|
l->removeFromScene();
|
||||||
|
|
||||||
lines.clear();
|
lines.clear();
|
||||||
|
@ -544,13 +544,13 @@ void ChatLog::copySelectedText(bool toSelectionBuffer) const
|
||||||
QString text = getSelectedText();
|
QString text = getSelectedText();
|
||||||
QClipboard* clipboard = QApplication::clipboard();
|
QClipboard* clipboard = QApplication::clipboard();
|
||||||
|
|
||||||
if(clipboard && !text.isNull())
|
if (clipboard && !text.isNull())
|
||||||
clipboard->setText(text, toSelectionBuffer ? QClipboard::Selection : QClipboard::Clipboard);
|
clipboard->setText(text, toSelectionBuffer ? QClipboard::Selection : QClipboard::Clipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLog::setBusyNotification(ChatLine::Ptr notification)
|
void ChatLog::setBusyNotification(ChatLine::Ptr notification)
|
||||||
{
|
{
|
||||||
if(!notification.get())
|
if (!notification.get())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
busyNotification = notification;
|
busyNotification = notification;
|
||||||
|
@ -569,7 +569,7 @@ void ChatLog::setTypingNotification(ChatLine::Ptr notification)
|
||||||
|
|
||||||
void ChatLog::setTypingNotificationVisible(bool visible)
|
void ChatLog::setTypingNotificationVisible(bool visible)
|
||||||
{
|
{
|
||||||
if(typingNotification.get())
|
if (typingNotification.get())
|
||||||
{
|
{
|
||||||
typingNotification->setVisible(visible);
|
typingNotification->setVisible(visible);
|
||||||
updateTypingNotification();
|
updateTypingNotification();
|
||||||
|
@ -578,7 +578,7 @@ void ChatLog::setTypingNotificationVisible(bool visible)
|
||||||
|
|
||||||
void ChatLog::scrollToLine(ChatLine::Ptr line)
|
void ChatLog::scrollToLine(ChatLine::Ptr line)
|
||||||
{
|
{
|
||||||
if(!line.get())
|
if (!line.get())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateSceneRect();
|
updateSceneRect();
|
||||||
|
@ -587,7 +587,7 @@ void ChatLog::scrollToLine(ChatLine::Ptr line)
|
||||||
|
|
||||||
void ChatLog::selectAll()
|
void ChatLog::selectAll()
|
||||||
{
|
{
|
||||||
if(lines.empty())
|
if (lines.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
@ -607,7 +607,7 @@ void ChatLog::forceRelayout()
|
||||||
|
|
||||||
void ChatLog::checkVisibility()
|
void ChatLog::checkVisibility()
|
||||||
{
|
{
|
||||||
if(lines.empty())
|
if (lines.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// find first visible line
|
// find first visible line
|
||||||
|
@ -618,18 +618,18 @@ void ChatLog::checkVisibility()
|
||||||
|
|
||||||
// set visibilty
|
// set visibilty
|
||||||
QList<ChatLine::Ptr> newVisibleLines;
|
QList<ChatLine::Ptr> newVisibleLines;
|
||||||
for(auto itr = lowerBound; itr != upperBound; ++itr)
|
for (auto itr = lowerBound; itr != upperBound; ++itr)
|
||||||
{
|
{
|
||||||
newVisibleLines.append(*itr);
|
newVisibleLines.append(*itr);
|
||||||
|
|
||||||
if(!visibleLines.contains(*itr))
|
if (!visibleLines.contains(*itr))
|
||||||
(*itr)->visibilityChanged(true);
|
(*itr)->visibilityChanged(true);
|
||||||
|
|
||||||
visibleLines.removeOne(*itr);
|
visibleLines.removeOne(*itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// these lines are no longer visible
|
// these lines are no longer visible
|
||||||
for(ChatLine::Ptr line : visibleLines)
|
for (ChatLine::Ptr line : visibleLines)
|
||||||
line->visibilityChanged(false);
|
line->visibilityChanged(false);
|
||||||
|
|
||||||
visibleLines = newVisibleLines;
|
visibleLines = newVisibleLines;
|
||||||
|
@ -637,7 +637,7 @@ void ChatLog::checkVisibility()
|
||||||
// enforce order
|
// enforce order
|
||||||
std::sort(visibleLines.begin(), visibleLines.end(), ChatLine::lessThanRowIndex);
|
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();
|
// qDebug() << "visible from " << visibleLines.first()->getRow() << "to " << visibleLines.last()->getRow() << " total " << visibleLines.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,7 +651,7 @@ void ChatLog::resizeEvent(QResizeEvent* ev)
|
||||||
{
|
{
|
||||||
bool stb = stickToBottom();
|
bool stb = stickToBottom();
|
||||||
|
|
||||||
if(ev->size().width() != ev->oldSize().width())
|
if (ev->size().width() != ev->oldSize().width())
|
||||||
{
|
{
|
||||||
startResizeWorker();
|
startResizeWorker();
|
||||||
stb = false; // let the resize worker handle it
|
stb = false; // let the resize worker handle it
|
||||||
|
@ -659,7 +659,7 @@ void ChatLog::resizeEvent(QResizeEvent* ev)
|
||||||
|
|
||||||
QGraphicsView::resizeEvent(ev);
|
QGraphicsView::resizeEvent(ev);
|
||||||
|
|
||||||
if(stb)
|
if (stb)
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
|
|
||||||
updateBusyNotification();
|
updateBusyNotification();
|
||||||
|
@ -667,13 +667,13 @@ void ChatLog::resizeEvent(QResizeEvent* ev)
|
||||||
|
|
||||||
void ChatLog::updateMultiSelectionRect()
|
void ChatLog::updateMultiSelectionRect()
|
||||||
{
|
{
|
||||||
if(selectionMode == Multi && selFirstRow >= 0 && selLastRow >= 0)
|
if (selectionMode == Multi && selFirstRow >= 0 && selLastRow >= 0)
|
||||||
{
|
{
|
||||||
QRectF selBBox;
|
QRectF selBBox;
|
||||||
selBBox = selBBox.united(lines[selFirstRow]->sceneBoundingRect());
|
selBBox = selBBox.united(lines[selFirstRow]->sceneBoundingRect());
|
||||||
selBBox = selBBox.united(lines[selLastRow]->sceneBoundingRect());
|
selBBox = selBBox.united(lines[selLastRow]->sceneBoundingRect());
|
||||||
|
|
||||||
if(selGraphItem->rect() != selBBox)
|
if (selGraphItem->rect() != selBBox)
|
||||||
scene->invalidate(selGraphItem->rect());
|
scene->invalidate(selGraphItem->rect());
|
||||||
|
|
||||||
selGraphItem->setRect(selBBox);
|
selGraphItem->setRect(selBBox);
|
||||||
|
@ -688,12 +688,12 @@ void ChatLog::updateMultiSelectionRect()
|
||||||
void ChatLog::updateTypingNotification()
|
void ChatLog::updateTypingNotification()
|
||||||
{
|
{
|
||||||
ChatLine* notification = typingNotification.get();
|
ChatLine* notification = typingNotification.get();
|
||||||
if(!notification)
|
if (!notification)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qreal posY = 0.0;
|
qreal posY = 0.0;
|
||||||
|
|
||||||
if(!lines.empty())
|
if (!lines.empty())
|
||||||
posY = lines.last()->sceneBoundingRect().bottom() + lineSpacing;
|
posY = lines.last()->sceneBoundingRect().bottom() + lineSpacing;
|
||||||
|
|
||||||
notification->layout(useableWidth(), QPointF(0.0, posY));
|
notification->layout(useableWidth(), QPointF(0.0, posY));
|
||||||
|
@ -701,7 +701,7 @@ void ChatLog::updateTypingNotification()
|
||||||
|
|
||||||
void ChatLog::updateBusyNotification()
|
void ChatLog::updateBusyNotification()
|
||||||
{
|
{
|
||||||
if(busyNotification.get())
|
if (busyNotification.get())
|
||||||
{
|
{
|
||||||
//repoisition the busy notification (centered)
|
//repoisition the busy notification (centered)
|
||||||
busyNotification->layout(useableWidth(), getVisibleRect().topLeft() + QPointF(0, getVisibleRect().height()/2.0));
|
busyNotification->layout(useableWidth(), getVisibleRect().topLeft() + QPointF(0, getVisibleRect().height()/2.0));
|
||||||
|
@ -712,7 +712,7 @@ ChatLine::Ptr ChatLog::findLineByPosY(qreal yPos) const
|
||||||
{
|
{
|
||||||
auto itr = std::lower_bound(lines.cbegin(), lines.cend(), yPos, ChatLine::lessThanBSRectBottom);
|
auto itr = std::lower_bound(lines.cbegin(), lines.cend(), yPos, ChatLine::lessThanBSRectBottom);
|
||||||
|
|
||||||
if(itr != lines.cend())
|
if (itr != lines.cend())
|
||||||
return *itr;
|
return *itr;
|
||||||
|
|
||||||
return ChatLine::Ptr();
|
return ChatLine::Ptr();
|
||||||
|
@ -722,7 +722,7 @@ QRectF ChatLog::calculateSceneRect() const
|
||||||
{
|
{
|
||||||
qreal bottom = (lines.empty() ? 0.0 : lines.last()->sceneBoundingRect().bottom());
|
qreal bottom = (lines.empty() ? 0.0 : lines.last()->sceneBoundingRect().bottom());
|
||||||
|
|
||||||
if(typingNotification.get() != nullptr)
|
if (typingNotification.get() != nullptr)
|
||||||
bottom += typingNotification->sceneBoundingRect().height() + lineSpacing;
|
bottom += typingNotification->sceneBoundingRect().height() + lineSpacing;
|
||||||
|
|
||||||
return QRectF(-margins.left(), -margins.top(), useableWidth(), bottom + margins.bottom() + margins.top());
|
return QRectF(-margins.left(), -margins.top(), useableWidth(), bottom + margins.bottom() + margins.top());
|
||||||
|
@ -755,7 +755,7 @@ void ChatLog::onWorkerTimeout()
|
||||||
workerLastIndex += stepSize;
|
workerLastIndex += stepSize;
|
||||||
|
|
||||||
// done?
|
// done?
|
||||||
if(workerLastIndex >= lines.size())
|
if (workerLastIndex >= lines.size())
|
||||||
{
|
{
|
||||||
workerTimer->stop();
|
workerTimer->stop();
|
||||||
|
|
||||||
|
@ -769,7 +769,7 @@ void ChatLog::onWorkerTimeout()
|
||||||
updateMultiSelectionRect();
|
updateMultiSelectionRect();
|
||||||
|
|
||||||
// scroll
|
// scroll
|
||||||
if(workerStb)
|
if (workerStb)
|
||||||
scrollToBottom();
|
scrollToBottom();
|
||||||
else
|
else
|
||||||
scrollToLine(workerAnchorLine);
|
scrollToLine(workerAnchorLine);
|
||||||
|
@ -793,11 +793,11 @@ void ChatLog::focusInEvent(QFocusEvent* ev)
|
||||||
{
|
{
|
||||||
QGraphicsView::focusInEvent(ev);
|
QGraphicsView::focusInEvent(ev);
|
||||||
|
|
||||||
if(selectionMode != None)
|
if (selectionMode != None)
|
||||||
{
|
{
|
||||||
selGraphItem->setBrush(QBrush(selectionRectColor));
|
selGraphItem->setBrush(QBrush(selectionRectColor));
|
||||||
|
|
||||||
for(int i=selFirstRow; i<=selLastRow; ++i)
|
for (int i=selFirstRow; i<=selLastRow; ++i)
|
||||||
lines[i]->selectionFocusChanged(true);
|
lines[i]->selectionFocusChanged(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -806,11 +806,11 @@ void ChatLog::focusOutEvent(QFocusEvent* ev)
|
||||||
{
|
{
|
||||||
QGraphicsView::focusOutEvent(ev);
|
QGraphicsView::focusOutEvent(ev);
|
||||||
|
|
||||||
if(selectionMode != None)
|
if (selectionMode != None)
|
||||||
{
|
{
|
||||||
selGraphItem->setBrush(QBrush(selectionRectColor.lighter(120)));
|
selGraphItem->setBrush(QBrush(selectionRectColor.lighter(120)));
|
||||||
|
|
||||||
for(int i=selFirstRow; i<=selLastRow; ++i)
|
for (int i=selFirstRow; i<=selLastRow; ++i)
|
||||||
lines[i]->selectionFocusChanged(false);
|
lines[i]->selectionFocusChanged(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
const QColor actionColor = QColor("#1818FF"); // has to match the color in innerStyle.css (div.action)
|
||||||
|
|
||||||
//smileys
|
//smileys
|
||||||
if(Settings::getInstance().getUseEmoticons())
|
if (Settings::getInstance().getUseEmoticons())
|
||||||
text = SmileyPack::getInstance().smileyfied(text);
|
text = SmileyPack::getInstance().smileyfied(text);
|
||||||
|
|
||||||
//quotes (green text)
|
//quotes (green text)
|
||||||
|
@ -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 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));
|
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);
|
msg->markAsSent(date);
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
|
@ -137,7 +137,7 @@ void ChatMessage::markAsSent(const QDateTime &time)
|
||||||
QString ChatMessage::toString() const
|
QString ChatMessage::toString() const
|
||||||
{
|
{
|
||||||
ChatLineContent* c = getContent(1);
|
ChatLineContent* c = getContent(1);
|
||||||
if(c)
|
if (c)
|
||||||
return c->getText();
|
return c->getText();
|
||||||
|
|
||||||
return QString();
|
return QString();
|
||||||
|
@ -156,14 +156,14 @@ void ChatMessage::setAsAction()
|
||||||
void ChatMessage::hideSender()
|
void ChatMessage::hideSender()
|
||||||
{
|
{
|
||||||
ChatLineContent* c = getContent(0);
|
ChatLineContent* c = getContent(0);
|
||||||
if(c)
|
if (c)
|
||||||
c->hide();
|
c->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatMessage::hideDate()
|
void ChatMessage::hideDate()
|
||||||
{
|
{
|
||||||
ChatLineContent* c = getContent(2);
|
ChatLineContent* c = getContent(2);
|
||||||
if(c)
|
if (c)
|
||||||
c->hide();
|
c->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
|
||||||
setupButtons();
|
setupButtons();
|
||||||
|
|
||||||
//preview
|
//preview
|
||||||
if(fileInfo.direction == ToxFile::SENDING)
|
if (fileInfo.direction == ToxFile::SENDING)
|
||||||
{
|
{
|
||||||
showPreview(fileInfo.filePath);
|
showPreview(fileInfo.filePath);
|
||||||
ui->progressLabel->setText(tr("Waiting to send...", "file transfer widget"));
|
ui->progressLabel->setText(tr("Waiting to send...", "file transfer widget"));
|
||||||
|
@ -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);
|
filepath = QString("%1/%2%3.%4").arg(path, base, number > 0 ? QString(" (%1)").arg(QString::number(number)) : QString(), suffix);
|
||||||
number++;
|
number++;
|
||||||
}
|
}
|
||||||
while(QFileInfo(filepath).exists());
|
while (QFileInfo(filepath).exists());
|
||||||
|
|
||||||
//Do not automatically accept the file-transfer if the path is not writable.
|
//Do not automatically accept the file-transfer if the path is not writable.
|
||||||
//The user can still accept it manually.
|
//The user can still accept it manually.
|
||||||
|
@ -126,11 +126,11 @@ void FileTransferWidget::autoAcceptTransfer(const QString &path)
|
||||||
|
|
||||||
void FileTransferWidget::acceptTransfer(const QString &filepath)
|
void FileTransferWidget::acceptTransfer(const QString &filepath)
|
||||||
{
|
{
|
||||||
if(filepath.isEmpty())
|
if (filepath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//test if writable
|
//test if writable
|
||||||
if(!Nexus::tryRemoveFile(filepath))
|
if (!Nexus::tryRemoveFile(filepath))
|
||||||
{
|
{
|
||||||
QMessageBox::warning(0,
|
QMessageBox::warning(0,
|
||||||
tr("Location not writable","Title of permissions popup"),
|
tr("Location not writable","Title of permissions popup"),
|
||||||
|
@ -144,7 +144,7 @@ void FileTransferWidget::acceptTransfer(const QString &filepath)
|
||||||
|
|
||||||
void FileTransferWidget::setBackgroundColor(const QColor &c, bool whiteFont)
|
void FileTransferWidget::setBackgroundColor(const QColor &c, bool whiteFont)
|
||||||
{
|
{
|
||||||
if(c != backgroundColor)
|
if (c != backgroundColor)
|
||||||
{
|
{
|
||||||
backgroundColorAnimation->setStartValue(backgroundColor);
|
backgroundColorAnimation->setStartValue(backgroundColor);
|
||||||
backgroundColorAnimation->setEndValue(c);
|
backgroundColorAnimation->setEndValue(c);
|
||||||
|
@ -161,7 +161,7 @@ void FileTransferWidget::setBackgroundColor(const QColor &c, bool whiteFont)
|
||||||
|
|
||||||
void FileTransferWidget::setButtonColor(const QColor &c)
|
void FileTransferWidget::setButtonColor(const QColor &c)
|
||||||
{
|
{
|
||||||
if(c != buttonColor)
|
if (c != buttonColor)
|
||||||
{
|
{
|
||||||
buttonColorAnimation->setStartValue(buttonColor);
|
buttonColorAnimation->setStartValue(buttonColor);
|
||||||
buttonColorAnimation->setEndValue(c);
|
buttonColorAnimation->setEndValue(c);
|
||||||
|
@ -188,13 +188,13 @@ void FileTransferWidget::paintEvent(QPaintEvent *)
|
||||||
const int lineWidth = 1;
|
const int lineWidth = 1;
|
||||||
|
|
||||||
// draw background
|
// draw background
|
||||||
if(drawButtonAreaNeeded())
|
if (drawButtonAreaNeeded())
|
||||||
painter.setClipRect(QRect(0,0,width()-buttonFieldWidth,height()));
|
painter.setClipRect(QRect(0,0,width()-buttonFieldWidth,height()));
|
||||||
|
|
||||||
painter.setBrush(QBrush(backgroundColor));
|
painter.setBrush(QBrush(backgroundColor));
|
||||||
painter.drawRoundRect(geometry(), r * ratio, r);
|
painter.drawRoundRect(geometry(), r * ratio, r);
|
||||||
|
|
||||||
if(drawButtonAreaNeeded())
|
if (drawButtonAreaNeeded())
|
||||||
{
|
{
|
||||||
// draw button background (top)
|
// draw button background (top)
|
||||||
painter.setBrush(QBrush(buttonColor));
|
painter.setBrush(QBrush(buttonColor));
|
||||||
|
@ -213,12 +213,12 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
|
||||||
QTime now = QTime::currentTime();
|
QTime now = QTime::currentTime();
|
||||||
qint64 dt = lastTick.msecsTo(now); //ms
|
qint64 dt = lastTick.msecsTo(now); //ms
|
||||||
|
|
||||||
if(fileInfo != file || dt < 1000)
|
if (fileInfo != file || dt < 1000)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fileInfo = file;
|
fileInfo = file;
|
||||||
|
|
||||||
if(fileInfo.status == ToxFile::TRANSMITTING)
|
if (fileInfo.status == ToxFile::TRANSMITTING)
|
||||||
{
|
{
|
||||||
// update progress
|
// update progress
|
||||||
qreal progress = static_cast<qreal>(file.bytesSent) / static_cast<qreal>(file.filesize);
|
qreal progress = static_cast<qreal>(file.bytesSent) / static_cast<qreal>(file.filesize);
|
||||||
|
@ -238,13 +238,13 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
|
||||||
meanData[meanIndex++] = bytesPerSec;
|
meanData[meanIndex++] = bytesPerSec;
|
||||||
|
|
||||||
qreal meanBytesPerSec = 0.0;
|
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 += meanData[i];
|
||||||
|
|
||||||
meanBytesPerSec /= static_cast<qreal>(TRANSFER_ROLLING_AVG_COUNT);
|
meanBytesPerSec /= static_cast<qreal>(TRANSFER_ROLLING_AVG_COUNT);
|
||||||
|
|
||||||
// update UI
|
// update UI
|
||||||
if(meanBytesPerSec > 0)
|
if (meanBytesPerSec > 0)
|
||||||
{
|
{
|
||||||
// ETA
|
// ETA
|
||||||
QTime toGo = QTime(0,0).addSecs((file.filesize - file.bytesSent) / meanBytesPerSec);
|
QTime toGo = QTime(0,0).addSecs((file.filesize - file.bytesSent) / meanBytesPerSec);
|
||||||
|
@ -269,7 +269,7 @@ void FileTransferWidget::onFileTransferInfo(ToxFile file)
|
||||||
|
|
||||||
void FileTransferWidget::onFileTransferAccepted(ToxFile file)
|
void FileTransferWidget::onFileTransferAccepted(ToxFile file)
|
||||||
{
|
{
|
||||||
if(fileInfo != file)
|
if (fileInfo != file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fileInfo = file;
|
fileInfo = file;
|
||||||
|
@ -281,7 +281,7 @@ void FileTransferWidget::onFileTransferAccepted(ToxFile file)
|
||||||
|
|
||||||
void FileTransferWidget::onFileTransferCancelled(ToxFile file)
|
void FileTransferWidget::onFileTransferCancelled(ToxFile file)
|
||||||
{
|
{
|
||||||
if(fileInfo != file)
|
if (fileInfo != file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fileInfo = file;
|
fileInfo = file;
|
||||||
|
@ -296,7 +296,7 @@ void FileTransferWidget::onFileTransferCancelled(ToxFile file)
|
||||||
|
|
||||||
void FileTransferWidget::onFileTransferPaused(ToxFile file)
|
void FileTransferWidget::onFileTransferPaused(ToxFile file)
|
||||||
{
|
{
|
||||||
if(fileInfo != file)
|
if (fileInfo != file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fileInfo = file;
|
fileInfo = file;
|
||||||
|
@ -306,7 +306,7 @@ void FileTransferWidget::onFileTransferPaused(ToxFile file)
|
||||||
|
|
||||||
// reset mean
|
// reset mean
|
||||||
meanIndex = 0;
|
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;
|
meanData[i] = 0.0;
|
||||||
|
|
||||||
setBackgroundColor(Style::getColor(Style::LightGrey), false);
|
setBackgroundColor(Style::getColor(Style::LightGrey), false);
|
||||||
|
@ -316,7 +316,7 @@ void FileTransferWidget::onFileTransferPaused(ToxFile file)
|
||||||
|
|
||||||
void FileTransferWidget::onFileTransferResumed(ToxFile file)
|
void FileTransferWidget::onFileTransferResumed(ToxFile file)
|
||||||
{
|
{
|
||||||
if(fileInfo != file)
|
if (fileInfo != file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fileInfo = file;
|
fileInfo = file;
|
||||||
|
@ -326,7 +326,7 @@ void FileTransferWidget::onFileTransferResumed(ToxFile file)
|
||||||
|
|
||||||
// reset mean
|
// reset mean
|
||||||
meanIndex = 0;
|
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;
|
meanData[i] = 0.0;
|
||||||
|
|
||||||
setBackgroundColor(Style::getColor(Style::LightGrey), false);
|
setBackgroundColor(Style::getColor(Style::LightGrey), false);
|
||||||
|
@ -336,7 +336,7 @@ void FileTransferWidget::onFileTransferResumed(ToxFile file)
|
||||||
|
|
||||||
void FileTransferWidget::onFileTransferFinished(ToxFile file)
|
void FileTransferWidget::onFileTransferFinished(ToxFile file)
|
||||||
{
|
{
|
||||||
if(fileInfo != file)
|
if (fileInfo != file)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fileInfo = file;
|
fileInfo = file;
|
||||||
|
@ -357,7 +357,7 @@ void FileTransferWidget::onFileTransferFinished(ToxFile file)
|
||||||
ui->bottomButton->show();
|
ui->bottomButton->show();
|
||||||
|
|
||||||
// preview
|
// preview
|
||||||
if(fileInfo.direction == ToxFile::RECEIVING)
|
if (fileInfo.direction == ToxFile::RECEIVING)
|
||||||
showPreview(fileInfo.filePath);
|
showPreview(fileInfo.filePath);
|
||||||
|
|
||||||
disconnect(Core::getInstance(), 0, this, 0);
|
disconnect(Core::getInstance(), 0, this, 0);
|
||||||
|
@ -432,7 +432,7 @@ void FileTransferWidget::setupButtons()
|
||||||
ui->topButton->setObjectName("cancel");
|
ui->topButton->setObjectName("cancel");
|
||||||
ui->topButton->setToolTip(tr("Cancel transfer"));
|
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->setIcon(QIcon(":/ui/fileTransferInstance/pause.svg"));
|
||||||
ui->bottomButton->setObjectName("pause");
|
ui->bottomButton->setObjectName("pause");
|
||||||
|
@ -450,31 +450,31 @@ void FileTransferWidget::setupButtons()
|
||||||
|
|
||||||
void FileTransferWidget::handleButton(QPushButton *btn)
|
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);
|
Core::getInstance()->cancelFileSend(fileInfo.friendId, fileInfo.fileNum);
|
||||||
else if(btn->objectName() == "pause")
|
else if (btn->objectName() == "pause")
|
||||||
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
|
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
|
||||||
else if(btn->objectName() == "resume")
|
else if (btn->objectName() == "resume")
|
||||||
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
|
Core::getInstance()->pauseResumeFileSend(fileInfo.friendId, fileInfo.fileNum);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(btn->objectName() == "cancel")
|
if (btn->objectName() == "cancel")
|
||||||
Core::getInstance()->cancelFileRecv(fileInfo.friendId, fileInfo.fileNum);
|
Core::getInstance()->cancelFileRecv(fileInfo.friendId, fileInfo.fileNum);
|
||||||
else if(btn->objectName() == "pause")
|
else if (btn->objectName() == "pause")
|
||||||
Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum);
|
Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum);
|
||||||
else if(btn->objectName() == "resume")
|
else if (btn->objectName() == "resume")
|
||||||
Core::getInstance()->pauseResumeFileRecv(fileInfo.friendId, fileInfo.fileNum);
|
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));
|
QString path = QFileDialog::getSaveFileName(0, tr("Save a file","Title of the file saving dialog"), QDir::home().filePath(fileInfo.fileName));
|
||||||
acceptTransfer(path);
|
acceptTransfer(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(btn->objectName() == "ok")
|
if (btn->objectName() == "ok")
|
||||||
{
|
{
|
||||||
Widget::confirmExecutableOpen(QFileInfo(fileInfo.filePath));
|
Widget::confirmExecutableOpen(QFileInfo(fileInfo.filePath));
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ void FileTransferWidget::showPreview(const QString &filename)
|
||||||
{
|
{
|
||||||
static const QStringList previewExtensions = { "png", "jpeg", "jpg", "gif" };
|
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());
|
const int size = qMax(ui->previewLabel->width(), ui->previewLabel->height());
|
||||||
QPixmap pmap = QPixmap(filename).scaled(QSize(size, size), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
QPixmap pmap = QPixmap(filename).scaled(QSize(size, size), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||||
|
|
|
@ -68,7 +68,7 @@ void NotificationIcon::updateGradient()
|
||||||
{
|
{
|
||||||
alpha += 0.01;
|
alpha += 0.01;
|
||||||
|
|
||||||
if(alpha + dotWidth >= 1.0)
|
if (alpha + dotWidth >= 1.0)
|
||||||
alpha = 0.0;
|
alpha = 0.0;
|
||||||
|
|
||||||
grad = QLinearGradient(QPointF(-0.5*size.width(),0), QPointF(3.0/2.0*size.width(),0));
|
grad = QLinearGradient(QPointF(-0.5*size.width(),0), QPointF(3.0/2.0*size.width(),0));
|
||||||
|
@ -78,6 +78,6 @@ void NotificationIcon::updateGradient()
|
||||||
grad.setColorAt(qMin(1.0, alpha + dotWidth), Qt::lightGray);
|
grad.setColorAt(qMin(1.0, alpha + dotWidth), Qt::lightGray);
|
||||||
grad.setColorAt(1, Qt::lightGray);
|
grad.setColorAt(1, Qt::lightGray);
|
||||||
|
|
||||||
if(scene() && isVisible())
|
if (scene() && isVisible())
|
||||||
scene()->invalidate(sceneBoundingRect());
|
scene()->invalidate(sceneBoundingRect());
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ void Spinner::setWidth(qreal width)
|
||||||
|
|
||||||
void Spinner::visibilityChanged(bool visible)
|
void Spinner::visibilityChanged(bool visible)
|
||||||
{
|
{
|
||||||
if(visible)
|
if (visible)
|
||||||
timer.start();
|
timer.start();
|
||||||
else
|
else
|
||||||
timer.stop();
|
timer.stop();
|
||||||
|
@ -83,6 +83,6 @@ qreal Spinner::getAscent() const
|
||||||
|
|
||||||
void Spinner::timeout()
|
void Spinner::timeout()
|
||||||
{
|
{
|
||||||
if(scene())
|
if (scene())
|
||||||
scene()->invalidate(sceneBoundingRect());
|
scene()->invalidate(sceneBoundingRect());
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ Text::Text(const QString& txt, QFont font, bool enableElide, const QString &rwTe
|
||||||
|
|
||||||
Text::~Text()
|
Text::~Text()
|
||||||
{
|
{
|
||||||
if(doc)
|
if (doc)
|
||||||
DocumentCache::getInstance().push(doc);
|
DocumentCache::getInstance().push(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ void Text::setWidth(qreal w)
|
||||||
width = w;
|
width = w;
|
||||||
dirty = true;
|
dirty = true;
|
||||||
|
|
||||||
if(elide)
|
if (elide)
|
||||||
{
|
{
|
||||||
QFontMetrics metrics = QFontMetrics(defFont);
|
QFontMetrics metrics = QFontMetrics(defFont);
|
||||||
elidedText = metrics.elidedText(text, Qt::ElideRight, width);
|
elidedText = metrics.elidedText(text, Qt::ElideRight, width);
|
||||||
|
@ -67,11 +67,11 @@ void Text::setWidth(qreal w)
|
||||||
|
|
||||||
void Text::selectionMouseMove(QPointF scenePos)
|
void Text::selectionMouseMove(QPointF scenePos)
|
||||||
{
|
{
|
||||||
if(!doc)
|
if (!doc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int cur = cursorFromPos(scenePos);
|
int cur = cursorFromPos(scenePos);
|
||||||
if(cur >= 0)
|
if (cur >= 0)
|
||||||
{
|
{
|
||||||
selectionEnd = cur;
|
selectionEnd = cur;
|
||||||
selectedText = extractSanitizedText(getSelectionStart(), getSelectionEnd());
|
selectedText = extractSanitizedText(getSelectionStart(), getSelectionEnd());
|
||||||
|
@ -83,7 +83,7 @@ void Text::selectionMouseMove(QPointF scenePos)
|
||||||
void Text::selectionStarted(QPointF scenePos)
|
void Text::selectionStarted(QPointF scenePos)
|
||||||
{
|
{
|
||||||
int cur = cursorFromPos(scenePos);
|
int cur = cursorFromPos(scenePos);
|
||||||
if(cur >= 0)
|
if (cur >= 0)
|
||||||
{
|
{
|
||||||
selectionEnd = cur;
|
selectionEnd = cur;
|
||||||
selectionAnchor = cur;
|
selectionAnchor = cur;
|
||||||
|
@ -103,12 +103,12 @@ void Text::selectionCleared()
|
||||||
|
|
||||||
void Text::selectionDoubleClick(QPointF scenePos)
|
void Text::selectionDoubleClick(QPointF scenePos)
|
||||||
{
|
{
|
||||||
if(!doc)
|
if (!doc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int cur = cursorFromPos(scenePos);
|
int cur = cursorFromPos(scenePos);
|
||||||
|
|
||||||
if(cur >= 0)
|
if (cur >= 0)
|
||||||
{
|
{
|
||||||
QTextCursor cursor(doc);
|
QTextCursor cursor(doc);
|
||||||
cursor.setPosition(cur);
|
cursor.setPosition(cur);
|
||||||
|
@ -132,7 +132,7 @@ void Text::selectionFocusChanged(bool focusIn)
|
||||||
bool Text::isOverSelection(QPointF scenePos) const
|
bool Text::isOverSelection(QPointF scenePos) const
|
||||||
{
|
{
|
||||||
int cur = cursorFromPos(scenePos);
|
int cur = cursorFromPos(scenePos);
|
||||||
if(getSelectionStart() < cur && getSelectionEnd() >= cur)
|
if (getSelectionStart() < cur && getSelectionEnd() >= cur)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -150,7 +150,7 @@ QRectF Text::boundingRect() const
|
||||||
|
|
||||||
void Text::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
void Text::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
|
||||||
{
|
{
|
||||||
if(doc)
|
if (doc)
|
||||||
{
|
{
|
||||||
painter->setClipRect(boundingRect());
|
painter->setClipRect(boundingRect());
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ void Text::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWid
|
||||||
QAbstractTextDocumentLayout::PaintContext ctx;
|
QAbstractTextDocumentLayout::PaintContext ctx;
|
||||||
QAbstractTextDocumentLayout::Selection sel;
|
QAbstractTextDocumentLayout::Selection sel;
|
||||||
|
|
||||||
if(hasSelection())
|
if (hasSelection())
|
||||||
{
|
{
|
||||||
sel.cursor = QTextCursor(doc);
|
sel.cursor = QTextCursor(doc);
|
||||||
sel.cursor.setPosition(getSelectionStart());
|
sel.cursor.setPosition(getSelectionStart());
|
||||||
|
@ -194,30 +194,30 @@ qreal Text::getAscent() const
|
||||||
|
|
||||||
void Text::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
void Text::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if(event->button() == Qt::LeftButton)
|
if (event->button() == Qt::LeftButton)
|
||||||
event->accept(); // grabber
|
event->accept(); // grabber
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
void Text::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
{
|
{
|
||||||
if(!doc)
|
if (!doc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString anchor = doc->documentLayout()->anchorAt(event->pos());
|
QString anchor = doc->documentLayout()->anchorAt(event->pos());
|
||||||
|
|
||||||
// open anchor in browser
|
// open anchor in browser
|
||||||
if(!anchor.isEmpty())
|
if (!anchor.isEmpty())
|
||||||
QDesktopServices::openUrl(anchor);
|
QDesktopServices::openUrl(anchor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Text::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
void Text::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
|
||||||
{
|
{
|
||||||
if(!doc)
|
if (!doc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString anchor = doc->documentLayout()->anchorAt(event->pos());
|
QString anchor = doc->documentLayout()->anchorAt(event->pos());
|
||||||
|
|
||||||
if(!anchor.isEmpty())
|
if (!anchor.isEmpty())
|
||||||
setCursor(QCursor(Qt::PointingHandCursor));
|
setCursor(QCursor(Qt::PointingHandCursor));
|
||||||
else
|
else
|
||||||
setCursor(QCursor());
|
setCursor(QCursor());
|
||||||
|
@ -233,17 +233,17 @@ QString Text::getText() const
|
||||||
|
|
||||||
void Text::regenerate()
|
void Text::regenerate()
|
||||||
{
|
{
|
||||||
if(!doc)
|
if (!doc)
|
||||||
{
|
{
|
||||||
doc = DocumentCache::getInstance().pop();
|
doc = DocumentCache::getInstance().pop();
|
||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dirty)
|
if (dirty)
|
||||||
{
|
{
|
||||||
doc->setDefaultFont(defFont);
|
doc->setDefaultFont(defFont);
|
||||||
|
|
||||||
if(!elide)
|
if (!elide)
|
||||||
doc->setHtml(text);
|
doc->setHtml(text);
|
||||||
else
|
else
|
||||||
doc->setPlainText(elidedText);
|
doc->setPlainText(elidedText);
|
||||||
|
@ -258,11 +258,11 @@ void Text::regenerate()
|
||||||
doc->documentLayout()->update();
|
doc->documentLayout()->update();
|
||||||
|
|
||||||
// update ascent
|
// update ascent
|
||||||
if(doc->firstBlock().layout()->lineCount() > 0)
|
if (doc->firstBlock().layout()->lineCount() > 0)
|
||||||
ascent = doc->firstBlock().layout()->lineAt(0).ascent();
|
ascent = doc->firstBlock().layout()->lineAt(0).ascent();
|
||||||
|
|
||||||
// let the scene know about our change in size
|
// let the scene know about our change in size
|
||||||
if(size != idealSize())
|
if (size != idealSize())
|
||||||
prepareGeometryChange();
|
prepareGeometryChange();
|
||||||
|
|
||||||
// get the new width and height
|
// get the new width and height
|
||||||
|
@ -272,7 +272,7 @@ void Text::regenerate()
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we are not visible -> free mem
|
// if we are not visible -> free mem
|
||||||
if(!keepInMemory)
|
if (!keepInMemory)
|
||||||
freeResources();
|
freeResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ void Text::freeResources()
|
||||||
|
|
||||||
QSizeF Text::idealSize()
|
QSizeF Text::idealSize()
|
||||||
{
|
{
|
||||||
if(doc)
|
if (doc)
|
||||||
return QSizeF(qMin(doc->idealWidth(), width), doc->size().height());
|
return QSizeF(qMin(doc->idealWidth(), width), doc->size().height());
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
@ -292,7 +292,7 @@ QSizeF Text::idealSize()
|
||||||
|
|
||||||
int Text::cursorFromPos(QPointF scenePos, bool fuzzy) const
|
int Text::cursorFromPos(QPointF scenePos, bool fuzzy) const
|
||||||
{
|
{
|
||||||
if(doc)
|
if (doc)
|
||||||
return doc->documentLayout()->hitTest(mapFromScene(scenePos), fuzzy ? Qt::FuzzyHit : Qt::ExactHit);
|
return doc->documentLayout()->hitTest(mapFromScene(scenePos), fuzzy ? Qt::FuzzyHit : Qt::ExactHit);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -315,23 +315,23 @@ bool Text::hasSelection() const
|
||||||
|
|
||||||
QString Text::extractSanitizedText(int from, int to) const
|
QString Text::extractSanitizedText(int from, int to) const
|
||||||
{
|
{
|
||||||
if(!doc)
|
if (!doc)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
QString txt;
|
QString txt;
|
||||||
QTextBlock block = doc->firstBlock();
|
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
|
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();
|
QTextImageFormat imgFmt = itr.fragment().charFormat().toImageFormat();
|
||||||
QString key = imgFmt.name(); //img key (eg. key::D for :D)
|
QString key = imgFmt.name(); //img key (eg. key::D for :D)
|
||||||
QString rune = key.mid(4);
|
QString rune = key.mid(4);
|
||||||
|
|
||||||
if(pos >= from && pos < to)
|
if (pos >= from && pos < to)
|
||||||
{
|
{
|
||||||
txt += rune;
|
txt += rune;
|
||||||
pos++;
|
pos++;
|
||||||
|
@ -339,9 +339,9 @@ QString Text::extractSanitizedText(int from, int to) const
|
||||||
}
|
}
|
||||||
else
|
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;
|
txt += c;
|
||||||
|
|
||||||
pos++;
|
pos++;
|
||||||
|
@ -354,9 +354,9 @@ QString Text::extractSanitizedText(int from, int to) const
|
||||||
|
|
||||||
QString Text::extractImgTooltip(int pos) 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();
|
QTextImageFormat imgFmt = itr.fragment().charFormat().toImageFormat();
|
||||||
return imgFmt.toolTip();
|
return imgFmt.toolTip();
|
||||||
|
|
|
@ -19,13 +19,13 @@
|
||||||
|
|
||||||
DocumentCache::~DocumentCache()
|
DocumentCache::~DocumentCache()
|
||||||
{
|
{
|
||||||
while(!documents.isEmpty())
|
while (!documents.isEmpty())
|
||||||
delete documents.pop();
|
delete documents.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
QTextDocument* DocumentCache::pop()
|
QTextDocument* DocumentCache::pop()
|
||||||
{
|
{
|
||||||
if(documents.empty())
|
if (documents.empty())
|
||||||
documents.push(new CustomTextDocument);
|
documents.push(new CustomTextDocument);
|
||||||
|
|
||||||
return documents.pop();
|
return documents.pop();
|
||||||
|
@ -33,7 +33,7 @@ QTextDocument* DocumentCache::pop()
|
||||||
|
|
||||||
void DocumentCache::push(QTextDocument *doc)
|
void DocumentCache::push(QTextDocument *doc)
|
||||||
{
|
{
|
||||||
if(doc)
|
if (doc)
|
||||||
{
|
{
|
||||||
doc->clear();
|
doc->clear();
|
||||||
documents.push(doc);
|
documents.push(doc);
|
||||||
|
|
|
@ -20,7 +20,7 @@ QPixmap PixmapCache::get(const QString &filename, QSize size)
|
||||||
{
|
{
|
||||||
auto itr = cache.find(filename);
|
auto itr = cache.find(filename);
|
||||||
|
|
||||||
if(itr == cache.end())
|
if (itr == cache.end())
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
icon.addFile(filename);
|
icon.addFile(filename);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -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))
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,20 +67,18 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ bool SmileyPack::load(const QString& filename)
|
||||||
|
|
||||||
cacheSmiley(file); // preload all smileys
|
cacheSmiley(file); // preload all smileys
|
||||||
|
|
||||||
if(!getCachedSmiley(emoticon).isNull())
|
if (!getCachedSmiley(emoticon).isNull())
|
||||||
emoticonSet.push_back(emoticon);
|
emoticonSet.push_back(emoticon);
|
||||||
|
|
||||||
stringElement = stringElement.nextSibling().toElement();
|
stringElement = stringElement.nextSibling().toElement();
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,13 +20,14 @@ 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" },
|
||||||
{ STATUS_NOTIFIER_ERROR_NO_WATCHER, "STATUS_NOTIFIER_ERROR_NO_WATCHER", "watcher" },
|
{ STATUS_NOTIFIER_ERROR_NO_WATCHER, "STATUS_NOTIFIER_ERROR_NO_WATCHER", "watcher" },
|
||||||
{ STATUS_NOTIFIER_ERROR_NO_HOST, "STATUS_NOTIFIER_ERROR_NO_HOST", "host" },
|
{ STATUS_NOTIFIER_ERROR_NO_HOST, "STATUS_NOTIFIER_ERROR_NO_HOST", "host" },
|
||||||
{ 0, NULL, NULL }
|
{ 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
etype = g_enum_register_static ("StatusNotifierError", values);
|
etype = g_enum_register_static ("StatusNotifierError", values);
|
||||||
}
|
}
|
||||||
|
@ -22,13 +37,14 @@ 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" },
|
||||||
{ STATUS_NOTIFIER_STATE_REGISTERED, "STATUS_NOTIFIER_STATE_REGISTERED", "registered" },
|
{ STATUS_NOTIFIER_STATE_REGISTERED, "STATUS_NOTIFIER_STATE_REGISTERED", "registered" },
|
||||||
{ STATUS_NOTIFIER_STATE_FAILED, "STATUS_NOTIFIER_STATE_FAILED", "failed" },
|
{ STATUS_NOTIFIER_STATE_FAILED, "STATUS_NOTIFIER_STATE_FAILED", "failed" },
|
||||||
{ 0, NULL, NULL }
|
{ 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
etype = g_enum_register_static ("StatusNotifierState", values);
|
etype = g_enum_register_static ("StatusNotifierState", values);
|
||||||
}
|
}
|
||||||
|
@ -38,14 +54,15 @@ 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" },
|
||||||
{ STATUS_NOTIFIER_OVERLAY_ICON, "STATUS_NOTIFIER_OVERLAY_ICON", "status-notifier-overlay-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" },
|
{ STATUS_NOTIFIER_TOOLTIP_ICON, "STATUS_NOTIFIER_TOOLTIP_ICON", "status-notifier-tooltip-icon" },
|
||||||
{ _NB_STATUS_NOTIFIER_ICONS, "_NB_STATUS_NOTIFIER_ICONS", "-nb-status-notifier-icons" },
|
{ _NB_STATUS_NOTIFIER_ICONS, "_NB_STATUS_NOTIFIER_ICONS", "-nb-status-notifier-icons" },
|
||||||
{ 0, NULL, NULL }
|
{ 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
etype = g_enum_register_static ("StatusNotifierIcon", values);
|
etype = g_enum_register_static ("StatusNotifierIcon", values);
|
||||||
}
|
}
|
||||||
|
@ -55,13 +72,14 @@ 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" },
|
||||||
{ STATUS_NOTIFIER_CATEGORY_SYSTEM_SERVICES, "STATUS_NOTIFIER_CATEGORY_SYSTEM_SERVICES", "system-services" },
|
{ STATUS_NOTIFIER_CATEGORY_SYSTEM_SERVICES, "STATUS_NOTIFIER_CATEGORY_SYSTEM_SERVICES", "system-services" },
|
||||||
{ STATUS_NOTIFIER_CATEGORY_HARDWARE, "STATUS_NOTIFIER_CATEGORY_HARDWARE", "hardware" },
|
{ STATUS_NOTIFIER_CATEGORY_HARDWARE, "STATUS_NOTIFIER_CATEGORY_HARDWARE", "hardware" },
|
||||||
{ 0, NULL, NULL }
|
{ 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
etype = g_enum_register_static ("StatusNotifierCategory", values);
|
etype = g_enum_register_static ("StatusNotifierCategory", values);
|
||||||
}
|
}
|
||||||
|
@ -71,12 +89,13 @@ 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" },
|
||||||
{ STATUS_NOTIFIER_STATUS_NEEDS_ATTENTION, "STATUS_NOTIFIER_STATUS_NEEDS_ATTENTION", "needs-attention" },
|
{ STATUS_NOTIFIER_STATUS_NEEDS_ATTENTION, "STATUS_NOTIFIER_STATUS_NEEDS_ATTENTION", "needs-attention" },
|
||||||
{ 0, NULL, NULL }
|
{ 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
etype = g_enum_register_static ("StatusNotifierStatus", values);
|
etype = g_enum_register_static ("StatusNotifierStatus", values);
|
||||||
}
|
}
|
||||||
|
@ -86,16 +105,14 @@ 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" },
|
||||||
{ 0, NULL, NULL }
|
{ 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
etype = g_enum_register_static ("StatusNotifierScrollOrientation", values);
|
etype = g_enum_register_static ("StatusNotifierScrollOrientation", values);
|
||||||
}
|
}
|
||||||
return etype;
|
return etype;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -159,7 +159,7 @@ void CameraWorker::subscribe()
|
||||||
qDebug() << "CameraWorker:" << "OpenCV exception caught: " << e.what();
|
qDebug() << "CameraWorker:" << "OpenCV exception caught: " << e.what();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!bSuccess)
|
if (!bSuccess)
|
||||||
{
|
{
|
||||||
qDebug() << "CameraWorker: Could not open camera";
|
qDebug() << "CameraWorker: Could not open camera";
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,11 +221,11 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
||||||
|| Settings::getInstance().getAutoSaveEnabled())
|
|| Settings::getInstance().getAutoSaveEnabled())
|
||||||
{
|
{
|
||||||
ChatLineContentProxy* proxy = dynamic_cast<ChatLineContentProxy*>(msg->getContent(1));
|
ChatLineContentProxy* proxy = dynamic_cast<ChatLineContentProxy*>(msg->getContent(1));
|
||||||
if(proxy)
|
if (proxy)
|
||||||
{
|
{
|
||||||
FileTransferWidget* tfWidget = dynamic_cast<FileTransferWidget*>(proxy->getWidget());
|
FileTransferWidget* tfWidget = dynamic_cast<FileTransferWidget*>(proxy->getWidget());
|
||||||
|
|
||||||
if(tfWidget)
|
if (tfWidget)
|
||||||
tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxID()));
|
tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxID()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -538,7 +538,7 @@ void ChatForm::onHangupCallTriggered()
|
||||||
qDebug() << "onHangupCallTriggered";
|
qDebug() << "onHangupCallTriggered";
|
||||||
|
|
||||||
//Fixes an OS X bug with ending a call while in full screen
|
//Fixes an OS X bug with ending a call while in full screen
|
||||||
if(netcam->isFullScreen())
|
if (netcam->isFullScreen())
|
||||||
netcam->showNormal();
|
netcam->showNormal();
|
||||||
|
|
||||||
audioInputFlag = false;
|
audioInputFlag = false;
|
||||||
|
@ -635,7 +635,7 @@ void ChatForm::enableCallButtons()
|
||||||
videoButton->setToolTip("");
|
videoButton->setToolTip("");
|
||||||
videoButton->disconnect();
|
videoButton->disconnect();
|
||||||
|
|
||||||
if(disableCallButtonsTimer == nullptr)
|
if (disableCallButtonsTimer == nullptr)
|
||||||
{
|
{
|
||||||
disableCallButtonsTimer = new QTimer();
|
disableCallButtonsTimer = new QTimer();
|
||||||
connect(disableCallButtonsTimer, SIGNAL(timeout()),
|
connect(disableCallButtonsTimer, SIGNAL(timeout()),
|
||||||
|
@ -827,7 +827,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
|
||||||
authorId.isMine(),
|
authorId.isMine(),
|
||||||
QDateTime());
|
QDateTime());
|
||||||
|
|
||||||
if(!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) )
|
if (!isAction && (prevId == authorId) && (prevMsgDateTime.secsTo(msgDateTime) < getChatLog()->repNameAfter) )
|
||||||
msg->hideSender();
|
msg->hideSender();
|
||||||
|
|
||||||
prevId = authorId;
|
prevId = authorId;
|
||||||
|
@ -973,7 +973,7 @@ void ChatForm::setFriendTyping(bool isTyping)
|
||||||
|
|
||||||
Text* text = dynamic_cast<Text*>(chatWidget->getTypingNotification()->getContent(1));
|
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>");
|
text->setText("<div class=typing>" + QString("%1 is typing").arg(f->getDisplayedName()) + "</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ ChatMessage::Ptr GenericChatForm::addMessage(const ToxID& author, const QString
|
||||||
QString authorStr = author.isMine() ? Core::getInstance()->getUsername() : resolveToxID(author);
|
QString authorStr = author.isMine() ? Core::getInstance()->getUsername() : resolveToxID(author);
|
||||||
|
|
||||||
ChatMessage::Ptr msg;
|
ChatMessage::Ptr msg;
|
||||||
if(isAction)
|
if (isAction)
|
||||||
{
|
{
|
||||||
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::ACTION, false);
|
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::ACTION, false);
|
||||||
previousId.clear();
|
previousId.clear();
|
||||||
|
@ -270,7 +270,7 @@ ChatMessage::Ptr GenericChatForm::addMessage(const ToxID& author, const QString
|
||||||
|
|
||||||
insertChatMessage(msg);
|
insertChatMessage(msg);
|
||||||
|
|
||||||
if(isSent)
|
if (isSent)
|
||||||
msg->markAsSent(datetime);
|
msg->markAsSent(datetime);
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
|
@ -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);
|
ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::ALERT, author.isMine(), datetime);
|
||||||
insertChatMessage(msg);
|
insertChatMessage(msg);
|
||||||
|
|
||||||
if( (author == previousId) && (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter) )
|
if ((author == previousId) && (prevMsgDateTime.secsTo(QDateTime::currentDateTime()) < getChatLog()->repNameAfter))
|
||||||
msg->hideSender();
|
msg->hideSender();
|
||||||
|
|
||||||
previousId = author;
|
previousId = author;
|
||||||
|
@ -333,7 +333,7 @@ void GenericChatForm::onSaveLogClicked()
|
||||||
|
|
||||||
QString plainText;
|
QString plainText;
|
||||||
auto lines = chatWidget->getLines();
|
auto lines = chatWidget->getLines();
|
||||||
for(ChatLine::Ptr l : lines)
|
for (ChatLine::Ptr l : lines)
|
||||||
{
|
{
|
||||||
Timestamp* rightCol = dynamic_cast<Timestamp*>(l->getContent(2));
|
Timestamp* rightCol = dynamic_cast<Timestamp*>(l->getContent(2));
|
||||||
ChatLineContent* middleCol = l->getContent(1);
|
ChatLineContent* middleCol = l->getContent(1);
|
||||||
|
|
|
@ -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);
|
||||||
|
@ -695,7 +693,7 @@ void Widget::onFriendStatusChanged(int friendId, Status status)
|
||||||
&& Settings::getInstance().getStatusChangeNotificationEnabled())
|
&& Settings::getInstance().getStatusChangeNotificationEnabled())
|
||||||
{
|
{
|
||||||
QString fStatus = "";
|
QString fStatus = "";
|
||||||
switch(f->getStatus())
|
switch (f->getStatus())
|
||||||
{
|
{
|
||||||
case Status::Away:
|
case Status::Away:
|
||||||
fStatus = tr("away", "contact status"); break;
|
fStatus = tr("away", "contact status"); break;
|
||||||
|
@ -1075,7 +1073,7 @@ bool Widget::isFriendWidgetCurActiveWidget(Friend* f)
|
||||||
|
|
||||||
bool Widget::event(QEvent * e)
|
bool Widget::event(QEvent * e)
|
||||||
{
|
{
|
||||||
switch(e->type())
|
switch (e->type())
|
||||||
{
|
{
|
||||||
case QEvent::WindowActivate:
|
case QEvent::WindowActivate:
|
||||||
if (activeChatroomWidget != nullptr)
|
if (activeChatroomWidget != nullptr)
|
||||||
|
@ -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");
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user