From 02da6803f100356e40e603928e64ddbb81ceec42 Mon Sep 17 00:00:00 2001 From: apprb Date: Fri, 5 Sep 2014 01:09:55 +0700 Subject: [PATCH 01/46] initial merging common parts of chatforms' widget --- qtox.pro | 6 +- widget/form/chatform.cpp | 190 ++------------------------ widget/form/chatform.h | 22 +-- widget/form/genericchatform.cpp | 232 ++++++++++++++++++++++++++++++++ widget/form/genericchatform.h | 72 ++++++++++ widget/form/groupchatform.cpp | 127 ++--------------- widget/form/groupchatform.h | 23 +--- 7 files changed, 338 insertions(+), 334 deletions(-) create mode 100644 widget/form/genericchatform.cpp create mode 100644 widget/form/genericchatform.h diff --git a/qtox.pro b/qtox.pro index 679e6d17e..2e8468c07 100644 --- a/qtox.pro +++ b/qtox.pro @@ -101,7 +101,8 @@ HEADERS += widget/form/addfriendform.h \ widget/adjustingscrollarea.h \ widget/croppinglabel.h \ widget/friendlistwidget.h \ - widget/genericchatroomwidget.h + widget/genericchatroomwidget.h \ + widget/form/genericchatform.h SOURCES += \ widget/form/addfriendform.cpp \ @@ -134,4 +135,5 @@ SOURCES += \ widget/croppinglabel.cpp \ widget/friendlistwidget.cpp \ coreav.cpp \ - widget/genericchatroomwidget.cpp + widget/genericchatroomwidget.cpp \ + widget/form/genericchatform.cpp diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 50f09f5a2..6a7d0e114 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -32,124 +32,16 @@ #include ChatForm::ChatForm(Friend* chatFriend) - : f(chatFriend), curRow{0}, lockSliderToBottom{true} + : f(chatFriend) { - main = new QWidget(), head = new QWidget(), chatAreaWidget = new QWidget(); - name = new QLabel(), avatar = new QLabel(), statusMessage = new QLabel(); - headLayout = new QHBoxLayout(), mainFootLayout = new QHBoxLayout(); - headTextLayout = new QVBoxLayout(), mainLayout = new QVBoxLayout(), - footButtonsSmall = new QVBoxLayout(), volMicLayout = new QVBoxLayout(); - mainChatLayout = new QGridLayout(); - msgEdit = new ChatTextEdit(); - sendButton = new QPushButton(), fileButton = new QPushButton(), emoteButton = new QPushButton(), - callButton = new QPushButton(), videoButton = new QPushButton(), - volButton = new QPushButton(), micButton = new QPushButton(); - chatArea = new QScrollArea(); + nameLabel->setText(f->getName()); + avatarLabel->setPixmap(QPixmap(":/img/contact_dark.png")); + + statusMessageLabel = new QLabel(); netcam = new NetCamView(); - audioInputFlag = false; - - QFont bold; - bold.setBold(true); - name->setText(chatFriend->widget->name.text()); - name->setFont(bold); - statusMessage->setText(chatFriend->widget->statusMessage.text()); - - // No real avatar support in toxcore, better draw a pretty picture - //avatar->setPixmap(*chatFriend->widget->avatar.pixmap()); - avatar->setPixmap(QPixmap(":/img/contact_dark.png")); - - chatAreaWidget->setLayout(mainChatLayout); - chatAreaWidget->setStyleSheet(Style::get(":/ui/chatArea/chatArea.css")); - - chatArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - chatArea->setWidgetResizable(true); - chatArea->setContextMenuPolicy(Qt::CustomContextMenu); - chatArea->setFrameStyle(QFrame::NoFrame); - - mainChatLayout->setColumnStretch(1,1); - mainChatLayout->setSpacing(5); - - footButtonsSmall->setSpacing(2); - - msgEdit->setStyleSheet(Style::get(":/ui/msgEdit/msgEdit.css")); - msgEdit->setFixedHeight(50); - msgEdit->setFrameStyle(QFrame::NoFrame); - - sendButton->setStyleSheet(Style::get(":/ui/sendButton/sendButton.css")); - fileButton->setStyleSheet(Style::get(":/ui/fileButton/fileButton.css")); - emoteButton->setStyleSheet(Style::get(":/ui/emoteButton/emoteButton.css")); - - callButton->setObjectName("green"); - callButton->setStyleSheet(Style::get(":/ui/callButton/callButton.css")); - - videoButton->setObjectName("green"); - videoButton->setStyleSheet(Style::get(":/ui/videoButton/videoButton.css")); - - QString volButtonStylesheet = ""; - try - { - QFile f(":/ui/volButton/volButton.css"); - f.open(QFile::ReadOnly | QFile::Text); - QTextStream volButtonStylesheetStream(&f); - volButtonStylesheet = volButtonStylesheetStream.readAll(); - } - catch (int e) {} - volButton->setObjectName("green"); - volButton->setStyleSheet(volButtonStylesheet); - - QString micButtonStylesheet = ""; - try - { - QFile f(":/ui/micButton/micButton.css"); - f.open(QFile::ReadOnly | QFile::Text); - QTextStream micButtonStylesheetStream(&f); - micButtonStylesheet = micButtonStylesheetStream.readAll(); - } - catch (int e) {} - micButton->setObjectName("green"); - micButton->setStyleSheet(micButtonStylesheet); - - main->setLayout(mainLayout); - mainLayout->addWidget(chatArea); - mainLayout->addLayout(mainFootLayout); - mainLayout->setMargin(0); - - footButtonsSmall->addWidget(emoteButton); - footButtonsSmall->addWidget(fileButton); - - mainFootLayout->addWidget(msgEdit); - mainFootLayout->addLayout(footButtonsSmall); - mainFootLayout->addSpacing(5); - mainFootLayout->addWidget(sendButton); - mainFootLayout->setSpacing(0); - - head->setLayout(headLayout); - headLayout->addWidget(avatar); - headLayout->addLayout(headTextLayout); - headLayout->addStretch(); - headLayout->addLayout(volMicLayout); - headLayout->addWidget(callButton); - headLayout->addWidget(videoButton); - - volMicLayout->addWidget(micButton); - volMicLayout->addWidget(volButton); + headTextLayout->addWidget(statusMessageLabel); headTextLayout->addStretch(); - headTextLayout->addWidget(name); - headTextLayout->addWidget(statusMessage); - headTextLayout->addStretch(); - - chatArea->setWidget(chatAreaWidget); - - //Fix for incorrect layouts on OS X as per - //https://bugreports.qt-project.org/browse/QTBUG-14591 - sendButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); - fileButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); - emoteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); - // callButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); - // videoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); - // msgEdit->setAttribute(Qt::WA_LayoutUsesWidgetRect); - // chatArea->setAttribute(Qt::WA_LayoutUsesWidgetRect); connect(Widget::getInstance()->getCore(), &Core::fileSendStarted, this, &ChatForm::startFileSend); connect(Widget::getInstance()->getCore(), &Core::videoFrameReceived, netcam, &NetCamView::updateDisplay); @@ -166,29 +58,13 @@ ChatForm::ChatForm(Friend* chatFriend) ChatForm::~ChatForm() { - delete main; - delete head; delete netcam; } -void ChatForm::show(Ui::MainWindow &ui) -{ - ui.mainContent->layout()->addWidget(main); - ui.mainHead->layout()->addWidget(head); - main->show(); - head->show(); -} - -void ChatForm::setName(QString newName) -{ - name->setText(newName); - name->setToolTip(newName); // for overlength names -} - void ChatForm::setStatusMessage(QString newMessage) { - statusMessage->setText(newMessage); - statusMessage->setToolTip(newMessage); // for overlength messsages + statusMessageLabel->setText(newMessage); + statusMessageLabel->setToolTip(newMessage); // for overlength messsages } void ChatForm::onSendTriggered() @@ -204,7 +80,7 @@ void ChatForm::onSendTriggered() void ChatForm::addFriendMessage(QString message) { - QLabel *msgAuthor = new QLabel(name->text()); + QLabel *msgAuthor = new QLabel(nameLabel->text()); QLabel *msgText = new QLabel(message); QLabel *msgDate = new QLabel(QTime::currentTime().toString("hh:mm")); @@ -299,13 +175,6 @@ void ChatForm::onAttachClicked() emit sendFile(f->friendId, fi.fileName(), path, filesize); } -void ChatForm::onSliderRangeChanged() -{ - QScrollBar* scroll = chatArea->verticalScrollBar(); - if (lockSliderToBottom) - scroll->setValue(scroll->maximum()); -} - void ChatForm::startFileSend(ToxFile file) { if (file.friendId != f->friendId) @@ -661,47 +530,6 @@ void ChatForm::onCancelCallTriggered() emit cancelCall(callId, f->friendId); } -void ChatForm::onChatContextMenuRequested(QPoint pos) -{ - QWidget* sender = (QWidget*)QObject::sender(); - pos = sender->mapToGlobal(pos); - QMenu menu; - menu.addAction(tr("Save chat log"), this, SLOT(onSaveLogClicked())); - menu.exec(pos); -} - -void ChatForm::onSaveLogClicked() -{ - QString path = QFileDialog::getSaveFileName(0,tr("Save chat log")); - if (path.isEmpty()) - return; - - QFile file(path); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - return; - - QString log; - QList labels = chatAreaWidget->findChildren(); - int i=0; - for (QLabel* label : labels) - { - log += label->text(); - if (i==2) - { - i=0; - log += '\n'; - } - else - { - log += '\t'; - i++; - } - } - - file.write(log.toUtf8()); - file.close(); -} - void ChatForm::onEmoteButtonClicked() { // don't show the smiley selection widget if there are no smileys available diff --git a/widget/form/chatform.h b/widget/form/chatform.h index dd746d6c1..c2c530863 100644 --- a/widget/form/chatform.h +++ b/widget/form/chatform.h @@ -27,6 +27,7 @@ #include #include +#include "genericchatform.h" #include "widget/tool/chattextedit.h" #include "ui_mainwindow.h" #include "core.h" @@ -37,21 +38,18 @@ struct Friend; -class ChatForm : public QObject +class ChatForm : public GenericChatForm { Q_OBJECT public: ChatForm(Friend* chatFriend); ~ChatForm(); - void show(Ui::MainWindow &ui); - void setName(QString newName); void setStatusMessage(QString newMessage); void addFriendMessage(QString message); void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm")); void addMessage(QLabel* author, QLabel* message, QLabel* date); signals: - void sendMessage(int, QString); void sendFile(int32_t friendId, QString, QString, long long); void startCall(int friendId); void startVideoCall(int friendId, bool video); @@ -78,31 +76,19 @@ public slots: private slots: void onSendTriggered(); void onAttachClicked(); - void onSliderRangeChanged(); void onCallTriggered(); void onVideoCallTriggered(); void onAnswerCallTriggered(); void onHangupCallTriggered(); void onCancelCallTriggered(); - void onChatContextMenuRequested(QPoint pos); - void onSaveLogClicked(); void onEmoteButtonClicked(); void onEmoteInsertRequested(QString str); private: Friend* f; - QHBoxLayout *headLayout, *mainFootLayout; - QVBoxLayout *headTextLayout, *mainLayout, *footButtonsSmall, *volMicLayout; - QGridLayout *mainChatLayout; - QLabel *avatar, *name, *statusMessage; - ChatTextEdit *msgEdit; - QPushButton *sendButton, *fileButton, *emoteButton, *callButton, *videoButton, *volButton, *micButton; - QScrollArea *chatArea; - QWidget *main, *head, *chatAreaWidget; - QString previousName; + QLabel *statusMessageLabel; NetCamView* netcam; - int curRow; - bool lockSliderToBottom, audioInputFlag; + bool audioInputFlag; int callId; }; diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp new file mode 100644 index 000000000..f28173e72 --- /dev/null +++ b/widget/form/genericchatform.cpp @@ -0,0 +1,232 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 "genericchatform.h" +#include "ui_mainwindow.h" +#include +#include +#include +#include "style.h" + +GenericChatForm::GenericChatForm(QObject *parent) : + QObject(parent) +{ + lockSliderToBottom = true; + curRow = 0; + + mainWidget = new QWidget(); headWidget = new QWidget(); chatAreaWidget = new QWidget(); + + nameLabel = new QLabel(); + avatarLabel = new QLabel(); + QHBoxLayout *headLayout = new QHBoxLayout(), *mainFootLayout = new QHBoxLayout(); + headTextLayout = new QVBoxLayout(); + QVBoxLayout *mainLayout = new QVBoxLayout(); + QVBoxLayout *footButtonsSmall = new QVBoxLayout(), *volMicLayout = new QVBoxLayout(); + mainChatLayout = new QGridLayout(); + + msgEdit = new ChatTextEdit(); + + sendButton = new QPushButton(); + emoteButton = new QPushButton(); + + fileButton = new QPushButton(); + callButton = new QPushButton(); + videoButton = new QPushButton(); + volButton = new QPushButton(); + micButton = new QPushButton(); + + chatArea = new QScrollArea(); + + QFont bold; + bold.setBold(true); + nameLabel->setFont(bold); + + chatAreaWidget->setLayout(mainChatLayout); + chatAreaWidget->setStyleSheet(Style::get(":/ui/chatArea/chatArea.css")); + + chatArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + chatArea->setWidgetResizable(true); + chatArea->setContextMenuPolicy(Qt::CustomContextMenu); + chatArea->setFrameStyle(QFrame::NoFrame); + + mainChatLayout->setColumnStretch(1,1); + mainChatLayout->setSpacing(5); + + footButtonsSmall->setSpacing(2); + + msgEdit->setStyleSheet(Style::get(":/ui/msgEdit/msgEdit.css")); + msgEdit->setFixedHeight(50); + msgEdit->setFrameStyle(QFrame::NoFrame); + + sendButton->setStyleSheet(Style::get(":/ui/sendButton/sendButton.css")); + fileButton->setStyleSheet(Style::get(":/ui/fileButton/fileButton.css")); + emoteButton->setStyleSheet(Style::get(":/ui/emoteButton/emoteButton.css")); + + callButton->setObjectName("green"); + callButton->setStyleSheet(Style::get(":/ui/callButton/callButton.css")); + + videoButton->setObjectName("green"); + videoButton->setStyleSheet(Style::get(":/ui/videoButton/videoButton.css")); + + QString volButtonStylesheet = ""; + try + { + QFile f(":/ui/volButton/volButton.css"); + f.open(QFile::ReadOnly | QFile::Text); + QTextStream volButtonStylesheetStream(&f); + volButtonStylesheet = volButtonStylesheetStream.readAll(); + } + catch (int e) {} + + volButton->setObjectName("green"); + volButton->setStyleSheet(volButtonStylesheet); + + QString micButtonStylesheet = ""; + try + { + QFile f(":/ui/micButton/micButton.css"); + f.open(QFile::ReadOnly | QFile::Text); + QTextStream micButtonStylesheetStream(&f); + micButtonStylesheet = micButtonStylesheetStream.readAll(); + } + catch (int e) {} + + micButton->setObjectName("green"); + micButton->setStyleSheet(micButtonStylesheet); + + mainWidget->setLayout(mainLayout); + mainLayout->addWidget(chatArea); + mainLayout->addLayout(mainFootLayout); + mainLayout->setMargin(0); + + footButtonsSmall->addWidget(emoteButton); + footButtonsSmall->addWidget(fileButton); + + mainFootLayout->addWidget(msgEdit); + mainFootLayout->addLayout(footButtonsSmall); + mainFootLayout->addSpacing(5); + mainFootLayout->addWidget(sendButton); + mainFootLayout->setSpacing(0); + + headWidget->setLayout(headLayout); + headLayout->addWidget(avatarLabel); + headLayout->addLayout(headTextLayout); + headLayout->addStretch(); + headLayout->addLayout(volMicLayout); + headLayout->addWidget(callButton); + headLayout->addWidget(videoButton); + + volMicLayout->addWidget(micButton); + volMicLayout->addWidget(volButton); + + headTextLayout->addStretch(); + headTextLayout->addWidget(nameLabel); +// headTextLayout->addWidget(statusMessage); +// headTextLayout->addStretch(); + + chatArea->setWidget(chatAreaWidget); + + //Fix for incorrect layouts on OS X as per + //https://bugreports.qt-project.org/browse/QTBUG-14591 + sendButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); + fileButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); + emoteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); + + // connect(Widget::getInstance()->getCore(), &Core::fileSendStarted, this, &ChatForm::startFileSend); + // connect(Widget::getInstance()->getCore(), &Core::videoFrameReceived, netcam, &NetCamView::updateDisplay); + // connect(sendButton, &QPushButton::clicked, this, &ChatForm::onSendTriggered); + // connect(fileButton, &QPushButton::clicked, this, &ChatForm::onAttachClicked); + // connect(callButton, &QPushButton::clicked, this, &ChatForm::onCallTriggered); + // connect(videoButton, &QPushButton::clicked, this, &ChatForm::onVideoCallTriggered); + // connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered); + // connect(chatArea->verticalScrollBar(), &QScrollBar::rangeChanged, this, &ChatForm::onSliderRangeChanged); + // connect(chatArea, &QScrollArea::customContextMenuRequested, this, &ChatForm::onChatContextMenuRequested); + // connect(emoteButton, &QPushButton::clicked, this, &ChatForm::onEmoteButtonClicked); + // connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle())); +} + +void GenericChatForm::setName(const QString &newName) +{ + nameLabel->setText(newName); + nameLabel->setToolTip(newName); // for overlength names +} + +void GenericChatForm::show(Ui::MainWindow &ui) +{ + ui.mainContent->layout()->addWidget(mainWidget); + ui.mainHead->layout()->addWidget(headWidget); + mainWidget->show(); + headWidget->show(); +} + +void GenericChatForm::onChatContextMenuRequested(QPoint pos) +{ + QWidget* sender = (QWidget*)QObject::sender(); + pos = sender->mapToGlobal(pos); + QMenu menu; + menu.addAction(tr("Save chat log"), this, SLOT(onSaveLogClicked())); + menu.exec(pos); +} + +void GenericChatForm::onSliderRangeChanged() +{ + QScrollBar* scroll = chatArea->verticalScrollBar(); + if (lockSliderToBottom) + scroll->setValue(scroll->maximum()); +} + +void GenericChatForm::onSaveLogClicked() +{ + QString path = QFileDialog::getSaveFileName(0,tr("Save chat log")); + if (path.isEmpty()) + return; + + QFile file(path); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + return; + + QString log; + QList labels = chatAreaWidget->findChildren(); + int i=0; + for (QLabel* label : labels) + { + log += label->text(); + if (i==2) + { + i=0; + log += '\n'; + } + else + { + log += '\t'; + i++; + } + } + + file.write(log.toUtf8()); + file.close(); +} + +void GenericChatForm::addMessage(QString author, QString message, QString date) +{ + // +} + +GenericChatForm::~GenericChatForm() +{ + delete mainWidget; + delete headWidget; +} diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h new file mode 100644 index 000000000..b223bb395 --- /dev/null +++ b/widget/form/genericchatform.h @@ -0,0 +1,72 @@ +/* + Copyright (C) 2014 by Project Tox + + 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. +*/ + +#ifndef GENERICCHATFORM_H +#define GENERICCHATFORM_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "widget/tool/chattextedit.h" + +namespace Ui { + class MainWindow; +} + +class GenericChatForm : public QObject +{ + Q_OBJECT +public: + GenericChatForm(QObject *parent = 0); + virtual ~GenericChatForm(); + + virtual void setName(const QString &newName); + virtual void show(Ui::MainWindow &ui); + virtual void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm")); + +signals: + void sendMessage(int, QString); + +public slots: + +protected slots: + void onChatContextMenuRequested(QPoint pos); + void onSliderRangeChanged(); + void onSaveLogClicked(); + +protected: + QLabel *nameLabel, *avatarLabel; + QWidget *mainWidget, *headWidget, *chatAreaWidget; + QScrollArea *chatArea; + QPushButton *fileButton, *emoteButton, *callButton, *videoButton, *volButton, *micButton; + QGridLayout *mainChatLayout; + QVBoxLayout *headTextLayout; + ChatTextEdit *msgEdit; + QPushButton *sendButton; + QString previousName; + int curRow; + bool lockSliderToBottom; +}; + +#endif // GENERICCHATFORM_H diff --git a/widget/form/groupchatform.cpp b/widget/form/groupchatform.cpp index e5e630ae1..a48ae539b 100644 --- a/widget/form/groupchatform.cpp +++ b/widget/form/groupchatform.cpp @@ -29,25 +29,25 @@ #include GroupChatForm::GroupChatForm(Group* chatGroup) - : group(chatGroup), curRow{0}, lockSliderToBottom{true} + : group(chatGroup) { - main = new QWidget(), head = new QWidget(), chatAreaWidget = new QWidget(); - headLayout = new QHBoxLayout(), mainFootLayout = new QHBoxLayout(); - headTextLayout = new QVBoxLayout(), mainLayout = new QVBoxLayout(); - mainChatLayout = new QGridLayout(); - avatar = new QLabel(), name = new QLabel(), nusers = new QLabel(), namesList = new QLabel(); - msgEdit = new ChatTextEdit(); - sendButton = new QPushButton(); - chatArea = new QScrollArea(); - QFont bold; - bold.setBold(true); + nusers = new QLabel(); + namesList = new QLabel(); + + fileButton->setEnabled(false); + callButton->setVisible(false); + videoButton->setVisible(false); + volButton->setVisible(false); + micButton->setVisible(false); + QFont small; small.setPixelSize(10); - name->setText(group->widget->name.text()); - name->setFont(bold); + + nameLabel->setText(group->widget->name.text()); nusers->setFont(small); nusers->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size())); - avatar->setPixmap(QPixmap(":/img/group.png")); + avatarLabel->setPixmap(QPixmap(":/img/group_dark.png")); + QString names; for (QString& s : group->peers) names.append(s+", "); @@ -55,54 +55,17 @@ GroupChatForm::GroupChatForm(Group* chatGroup) namesList->setText(names); namesList->setFont(small); - chatAreaWidget->setLayout(mainChatLayout); - - chatArea->setStyleSheet(Style::get(":/ui/chatArea/chatArea.css")); - chatArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - chatArea->setWidgetResizable(true); - chatArea->setContextMenuPolicy(Qt::CustomContextMenu); - chatArea->setFrameStyle(QFrame::NoFrame); - - mainChatLayout->setColumnStretch(1,1); - mainChatLayout->setSpacing(10); - msgEdit->setObjectName("group"); - msgEdit->setStyleSheet(Style::get(":/ui/msgEdit/msgEdit.css")); - msgEdit->setFixedHeight(50); - msgEdit->setFrameStyle(QFrame::NoFrame); mainChatLayout->setColumnStretch(1,1); mainChatLayout->setHorizontalSpacing(10); - sendButton->setStyleSheet(Style::get(":/ui/sendButton/sendButton.css")); - sendButton->setFixedSize(50, 50); - - main->setLayout(mainLayout); - mainLayout->addWidget(chatArea); - mainLayout->addLayout(mainFootLayout); - mainLayout->setMargin(0); - - mainFootLayout->addWidget(msgEdit); - mainFootLayout->addWidget(sendButton); - - head->setLayout(headLayout); - headLayout->addWidget(avatar); - headLayout->addLayout(headTextLayout); - headLayout->addStretch(); - headLayout->setMargin(0); - - headTextLayout->addStretch(); - headTextLayout->addWidget(name); headTextLayout->addWidget(nusers); headTextLayout->addWidget(namesList); headTextLayout->setMargin(0); headTextLayout->setSpacing(0); headTextLayout->addStretch(); - chatArea->setWidget(chatAreaWidget); - - sendButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); - connect(sendButton, SIGNAL(clicked()), this, SLOT(onSendTriggered())); connect(msgEdit, SIGNAL(enterPressed()), this, SLOT(onSendTriggered())); connect(chatArea->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); @@ -111,21 +74,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup) GroupChatForm::~GroupChatForm() { - delete head; - delete main; -} -void GroupChatForm::show(Ui::MainWindow &ui) -{ - ui.mainContent->layout()->addWidget(main); - ui.mainHead->layout()->addWidget(head); - main->show(); - head->show(); -} - -void GroupChatForm::setName(QString newName) -{ - name->setText(newName); } void GroupChatForm::onSendTriggered() @@ -203,13 +152,6 @@ void GroupChatForm::addMessage(QLabel* author, QLabel* message, QLabel* date) connect(date, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); } -void GroupChatForm::onSliderRangeChanged() -{ - QScrollBar* scroll = chatArea->verticalScrollBar(); - if (lockSliderToBottom) - scroll->setValue(scroll->maximum()); -} - void GroupChatForm::onUserListChanged() { nusers->setText(tr("%1 users in chat").arg(group->nPeers)); @@ -219,44 +161,3 @@ void GroupChatForm::onUserListChanged() names.chop(2); namesList->setText(names); } - -void GroupChatForm::onChatContextMenuRequested(QPoint pos) -{ - QWidget* sender = (QWidget*)QObject::sender(); - pos = sender->mapToGlobal(pos); - QMenu menu; - menu.addAction("Save chat log", this, SLOT(onSaveLogClicked())); - menu.exec(pos); -} - -void GroupChatForm::onSaveLogClicked() -{ - QString path = QFileDialog::getSaveFileName(0,tr("Save chat log")); - if (path.isEmpty()) - return; - - QFile file(path); - if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) - return; - - QString log; - QList labels = chatAreaWidget->findChildren(); - int i=0; - for (QLabel* label : labels) - { - log += label->text(); - if (i==2) - { - i=0; - log += '\n'; - } - else - { - log += '\t'; - i++; - } - } - - file.write(log.toUtf8()); - file.close(); -} diff --git a/widget/form/groupchatform.h b/widget/form/groupchatform.h index af008476a..519eafb30 100644 --- a/widget/form/groupchatform.h +++ b/widget/form/groupchatform.h @@ -26,6 +26,7 @@ #include #include +#include "genericchatform.h" #include "widget/tool/chattextedit.h" #include "ui_mainwindow.h" @@ -34,41 +35,23 @@ class Group; -class GroupChatForm : public QObject +class GroupChatForm : public GenericChatForm { Q_OBJECT public: GroupChatForm(Group* chatGroup); ~GroupChatForm(); - void show(Ui::MainWindow &ui); - void setName(QString newName); void addGroupMessage(QString message, int peerId); void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm")); void addMessage(QLabel* author, QLabel* message, QLabel* date); void onUserListChanged(); -signals: - void sendMessage(int, QString); - private slots: void onSendTriggered(); - void onSliderRangeChanged(); - void onChatContextMenuRequested(QPoint pos); - void onSaveLogClicked(); private: Group* group; - QHBoxLayout *headLayout, *mainFootLayout; - QVBoxLayout *headTextLayout, *mainLayout; - QGridLayout *mainChatLayout; - QLabel *avatar, *name, *nusers, *namesList; - ChatTextEdit *msgEdit; - QPushButton *sendButton; - QScrollArea *chatArea; - QWidget *main, *head, *chatAreaWidget; - QString previousName; - int curRow; - bool lockSliderToBottom; + QLabel *nusers, *namesList; }; #endif // GROUPCHATFORM_H From 522d570e62259eedf1838d278fa2c3cf0e8ac535 Mon Sep 17 00:00:00 2001 From: apprb Date: Fri, 5 Sep 2014 22:05:57 +0700 Subject: [PATCH 02/46] code cleanup --- res.qrc | 1 + ui/fileButton/fileButton.css | 5 ++++ ui/fileButton/fileButtonDisabled.png | Bin 0 -> 457 bytes widget/form/chatform.cpp | 28 ----------------- widget/form/chatform.h | 2 -- widget/form/genericchatform.cpp | 43 +++++++++++++++++++-------- widget/form/genericchatform.h | 2 ++ 7 files changed, 38 insertions(+), 43 deletions(-) create mode 100644 ui/fileButton/fileButtonDisabled.png diff --git a/res.qrc b/res.qrc index f413e0209..0b6abfff5 100644 --- a/res.qrc +++ b/res.qrc @@ -124,5 +124,6 @@ ui/micButton/micButtonPressed.png ui/micButton/micButton.css ui/volButton/volButton.css + ui/fileButton/fileButtonDisabled.png diff --git a/ui/fileButton/fileButton.css b/ui/fileButton/fileButton.css index 59b110ced..fd06c6f0e 100644 --- a/ui/fileButton/fileButton.css +++ b/ui/fileButton/fileButton.css @@ -17,6 +17,11 @@ QPushButton:pressed background-image: url(":/ui/fileButton/fileButtonPressed.png"); } +QPushButton[enabled="false"] +{ + background-image: url(":/ui/fileButton/fileButtonDisabled.png"); +} + QPushButton:focus { outline: none; } diff --git a/ui/fileButton/fileButtonDisabled.png b/ui/fileButton/fileButtonDisabled.png new file mode 100644 index 0000000000000000000000000000000000000000..ed024e2df5291c312c8cf89105ec958663a8f6e1 GIT binary patch literal 457 zcmV;)0XF`LP)cIDW zAW+j3igXMudSJz=<9rWQO;@}W8%XuEjjZOIuG==JC05f=z&8VhY!88|O+~LHmOWDR z(V6S!oo4+IsM!#TB(7;HdEgj7aZqNfldWwZvGqAQG$D z6ngG$*5MjvMUt__s(V5&bh0mf!)M1v;LN!-snlzUG#e=DySRLR@zfn7@102Vvh-D1 z<AI!lofDt(Qr{kn z#z6Ra00000NkvXXu0mjfJ#@w~ literal 0 HcmV?d00001 diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 6a7d0e114..2c57fc597 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -52,7 +52,6 @@ ChatForm::ChatForm(Friend* chatFriend) connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered); connect(chatArea->verticalScrollBar(), &QScrollBar::rangeChanged, this, &ChatForm::onSliderRangeChanged); connect(chatArea, &QScrollArea::customContextMenuRequested, this, &ChatForm::onChatContextMenuRequested); - connect(emoteButton, &QPushButton::clicked, this, &ChatForm::onEmoteButtonClicked); connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle())); } @@ -530,33 +529,6 @@ void ChatForm::onCancelCallTriggered() emit cancelCall(callId, f->friendId); } -void ChatForm::onEmoteButtonClicked() -{ - // don't show the smiley selection widget if there are no smileys available - if (SmileyPack::getInstance().getEmoticons().empty()) - return; - - EmoticonsWidget widget; - connect(&widget, &EmoticonsWidget::insertEmoticon, this, &ChatForm::onEmoteInsertRequested); - - QWidget* sender = qobject_cast(QObject::sender()); - if (sender) - { - QPoint pos = -QPoint(widget.sizeHint().width() / 2, widget.sizeHint().height()) - QPoint(0, 10); - widget.exec(sender->mapToGlobal(pos)); - } -} - -void ChatForm::onEmoteInsertRequested(QString str) -{ - // insert the emoticon - QWidget* sender = qobject_cast(QObject::sender()); - if (sender) - msgEdit->insertPlainText(str); - - msgEdit->setFocus(); // refocus so that we can continue typing -} - void ChatForm::onMicMuteToggle() { if (audioInputFlag == true) diff --git a/widget/form/chatform.h b/widget/form/chatform.h index c2c530863..395940663 100644 --- a/widget/form/chatform.h +++ b/widget/form/chatform.h @@ -81,8 +81,6 @@ private slots: void onAnswerCallTriggered(); void onHangupCallTriggered(); void onCancelCallTriggered(); - void onEmoteButtonClicked(); - void onEmoteInsertRequested(QString str); private: Friend* f; diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index f28173e72..56ae97558 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -19,6 +19,8 @@ #include #include #include +#include "smileypack.h" +#include "widget/emoticonswidget.h" #include "style.h" GenericChatForm::GenericChatForm(QObject *parent) : @@ -134,8 +136,6 @@ GenericChatForm::GenericChatForm(QObject *parent) : headTextLayout->addStretch(); headTextLayout->addWidget(nameLabel); -// headTextLayout->addWidget(statusMessage); -// headTextLayout->addStretch(); chatArea->setWidget(chatAreaWidget); @@ -145,17 +145,7 @@ GenericChatForm::GenericChatForm(QObject *parent) : fileButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); emoteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); - // connect(Widget::getInstance()->getCore(), &Core::fileSendStarted, this, &ChatForm::startFileSend); - // connect(Widget::getInstance()->getCore(), &Core::videoFrameReceived, netcam, &NetCamView::updateDisplay); - // connect(sendButton, &QPushButton::clicked, this, &ChatForm::onSendTriggered); - // connect(fileButton, &QPushButton::clicked, this, &ChatForm::onAttachClicked); - // connect(callButton, &QPushButton::clicked, this, &ChatForm::onCallTriggered); - // connect(videoButton, &QPushButton::clicked, this, &ChatForm::onVideoCallTriggered); - // connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered); - // connect(chatArea->verticalScrollBar(), &QScrollBar::rangeChanged, this, &ChatForm::onSliderRangeChanged); - // connect(chatArea, &QScrollArea::customContextMenuRequested, this, &ChatForm::onChatContextMenuRequested); - // connect(emoteButton, &QPushButton::clicked, this, &ChatForm::onEmoteButtonClicked); - // connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle())); + connect(emoteButton, SIGNAL(clicked()), this, SLOT(onEmoteButtonClicked())); } void GenericChatForm::setName(const QString &newName) @@ -230,3 +220,30 @@ GenericChatForm::~GenericChatForm() delete mainWidget; delete headWidget; } + +void GenericChatForm::onEmoteButtonClicked() +{ + // don't show the smiley selection widget if there are no smileys available + if (SmileyPack::getInstance().getEmoticons().empty()) + return; + + EmoticonsWidget widget; + connect(&widget, SIGNAL(insertEmoticon(QString)), this, SLOT(onEmoteInsertRequested(QString))); + + QWidget* sender = qobject_cast(QObject::sender()); + if (sender) + { + QPoint pos = -QPoint(widget.sizeHint().width() / 2, widget.sizeHint().height()) - QPoint(0, 10); + widget.exec(sender->mapToGlobal(pos)); + } +} + +void GenericChatForm::onEmoteInsertRequested(QString str) +{ + // insert the emoticon + QWidget* sender = qobject_cast(QObject::sender()); + if (sender) + msgEdit->insertPlainText(str); + + msgEdit->setFocus(); // refocus so that we can continue typing +} diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h index b223bb395..2b2d9c62e 100644 --- a/widget/form/genericchatform.h +++ b/widget/form/genericchatform.h @@ -54,6 +54,8 @@ protected slots: void onChatContextMenuRequested(QPoint pos); void onSliderRangeChanged(); void onSaveLogClicked(); + void onEmoteButtonClicked(); + void onEmoteInsertRequested(QString str); protected: QLabel *nameLabel, *avatarLabel; From 2826e83cefd1d3173e0f27c5f323434ad954301e Mon Sep 17 00:00:00 2001 From: apprb Date: Fri, 5 Sep 2014 22:24:29 +0700 Subject: [PATCH 03/46] addMessage moved to parent class --- widget/form/chatform.cpp | 75 --------------------------------- widget/form/chatform.h | 6 --- widget/form/genericchatform.cpp | 63 ++++++++++++++++++++++++++- widget/form/genericchatform.h | 3 ++ widget/form/groupchatform.cpp | 63 ++------------------------- widget/form/groupchatform.h | 5 --- widget/widget.cpp | 2 +- 7 files changed, 70 insertions(+), 147 deletions(-) diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 2c57fc597..82d919b09 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -77,81 +77,6 @@ void ChatForm::onSendTriggered() emit sendMessage(f->friendId, msg); } -void ChatForm::addFriendMessage(QString message) -{ - QLabel *msgAuthor = new QLabel(nameLabel->text()); - QLabel *msgText = new QLabel(message); - QLabel *msgDate = new QLabel(QTime::currentTime().toString("hh:mm")); - - addMessage(msgAuthor, msgText, msgDate); -} - -void ChatForm::addMessage(QString author, QString message, QString date) -{ - addMessage(new QLabel(author), new QLabel(message), new QLabel(date)); -} - -void ChatForm::addMessage(QLabel* author, QLabel* message, QLabel* date) -{ - QScrollBar* scroll = chatArea->verticalScrollBar(); - lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); - author->setAlignment(Qt::AlignTop | Qt::AlignRight); - date->setAlignment(Qt::AlignTop); - message->setWordWrap(true); - message->setTextInteractionFlags(Qt::TextBrowserInteraction); - author->setTextInteractionFlags(Qt::TextBrowserInteraction); - date->setTextInteractionFlags(Qt::TextBrowserInteraction); - if (author->text() == Widget::getInstance()->getUsername()) - { - QPalette pal; - pal.setColor(QPalette::WindowText, QColor(100,100,100)); - author->setPalette(pal); - message->setPalette(pal); - } - if (previousName.isEmpty() || previousName != author->text()) - { - if (curRow) - { - mainChatLayout->setRowStretch(curRow, 0); - mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3); - } - previousName = author->text(); - curRow++; - } - else if (curRow)// onSaveLogClicked expects 0 or 3 QLabel per line - author->setText(""); - - QColor greentext(61,204,61); - QString fontTemplate = "%2"; - - QString finalMessage; - QStringList messageLines = message->text().split("\n"); - for (QString& s : messageLines) - { - if (QRegExp("^[ ]*>.*").exactMatch(s)) - finalMessage += fontTemplate.arg(greentext.name(), s.replace(" ", " ")); - else - finalMessage += s.replace(" ", " "); - finalMessage += "
"; - } - message->setText(finalMessage.left(finalMessage.length()-4)); - message->setText(SmileyPack::getInstance().smileyfied(message->text())); - message->setTextFormat(Qt::RichText); - - mainChatLayout->addWidget(author, curRow, 0); - mainChatLayout->addWidget(message, curRow, 1); - mainChatLayout->addWidget(date, curRow, 3); - mainChatLayout->setRowStretch(curRow+1, 1); - mainChatLayout->setRowStretch(curRow, 0); - curRow++; - author->setContextMenuPolicy(Qt::CustomContextMenu); - message->setContextMenuPolicy(Qt::CustomContextMenu); - date->setContextMenuPolicy(Qt::CustomContextMenu); - connect(author, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); - connect(message, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); - connect(date, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); -} - void ChatForm::onAttachClicked() { QString path = QFileDialog::getOpenFileName(0,tr("Send a file")); diff --git a/widget/form/chatform.h b/widget/form/chatform.h index 395940663..9b803ae35 100644 --- a/widget/form/chatform.h +++ b/widget/form/chatform.h @@ -33,9 +33,6 @@ #include "core.h" #include "widget/netcamview.h" -// Spacing in px inserted when the author of the last message changes -#define AUTHOR_CHANGE_SPACING 5 - struct Friend; class ChatForm : public GenericChatForm @@ -45,9 +42,6 @@ public: ChatForm(Friend* chatFriend); ~ChatForm(); void setStatusMessage(QString newMessage); - void addFriendMessage(QString message); - void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm")); - void addMessage(QLabel* author, QLabel* message, QLabel* date); signals: void sendFile(int32_t friendId, QString, QString, long long); diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index 56ae97558..b26bedc03 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -22,6 +22,7 @@ #include "smileypack.h" #include "widget/emoticonswidget.h" #include "style.h" +#include "widget/widget.h" GenericChatForm::GenericChatForm(QObject *parent) : QObject(parent) @@ -212,7 +213,67 @@ void GenericChatForm::onSaveLogClicked() void GenericChatForm::addMessage(QString author, QString message, QString date) { - // + QLabel *authorLabel = new QLabel(author); + QLabel *messageLabel = new QLabel(message); + QLabel *dateLabel = new QLabel(date); + + QScrollBar* scroll = chatArea->verticalScrollBar(); + lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); + authorLabel->setAlignment(Qt::AlignTop | Qt::AlignRight); + dateLabel->setAlignment(Qt::AlignTop); + messageLabel->setWordWrap(true); + messageLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); + authorLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); + dateLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); + if (author == Widget::getInstance()->getUsername()) + { + QPalette pal; + pal.setColor(QPalette::WindowText, QColor(100,100,100)); + authorLabel->setPalette(pal); + messageLabel->setPalette(pal); + } + if (previousName.isEmpty() || previousName != author) + { + if (curRow) + { + mainChatLayout->setRowStretch(curRow, 0); + mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3); + } + previousName = author; + curRow++; + } + else if (curRow)// onSaveLogClicked expects 0 or 3 QLabel per line + authorLabel->setText(""); + + QColor greentext(61,204,61); + QString fontTemplate = "%2"; + + QString finalMessage; + QStringList messageLines = message.split("\n"); + for (QString& s : messageLines) + { + if (QRegExp("^[ ]*>.*").exactMatch(s)) + finalMessage += fontTemplate.arg(greentext.name(), s.replace(" ", " ")); + else + finalMessage += s.replace(" ", " "); + finalMessage += "
"; + } + messageLabel->setText(finalMessage.left(finalMessage.length()-4)); + messageLabel->setText(SmileyPack::getInstance().smileyfied(messageLabel->text())); + messageLabel->setTextFormat(Qt::RichText); + + mainChatLayout->addWidget(authorLabel, curRow, 0); + mainChatLayout->addWidget(messageLabel, curRow, 1); + mainChatLayout->addWidget(dateLabel, curRow, 3); + mainChatLayout->setRowStretch(curRow+1, 1); + mainChatLayout->setRowStretch(curRow, 0); + curRow++; + authorLabel->setContextMenuPolicy(Qt::CustomContextMenu); + messageLabel->setContextMenuPolicy(Qt::CustomContextMenu); + dateLabel->setContextMenuPolicy(Qt::CustomContextMenu); + connect(authorLabel, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); + connect(messageLabel, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); + connect(dateLabel, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); } GenericChatForm::~GenericChatForm() diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h index 2b2d9c62e..f25ccdc1e 100644 --- a/widget/form/genericchatform.h +++ b/widget/form/genericchatform.h @@ -30,6 +30,9 @@ #include "widget/tool/chattextedit.h" +// Spacing in px inserted when the author of the last message changes +#define AUTHOR_CHANGE_SPACING 5 + namespace Ui { class MainWindow; } diff --git a/widget/form/groupchatform.cpp b/widget/form/groupchatform.cpp index a48ae539b..0d743feea 100644 --- a/widget/form/groupchatform.cpp +++ b/widget/form/groupchatform.cpp @@ -88,68 +88,13 @@ void GroupChatForm::onSendTriggered() void GroupChatForm::addGroupMessage(QString message, int peerId) { - QLabel *msgAuthor; + QString msgAuthor; if (group->peers.contains(peerId)) - msgAuthor = new QLabel(group->peers[peerId]); + msgAuthor = group->peers[peerId]; else - msgAuthor = new QLabel(tr("")); + msgAuthor = tr(""); - QLabel *msgText = new QLabel(message); - QLabel *msgDate = new QLabel(QTime::currentTime().toString("hh:mm")); - - addMessage(msgAuthor, msgText, msgDate); -} - -void GroupChatForm::addMessage(QString author, QString message, QString date) -{ - addMessage(new QLabel(author), new QLabel(message), new QLabel(date)); -} - -void GroupChatForm::addMessage(QLabel* author, QLabel* message, QLabel* date) -{ - QPalette greentext; - greentext.setColor(QPalette::WindowText, QColor(61,204,61)); - QScrollBar* scroll = chatArea->verticalScrollBar(); - lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); - author->setAlignment(Qt::AlignTop | Qt::AlignLeft); - date->setAlignment(Qt::AlignTop); - message->setWordWrap(true); - message->setTextInteractionFlags(Qt::TextBrowserInteraction); - author->setTextInteractionFlags(Qt::TextBrowserInteraction); - date->setTextInteractionFlags(Qt::TextBrowserInteraction); - if (author->text() == Widget::getInstance()->getUsername()) - { - QPalette pal; - pal.setColor(QPalette::WindowText, Qt::gray); - author->setPalette(pal); - message->setPalette(pal); - } - if (previousName.isEmpty() || previousName != author->text()) - { - if (curRow) - { - mainChatLayout->setRowStretch(curRow, 0); - mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3); - } - previousName = author->text(); - curRow++; - } - else if (curRow)// onSaveLogClicked expects 0 or 3 QLabel per line - author->setText(""); - if (message->text()[0] == '>') - message->setPalette(greentext); - mainChatLayout->addWidget(author, curRow, 0); - mainChatLayout->addWidget(message, curRow, 1); - mainChatLayout->addWidget(date, curRow, 3); - mainChatLayout->setRowStretch(curRow+1, 1); - mainChatLayout->setRowStretch(curRow, 0); - curRow++; - author->setContextMenuPolicy(Qt::CustomContextMenu); - message->setContextMenuPolicy(Qt::CustomContextMenu); - date->setContextMenuPolicy(Qt::CustomContextMenu); - connect(author, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); - connect(message, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); - connect(date, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); + addMessage(msgAuthor, message); } void GroupChatForm::onUserListChanged() diff --git a/widget/form/groupchatform.h b/widget/form/groupchatform.h index 519eafb30..63546751e 100644 --- a/widget/form/groupchatform.h +++ b/widget/form/groupchatform.h @@ -30,9 +30,6 @@ #include "widget/tool/chattextedit.h" #include "ui_mainwindow.h" -// Spacing in px inserted when the author of the last message changes -#define AUTHOR_CHANGE_SPACING 5 - class Group; class GroupChatForm : public GenericChatForm @@ -42,8 +39,6 @@ public: GroupChatForm(Group* chatGroup); ~GroupChatForm(); void addGroupMessage(QString message, int peerId); - void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm")); - void addMessage(QLabel* author, QLabel* message, QLabel* date); void onUserListChanged(); private slots: diff --git a/widget/widget.cpp b/widget/widget.cpp index 81cd893bf..d08ea0fe1 100644 --- a/widget/widget.cpp +++ b/widget/widget.cpp @@ -509,7 +509,7 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message) if (!f) return; - f->chatForm->addFriendMessage(message); + f->chatForm->addMessage(f->getName(), message); if (activeChatroomWidget != nullptr) { From 502229a6f250e3dfa01d5187c09c0958cf755ec0 Mon Sep 17 00:00:00 2001 From: apprb Date: Fri, 5 Sep 2014 22:29:14 +0700 Subject: [PATCH 04/46] cleanup --- widget/form/chatform.cpp | 10 ---------- widget/form/chatform.h | 12 ------------ widget/form/genericchatform.cpp | 19 ++++++++++++++++--- widget/form/genericchatform.h | 5 ++++- widget/form/groupchatform.cpp | 21 +++++---------------- widget/form/groupchatform.h | 11 +---------- 6 files changed, 26 insertions(+), 52 deletions(-) diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 82d919b09..141451c4c 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -16,19 +16,11 @@ #include "chatform.h" #include "friend.h" -#include "smileypack.h" #include "widget/friendwidget.h" #include "widget/widget.h" #include "widget/filetransfertwidget.h" -#include "widget/emoticonswidget.h" -#include "style.h" -#include -#include #include #include -#include -#include -#include #include ChatForm::ChatForm(Friend* chatFriend) @@ -50,8 +42,6 @@ ChatForm::ChatForm(Friend* chatFriend) connect(callButton, &QPushButton::clicked, this, &ChatForm::onCallTriggered); connect(videoButton, &QPushButton::clicked, this, &ChatForm::onVideoCallTriggered); connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered); - connect(chatArea->verticalScrollBar(), &QScrollBar::rangeChanged, this, &ChatForm::onSliderRangeChanged); - connect(chatArea, &QScrollArea::customContextMenuRequested, this, &ChatForm::onChatContextMenuRequested); connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle())); } diff --git a/widget/form/chatform.h b/widget/form/chatform.h index 9b803ae35..6a7a9362d 100644 --- a/widget/form/chatform.h +++ b/widget/form/chatform.h @@ -17,19 +17,7 @@ #ifndef CHATFORM_H #define CHATFORM_H -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "genericchatform.h" -#include "widget/tool/chattextedit.h" -#include "ui_mainwindow.h" #include "core.h" #include "widget/netcamview.h" diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index b26bedc03..d7727adf7 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -147,6 +147,8 @@ GenericChatForm::GenericChatForm(QObject *parent) : emoteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); connect(emoteButton, SIGNAL(clicked()), this, SLOT(onEmoteButtonClicked())); + connect(chatArea, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); + connect(chatArea->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); } void GenericChatForm::setName(const QString &newName) @@ -214,7 +216,7 @@ void GenericChatForm::onSaveLogClicked() void GenericChatForm::addMessage(QString author, QString message, QString date) { QLabel *authorLabel = new QLabel(author); - QLabel *messageLabel = new QLabel(message); + QLabel *messageLabel = new QLabel(); QLabel *dateLabel = new QLabel(date); QScrollBar* scroll = chatArea->verticalScrollBar(); @@ -253,9 +255,9 @@ void GenericChatForm::addMessage(QString author, QString message, QString date) for (QString& s : messageLines) { if (QRegExp("^[ ]*>.*").exactMatch(s)) - finalMessage += fontTemplate.arg(greentext.name(), s.replace(" ", " ")); + finalMessage += fontTemplate.arg(greentext.name(), toHtmlChars(s)); else - finalMessage += s.replace(" ", " "); + finalMessage += toHtmlChars(s); finalMessage += "
"; } messageLabel->setText(finalMessage.left(finalMessage.length()-4)); @@ -308,3 +310,14 @@ void GenericChatForm::onEmoteInsertRequested(QString str) msgEdit->setFocus(); // refocus so that we can continue typing } + +QString GenericChatForm::toHtmlChars(const QString &str) +{ + static QList> replaceList = {{"&","&"}, {" "," "}, {">",">"}, {"<","<"}}; + QString res = str; + + for (auto &it : replaceList) + res = res.replace(it.first,it.second); + + return res; +} diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h index f25ccdc1e..59216f755 100644 --- a/widget/form/genericchatform.h +++ b/widget/form/genericchatform.h @@ -46,7 +46,7 @@ public: virtual void setName(const QString &newName); virtual void show(Ui::MainWindow &ui); - virtual void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm")); + void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm")); signals: void sendMessage(int, QString); @@ -72,6 +72,9 @@ protected: QString previousName; int curRow; bool lockSliderToBottom; + +private: + QString toHtmlChars(const QString &str); }; #endif // GENERICCHATFORM_H diff --git a/widget/form/groupchatform.cpp b/widget/form/groupchatform.cpp index 0d743feea..e444e0ac3 100644 --- a/widget/form/groupchatform.cpp +++ b/widget/form/groupchatform.cpp @@ -18,20 +18,11 @@ #include "group.h" #include "widget/groupwidget.h" #include "widget/widget.h" -#include "friend.h" -#include "friendlist.h" -#include "style.h" -#include -#include -#include -#include -#include -#include GroupChatForm::GroupChatForm(Group* chatGroup) : group(chatGroup) { - nusers = new QLabel(); + nusersLabel = new QLabel(); namesList = new QLabel(); fileButton->setEnabled(false); @@ -44,8 +35,8 @@ GroupChatForm::GroupChatForm(Group* chatGroup) small.setPixelSize(10); nameLabel->setText(group->widget->name.text()); - nusers->setFont(small); - nusers->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size())); + nusersLabel->setFont(small); + nusersLabel->setText(GroupChatForm::tr("%1 users in chat","Number of users in chat").arg(group->peers.size())); avatarLabel->setPixmap(QPixmap(":/img/group_dark.png")); QString names; @@ -60,7 +51,7 @@ GroupChatForm::GroupChatForm(Group* chatGroup) mainChatLayout->setColumnStretch(1,1); mainChatLayout->setHorizontalSpacing(10); - headTextLayout->addWidget(nusers); + headTextLayout->addWidget(nusersLabel); headTextLayout->addWidget(namesList); headTextLayout->setMargin(0); headTextLayout->setSpacing(0); @@ -68,8 +59,6 @@ GroupChatForm::GroupChatForm(Group* chatGroup) connect(sendButton, SIGNAL(clicked()), this, SLOT(onSendTriggered())); connect(msgEdit, SIGNAL(enterPressed()), this, SLOT(onSendTriggered())); - connect(chatArea->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); - connect(chatArea, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); } GroupChatForm::~GroupChatForm() @@ -99,7 +88,7 @@ void GroupChatForm::addGroupMessage(QString message, int peerId) void GroupChatForm::onUserListChanged() { - nusers->setText(tr("%1 users in chat").arg(group->nPeers)); + nusersLabel->setText(tr("%1 users in chat").arg(group->nPeers)); QString names; for (QString& s : group->peers) names.append(s+", "); diff --git a/widget/form/groupchatform.h b/widget/form/groupchatform.h index 63546751e..9b4766180 100644 --- a/widget/form/groupchatform.h +++ b/widget/form/groupchatform.h @@ -17,15 +17,6 @@ #ifndef GROUPCHATFORM_H #define GROUPCHATFORM_H -#include -#include -#include -#include -#include -#include -#include -#include - #include "genericchatform.h" #include "widget/tool/chattextedit.h" #include "ui_mainwindow.h" @@ -46,7 +37,7 @@ private slots: private: Group* group; - QLabel *nusers, *namesList; + QLabel *nusersLabel, *namesList; }; #endif // GROUPCHATFORM_H From 25ee6a24d96a6198105745e8c489258b70e59ca9 Mon Sep 17 00:00:00 2001 From: apprb Date: Sat, 6 Sep 2014 02:27:26 +0700 Subject: [PATCH 05/46] new chat beginning --- filetransferinstance.cpp | 274 ++++++++++++++++++++++++++++++ filetransferinstance.h | 76 +++++++++ qtox.pro | 10 +- res.qrc | 3 +- ui/chatArea/innerStyle.css | 37 ++++ widget/chatareawidget.cpp | 56 ++++++ widget/chatareawidget.h | 38 +++++ widget/filetransfertwidget.cpp | 67 ++++++++ widget/filetransfertwidget.h | 11 ++ widget/form/chatform.cpp | 135 +++++++++------ widget/form/chatform.h | 4 + widget/form/genericchatform.cpp | 123 ++++---------- widget/form/genericchatform.h | 10 +- widget/tool/genericchataction.cpp | 116 +++++++++++++ widget/tool/genericchataction.h | 63 +++++++ 15 files changed, 875 insertions(+), 148 deletions(-) create mode 100644 filetransferinstance.cpp create mode 100644 filetransferinstance.h create mode 100644 ui/chatArea/innerStyle.css create mode 100644 widget/chatareawidget.cpp create mode 100644 widget/chatareawidget.h create mode 100644 widget/tool/genericchataction.cpp create mode 100644 widget/tool/genericchataction.h diff --git a/filetransferinstance.cpp b/filetransferinstance.cpp new file mode 100644 index 000000000..b1d11ac61 --- /dev/null +++ b/filetransferinstance.cpp @@ -0,0 +1,274 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 "filetransferinstance.h" +#include "widget/widget.h" +#include "core.h" +#include "math.h" +#include "style.h" +#include +#include +#include +#include +#include + +uint FileTransferInstance::Idconter = 0; + +FileTransferInstance::FileTransferInstance(ToxFile File) + : lastUpdate{QDateTime::currentDateTime()}, lastBytesSent{0}, + fileNum{File.fileNum}, friendId{File.friendId}, direction{File.direction} +{ + id = Idconter++; + state = tsPending; + + filename = File.fileName; + size = getHumanReadableSize(File.filesize); + speed = "0B/s"; + eta = "00:00"; + if (File.direction == ToxFile::SENDING) + { + QImage preview; + File.file->seek(0); + if (preview.loadFromData(File.file->readAll())) + { + pic = preview.scaledToHeight(40); + } + File.file->seek(0); + } +} + +QString FileTransferInstance::getHumanReadableSize(unsigned long long size) +{ + static const char* suffix[] = {"B","kiB","MiB","GiB","TiB"}; + int exp = 0; + if (size) + exp = std::min( (int) (log(size) / log(1024)), (int) (sizeof(suffix) / sizeof(suffix[0]) - 1)); + return QString().setNum(size / pow(1024, exp),'f',2).append(suffix[exp]); +} + +void FileTransferInstance::onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection Direction) +{ + if (FileNum != fileNum || FriendId != friendId || Direction != direction) + return; + +// state = tsProcessing; + QDateTime newtime = QDateTime::currentDateTime(); + int timediff = lastUpdate.secsTo(newtime); + if (timediff <= 0) + return; + qint64 diff = BytesSent - lastBytesSent; + if (diff < 0) + { + qWarning() << "FileTransferInstance::onFileTransferInfo: Negative transfer speed !"; + diff = 0; + } + long rawspeed = diff / timediff; + speed = getHumanReadableSize(rawspeed)+"/s"; + size = getHumanReadableSize(Filesize); + if (!rawspeed) + return; + int etaSecs = (Filesize - BytesSent) / rawspeed; + QTime etaTime(0,0); + etaTime = etaTime.addSecs(etaSecs); + eta = etaTime.toString("mm:ss"); + lastUpdate = newtime; + lastBytesSent = BytesSent; + emit stateUpdated(); +} + +void FileTransferInstance::onFileTransferCancelled(int FriendId, int FileNum, ToxFile::FileDirection Direction) +{ + if (FileNum != fileNum || FriendId != friendId || Direction != direction) + return; + disconnect(Widget::getInstance()->getCore(),0,this,0); + state = tsCanceled; + + emit stateUpdated(); +} + +void FileTransferInstance::onFileTransferFinished(ToxFile File) +{ + if (File.fileNum != fileNum || File.friendId != friendId || File.direction != direction) + return; + disconnect(Widget::getInstance()->getCore(),0,this,0); + + if (File.direction == ToxFile::RECEIVING) + { + QPixmap preview; + QFile previewFile(File.filePath); + if (previewFile.open(QIODevice::ReadOnly) && previewFile.size() <= 1024*1024*25) // Don't preview big (>25MiB) images + { + if (preview.loadFromData(previewFile.readAll())) + { + preview = preview.scaledToHeight(40); +// pic->setPixmap(preview); + } + previewFile.close(); + } + } + + state = tsFinished; + + emit stateUpdated(); +} + +void FileTransferInstance::cancelTransfer() +{ + Widget::getInstance()->getCore()->cancelFileSend(friendId, fileNum); + state = tsCanceled; + emit stateUpdated(); +} + +void FileTransferInstance::rejectRecvRequest() +{ + Widget::getInstance()->getCore()->rejectFileRecvRequest(friendId, fileNum); + onFileTransferCancelled(friendId, fileNum, direction); + state = tsCanceled; + emit stateUpdated(); +} + +// for whatever the fuck reason, QFileInfo::isWritable() always fails for files that don't exist +// which makes it useless for our case +// since QDir doesn't have an isWritable(), the only option I can think of is to make/delete the file +// surely this is a common problem that has a qt-implemented solution? +bool isFileWritable(QString& path) +{ + QFile file(path); + bool exists = file.exists(); + bool out = file.open(QIODevice::WriteOnly); + file.close(); + if (!exists) + file.remove(); + return out; +} + +void FileTransferInstance::acceptRecvRequest() +{ + QString path; + while (true) + { + path = QFileDialog::getSaveFileName(Widget::getInstance(), tr("Save a file","Title of the file saving dialog"), QDir::current().filePath(filename)); + if (path.isEmpty()) + return; + else + { + //bool savable = QFileInfo(path).isWritable(); + //qDebug() << path << " is writable: " << savable; + //qDebug() << "/home/bill/bliss.pdf writable: " << QFileInfo("/home/bill/bliss.pdf").isWritable(); + if (isFileWritable(path)) + break; + else + QMessageBox::warning(Widget::getInstance(), tr("Location not writable","Title of permissions popup"), tr("You do not have permission to write that location. Choose another, or cancel the save dialog.", "text of permissions popup")); + } + } + + savePath = path; + + Widget::getInstance()->getCore()->acceptFileRecvRequest(friendId, fileNum, path); + state = tsProcessing; + + emit stateUpdated(); +} + +void FileTransferInstance::pauseResumeRecv() +{ + Widget::getInstance()->getCore()->pauseResumeFileRecv(friendId, fileNum); + if (state == tsProcessing) + state = tsPaused; + else state = tsProcessing; + emit stateUpdated(); +} + +void FileTransferInstance::pauseResumeSend() +{ + Widget::getInstance()->getCore()->pauseResumeFileSend(friendId, fileNum); + if (state == tsProcessing) + state = tsPaused; + else state = tsProcessing; + emit stateUpdated(); +} + +QString FileTransferInstance::getHtmlImage() +{ + qDebug() << "QString FileTransferInstance::getHtmlImage()"; + auto QImage2base64 = [](const QImage &img) + { + QByteArray ba; + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + img.save(&buffer, "PNG"); // writes image into ba in PNG format + return ba.toBase64(); + }; + + QString res; + if (state == tsPending || state == tsProcessing || state == tsPaused) + { + QImage rightUp(":ui/stopFileButton/default.png"); + QImage rightDown(":ui/acceptFileButton/default.png"); + + QString widgetId = QString::number(getId()); + QString strUp = ""; + QString strDown = ""; + + res = "\n"; + res += "\n\n\n\n"; + res += "
\n"; + res += "

PROCESSING

" + filename + "

" + size + "

\n"; + res += "
\n"; + res += "
" + strUp + "
" + strDown + "
\n"; + res += "
\n"; + } else if (state == tsCanceled) + { + res = "\n"; + res += "\n\n\n"; + res += "
\n"; + res += "

CANCELED

" + filename + "

" + size + "

\n"; + res += "
\n"; + } else if (state == tsFinished) + { + res = "\n"; + res += "\n\n\n"; + res += "
\n"; + res += "

FINISHED

" + filename + "

" + size + "

\n"; + res += "
\n"; + } + + return res; +} + +void FileTransferInstance::pressFromHtml(QString code) +{ + if (state == tsFinished || state == tsCanceled) + return; + + if (direction == ToxFile::SENDING) + { + if (code == "top") + cancelTransfer(); + else if (code == "bottom") + pauseResumeSend(); + } else { + if (code == "top") + rejectRecvRequest(); + else if (code == "bottom") + { + if (state == tsPending) + acceptRecvRequest(); + else + pauseResumeRecv(); + } + } +} diff --git a/filetransferinstance.h b/filetransferinstance.h new file mode 100644 index 000000000..27345ba58 --- /dev/null +++ b/filetransferinstance.h @@ -0,0 +1,76 @@ +/* + Copyright (C) 2014 by Project Tox + + 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. +*/ +#ifndef FILETRANSFERINSTANCE_H +#define FILETRANSFERINSTANCE_H + +#include +#include +#include +#include +#include +#include +#include + +#include "core.h" + +struct ToxFile; + +class FileTransferInstance : public QObject +{ + Q_OBJECT +public: + explicit FileTransferInstance(ToxFile File); + QString getHtmlImage(); + uint getId(){return id;} + +public slots: + void onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection Direction); + void onFileTransferCancelled(int FriendId, int FileNum, ToxFile::FileDirection Direction); + void onFileTransferFinished(ToxFile File); + void pressFromHtml(QString); + +signals: + void stateUpdated(); + +private slots: + void cancelTransfer(); + void rejectRecvRequest(); + void acceptRecvRequest(); + void pauseResumeRecv(); + void pauseResumeSend(); + +private: + QString getHumanReadableSize(unsigned long long size); + +private: + enum TransfState {tsPending, tsProcessing, tsPaused, tsFinished, tsCanceled}; + + static uint Idconter; + uint id; + + TransfState state; + QImage pic; + QString filename, size, speed, eta; + QDateTime lastUpdate; + long long lastBytesSent; + int fileNum; + int friendId; + QString savePath; + ToxFile::FileDirection direction; + QString stopFileButtonStylesheet, pauseFileButtonStylesheet, acceptFileButtonStylesheet; +}; + +#endif // FILETRANSFERINSTANCE_H diff --git a/qtox.pro b/qtox.pro index 2e8468c07..25953fb0e 100644 --- a/qtox.pro +++ b/qtox.pro @@ -102,7 +102,10 @@ HEADERS += widget/form/addfriendform.h \ widget/croppinglabel.h \ widget/friendlistwidget.h \ widget/genericchatroomwidget.h \ - widget/form/genericchatform.h + widget/form/genericchatform.h \ + widget/tool/genericchataction.h \ + widget/chatareawidget.h \ + filetransferinstance.h SOURCES += \ widget/form/addfriendform.cpp \ @@ -136,4 +139,7 @@ SOURCES += \ widget/friendlistwidget.cpp \ coreav.cpp \ widget/genericchatroomwidget.cpp \ - widget/form/genericchatform.cpp + widget/form/genericchatform.cpp \ + widget/tool/genericchataction.cpp \ + widget/chatareawidget.cpp \ + filetransferinstance.cpp diff --git a/res.qrc b/res.qrc index 0b6abfff5..7cd8ca7ff 100644 --- a/res.qrc +++ b/res.qrc @@ -42,6 +42,7 @@ ui/callButton/callButtonYellowHover.png ui/callButton/callButtonYellowPressed.png ui/chatArea/chatArea.css + ui/chatArea/innerStyle.css ui/chatArea/scrollBarDownArrow.png ui/chatArea/scrollBarDownArrowHover.png ui/chatArea/scrollBarDownArrowPressed.png @@ -57,6 +58,7 @@ ui/fileButton/fileButton.png ui/fileButton/fileButtonHover.png ui/fileButton/fileButtonPressed.png + ui/fileButton/fileButtonDisabled.png ui/msgEdit/msgEdit.css ui/pauseFileButton/default.png ui/pauseFileButton/hover.png @@ -124,6 +126,5 @@ ui/micButton/micButtonPressed.png ui/micButton/micButton.css ui/volButton/volButton.css - ui/fileButton/fileButtonDisabled.png diff --git a/ui/chatArea/innerStyle.css b/ui/chatArea/innerStyle.css new file mode 100644 index 000000000..c23f4aa7a --- /dev/null +++ b/ui/chatArea/innerStyle.css @@ -0,0 +1,37 @@ +div.name_me { + color: #646464; + font-weight: bold; + padding-right: 3px; +} + +div.message_me { + color: #646464; + padding-right: 3px; + padding-left: 3px; +} + +div.date_me { + color: #646464; + padding-left: 3px; +} + +div.quote { + background-color: #6bc260; +} + +div.name { + color: #000000; + font-weight: bold; + padding-right: 3px; +} + +div.message { + color: #000000; + padding-right: 3px; + padding-left: 3px; +} + +div.date { + color: #000000; + padding-left: 3px; +} diff --git a/widget/chatareawidget.cpp b/widget/chatareawidget.cpp new file mode 100644 index 000000000..923ff8f38 --- /dev/null +++ b/widget/chatareawidget.cpp @@ -0,0 +1,56 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 "chatareawidget.h" +#include +#include + +ChatAreaWidget::ChatAreaWidget(QWidget *parent) : + QTextEdit(parent) +{ + setReadOnly(true); + viewport()->setCursor(Qt::ArrowCursor); + setContextMenuPolicy(Qt::CustomContextMenu); +} + +void ChatAreaWidget::mouseReleaseEvent(QMouseEvent * event) +{ + QTextEdit::mouseReleaseEvent(event); + int pos = this->document()->documentLayout()->hitTest(event->pos(), Qt::ExactHit); + if (pos > 0) + { + QTextCursor cursor(document()); + cursor.setPosition(pos); + if( ! cursor.atEnd() ) + { + cursor.setPosition(pos+1); + + QTextFormat format = cursor.charFormat(); + if (format.isImageFormat()) + { + QString image = format.toImageFormat().name(); + if (QRegExp("^data:ftrans.*").exactMatch(image)) + { + image = image.right(image.length() - 12); + int endpos = image.indexOf("/png;base64"); + image = image.left(endpos); + int middlepos = image.indexOf("."); + emit onFileTranfertInterract(image.left(middlepos),image.right(image.length() - middlepos - 1)); + } + } + } + } +} diff --git a/widget/chatareawidget.h b/widget/chatareawidget.h new file mode 100644 index 000000000..aae1960f8 --- /dev/null +++ b/widget/chatareawidget.h @@ -0,0 +1,38 @@ +/* + Copyright (C) 2014 by Project Tox + + 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. +*/ + +#ifndef CHATAREAWIDGET_H +#define CHATAREAWIDGET_H + +#include + +class ChatAreaWidget : public QTextEdit +{ + Q_OBJECT +public: + explicit ChatAreaWidget(QWidget *parent = 0); + +signals: + void onFileTranfertInterract(QString widgetName, QString buttonName); + +protected: + void mouseReleaseEvent(QMouseEvent * event); + +public slots: + +}; + +#endif // CHATAREAWIDGET_H diff --git a/widget/filetransfertwidget.cpp b/widget/filetransfertwidget.cpp index 41fb4ed56..1e63126ee 100644 --- a/widget/filetransfertwidget.cpp +++ b/widget/filetransfertwidget.cpp @@ -23,11 +23,15 @@ #include #include #include +#include + +uint FileTransfertWidget::Idconter = 0; FileTransfertWidget::FileTransfertWidget(ToxFile File) : lastUpdate{QDateTime::currentDateTime()}, lastBytesSent{0}, fileNum{File.fileNum}, friendId{File.friendId}, direction{File.direction} { + id = Idconter++; pic=new QLabel(), filename=new QLabel(), size=new QLabel(), speed=new QLabel(), eta=new QLabel(); topright = new QPushButton(), bottomright = new QPushButton(); progress = new QProgressBar(); @@ -182,6 +186,7 @@ void FileTransfertWidget::onFileTransferInfo(int FriendId, int FileNum, int64_t } lastUpdate = newtime; lastBytesSent = BytesSent; + emit stateUpdated(); } void FileTransfertWidget::onFileTransferCancelled(int FriendId, int FileNum, ToxFile::FileDirection Direction) @@ -206,6 +211,8 @@ void FileTransfertWidget::onFileTransferCancelled(int FriendId, int FileNum, Tox //Toggle window visibility to fix draw order bug this->hide(); this->show(); + + emit stateUpdated(); } void FileTransfertWidget::onFileTransferFinished(ToxFile File) @@ -245,17 +252,21 @@ void FileTransfertWidget::onFileTransferFinished(ToxFile File) previewFile.close(); } } + + emit stateUpdated(); } void FileTransfertWidget::cancelTransfer() { Widget::getInstance()->getCore()->cancelFileSend(friendId, fileNum); + emit stateUpdated(); } void FileTransfertWidget::rejectRecvRequest() { Widget::getInstance()->getCore()->rejectFileRecvRequest(friendId, fileNum); onFileTransferCancelled(friendId, fileNum, direction); + emit stateUpdated(); } // for whatever the fuck reason, QFileInfo::isWritable() always fails for files that don't exist @@ -299,16 +310,20 @@ void FileTransfertWidget::acceptRecvRequest() bottomright->disconnect(); connect(bottomright, SIGNAL(clicked()), this, SLOT(pauseResumeRecv())); Widget::getInstance()->getCore()->acceptFileRecvRequest(friendId, fileNum, path); + + emit stateUpdated(); } void FileTransfertWidget::pauseResumeRecv() { Widget::getInstance()->getCore()->pauseResumeFileRecv(friendId, fileNum); + emit stateUpdated(); } void FileTransfertWidget::pauseResumeSend() { Widget::getInstance()->getCore()->pauseResumeFileSend(friendId, fileNum); + emit stateUpdated(); } void FileTransfertWidget::paintEvent(QPaintEvent *) @@ -317,4 +332,56 @@ void FileTransfertWidget::paintEvent(QPaintEvent *) opt.init(this); QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); + emit stateUpdated(); +} + +QString FileTransfertWidget::getHtmlImage() +{ + qDebug() << "QString FileTransfertWidget::getHtmlImage()"; + auto QImage2base64 = [](const QImage &img) + { + QByteArray ba; + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + img.save(&buffer, "PNG"); // writes image into ba in PNG format + return ba.toBase64(); + }; + + auto renderButton = [](QPushButton *pb) + { + QImage bitmap(pb->size(), QImage::Format_ARGB32); + bitmap.fill(Qt::transparent); + QPainter painter(&bitmap); + + pb->render(&painter, QPoint(), QRegion(), QWidget::DrawChildren); + return bitmap; + }; + + // QImage rightUp = renderButton(topright); + // QImage rightDown = renderButton(bottomright); + QImage rightUp(":ui/stopFileButton/default.png"); + QImage rightDown(":ui/acceptFileButton/default.png"); + + QString res; + QString widgetId = QString::number(getId()); + QString strUp = ""; + QString strDown = ""; + + res = "\n"; + res += "\n\n\n\n"; + res += "
\n"; + res += "
\n"; + res += "
\n"; + if (topright->isVisible() && bottomright->isVisible()) + res += "
" + strUp + "
" + strDown + "
\n"; + res += "
\n"; + return res; +} + +void FileTransfertWidget::pressFromHtml(QString code) +{ + if (code == "top") + topright->clicked(); + else if (code == "bottom") + bottomright->clicked(); } diff --git a/widget/filetransfertwidget.h b/widget/filetransfertwidget.h index 699c9d548..def939354 100644 --- a/widget/filetransfertwidget.h +++ b/widget/filetransfertwidget.h @@ -35,12 +35,19 @@ class FileTransfertWidget : public QWidget public: FileTransfertWidget(ToxFile File); + QString getHtmlImage(); + uint getId(){return id;} public slots: void onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection Direction); void onFileTransferCancelled(int FriendId, int FileNum, ToxFile::FileDirection Direction); void onFileTransferFinished(ToxFile File); + void pressFromHtml(QString); + +signals: + void stateUpdated(); + private slots: void cancelTransfer(); void rejectRecvRequest(); @@ -52,6 +59,10 @@ private: QString getHumanReadableSize(unsigned long long size); private: + static uint Idconter; + uint id; + + QLabel *pic, *filename, *size, *speed, *eta; QPushButton *topright, *bottomright; QProgressBar *progress; diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 141451c4c..52edf523a 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -43,6 +43,7 @@ ChatForm::ChatForm(Friend* chatFriend) connect(videoButton, &QPushButton::clicked, this, &ChatForm::onVideoCallTriggered); connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered); connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle())); + connect(newChatForm, SIGNAL(onFileTranfertInterract(QString,QString)), this, SLOT(onFileTansBtnClicked(QString,QString))); } ChatForm::~ChatForm() @@ -94,36 +95,42 @@ void ChatForm::startFileSend(ToxFile file) if (file.friendId != f->friendId) return; - QLabel *author = new QLabel(Widget::getInstance()->getUsername()); - QLabel *date = new QLabel(QTime::currentTime().toString("hh:mm")); - QScrollBar* scroll = chatArea->verticalScrollBar(); - lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); - author->setAlignment(Qt::AlignTop | Qt::AlignRight); - date->setAlignment(Qt::AlignTop); - QPalette pal; - pal.setColor(QPalette::WindowText, Qt::gray); - author->setPalette(pal); - if (previousName.isEmpty() || previousName != author->text()) - { - if (curRow) - { - mainChatLayout->setRowStretch(curRow, 0); - mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3); - curRow++; - } - mainChatLayout->addWidget(author, curRow, 0); - } - FileTransfertWidget* fileTrans = new FileTransfertWidget(file); - previousName = author->text(); - mainChatLayout->addWidget(fileTrans, curRow, 1); - mainChatLayout->addWidget(date, curRow, 3); - mainChatLayout->setRowStretch(curRow+1, 1); - mainChatLayout->setRowStretch(curRow, 0); - curRow++; +// QLabel *author = new QLabel(Widget::getInstance()->getUsername()); +// QLabel *date = new QLabel(QTime::currentTime().toString("hh:mm")); +// QScrollBar* scroll = chatArea->verticalScrollBar(); +// lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); +// author->setAlignment(Qt::AlignTop | Qt::AlignRight); +// date->setAlignment(Qt::AlignTop); +// QPalette pal; +// pal.setColor(QPalette::WindowText, Qt::gray); +// author->setPalette(pal); +// if (previousName.isEmpty() || previousName != author->text()) +// { +// if (curRow) +// { +// mainChatLayout->setRowStretch(curRow, 0); +// mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3); +// curRow++; +// } +// mainChatLayout->addWidget(author, curRow, 0); +// } - connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransfertWidget::onFileTransferInfo); - connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransfertWidget::onFileTransferCancelled); - connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransfertWidget::onFileTransferFinished); + FileTransferInstance* fileTrans = new FileTransferInstance(file); + ftransWidgets.insert(fileTrans->getId(), fileTrans); +// previousName = author->text(); +// mainChatLayout->addWidget(fileTrans, curRow, 1); +// mainChatLayout->addWidget(date, curRow, 3); +// mainChatLayout->setRowStretch(curRow+1, 1); +// mainChatLayout->setRowStretch(curRow, 0); +// curRow++; + + connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo); + connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled); + connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransferInstance::onFileTransferFinished); + connect(fileTrans, SIGNAL(stateUpdated()), this, SLOT(updateChatContent())); + + messages.append(new FileTransferAction(fileTrans, Widget::getInstance()->getUsername(), QTime::currentTime().toString("hh:mm"))); + updateChatContent(); } void ChatForm::onFileRecvRequest(ToxFile file) @@ -131,33 +138,35 @@ void ChatForm::onFileRecvRequest(ToxFile file) if (file.friendId != f->friendId) return; - QLabel *author = new QLabel(f->getName()); - QLabel *date = new QLabel(QTime::currentTime().toString("hh:mm")); - QScrollBar* scroll = chatArea->verticalScrollBar(); - lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); - author->setAlignment(Qt::AlignTop | Qt::AlignRight); - date->setAlignment(Qt::AlignTop); - if (previousName.isEmpty() || previousName != author->text()) - { - if (curRow) - { - mainChatLayout->setRowStretch(curRow, 0); - mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3); - curRow++; - } - mainChatLayout->addWidget(author, curRow, 0); - } - FileTransfertWidget* fileTrans = new FileTransfertWidget(file); - previousName = author->text(); - mainChatLayout->addWidget(fileTrans, curRow, 1); - mainChatLayout->addWidget(date, curRow, 3); - mainChatLayout->setRowStretch(curRow+1, 1); - mainChatLayout->setRowStretch(curRow, 0); - curRow++; +// QLabel *author = new QLabel(f->getName()); +// QLabel *date = new QLabel(QTime::currentTime().toString("hh:mm")); +// QScrollBar* scroll = chatArea->verticalScrollBar(); +// lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); +// author->setAlignment(Qt::AlignTop | Qt::AlignRight); +// date->setAlignment(Qt::AlignTop); +// if (previousName.isEmpty() || previousName != author->text()) +// { +// if (curRow) +// { +// mainChatLayout->setRowStretch(curRow, 0); +// mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3); +// curRow++; +// } +// mainChatLayout->addWidget(author, curRow, 0); +// } + FileTransferInstance* fileTrans = new FileTransferInstance(file); + ftransWidgets.insert(fileTrans->getId(), fileTrans); +// previousName = author->text(); +// mainChatLayout->addWidget(fileTrans, curRow, 1); +// mainChatLayout->addWidget(date, curRow, 3); +// mainChatLayout->setRowStretch(curRow+1, 1); +// mainChatLayout->setRowStretch(curRow, 0); +// curRow++; - connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransfertWidget::onFileTransferInfo); - connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransfertWidget::onFileTransferCancelled); - connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransfertWidget::onFileTransferFinished); + connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo); + connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled); + connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransferInstance::onFileTransferFinished); + connect(fileTrans, SIGNAL(stateUpdated()), this, SLOT(updateChatContent())); Widget* w = Widget::getInstance(); if (!w->isFriendWidgetCurActiveWidget(f)|| w->getIsWindowMinimized() || !w->isActiveWindow()) @@ -166,6 +175,9 @@ void ChatForm::onFileRecvRequest(ToxFile file) f->hasNewEvents=true; f->widget->updateStatusLight(); } + + messages.append(new FileTransferAction(fileTrans, f->getName(), QTime::currentTime().toString("hh:mm"))); + updateChatContent(); } void ChatForm::onAvInvite(int FriendId, int CallId, bool video) @@ -461,3 +473,16 @@ void ChatForm::onMicMuteToggle() } } } + +void ChatForm::onFileTansBtnClicked(QString widgetName, QString buttonName) +{ + uint id = widgetName.toUInt(); + + auto it = ftransWidgets.find(id); + if (it != ftransWidgets.end()) + it.value()->pressFromHtml(buttonName); + else + qDebug() << "no filetransferwidget: " << id; + +// QMessageBox::information(nullptr, message, message); +} diff --git a/widget/form/chatform.h b/widget/form/chatform.h index 6a7a9362d..1527a701b 100644 --- a/widget/form/chatform.h +++ b/widget/form/chatform.h @@ -22,6 +22,7 @@ #include "widget/netcamview.h" struct Friend; +class FileTransferInstance; class ChatForm : public GenericChatForm { @@ -63,6 +64,7 @@ private slots: void onAnswerCallTriggered(); void onHangupCallTriggered(); void onCancelCallTriggered(); + void onFileTansBtnClicked(QString widgetName, QString buttonName); private: Friend* f; @@ -70,6 +72,8 @@ private: NetCamView* netcam; bool audioInputFlag; int callId; + + QHash ftransWidgets; }; #endif // CHATFORM_H diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index d7727adf7..efbfed001 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -23,6 +23,7 @@ #include "widget/emoticonswidget.h" #include "style.h" #include "widget/widget.h" +#include "settings.h" GenericChatForm::GenericChatForm(QObject *parent) : QObject(parent) @@ -40,6 +41,10 @@ GenericChatForm::GenericChatForm(QObject *parent) : QVBoxLayout *footButtonsSmall = new QVBoxLayout(), *volMicLayout = new QVBoxLayout(); mainChatLayout = new QGridLayout(); + newChatForm = new ChatAreaWidget(); + newChatForm->document()->setDefaultStyleSheet(Style::get(":ui/chatArea/innerStyle.css")); + newChatForm->setStyleSheet(Style::get(":/ui/chatArea/chatArea.css")); + msgEdit = new ChatTextEdit(); sendButton = new QPushButton(); @@ -112,6 +117,7 @@ GenericChatForm::GenericChatForm(QObject *parent) : mainWidget->setLayout(mainLayout); mainLayout->addWidget(chatArea); + mainLayout->addWidget(newChatForm); mainLayout->addLayout(mainFootLayout); mainLayout->setMargin(0); @@ -147,8 +153,8 @@ GenericChatForm::GenericChatForm(QObject *parent) : emoteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); connect(emoteButton, SIGNAL(clicked()), this, SLOT(onEmoteButtonClicked())); - connect(chatArea, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); - connect(chatArea->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); + connect(newChatForm, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); + connect(newChatForm->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); } void GenericChatForm::setName(const QString &newName) @@ -176,14 +182,14 @@ void GenericChatForm::onChatContextMenuRequested(QPoint pos) void GenericChatForm::onSliderRangeChanged() { - QScrollBar* scroll = chatArea->verticalScrollBar(); + QScrollBar* scroll = newChatForm->verticalScrollBar(); if (lockSliderToBottom) scroll->setValue(scroll->maximum()); } void GenericChatForm::onSaveLogClicked() { - QString path = QFileDialog::getSaveFileName(0,tr("Save chat log")); + QString path = QFileDialog::getSaveFileName(0, tr("Save chat log")); if (path.isEmpty()) return; @@ -192,96 +198,28 @@ void GenericChatForm::onSaveLogClicked() return; QString log; - QList labels = chatAreaWidget->findChildren(); - int i=0; - for (QLabel* label : labels) - { - log += label->text(); - if (i==2) - { - i=0; - log += '\n'; - } - else - { - log += '\t'; - i++; - } - } + log = newChatForm->toPlainText(); file.write(log.toUtf8()); file.close(); } -void GenericChatForm::addMessage(QString author, QString message, QString date) +void GenericChatForm::addMessage(QString author, QString message, QDateTime datetime) { - QLabel *authorLabel = new QLabel(author); - QLabel *messageLabel = new QLabel(); - QLabel *dateLabel = new QLabel(date); - - QScrollBar* scroll = chatArea->verticalScrollBar(); - lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); - authorLabel->setAlignment(Qt::AlignTop | Qt::AlignRight); - dateLabel->setAlignment(Qt::AlignTop); - messageLabel->setWordWrap(true); - messageLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - authorLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - dateLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); - if (author == Widget::getInstance()->getUsername()) - { - QPalette pal; - pal.setColor(QPalette::WindowText, QColor(100,100,100)); - authorLabel->setPalette(pal); - messageLabel->setPalette(pal); - } - if (previousName.isEmpty() || previousName != author) - { - if (curRow) - { - mainChatLayout->setRowStretch(curRow, 0); - mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3); - } - previousName = author; - curRow++; - } - else if (curRow)// onSaveLogClicked expects 0 or 3 QLabel per line - authorLabel->setText(""); - - QColor greentext(61,204,61); - QString fontTemplate = "%2"; - - QString finalMessage; - QStringList messageLines = message.split("\n"); - for (QString& s : messageLines) - { - if (QRegExp("^[ ]*>.*").exactMatch(s)) - finalMessage += fontTemplate.arg(greentext.name(), toHtmlChars(s)); - else - finalMessage += toHtmlChars(s); - finalMessage += "
"; - } - messageLabel->setText(finalMessage.left(finalMessage.length()-4)); - messageLabel->setText(SmileyPack::getInstance().smileyfied(messageLabel->text())); - messageLabel->setTextFormat(Qt::RichText); - - mainChatLayout->addWidget(authorLabel, curRow, 0); - mainChatLayout->addWidget(messageLabel, curRow, 1); - mainChatLayout->addWidget(dateLabel, curRow, 3); - mainChatLayout->setRowStretch(curRow+1, 1); - mainChatLayout->setRowStretch(curRow, 0); - curRow++; - authorLabel->setContextMenuPolicy(Qt::CustomContextMenu); - messageLabel->setContextMenuPolicy(Qt::CustomContextMenu); - dateLabel->setContextMenuPolicy(Qt::CustomContextMenu); - connect(authorLabel, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); - connect(messageLabel, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); - connect(dateLabel, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); + QString date = datetime.toString(Settings::getInstance().getTimestampFormat()); + if (previousName == author) + messages.append(new MessageAction("", message, date)); + else messages.append(new MessageAction(author , message, date)); + previousName = author; + updateChatContent(); } GenericChatForm::~GenericChatForm() { delete mainWidget; delete headWidget; + for (ChatAction *it : messages) + delete it; } void GenericChatForm::onEmoteButtonClicked() @@ -311,13 +249,22 @@ void GenericChatForm::onEmoteInsertRequested(QString str) msgEdit->setFocus(); // refocus so that we can continue typing } -QString GenericChatForm::toHtmlChars(const QString &str) +QString GenericChatForm::getHtmledMessages() { - static QList> replaceList = {{"&","&"}, {" "," "}, {">",">"}, {"<","<"}}; - QString res = str; - - for (auto &it : replaceList) - res = res.replace(it.first,it.second); + QString res("\n"); + for (ChatAction *it : messages) + { + res += it->getHtml(); + } + res += "
"; return res; } + +void GenericChatForm::updateChatContent() +{ + QScrollBar* scroll = newChatForm->verticalScrollBar(); + lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); + + newChatForm->setHtml(getHtmledMessages()); +} diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h index 59216f755..da891fc2b 100644 --- a/widget/form/genericchatform.h +++ b/widget/form/genericchatform.h @@ -28,7 +28,9 @@ #include #include +#include "widget/chatareawidget.h" #include "widget/tool/chattextedit.h" +#include "widget/tool/genericchataction.h" // Spacing in px inserted when the author of the last message changes #define AUTHOR_CHANGE_SPACING 5 @@ -46,7 +48,7 @@ public: virtual void setName(const QString &newName); virtual void show(Ui::MainWindow &ui); - void addMessage(QString author, QString message, QString date=QTime::currentTime().toString("hh:mm")); + void addMessage(QString author, QString message, QDateTime datetime=QDateTime::currentDateTime()); signals: void sendMessage(int, QString); @@ -59,6 +61,7 @@ protected slots: void onSaveLogClicked(); void onEmoteButtonClicked(); void onEmoteInsertRequested(QString str); + void updateChatContent(); protected: QLabel *nameLabel, *avatarLabel; @@ -70,11 +73,14 @@ protected: ChatTextEdit *msgEdit; QPushButton *sendButton; QString previousName; + ChatAreaWidget *newChatForm; int curRow; bool lockSliderToBottom; + QList messages; + private: - QString toHtmlChars(const QString &str); + QString getHtmledMessages(); }; #endif // GENERICCHATFORM_H diff --git a/widget/tool/genericchataction.cpp b/widget/tool/genericchataction.cpp new file mode 100644 index 000000000..c42721791 --- /dev/null +++ b/widget/tool/genericchataction.cpp @@ -0,0 +1,116 @@ +/* + Copyright (C) 2014 by Project Tox + + 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 "genericchataction.h" +#include "smileypack.h" +#include +#include + +QString ChatAction::toHtmlChars(const QString &str) +{ + static QList> replaceList = {{"&","&"}, {" "," "}, {">",">"}, {"<","<"}}; + QString res = str; + + for (auto &it : replaceList) + res = res.replace(it.first,it.second); + + return res; +} + +QString ChatAction::QImage2base64(const QImage &img) +{ + QByteArray ba; + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + img.save(&buffer, "PNG"); // writes image into ba in PNG format + return ba.toBase64(); +} + +QString ChatAction::wrapName(const QString &name) +{ + QString res = "
" + name + "
\n"; + return res; +} + +QString ChatAction::wrapDate(const QString &date) +{ + QString res = "
" + date + "
\n"; + return res; +} + +QString ChatAction::wrapMessage(const QString &message) +{ + QString res = "
" + message + "
\n"; + return res; +} + +QString ChatAction::wrapWholeLine(const QString &line) +{ + QString res = "\n" + line + "\n"; + return res; +} + +MessageAction::MessageAction(const QString &author, const QString &message, const QString &date) +{ + QString message_ = SmileyPack::getInstance().smileyfied(toHtmlChars(message)); + + QStringList messageLines = message_.split("\n"); + message_ = ""; + for (QString& s : messageLines) + { + if (QRegExp("^[ ]*>.*").exactMatch(s)) + message_ += "
" + s.right(s.length()-4) + "

"; + else + message_ += s + "
"; + } + message_ = message_.left(message_.length()-4); + + content = wrapWholeLine(wrapName(author) + wrapMessage(message_) + wrapDate(date)); +} + +QString MessageAction::getHtml() +{ + return content; +} + +FileTransferAction::FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date) : + sender(author), + timestamp(date) +{ + w = widget; +} + +FileTransferAction::~FileTransferAction() +{ + +} + +QString FileTransferAction::getHtml() +{ + QString widgetHtml; + if (w != nullptr) + widgetHtml = w->getHtmlImage(); + else + widgetHtml = "
EMPTY CONTENT
"; + QString res = wrapWholeLine(wrapName(sender) + wrapMessage(widgetHtml) + wrapDate(timestamp));; + return res; +} + +QString FileTransferAction::wrapMessage(const QString &message) +{ + QString res = "" + message + "\n"; + return res; +} diff --git a/widget/tool/genericchataction.h b/widget/tool/genericchataction.h new file mode 100644 index 000000000..ebe531c70 --- /dev/null +++ b/widget/tool/genericchataction.h @@ -0,0 +1,63 @@ +/* + Copyright (C) 2014 by Project Tox + + 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. +*/ + +#ifndef CHATACTION_H +#define CHATACTION_H + +#include +#include "filetransferinstance.h" + +class ChatAction +{ +public: + virtual ~ChatAction(){;} + virtual QString getHtml() = 0; + +protected: + QString toHtmlChars(const QString &str); + QString QImage2base64(const QImage &img); + + virtual QString wrapName(const QString &name); + virtual QString wrapDate(const QString &date); + virtual QString wrapMessage(const QString &message); + virtual QString wrapWholeLine(const QString &line); +}; + +class MessageAction : public ChatAction +{ +public: + MessageAction(const QString &author, const QString &message, const QString &date); + virtual ~MessageAction(){;} + virtual QString getHtml(); + +private: + QString content; +}; + +class FileTransferAction : public ChatAction +{ +public: + FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date); + virtual ~FileTransferAction(); + virtual QString getHtml(); + virtual QString wrapMessage(const QString &message); + +private: + FileTransferInstance *w; + QString sender, timestamp; +}; + +#endif // CHATACTION_H From 0fe14953c875e66311fa29ea82fefb3c345f3546 Mon Sep 17 00:00:00 2001 From: apprb Date: Sat, 6 Sep 2014 20:13:06 +0700 Subject: [PATCH 06/46] somehow working example --- filetransferinstance.cpp | 13 +++++++---- ui/chatArea/innerStyle.css | 18 ++++++++++++++ widget/form/chatform.cpp | 48 -------------------------------------- 3 files changed, 27 insertions(+), 52 deletions(-) diff --git a/filetransferinstance.cpp b/filetransferinstance.cpp index b1d11ac61..0338801eb 100644 --- a/filetransferinstance.cpp +++ b/filetransferinstance.cpp @@ -217,7 +217,11 @@ QString FileTransferInstance::getHtmlImage() if (state == tsPending || state == tsProcessing || state == tsPaused) { QImage rightUp(":ui/stopFileButton/default.png"); - QImage rightDown(":ui/acceptFileButton/default.png"); + QImage rightDown; + if (state == tsProcessing) + rightDown = QImage(":ui/pauseFileButton/default.png"); + else + rightDown = QImage(":ui/acceptFileButton/default.png"); QString widgetId = QString::number(getId()); QString strUp = ""; @@ -225,7 +229,8 @@ QString FileTransferInstance::getHtmlImage() res = "\n"; res += "\n\n\n\n"; @@ -234,14 +239,14 @@ QString FileTransferInstance::getHtmlImage() { res = "
\n"; - res += "

PROCESSING

" + filename + "

" + size + "

\n"; + res += "

" + filename + "

" + getHumanReadableSize(lastBytesSent) + "/" + size; + res += " (" + speed + ")

\n"; res += "
\n"; res += "
" + strUp + "
" + strDown + "
\n"; res += "
\n"; res += "\n\n\n"; res += "
\n"; - res += "

CANCELED

" + filename + "

" + size + "

\n"; + res += "

" + filename + "

" + size + "

\n"; res += "
\n"; } else if (state == tsFinished) { res = "\n"; res += "\n\n\n"; res += "
\n"; - res += "

FINISHED

" + filename + "

" + size + "

\n"; + res += "

" + filename + "

" + size + "

\n"; res += "
\n"; } diff --git a/ui/chatArea/innerStyle.css b/ui/chatArea/innerStyle.css index c23f4aa7a..e5bd537c3 100644 --- a/ui/chatArea/innerStyle.css +++ b/ui/chatArea/innerStyle.css @@ -35,3 +35,21 @@ div.date { color: #000000; padding-left: 3px; } + +div.green { + margin-top: 12px; + margin-bottom: 12px; + margin-left: 12px; + color: #ffffff; + background-color: #6bc260; + font-size: 10px; +} + +div.red { + margin-top: 12px; + margin-bottom: 12px; + margin-left: 12px; + color: #ffffff; + background-color: rgb(200,78,78); + font-size: 10px; +} diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 52edf523a..7825c2cbb 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -95,34 +95,8 @@ void ChatForm::startFileSend(ToxFile file) if (file.friendId != f->friendId) return; -// QLabel *author = new QLabel(Widget::getInstance()->getUsername()); -// QLabel *date = new QLabel(QTime::currentTime().toString("hh:mm")); -// QScrollBar* scroll = chatArea->verticalScrollBar(); -// lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); -// author->setAlignment(Qt::AlignTop | Qt::AlignRight); -// date->setAlignment(Qt::AlignTop); -// QPalette pal; -// pal.setColor(QPalette::WindowText, Qt::gray); -// author->setPalette(pal); -// if (previousName.isEmpty() || previousName != author->text()) -// { -// if (curRow) -// { -// mainChatLayout->setRowStretch(curRow, 0); -// mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3); -// curRow++; -// } -// mainChatLayout->addWidget(author, curRow, 0); -// } - FileTransferInstance* fileTrans = new FileTransferInstance(file); ftransWidgets.insert(fileTrans->getId(), fileTrans); -// previousName = author->text(); -// mainChatLayout->addWidget(fileTrans, curRow, 1); -// mainChatLayout->addWidget(date, curRow, 3); -// mainChatLayout->setRowStretch(curRow+1, 1); -// mainChatLayout->setRowStretch(curRow, 0); -// curRow++; connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo); connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled); @@ -138,30 +112,8 @@ void ChatForm::onFileRecvRequest(ToxFile file) if (file.friendId != f->friendId) return; -// QLabel *author = new QLabel(f->getName()); -// QLabel *date = new QLabel(QTime::currentTime().toString("hh:mm")); -// QScrollBar* scroll = chatArea->verticalScrollBar(); -// lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); -// author->setAlignment(Qt::AlignTop | Qt::AlignRight); -// date->setAlignment(Qt::AlignTop); -// if (previousName.isEmpty() || previousName != author->text()) -// { -// if (curRow) -// { -// mainChatLayout->setRowStretch(curRow, 0); -// mainChatLayout->addItem(new QSpacerItem(0,AUTHOR_CHANGE_SPACING),curRow,0,1,3); -// curRow++; -// } -// mainChatLayout->addWidget(author, curRow, 0); -// } FileTransferInstance* fileTrans = new FileTransferInstance(file); ftransWidgets.insert(fileTrans->getId(), fileTrans); -// previousName = author->text(); -// mainChatLayout->addWidget(fileTrans, curRow, 1); -// mainChatLayout->addWidget(date, curRow, 3); -// mainChatLayout->setRowStretch(curRow+1, 1); -// mainChatLayout->setRowStretch(curRow, 0); -// curRow++; connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo); connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled); From 92b2848916b933509c44f50b88bb6be4b3a7cf06 Mon Sep 17 00:00:00 2001 From: apprb Date: Sat, 6 Sep 2014 23:43:29 +0700 Subject: [PATCH 07/46] rewrite --- filetransferinstance.cpp | 52 +++++++++++++++++++++++++++++--------- ui/chatArea/innerStyle.css | 8 ++++++ 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/filetransferinstance.cpp b/filetransferinstance.cpp index 0338801eb..472fed501 100644 --- a/filetransferinstance.cpp +++ b/filetransferinstance.cpp @@ -213,6 +213,8 @@ QString FileTransferInstance::getHtmlImage() return ba.toBase64(); }; + QString widgetId = QString::number(getId()); + QString res; if (state == tsPending || state == tsProcessing || state == tsPaused) { @@ -223,29 +225,55 @@ QString FileTransferInstance::getHtmlImage() else rightDown = QImage(":ui/acceptFileButton/default.png"); - QString widgetId = QString::number(getId()); QString strUp = ""; QString strDown = ""; - res = "\n"; - res += "\n\n\n\n"; + res = "
\n"; - res += "

" + filename + "

" + getHumanReadableSize(lastBytesSent) + "/" + size; - res += " (" + speed + ")

\n"; - res += "
\n"; - res += "
" + strUp + "
" + strDown + "
\n"; - res += "
\n"; + res += "\n"; + res += "\n"; + if (pic != QImage()) + { + res += "\n"; + } + res += "\n"; + res += "\n"; + res += "\n"; res += "
\n"; + res += "
" + strUp + "
\n"; + res += "
\n"; + res += ""; + res += "\n"; + res += "
"; + res += "

" + filename + "

"; + res += "

" + getHumanReadableSize(lastBytesSent) + " / " + size; + " (" + speed + ")

\n"; + res += "
\n"; + res += "
\n"; + res += "
" + strDown + "
\n"; + res += "
\n"; + } else if (state == tsCanceled) { - res = "\n"; - res += "\n
\n"; + res = "\n\n"; + if (pic != QImage()) + { + res += "\n"; + } + res += "\n\n"; res += "
\n"; + res += ""; + res += "\n"; res += "

" + filename + "

" + size + "

\n"; res += "
\n"; } else if (state == tsFinished) { - res = "\n"; - res += "\n\n"; + return res; +} + +QString FileTransferInstance::draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB) +{ + QString res; + + QString widgetId = QString::number(getId()); + QString imgAstr = ""; + QString imgBstr = ""; + + res = "
\n"; + res = "\n\n"; + if (pic != QImage()) + { + res += "\n"; + } + res += "\n\n"; res += "
\n"; + res += ""; + res += "\n"; res += "

" + filename + "

" + size + "

\n"; res += "
\n"; diff --git a/ui/chatArea/innerStyle.css b/ui/chatArea/innerStyle.css index e5bd537c3..e45691330 100644 --- a/ui/chatArea/innerStyle.css +++ b/ui/chatArea/innerStyle.css @@ -45,6 +45,14 @@ div.green { font-size: 10px; } +div.button { + margin-top: 0px; + margin-bottom: 0px; + margin-left: 0px; + color: #ffffff; + background-color: #6bc260; +} + div.red { margin-top: 12px; margin-bottom: 12px; From db4c84a222a3c3c1c519fab7bca6b0546cf53957 Mon Sep 17 00:00:00 2001 From: apprb Date: Sun, 7 Sep 2014 00:01:34 +0700 Subject: [PATCH 08/46] cleanup --- qtox.pro | 4 +- widget/filetransfertwidget.cpp | 387 -------------------------------- widget/filetransfertwidget.h | 82 ------- widget/form/chatform.cpp | 3 +- widget/form/genericchatform.cpp | 19 +- widget/form/genericchatform.h | 4 +- widget/form/groupchatform.cpp | 3 - 7 files changed, 5 insertions(+), 497 deletions(-) delete mode 100644 widget/filetransfertwidget.cpp delete mode 100644 widget/filetransfertwidget.h diff --git a/qtox.pro b/qtox.pro index 25953fb0e..c690e8727 100644 --- a/qtox.pro +++ b/qtox.pro @@ -57,7 +57,7 @@ win32 { LIBS += -L$$PWD/libs/lib/ -ltoxcore -ltoxav -lvpx -lopenal -lopencv_core -lopencv_highgui } - contains(JENKINS, YES) { + contains(JENKINS, YES) { LIBS = ./libs/lib/libtoxav.a ./libs/lib/libvpx.a ./libs/lib/libopus.a ./libs/lib/libtoxcore.a ./libs/lib/libsodium.a -lopencv_core -lopencv_highgui -lopenal } } @@ -80,7 +80,6 @@ HEADERS += widget/form/addfriendform.h \ widget/form/filesform.h \ widget/tool/chattextedit.h \ widget/tool/friendrequestdialog.h \ - widget/filetransfertwidget.h \ widget/friendwidget.h \ widget/groupwidget.h \ widget/widget.h \ @@ -115,7 +114,6 @@ SOURCES += \ widget/form/filesform.cpp \ widget/tool/chattextedit.cpp \ widget/tool/friendrequestdialog.cpp \ - widget/filetransfertwidget.cpp \ widget/friendwidget.cpp \ widget/groupwidget.cpp \ widget/widget.cpp \ diff --git a/widget/filetransfertwidget.cpp b/widget/filetransfertwidget.cpp deleted file mode 100644 index 1e63126ee..000000000 --- a/widget/filetransfertwidget.cpp +++ /dev/null @@ -1,387 +0,0 @@ -/* - Copyright (C) 2014 by Project Tox - - 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 "filetransfertwidget.h" -#include "widget.h" -#include "core.h" -#include "math.h" -#include "style.h" -#include -#include -#include -#include -#include - -uint FileTransfertWidget::Idconter = 0; - -FileTransfertWidget::FileTransfertWidget(ToxFile File) - : lastUpdate{QDateTime::currentDateTime()}, lastBytesSent{0}, - fileNum{File.fileNum}, friendId{File.friendId}, direction{File.direction} -{ - id = Idconter++; - pic=new QLabel(), filename=new QLabel(), size=new QLabel(), speed=new QLabel(), eta=new QLabel(); - topright = new QPushButton(), bottomright = new QPushButton(); - progress = new QProgressBar(); - mainLayout = new QHBoxLayout(), textLayout = new QHBoxLayout(); - infoLayout = new QVBoxLayout(), buttonLayout = new QVBoxLayout(); - buttonWidget = new QWidget(); - QFont prettysmall; - prettysmall.setPixelSize(10); - this->setObjectName("default"); - this->setStyleSheet(Style::get(":/ui/fileTransferWidget/fileTransferWidget.css")); - QPalette greybg; - greybg.setColor(QPalette::Window, QColor(209,209,209)); - greybg.setColor(QPalette::Base, QColor(150,150,150)); - setPalette(greybg); - setAutoFillBackground(true); - - setMinimumSize(250,58); - setMaximumHeight(58); - setLayout(mainLayout); - mainLayout->setMargin(0); - - pic->setMaximumHeight(40); - pic->setContentsMargins(5,0,0,0); - filename->setText(File.fileName); - filename->setFont(prettysmall); - size->setText(getHumanReadableSize(File.filesize)); - size->setFont(prettysmall); - speed->setText("0B/s"); - speed->setFont(prettysmall); - eta->setText("00:00"); - eta->setFont(prettysmall); - progress->setValue(0); - progress->setMinimumHeight(11); - progress->setFont(prettysmall); - progress->setTextVisible(false); - QPalette whitebg; - whitebg.setColor(QPalette::Window, QColor(255,255,255)); - buttonWidget->setPalette(whitebg); - buttonWidget->setAutoFillBackground(true); - buttonWidget->setLayout(buttonLayout); - - stopFileButtonStylesheet = Style::get(":/ui/stopFileButton/style.css"); - pauseFileButtonStylesheet = Style::get(":/ui/pauseFileButton/style.css"); - acceptFileButtonStylesheet = Style::get(":/ui/acceptFileButton/style.css"); - - topright->setStyleSheet(stopFileButtonStylesheet); - if (File.direction == ToxFile::SENDING) - { - bottomright->setStyleSheet(pauseFileButtonStylesheet); - connect(topright, SIGNAL(clicked()), this, SLOT(cancelTransfer())); - connect(bottomright, SIGNAL(clicked()), this, SLOT(pauseResumeSend())); - - QPixmap preview; - File.file->seek(0); - if (preview.loadFromData(File.file->readAll())) - { - preview = preview.scaledToHeight(40); - pic->setPixmap(preview); - } - File.file->seek(0); - } - else - { - bottomright->setStyleSheet(acceptFileButtonStylesheet); - connect(topright, SIGNAL(clicked()), this, SLOT(rejectRecvRequest())); - connect(bottomright, SIGNAL(clicked()), this, SLOT(acceptRecvRequest())); - } - - QPalette toxgreen; - toxgreen.setColor(QPalette::Button, QColor(107,194,96)); // Tox Green - topright->setIconSize(QSize(10,10)); - topright->setMinimumSize(25,28); - topright->setFlat(true); - topright->setAutoFillBackground(true); - topright->setPalette(toxgreen); - bottomright->setIconSize(QSize(10,10)); - bottomright->setMinimumSize(25,28); - bottomright->setFlat(true); - bottomright->setAutoFillBackground(true); - bottomright->setPalette(toxgreen); - - mainLayout->addStretch(); - mainLayout->addWidget(pic); - mainLayout->addLayout(infoLayout,3); - mainLayout->addStretch(); - mainLayout->addWidget(buttonWidget); - mainLayout->setMargin(0); - mainLayout->setSpacing(0); - - infoLayout->addWidget(filename); - infoLayout->addLayout(textLayout); - infoLayout->addWidget(progress); - infoLayout->setMargin(4); - infoLayout->setSpacing(4); - - textLayout->addWidget(size); - textLayout->addStretch(0); - textLayout->addWidget(speed); - textLayout->addStretch(0); - textLayout->addWidget(eta); - textLayout->setMargin(2); - textLayout->setSpacing(5); - - buttonLayout->addWidget(topright); - buttonLayout->addSpacing(2); - buttonLayout->addWidget(bottomright); - buttonLayout->setContentsMargins(2,0,0,0); - buttonLayout->setSpacing(0); -} - -QString FileTransfertWidget::getHumanReadableSize(unsigned long long size) -{ - static const char* suffix[] = {"B","kiB","MiB","GiB","TiB"}; - int exp = 0; - if (size) - exp = std::min( (int) (log(size) / log(1024)), (int) (sizeof(suffix) / sizeof(suffix[0]) - 1)); - return QString().setNum(size / pow(1024, exp),'f',2).append(suffix[exp]); -} - -void FileTransfertWidget::onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection Direction) -{ - if (FileNum != fileNum || FriendId != friendId || Direction != direction) - return; - QDateTime newtime = QDateTime::currentDateTime(); - int timediff = lastUpdate.secsTo(newtime); - if (timediff <= 0) - return; - qint64 diff = BytesSent - lastBytesSent; - if (diff < 0) - { - qWarning() << "FileTransfertWidget::onFileTransferInfo: Negative transfer speed !"; - diff = 0; - } - long rawspeed = diff / timediff; - speed->setText(getHumanReadableSize(rawspeed)+"/s"); - size->setText(getHumanReadableSize(Filesize)); - if (!rawspeed) - return; - int etaSecs = (Filesize - BytesSent) / rawspeed; - QTime etaTime(0,0); - etaTime = etaTime.addSecs(etaSecs); - eta->setText(etaTime.toString("mm:ss")); - if (!Filesize) - { - progress->setValue(0); - qDebug() << QString("FT: received %1 bytes of an empty file, stop sending sequential devices, zetok!").arg(BytesSent); - } - else - { - progress->setValue(BytesSent*100/Filesize); - qDebug() << QString("FT: received %1/%2 bytes, progress is %3%").arg(BytesSent).arg(Filesize).arg(BytesSent*100/Filesize); - } - lastUpdate = newtime; - lastBytesSent = BytesSent; - emit stateUpdated(); -} - -void FileTransfertWidget::onFileTransferCancelled(int FriendId, int FileNum, ToxFile::FileDirection Direction) -{ - if (FileNum != fileNum || FriendId != friendId || Direction != direction) - return; - buttonLayout->setContentsMargins(0,0,0,0); - disconnect(topright); - disconnect(Widget::getInstance()->getCore(),0,this,0); - progress->hide(); - speed->hide(); - eta->hide(); - topright->hide(); - bottomright->hide(); - QPalette whiteText; - whiteText.setColor(QPalette::WindowText, Qt::white); - filename->setPalette(whiteText); - size->setPalette(whiteText); - this->setObjectName("error"); - this->style()->polish(this); - - //Toggle window visibility to fix draw order bug - this->hide(); - this->show(); - - emit stateUpdated(); -} - -void FileTransfertWidget::onFileTransferFinished(ToxFile File) -{ - if (File.fileNum != fileNum || File.friendId != friendId || File.direction != direction) - return; - topright->disconnect(); - disconnect(Widget::getInstance()->getCore(),0,this,0); - progress->hide(); - speed->hide(); - eta->hide(); - topright->hide(); - bottomright->hide(); - buttonLayout->setContentsMargins(0,0,0,0); - QPalette whiteText; - whiteText.setColor(QPalette::WindowText, Qt::white); - filename->setPalette(whiteText); - size->setPalette(whiteText); - this->setObjectName("success"); - this->style()->polish(this); - - //Toggle window visibility to fix draw order bug - this->hide(); - this->show(); - - if (File.direction == ToxFile::RECEIVING) - { - QPixmap preview; - QFile previewFile(File.filePath); - if (previewFile.open(QIODevice::ReadOnly) && previewFile.size() <= 1024*1024*25) // Don't preview big (>25MiB) images - { - if (preview.loadFromData(previewFile.readAll())) - { - preview = preview.scaledToHeight(40); - pic->setPixmap(preview); - } - previewFile.close(); - } - } - - emit stateUpdated(); -} - -void FileTransfertWidget::cancelTransfer() -{ - Widget::getInstance()->getCore()->cancelFileSend(friendId, fileNum); - emit stateUpdated(); -} - -void FileTransfertWidget::rejectRecvRequest() -{ - Widget::getInstance()->getCore()->rejectFileRecvRequest(friendId, fileNum); - onFileTransferCancelled(friendId, fileNum, direction); - emit stateUpdated(); -} - -// for whatever the fuck reason, QFileInfo::isWritable() always fails for files that don't exist -// which makes it useless for our case -// since QDir doesn't have an isWritable(), the only option I can think of is to make/delete the file -// surely this is a common problem that has a qt-implemented solution? -bool isWritable(QString& path) -{ - QFile file(path); - bool exists = file.exists(); - bool out = file.open(QIODevice::WriteOnly); - file.close(); - if (!exists) - file.remove(); - return out; -} - -void FileTransfertWidget::acceptRecvRequest() -{ - QString path; - while (true) - { - path = QFileDialog::getSaveFileName(this, tr("Save a file","Title of the file saving dialog"), QDir::current().filePath(filename->text())); - if (path.isEmpty()) - return; - else - { - //bool savable = QFileInfo(path).isWritable(); - //qDebug() << path << " is writable: " << savable; - //qDebug() << "/home/bill/bliss.pdf writable: " << QFileInfo("/home/bill/bliss.pdf").isWritable(); - if (isWritable(path)) - break; - else - QMessageBox::warning(this, tr("Location not writable","Title of permissions popup"), tr("You do not have permission to write that location. Choose another, or cancel the save dialog.", "text of permissions popup")); - } - } - - savePath = path; - - bottomright->setStyleSheet(pauseFileButtonStylesheet); - bottomright->disconnect(); - connect(bottomright, SIGNAL(clicked()), this, SLOT(pauseResumeRecv())); - Widget::getInstance()->getCore()->acceptFileRecvRequest(friendId, fileNum, path); - - emit stateUpdated(); -} - -void FileTransfertWidget::pauseResumeRecv() -{ - Widget::getInstance()->getCore()->pauseResumeFileRecv(friendId, fileNum); - emit stateUpdated(); -} - -void FileTransfertWidget::pauseResumeSend() -{ - Widget::getInstance()->getCore()->pauseResumeFileSend(friendId, fileNum); - emit stateUpdated(); -} - -void FileTransfertWidget::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); - emit stateUpdated(); -} - -QString FileTransfertWidget::getHtmlImage() -{ - qDebug() << "QString FileTransfertWidget::getHtmlImage()"; - auto QImage2base64 = [](const QImage &img) - { - QByteArray ba; - QBuffer buffer(&ba); - buffer.open(QIODevice::WriteOnly); - img.save(&buffer, "PNG"); // writes image into ba in PNG format - return ba.toBase64(); - }; - - auto renderButton = [](QPushButton *pb) - { - QImage bitmap(pb->size(), QImage::Format_ARGB32); - bitmap.fill(Qt::transparent); - QPainter painter(&bitmap); - - pb->render(&painter, QPoint(), QRegion(), QWidget::DrawChildren); - return bitmap; - }; - - // QImage rightUp = renderButton(topright); - // QImage rightDown = renderButton(bottomright); - QImage rightUp(":ui/stopFileButton/default.png"); - QImage rightDown(":ui/acceptFileButton/default.png"); - - QString res; - QString widgetId = QString::number(getId()); - QString strUp = ""; - QString strDown = ""; - - res = "\n"; - res += "\n\n\n\n"; - res += "
\n"; - res += "
\n"; - res += "
\n"; - if (topright->isVisible() && bottomright->isVisible()) - res += "
" + strUp + "
" + strDown + "
\n"; - res += "
\n"; - return res; -} - -void FileTransfertWidget::pressFromHtml(QString code) -{ - if (code == "top") - topright->clicked(); - else if (code == "bottom") - bottomright->clicked(); -} diff --git a/widget/filetransfertwidget.h b/widget/filetransfertwidget.h deleted file mode 100644 index def939354..000000000 --- a/widget/filetransfertwidget.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright (C) 2014 by Project Tox - - 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. -*/ - -#ifndef FILETRANSFERTWIDGET_H -#define FILETRANSFERTWIDGET_H - -#include -#include -#include -#include -#include -#include -#include - -#include "core.h" - -struct ToxFile; - -class FileTransfertWidget : public QWidget -{ - Q_OBJECT - -public: - FileTransfertWidget(ToxFile File); - QString getHtmlImage(); - uint getId(){return id;} - -public slots: - void onFileTransferInfo(int FriendId, int FileNum, int64_t Filesize, int64_t BytesSent, ToxFile::FileDirection Direction); - void onFileTransferCancelled(int FriendId, int FileNum, ToxFile::FileDirection Direction); - void onFileTransferFinished(ToxFile File); - - void pressFromHtml(QString); - -signals: - void stateUpdated(); - -private slots: - void cancelTransfer(); - void rejectRecvRequest(); - void acceptRecvRequest(); - void pauseResumeRecv(); - void pauseResumeSend(); - -private: - QString getHumanReadableSize(unsigned long long size); - -private: - static uint Idconter; - uint id; - - - QLabel *pic, *filename, *size, *speed, *eta; - QPushButton *topright, *bottomright; - QProgressBar *progress; - QHBoxLayout *mainLayout, *textLayout; - QVBoxLayout *infoLayout, *buttonLayout; - QWidget* buttonWidget; - QDateTime lastUpdate; - long long lastBytesSent; - int fileNum; - int friendId; - QString savePath; - ToxFile::FileDirection direction; - QString stopFileButtonStylesheet, pauseFileButtonStylesheet, acceptFileButtonStylesheet; - void paintEvent(QPaintEvent *); -}; - -#endif // FILETRANSFERTWIDGET_H diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 7825c2cbb..1490caa50 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -17,8 +17,8 @@ #include "chatform.h" #include "friend.h" #include "widget/friendwidget.h" +#include "filetransferinstance.h" #include "widget/widget.h" -#include "widget/filetransfertwidget.h" #include #include #include @@ -44,6 +44,7 @@ ChatForm::ChatForm(Friend* chatFriend) connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered); connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle())); connect(newChatForm, SIGNAL(onFileTranfertInterract(QString,QString)), this, SLOT(onFileTansBtnClicked(QString,QString))); + connect(newChatForm->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); } ChatForm::~ChatForm() diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index efbfed001..caa323ca7 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -31,7 +31,7 @@ GenericChatForm::GenericChatForm(QObject *parent) : lockSliderToBottom = true; curRow = 0; - mainWidget = new QWidget(); headWidget = new QWidget(); chatAreaWidget = new QWidget(); + mainWidget = new QWidget(); headWidget = new QWidget(); nameLabel = new QLabel(); avatarLabel = new QLabel(); @@ -39,7 +39,6 @@ GenericChatForm::GenericChatForm(QObject *parent) : headTextLayout = new QVBoxLayout(); QVBoxLayout *mainLayout = new QVBoxLayout(); QVBoxLayout *footButtonsSmall = new QVBoxLayout(), *volMicLayout = new QVBoxLayout(); - mainChatLayout = new QGridLayout(); newChatForm = new ChatAreaWidget(); newChatForm->document()->setDefaultStyleSheet(Style::get(":ui/chatArea/innerStyle.css")); @@ -56,23 +55,10 @@ GenericChatForm::GenericChatForm(QObject *parent) : volButton = new QPushButton(); micButton = new QPushButton(); - chatArea = new QScrollArea(); - QFont bold; bold.setBold(true); nameLabel->setFont(bold); - chatAreaWidget->setLayout(mainChatLayout); - chatAreaWidget->setStyleSheet(Style::get(":/ui/chatArea/chatArea.css")); - - chatArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); - chatArea->setWidgetResizable(true); - chatArea->setContextMenuPolicy(Qt::CustomContextMenu); - chatArea->setFrameStyle(QFrame::NoFrame); - - mainChatLayout->setColumnStretch(1,1); - mainChatLayout->setSpacing(5); - footButtonsSmall->setSpacing(2); msgEdit->setStyleSheet(Style::get(":/ui/msgEdit/msgEdit.css")); @@ -116,7 +102,6 @@ GenericChatForm::GenericChatForm(QObject *parent) : micButton->setStyleSheet(micButtonStylesheet); mainWidget->setLayout(mainLayout); - mainLayout->addWidget(chatArea); mainLayout->addWidget(newChatForm); mainLayout->addLayout(mainFootLayout); mainLayout->setMargin(0); @@ -144,8 +129,6 @@ GenericChatForm::GenericChatForm(QObject *parent) : headTextLayout->addStretch(); headTextLayout->addWidget(nameLabel); - chatArea->setWidget(chatAreaWidget); - //Fix for incorrect layouts on OS X as per //https://bugreports.qt-project.org/browse/QTBUG-14591 sendButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h index da891fc2b..f8b047ef3 100644 --- a/widget/form/genericchatform.h +++ b/widget/form/genericchatform.h @@ -65,10 +65,8 @@ protected slots: protected: QLabel *nameLabel, *avatarLabel; - QWidget *mainWidget, *headWidget, *chatAreaWidget; - QScrollArea *chatArea; + QWidget *mainWidget, *headWidget; QPushButton *fileButton, *emoteButton, *callButton, *videoButton, *volButton, *micButton; - QGridLayout *mainChatLayout; QVBoxLayout *headTextLayout; ChatTextEdit *msgEdit; QPushButton *sendButton; diff --git a/widget/form/groupchatform.cpp b/widget/form/groupchatform.cpp index e444e0ac3..ca355e3db 100644 --- a/widget/form/groupchatform.cpp +++ b/widget/form/groupchatform.cpp @@ -48,9 +48,6 @@ GroupChatForm::GroupChatForm(Group* chatGroup) msgEdit->setObjectName("group"); - mainChatLayout->setColumnStretch(1,1); - mainChatLayout->setHorizontalSpacing(10); - headTextLayout->addWidget(nusersLabel); headTextLayout->addWidget(namesList); headTextLayout->setMargin(0); From b68cc66ede517aea8dd618c124f678776269b350 Mon Sep 17 00:00:00 2001 From: apprb Date: Sun, 7 Sep 2014 00:10:48 +0700 Subject: [PATCH 09/46] scroll fix --- widget/form/chatform.cpp | 1 - widget/form/genericchatform.cpp | 12 ++++-------- widget/form/genericchatform.h | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index 1490caa50..efaa6219a 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -44,7 +44,6 @@ ChatForm::ChatForm(Friend* chatFriend) connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered); connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle())); connect(newChatForm, SIGNAL(onFileTranfertInterract(QString,QString)), this, SLOT(onFileTansBtnClicked(QString,QString))); - connect(newChatForm->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); } ChatForm::~ChatForm() diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index caa323ca7..d200963ef 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -137,7 +137,6 @@ GenericChatForm::GenericChatForm(QObject *parent) : connect(emoteButton, SIGNAL(clicked()), this, SLOT(onEmoteButtonClicked())); connect(newChatForm, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); - connect(newChatForm->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(onSliderRangeChanged())); } void GenericChatForm::setName(const QString &newName) @@ -163,13 +162,6 @@ void GenericChatForm::onChatContextMenuRequested(QPoint pos) menu.exec(pos); } -void GenericChatForm::onSliderRangeChanged() -{ - QScrollBar* scroll = newChatForm->verticalScrollBar(); - if (lockSliderToBottom) - scroll->setValue(scroll->maximum()); -} - void GenericChatForm::onSaveLogClicked() { QString path = QFileDialog::getSaveFileName(0, tr("Save chat log")); @@ -250,4 +242,8 @@ void GenericChatForm::updateChatContent() lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); newChatForm->setHtml(getHtmledMessages()); + if (lockSliderToBottom) + sliderPosition = scroll->maximum(); + + scroll->setValue(sliderPosition); } diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h index f8b047ef3..8c6b67f4b 100644 --- a/widget/form/genericchatform.h +++ b/widget/form/genericchatform.h @@ -57,7 +57,6 @@ public slots: protected slots: void onChatContextMenuRequested(QPoint pos); - void onSliderRangeChanged(); void onSaveLogClicked(); void onEmoteButtonClicked(); void onEmoteInsertRequested(QString str); @@ -74,6 +73,7 @@ protected: ChatAreaWidget *newChatForm; int curRow; bool lockSliderToBottom; + int sliderPosition; QList messages; From 9970fe293da30816964eb86ba24a22c7c3adec1c Mon Sep 17 00:00:00 2001 From: apprb Date: Sun, 7 Sep 2014 00:28:26 +0700 Subject: [PATCH 10/46] files renaming --- qtox.pro | 4 ++-- widget/form/genericchatform.h | 2 +- widget/tool/{genericchataction.cpp => chataction.cpp} | 2 +- widget/tool/{genericchataction.h => chataction.h} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename widget/tool/{genericchataction.cpp => chataction.cpp} (99%) rename widget/tool/{genericchataction.h => chataction.h} (100%) diff --git a/qtox.pro b/qtox.pro index c690e8727..05f1c16ce 100644 --- a/qtox.pro +++ b/qtox.pro @@ -102,7 +102,7 @@ HEADERS += widget/form/addfriendform.h \ widget/friendlistwidget.h \ widget/genericchatroomwidget.h \ widget/form/genericchatform.h \ - widget/tool/genericchataction.h \ + widget/tool/chataction.h \ widget/chatareawidget.h \ filetransferinstance.h @@ -138,6 +138,6 @@ SOURCES += \ coreav.cpp \ widget/genericchatroomwidget.cpp \ widget/form/genericchatform.cpp \ - widget/tool/genericchataction.cpp \ + widget/tool/chataction.cpp \ widget/chatareawidget.cpp \ filetransferinstance.cpp diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h index 8c6b67f4b..a6ef6d8f5 100644 --- a/widget/form/genericchatform.h +++ b/widget/form/genericchatform.h @@ -30,7 +30,7 @@ #include "widget/chatareawidget.h" #include "widget/tool/chattextedit.h" -#include "widget/tool/genericchataction.h" +#include "widget/tool/chataction.h" // Spacing in px inserted when the author of the last message changes #define AUTHOR_CHANGE_SPACING 5 diff --git a/widget/tool/genericchataction.cpp b/widget/tool/chataction.cpp similarity index 99% rename from widget/tool/genericchataction.cpp rename to widget/tool/chataction.cpp index c42721791..4735b3aa5 100644 --- a/widget/tool/genericchataction.cpp +++ b/widget/tool/chataction.cpp @@ -14,7 +14,7 @@ See the COPYING file for more details. */ -#include "genericchataction.h" +#include "chataction.h" #include "smileypack.h" #include #include diff --git a/widget/tool/genericchataction.h b/widget/tool/chataction.h similarity index 100% rename from widget/tool/genericchataction.h rename to widget/tool/chataction.h From b3d6102a202cd124d0e495fed800199ea3504c3b Mon Sep 17 00:00:00 2001 From: apprb Date: Sun, 7 Sep 2014 12:52:01 +0700 Subject: [PATCH 11/46] code cleanup: html creation code moved to the separated functions --- filetransferinstance.cpp | 135 +++++++++++++++++++++------------------ filetransferinstance.h | 4 ++ 2 files changed, 77 insertions(+), 62 deletions(-) diff --git a/filetransferinstance.cpp b/filetransferinstance.cpp index 472fed501..646daedf0 100644 --- a/filetransferinstance.cpp +++ b/filetransferinstance.cpp @@ -201,19 +201,18 @@ void FileTransferInstance::pauseResumeSend() emit stateUpdated(); } +QString FileTransferInstance::QImage2base64(const QImage &img) +{ + QByteArray ba; + QBuffer buffer(&ba); + buffer.open(QIODevice::WriteOnly); + img.save(&buffer, "PNG"); // writes image into ba in PNG format + return ba.toBase64(); +} + QString FileTransferInstance::getHtmlImage() { qDebug() << "QString FileTransferInstance::getHtmlImage()"; - auto QImage2base64 = [](const QImage &img) - { - QByteArray ba; - QBuffer buffer(&ba); - buffer.open(QIODevice::WriteOnly); - img.save(&buffer, "PNG"); // writes image into ba in PNG format - return ba.toBase64(); - }; - - QString widgetId = QString::number(getId()); QString res; if (state == tsPending || state == tsProcessing || state == tsPaused) @@ -225,58 +224,13 @@ QString FileTransferInstance::getHtmlImage() else rightDown = QImage(":ui/acceptFileButton/default.png"); - QString strUp = ""; - QString strDown = ""; - - res = "\n"; - res += "\n"; - res += "\n"; - if (pic != QImage()) - { - res += "\n"; - } - res += "\n"; - res += "\n"; - res += "\n"; - res += "
\n"; - res += "
" + strUp + "
\n"; - res += "
\n"; - res += ""; - res += "\n"; - res += "
"; - res += "

" + filename + "

"; - res += "

" + getHumanReadableSize(lastBytesSent) + " / " + size; + " (" + speed + ")

\n"; - res += "
\n"; - res += "
\n"; - res += "
" + strDown + "
\n"; - res += "
\n"; - + res = draw2ButtonsForm("green", rightUp, rightDown); } else if (state == tsCanceled) { - res = "\n\n"; - if (pic != QImage()) - { - res += "\n"; - } - res += "\n\n"; - res += "
\n"; - res += ""; - res += "\n"; - res += "

" + filename + "

" + size + "

\n"; - res += "
\n"; + res = drawButtonlessForm("red"); } else if (state == tsFinished) { - res = "\n\n"; - if (pic != QImage()) - { - res += "\n"; - } - res += "\n\n"; - res += "
\n"; - res += ""; - res += "\n"; - res += "

" + filename + "

" + size + "

\n"; - res += "
\n"; + res = drawButtonlessForm("green"); } return res; @@ -289,14 +243,14 @@ void FileTransferInstance::pressFromHtml(QString code) if (direction == ToxFile::SENDING) { - if (code == "top") + if (code == "btnA") cancelTransfer(); - else if (code == "bottom") + else if (code == "btnB") pauseResumeSend(); } else { - if (code == "top") + if (code == "btnA") rejectRecvRequest(); - else if (code == "bottom") + else if (code == "btnB") { if (state == tsPending) acceptRecvRequest(); @@ -305,3 +259,60 @@ void FileTransferInstance::pressFromHtml(QString code) } } } + +QString FileTransferInstance::drawButtonlessForm(const QString &type) +{ + QString res; + + res = "\n\n"; + res += insertMiniature(); + res += "\n\n"; + res += "
\n"; + res += "

" + filename + "

" + size + "

\n"; + res += "
\n"; + + return res; +} + +QString FileTransferInstance::insertMiniature() +{ + if (pic == QImage()) + return QString(); + + QString widgetId = QString::number(getId()); + + QString res; + res = "
\n"; + res += ""; + res += "
\n"; + res += "\n"; + res += "\n"; + res += insertMiniature(); + res += "\n"; + res += "\n"; + res += "\n"; + res += "
\n"; + res += "
" + imgAstr + "
\n"; + res += "
\n"; + res += "
"; + res += "

" + filename + "

"; + res += "

" + getHumanReadableSize(lastBytesSent) + " / " + size; + " (" + speed + ")

\n"; + res += "
\n"; + res += "
\n"; + res += "
" + imgBstr + "
\n"; + res += "
\n"; + + return res; +} diff --git a/filetransferinstance.h b/filetransferinstance.h index 27345ba58..5b8d791e6 100644 --- a/filetransferinstance.h +++ b/filetransferinstance.h @@ -54,6 +54,10 @@ private slots: private: QString getHumanReadableSize(unsigned long long size); + QString QImage2base64(const QImage &img); + QString drawButtonlessForm(const QString &type); + QString draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB); + QString insertMiniature(); private: enum TransfState {tsPending, tsProcessing, tsPaused, tsFinished, tsCanceled}; From 0a1eaac9a4cc587dbc363ea4e4bb6bc7de2f2191 Mon Sep 17 00:00:00 2001 From: apprb Date: Sun, 7 Sep 2014 15:04:42 +0700 Subject: [PATCH 12/46] filetransferinstance should use own pictures --- filetransferinstance.cpp | 49 ++++++++++++------ filetransferinstance.h | 1 + res.qrc | 8 +++ ui/chatArea/innerStyle.css | 1 - ui/fileTransferInstance/acceptFileButton.png | Bin 0 -> 490 bytes .../emptyLGreenFileButton.png | Bin 0 -> 259 bytes .../emptyLRedFileButton.png | Bin 0 -> 258 bytes .../emptyRGreenFileButton.png | Bin 0 -> 270 bytes .../emptyRRedFileButton.png | Bin 0 -> 268 bytes ui/fileTransferInstance/pauseFileButton.png | Bin 0 -> 353 bytes ui/fileTransferInstance/resumeFileButton.png | Bin 0 -> 273 bytes ui/fileTransferInstance/stopFileButton.png | Bin 0 -> 557 bytes 12 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 ui/fileTransferInstance/acceptFileButton.png create mode 100644 ui/fileTransferInstance/emptyLGreenFileButton.png create mode 100644 ui/fileTransferInstance/emptyLRedFileButton.png create mode 100644 ui/fileTransferInstance/emptyRGreenFileButton.png create mode 100644 ui/fileTransferInstance/emptyRRedFileButton.png create mode 100644 ui/fileTransferInstance/pauseFileButton.png create mode 100644 ui/fileTransferInstance/resumeFileButton.png create mode 100644 ui/fileTransferInstance/stopFileButton.png diff --git a/filetransferinstance.cpp b/filetransferinstance.cpp index 646daedf0..6b9a39250 100644 --- a/filetransferinstance.cpp +++ b/filetransferinstance.cpp @@ -217,14 +217,16 @@ QString FileTransferInstance::getHtmlImage() QString res; if (state == tsPending || state == tsProcessing || state == tsPaused) { - QImage rightUp(":ui/stopFileButton/default.png"); - QImage rightDown; + QImage leftBtnImg(":/ui/fileTransferInstance/stopFileButton.png"); + QImage rightBtnImg; if (state == tsProcessing) - rightDown = QImage(":ui/pauseFileButton/default.png"); + rightBtnImg = QImage(":/ui/fileTransferInstance/pauseFileButton.png"); + else if (state == tsPaused) + rightBtnImg = QImage(":/ui/fileTransferInstance/resumeFileButton.png"); else - rightDown = QImage(":ui/acceptFileButton/default.png"); + rightBtnImg = QImage(":/ui/fileTransferInstance/acceptFileButton.png"); - res = draw2ButtonsForm("green", rightUp, rightDown); + res = draw2ButtonsForm("green", leftBtnImg, rightBtnImg); } else if (state == tsCanceled) { res = drawButtonlessForm("red"); @@ -262,16 +264,21 @@ void FileTransferInstance::pressFromHtml(QString code) QString FileTransferInstance::drawButtonlessForm(const QString &type) { - QString res; + QString imgAStr; + QString imgBStr; - res = "\n\n"; - res += insertMiniature(); - res += "\n\n"; - res += "
\n"; - res += "

" + filename + "

" + size + "

\n"; - res += "
\n"; + if (type == "red") + { + imgAStr = ""; + imgBStr = ""; + } else { + imgAStr = ""; + imgBStr = ""; + } - return res; + QString content = "

" + filename + "

" + size + "

"; + + return wrapIntoForm(content, type, imgAStr, imgBStr); } QString FileTransferInstance::insertMiniature() @@ -290,12 +297,21 @@ QString FileTransferInstance::insertMiniature() QString FileTransferInstance::draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB) { - QString res; - QString widgetId = QString::number(getId()); QString imgAstr = ""; QString imgBstr = ""; + QString content; + content += "

" + filename + "

"; + content += "

" + getHumanReadableSize(lastBytesSent) + " / " + size; + " (" + speed + ")

\n"; + + return wrapIntoForm(content, type, imgAstr, imgBstr); +} + +QString FileTransferInstance::wrapIntoForm(const QString& content, const QString &type, const QString &imgAstr, const QString &imgBstr) +{ + QString res; + res = "\n"; res += "\n"; res += "\n"; res += "\n"; - return res; + if (isMe) + return QString("\n"); + else + return QString("\n"); } QString ChatAction::wrapDate(const QString &date) @@ -63,7 +65,8 @@ QString ChatAction::wrapWholeLine(const QString &line) return res; } -MessageAction::MessageAction(const QString &author, const QString &message, const QString &date) +MessageAction::MessageAction(const QString &author, const QString &message, const QString &date, const bool &me) : + ChatAction(me) { QString message_ = SmileyPack::getInstance().smileyfied(toHtmlChars(message)); @@ -86,7 +89,8 @@ QString MessageAction::getHtml() return content; } -FileTransferAction::FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date) : +FileTransferAction::FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date, const bool &me) : + ChatAction(me), sender(author), timestamp(date) { diff --git a/widget/tool/chataction.h b/widget/tool/chataction.h index ebe531c70..0e6d8ac87 100644 --- a/widget/tool/chataction.h +++ b/widget/tool/chataction.h @@ -23,6 +23,7 @@ class ChatAction { public: + ChatAction(const bool &me) : isMe(me) {;} virtual ~ChatAction(){;} virtual QString getHtml() = 0; @@ -34,12 +35,15 @@ protected: virtual QString wrapDate(const QString &date); virtual QString wrapMessage(const QString &message); virtual QString wrapWholeLine(const QString &line); + +private: + bool isMe; }; class MessageAction : public ChatAction { public: - MessageAction(const QString &author, const QString &message, const QString &date); + MessageAction(const QString &author, const QString &message, const QString &date, const bool &me); virtual ~MessageAction(){;} virtual QString getHtml(); @@ -50,7 +54,7 @@ private: class FileTransferAction : public ChatAction { public: - FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date); + FileTransferAction(FileTransferInstance *widget, const QString &author, const QString &date, const bool &me); virtual ~FileTransferAction(); virtual QString getHtml(); virtual QString wrapMessage(const QString &message); From 4406892d507ea251709f46c83d83541deaf0aac1 Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Sun, 7 Sep 2014 15:55:36 +0200 Subject: [PATCH 16/46] Italian translation: fix typo --- translations/it.qm | Bin 6053 -> 6055 bytes translations/it.ts | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/it.qm b/translations/it.qm index f62f3726c032f119124a367a83cf8f13405a911e..4fdfacd63a23248d09abbe664b028f2a1bfbdb6f 100644 GIT binary patch delta 147 zcmZ3gzg&NUjG`(7%bb-A45C2{tRAKe3_@KD?AaL%3)D9{$Fo@irXsga>FfrAi z@zBJr@|s<&_8BS+42(RisRph-pi=ZCYTA-vu^Vz#w7y0G7KRM`3w~dnGAUh>6;e{v9JOFl)5FZ delta 145 zcmZ3kzf^yMjG{6F%bb-A459%HtRAKe3_=|Y?AaL%3<6IW)D9{$Fo@ipXsgbsH!;

xDq}w5g~?MH)fu-=-pi=Z#-9n)vu5)r#w7yWQVbys`3w~dnGAWG7Ynhl0sugsB_#j= diff --git a/translations/it.ts b/translations/it.ts index 13bcf01fd..af860d4d8 100644 --- a/translations/it.ts +++ b/translations/it.ts @@ -246,7 +246,7 @@ Your status - Toxin on qTox + Toxing on qTox From f0b34dc40d7c51d1073a7c7b3e974ffbcd74cfdd Mon Sep 17 00:00:00 2001 From: apprb Date: Sun, 7 Sep 2014 23:14:06 +0700 Subject: [PATCH 17/46] filetransfer: original buttons positions --- filetransferinstance.cpp | 19 ++++++++---------- filetransferinstance.h | 2 +- ui/fileTransferInstance/acceptFileButton.png | Bin 490 -> 449 bytes .../emptyLGreenFileButton.png | Bin 259 -> 236 bytes .../emptyLRedFileButton.png | Bin 258 -> 229 bytes .../emptyRGreenFileButton.png | Bin 270 -> 216 bytes .../emptyRRedFileButton.png | Bin 268 -> 211 bytes ui/fileTransferInstance/pauseFileButton.png | Bin 353 -> 308 bytes ui/fileTransferInstance/resumeFileButton.png | Bin 273 -> 244 bytes ui/fileTransferInstance/stopFileButton.png | Bin 557 -> 516 bytes 10 files changed, 9 insertions(+), 12 deletions(-) diff --git a/filetransferinstance.cpp b/filetransferinstance.cpp index 274f55f1e..e927545c6 100644 --- a/filetransferinstance.cpp +++ b/filetransferinstance.cpp @@ -44,7 +44,7 @@ FileTransferInstance::FileTransferInstance(ToxFile File) File.file->seek(0); if (preview.loadFromData(File.file->readAll())) { - pic = preview.scaledToHeight(40); + pic = preview.scaledToHeight(50); } File.file->seek(0); } @@ -113,7 +113,7 @@ void FileTransferInstance::onFileTransferFinished(ToxFile File) { if (preview.loadFromData(previewFile.readAll())) { - pic = preview.scaledToHeight(40); + pic = preview.scaledToHeight(50); } previewFile.close(); } @@ -280,7 +280,7 @@ QString FileTransferInstance::drawButtonlessForm(const QString &type) return wrapIntoForm(content, type, imgAStr, imgBStr); } -QString FileTransferInstance::insertMiniature() +QString FileTransferInstance::insertMiniature(const QString &type) { if (pic == QImage()) return QString(); @@ -288,9 +288,9 @@ QString FileTransferInstance::insertMiniature() QString widgetId = QString::number(getId()); QString res; - res = "

\n"; + res += "\n"; return res; } @@ -311,19 +311,16 @@ QString FileTransferInstance::wrapIntoForm(const QString& content, const QString { QString res; - res = "
\n"; @@ -304,8 +320,7 @@ QString FileTransferInstance::draw2ButtonsForm(const QString &type, const QImage res += insertMiniature(); res += "\n"; res += "
"; - res += "

" + filename + "

"; - res += "

" + getHumanReadableSize(lastBytesSent) + " / " + size; + " (" + speed + ")

\n"; + res += content; res += "
\n"; res += "
\n"; diff --git a/filetransferinstance.h b/filetransferinstance.h index 5b8d791e6..2306129ee 100644 --- a/filetransferinstance.h +++ b/filetransferinstance.h @@ -58,6 +58,7 @@ private: QString drawButtonlessForm(const QString &type); QString draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB); QString insertMiniature(); + QString wrapIntoForm(const QString &content, const QString &type, const QString &imgAstr, const QString &imgBstr); private: enum TransfState {tsPending, tsProcessing, tsPaused, tsFinished, tsCanceled}; diff --git a/res.qrc b/res.qrc index 7cd8ca7ff..508fbef28 100644 --- a/res.qrc +++ b/res.qrc @@ -126,5 +126,13 @@ ui/micButton/micButtonPressed.png ui/micButton/micButton.css ui/volButton/volButton.css + ui/fileTransferInstance/acceptFileButton.png + ui/fileTransferInstance/pauseFileButton.png + ui/fileTransferInstance/resumeFileButton.png + ui/fileTransferInstance/stopFileButton.png + ui/fileTransferInstance/emptyLGreenFileButton.png + ui/fileTransferInstance/emptyLRedFileButton.png + ui/fileTransferInstance/emptyRGreenFileButton.png + ui/fileTransferInstance/emptyRRedFileButton.png diff --git a/ui/chatArea/innerStyle.css b/ui/chatArea/innerStyle.css index e45691330..22af8bc92 100644 --- a/ui/chatArea/innerStyle.css +++ b/ui/chatArea/innerStyle.css @@ -50,7 +50,6 @@ div.button { margin-bottom: 0px; margin-left: 0px; color: #ffffff; - background-color: #6bc260; } div.red { diff --git a/ui/fileTransferInstance/acceptFileButton.png b/ui/fileTransferInstance/acceptFileButton.png new file mode 100644 index 0000000000000000000000000000000000000000..a3d1f1c005d78e9832a59e1d2a1043d54c7ad0b4 GIT binary patch literal 490 zcmVP001Zm1^@s63(rw&00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY4#WTe4#WYKD-Ig~000McNliru-U$Z>00@7x6Mz5!0e4A6 zK~zY`?bp3aLQxpU@$WUkw;_~3)3l|REof+HP^id^BIrMGs7Y$=4-uyt{1aNrC`=L> znu7+#s8GYCB7D8(OOxOb>eYMibbssN@ZmfU&*2;)lni!|Cv_kN#DH+b7tM7SbjTMY zumqd{=}Q-Wo2>>L z>#i-tmPjIZO{H0u7qJ>__}#m#+P$-1!P(!5u5qxHl%VH^lN zeLZsVcFtS*MLOazI|+F9Se{xzK9xs>4g6`i_9WODV&qdq*~k`C9}8Hf93Y%?|8l2Y_UtZ%-O+k-L1Hc=n3&Z)s#; z;GA?J0GGu>B7ZFz7-|?BZIPSorFKDTh=wSex*AAI4J4*CQUk(DBgYY6G^bPW1cwn{ g^la>R*RWsgKk{;&%Tg~t=l}o!07*qoM6N<$g0&6HH~;_u literal 0 HcmV?d00001 diff --git a/ui/fileTransferInstance/emptyLGreenFileButton.png b/ui/fileTransferInstance/emptyLGreenFileButton.png new file mode 100644 index 0000000000000000000000000000000000000000..9e0aa60b6fe46323c2b5708ff1ae79243dc2187d GIT binary patch literal 259 zcmeAS@N?(olHy`uVBq!ia0vp^l0dA%!3HF`&j)4$DYhhUcNd2LAh=-f^2tCE&H|6f zVg?4jBOuH;Rhv&5D9B#o>FdgVkCUC>%LwaJxp3 zbIqv(msynpc{J4|ML2eK_)9JbW}Y}B`59M2xWWJI2ea=+7rTZ1&Ryrge&qnKhNZ&k z2I~(@dNOlT4>SZ%3)@oRvmtzmc>#0Tl4CoSVkcS$xhZf6D!FtBC_1%pSn_}BcX-C} zM7VKJ<5kg@t6#F)++DwV{W8Id3f~mL_&2;8{3I;@A30kMbQ^=GtDnm{r-UW|Kw4QG literal 0 HcmV?d00001 diff --git a/ui/fileTransferInstance/emptyLRedFileButton.png b/ui/fileTransferInstance/emptyLRedFileButton.png new file mode 100644 index 0000000000000000000000000000000000000000..946593dfc84527e889a6691ed1c74c284bdce02b GIT binary patch literal 258 zcmeAS@N?(olHy`uVBq!ia0vp^l0dA%!3HF`&j)4$DYhhUcNc~e41NrLr`@ht07W

(|XVv92WNF>x_i;n)wgd-gq3^xh!U)^(8k24nZZC4gp1{77k1PPu&i7 zf+u7eeGWY9`eM2Mz>B)r+H?62-kDBxt=ahB=8X8hB(9m(K<yy85}Sb4q9e00KKz Ah5!Hn literal 0 HcmV?d00001 diff --git a/ui/fileTransferInstance/emptyRGreenFileButton.png b/ui/fileTransferInstance/emptyRGreenFileButton.png new file mode 100644 index 0000000000000000000000000000000000000000..a4725df5a06cd9817f9aa14894b9d731355fc642 GIT binary patch literal 270 zcmeAS@N?(olHy`uVBq!ia0vp^l0dA%!3HF`&j)4$DYhhUcNd2LAh=-f^2tCE&H|6f zVg?4jBOuH;Rhv&5D9B#o>FdgVkCUC<(3s=tUooK2Y)==*5Rc<;uPgF3I|w*jJim;I z&ndNk!@lhfTe=$FI-Xb+_D1)EOmo&b20jtard@Ld&(>H!N>$4?Tiu?e>dS4wWP5>C zetGQ!k8r*_4dNfxw!czrl+kYZ&X>x0zVsT;6uz5W3nscTypuW+%6!sPfXDENfHQ>n zDW7uD!HsvxbhoqxlihATc>ILLyn;>Mo?-fw^)IfAS2M@FR$3DhsrVY`Oa@O^KbLh* G2~7ZSfLy=; literal 0 HcmV?d00001 diff --git a/ui/fileTransferInstance/emptyRRedFileButton.png b/ui/fileTransferInstance/emptyRRedFileButton.png new file mode 100644 index 0000000000000000000000000000000000000000..92effd3ace65559dbcd8178d0a64a819e7718812 GIT binary patch literal 268 zcmeAS@N?(olHy`uVBq!ia0vp^l0dA%!3HF`&j)4$DYhhUcNc~e41NrLr`@ht07W

E;BfK0 zFN??|k1tyrc4`Sp>a;32i)LpuN_8w_E9gvObG-Am>rCD5M`z#7*_q_^(s`a)0-M`{ zex=iP98XrWWG!I67wlEe`y_&OPuYqS73(&KJ&?MvmTBHC4u|B%J313CF&z|imnl2~ zCMN!OG~-U$=HQl_!djKPq*uv1;LZa literal 0 HcmV?d00001 diff --git a/ui/fileTransferInstance/pauseFileButton.png b/ui/fileTransferInstance/pauseFileButton.png new file mode 100644 index 0000000000000000000000000000000000000000..144f763b319a2fdab6493378c23861512a551886 GIT binary patch literal 353 zcmeAS@N?(olHy`uVBq!ia0vp^l0dA%!3HF`&j)4$DYhhUcNd2LAh=-f^2tCE&H|6f zVg?4jBOuH;Rhv&5D9B#o>FdgVkCUCvO8e*jYkPn~?>t=`Lp+YZy}ps}po7fukNLCt z!n3UnH-F^dW$xT=V8FRLeZwR_o?32B=8s%v&t}~U&7WZ4$>F%9y!-ds{|_hcKK=Le z|LDKD&zdZ5}@6l)tWN zW3IZqLA~bl2ezNT&(Ao;!p&WIZk~F}=gttdB}P9xR?G`Kb6EO_LcE^4)r7r#DGQ}e vHmuA_kzfnV(YA5a=UMdgc-Z{wUA3$my&N1>vklFGK4bP0l+XkKSu~2@ literal 0 HcmV?d00001 diff --git a/ui/fileTransferInstance/resumeFileButton.png b/ui/fileTransferInstance/resumeFileButton.png new file mode 100644 index 0000000000000000000000000000000000000000..ec97328e98e281c5dfe77ff8f29bc577d3d34c0a GIT binary patch literal 273 zcmeAS@N?(olHy`uVBq!ia0vp^l0dA%!2%=~9-H|9NHHaOySp&_Z|^^|AIRe@@Q5sC zVBk9f!i-b3`J{n@>?NMQuI%?X+1c5YJ_XfY017Sgba4!^IQ{nOM&4!vf!2re+8&Pc zl;2D=lCEf2!gD&HjqyfP001Zm1^@s63(rw&00006VoOIv0RI60 z0RN!9r;`8x010qNS#tmY4#WTe4#WYKD-Ig~000McNliru-U$Z>0S=GLhx7md0lG;< zK~zY`?bp9+6JZ?3@%M9y%_XMf7lr<1YAcMF*#lrWi2OF&lX{jh7ZK)=qNzTFKxFR%dlDnbYXFHC2UVNYD!*M6jWaaH*2v`O3 zKpc=6L4*ca0v-Z(MjW959-~u4cZ)vjF+nd<_Y8CcdPp9fBXwJ(J0cr_U?L`Rj*%;# zB#VhYKw5)!h-PA)Qs$L6Eftn%&P%W#vt+I|ket#BT{Bgnl=3s{Afix-^K znpKLGr@Y&JGaS-`Bq5QD%;Oq!1MvIkkYeRoU*JsbYP1`)m9~1_Qd%_H^;122s!39T z4B7B3cB_MW>kk%T!8PV)HgboK(oxGWFrsZyty$&u_Df`o%uFb!mO7$?8b%;xBajzHAdi5$ vuE=`2umh~=-mdj@;R*0SuZe^azu12P6ybyCRZJBs00000NkvXXu0mjf$JX?R literal 0 HcmV?d00001 From 1233357649b3be041fb6ef986605300155f76533 Mon Sep 17 00:00:00 2001 From: apprb Date: Sun, 7 Sep 2014 15:51:54 +0700 Subject: [PATCH 13/46] show image preview after file receiving completed --- filetransferinstance.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/filetransferinstance.cpp b/filetransferinstance.cpp index 6b9a39250..35bdf0533 100644 --- a/filetransferinstance.cpp +++ b/filetransferinstance.cpp @@ -107,14 +107,13 @@ void FileTransferInstance::onFileTransferFinished(ToxFile File) if (File.direction == ToxFile::RECEIVING) { - QPixmap preview; + QImage preview; QFile previewFile(File.filePath); if (previewFile.open(QIODevice::ReadOnly) && previewFile.size() <= 1024*1024*25) // Don't preview big (>25MiB) images { if (preview.loadFromData(previewFile.readAll())) { - preview = preview.scaledToHeight(40); -// pic->setPixmap(preview); + pic = preview.scaledToHeight(40); } previewFile.close(); } @@ -303,7 +302,7 @@ QString FileTransferInstance::draw2ButtonsForm(const QString &type, const QImage QString content; content += "

" + filename + "

"; - content += "

" + getHumanReadableSize(lastBytesSent) + " / " + size; + " (" + speed + ")

\n"; + content += "

" + getHumanReadableSize(lastBytesSent) + " / " + size + " (" + speed + " ETA: " + eta + ")

\n"; return wrapIntoForm(content, type, imgAstr, imgBstr); } From 16949cfdba60ef98b218ec9b9d3ae77a0005cd8c Mon Sep 17 00:00:00 2001 From: apprb Date: Sun, 7 Sep 2014 16:14:50 +0700 Subject: [PATCH 14/46] FileTransferInstance: correct buttons displaying --- filetransferinstance.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/filetransferinstance.cpp b/filetransferinstance.cpp index 35bdf0533..487e0b5cf 100644 --- a/filetransferinstance.cpp +++ b/filetransferinstance.cpp @@ -64,7 +64,7 @@ void FileTransferInstance::onFileTransferInfo(int FriendId, int FileNum, int64_t if (FileNum != fileNum || FriendId != friendId || Direction != direction) return; -// state = tsProcessing; + state = tsProcessing; QDateTime newtime = QDateTime::currentDateTime(); int timediff = lastUpdate.secsTo(newtime); if (timediff <= 0) @@ -211,7 +211,7 @@ QString FileTransferInstance::QImage2base64(const QImage &img) QString FileTransferInstance::getHtmlImage() { - qDebug() << "QString FileTransferInstance::getHtmlImage()"; + qDebug() << "QString FileTransferInstance::getHtmlImage() " << state; QString res; if (state == tsPending || state == tsProcessing || state == tsPaused) From aa2f67c983767b20f448ba5392957b2c95b58b4b Mon Sep 17 00:00:00 2001 From: apprb Date: Sun, 7 Sep 2014 18:42:06 +0700 Subject: [PATCH 15/46] code cleanup --- filetransferinstance.cpp | 2 +- ui/chatArea/innerStyle.css | 49 ++++++++++++------------- widget/chatareawidget.cpp | 63 +++++++++++++++++++++++++++++---- widget/chatareawidget.h | 11 ++++++ widget/form/chatform.cpp | 24 ++++++++----- widget/form/genericchatform.cpp | 48 ++++++------------------- widget/form/genericchatform.h | 14 +------- widget/tool/chataction.cpp | 12 ++++--- widget/tool/chataction.h | 8 +++-- 9 files changed, 133 insertions(+), 98 deletions(-) diff --git a/filetransferinstance.cpp b/filetransferinstance.cpp index 487e0b5cf..274f55f1e 100644 --- a/filetransferinstance.cpp +++ b/filetransferinstance.cpp @@ -225,7 +225,7 @@ QString FileTransferInstance::getHtmlImage() else rightBtnImg = QImage(":/ui/fileTransferInstance/acceptFileButton.png"); - res = draw2ButtonsForm("green", leftBtnImg, rightBtnImg); + res = draw2ButtonsForm("silver", leftBtnImg, rightBtnImg); } else if (state == tsCanceled) { res = drawButtonlessForm("red"); diff --git a/ui/chatArea/innerStyle.css b/ui/chatArea/innerStyle.css index 22af8bc92..5a1de4a94 100644 --- a/ui/chatArea/innerStyle.css +++ b/ui/chatArea/innerStyle.css @@ -4,21 +4,6 @@ div.name_me { padding-right: 3px; } -div.message_me { - color: #646464; - padding-right: 3px; - padding-left: 3px; -} - -div.date_me { - color: #646464; - padding-left: 3px; -} - -div.quote { - background-color: #6bc260; -} - div.name { color: #000000; font-weight: bold; @@ -36,27 +21,43 @@ div.date { padding-left: 3px; } +div.quote { + background-color: #6bc260; +} + div.green { margin-top: 12px; margin-bottom: 12px; margin-left: 12px; + margin-right: 12px; color: #ffffff; background-color: #6bc260; font-size: 10px; } +div.silver { + margin-top: 12px; + margin-bottom: 12px; + margin-left: 12px; + margin-right: 12px; + color: #000000; + background-color: #d1d1d1; + font-size: 10px; +} + +div.red { + margin-top: 12px; + margin-bottom: 12px; + margin-left: 12px; + margin-right: 12px; + color: #ffffff; + background-color: rgb(200,78,78); + font-size: 10px; +} + div.button { margin-top: 0px; margin-bottom: 0px; margin-left: 0px; color: #ffffff; } - -div.red { - margin-top: 12px; - margin-bottom: 12px; - margin-left: 12px; - color: #ffffff; - background-color: rgb(200,78,78); - font-size: 10px; -} diff --git a/widget/chatareawidget.cpp b/widget/chatareawidget.cpp index 923ff8f38..e3d021dd7 100644 --- a/widget/chatareawidget.cpp +++ b/widget/chatareawidget.cpp @@ -17,6 +17,7 @@ #include "chatareawidget.h" #include #include +#include ChatAreaWidget::ChatAreaWidget(QWidget *parent) : QTextEdit(parent) @@ -26,6 +27,12 @@ ChatAreaWidget::ChatAreaWidget(QWidget *parent) : setContextMenuPolicy(Qt::CustomContextMenu); } +ChatAreaWidget::~ChatAreaWidget() +{ + for (ChatAction *it : messages) + delete it; +} + void ChatAreaWidget::mouseReleaseEvent(QMouseEvent * event) { QTextEdit::mouseReleaseEvent(event); @@ -41,16 +48,58 @@ void ChatAreaWidget::mouseReleaseEvent(QMouseEvent * event) QTextFormat format = cursor.charFormat(); if (format.isImageFormat()) { - QString image = format.toImageFormat().name(); - if (QRegExp("^data:ftrans.*").exactMatch(image)) + QString imageName = format.toImageFormat().name(); + if (QRegExp("^data:ftrans.*").exactMatch(imageName)) { - image = image.right(image.length() - 12); - int endpos = image.indexOf("/png;base64"); - image = image.left(endpos); - int middlepos = image.indexOf("."); - emit onFileTranfertInterract(image.left(middlepos),image.right(image.length() - middlepos - 1)); + QString data = imageName.right(imageName.length() - 12); + int endpos = data.indexOf("/png;base64"); + data = data.left(endpos); + int middlepos = data.indexOf("."); + QString widgetID = data.left(middlepos); + QString widgetBtn = data.right(data.length() - middlepos - 1); + emit onFileTranfertInterract(widgetID, widgetBtn); } } } } } + +QString ChatAreaWidget::getHtmledMessages() +{ + QString res("\n"); + + for (ChatAction *it : messages) + { + res += it->getHtml(); + } + res += "
"; + return res; +} + +void ChatAreaWidget::insertMessage(ChatAction *msgAction) +{ + if (msgAction == nullptr) + return; + + messages.append(msgAction); + updateChatContent(); +} + +void ChatAreaWidget::updateChatContent() +{ + QScrollBar* scroll = verticalScrollBar(); + lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); + + setHtml(getHtmledMessages()); + if (lockSliderToBottom) + sliderPosition = scroll->maximum(); + + scroll->setValue(sliderPosition); +} + +void ChatAreaWidget::clearMessages() +{ + for (ChatAction *it : messages) + delete it; + updateChatContent(); +} diff --git a/widget/chatareawidget.h b/widget/chatareawidget.h index aae1960f8..2d85fc453 100644 --- a/widget/chatareawidget.h +++ b/widget/chatareawidget.h @@ -18,12 +18,17 @@ #define CHATAREAWIDGET_H #include +#include +#include "widget/tool/chataction.h" class ChatAreaWidget : public QTextEdit { Q_OBJECT public: explicit ChatAreaWidget(QWidget *parent = 0); + virtual ~ChatAreaWidget(); + void insertMessage(ChatAction *msgAction); + void clearMessages(); signals: void onFileTranfertInterract(QString widgetName, QString buttonName); @@ -32,7 +37,13 @@ protected: void mouseReleaseEvent(QMouseEvent * event); public slots: + void updateChatContent(); +private: + QString getHtmledMessages(); + QList messages; + bool lockSliderToBottom; + int sliderPosition; }; #endif // CHATAREAWIDGET_H diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index efaa6219a..dc9e3f410 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -43,7 +43,7 @@ ChatForm::ChatForm(Friend* chatFriend) connect(videoButton, &QPushButton::clicked, this, &ChatForm::onVideoCallTriggered); connect(msgEdit, &ChatTextEdit::enterPressed, this, &ChatForm::onSendTriggered); connect(micButton, SIGNAL(clicked()), this, SLOT(onMicMuteToggle())); - connect(newChatForm, SIGNAL(onFileTranfertInterract(QString,QString)), this, SLOT(onFileTansBtnClicked(QString,QString))); + connect(chatWidget, SIGNAL(onFileTranfertInterract(QString,QString)), this, SLOT(onFileTansBtnClicked(QString,QString))); } ChatForm::~ChatForm() @@ -101,10 +101,14 @@ void ChatForm::startFileSend(ToxFile file) connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo); connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled); connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransferInstance::onFileTransferFinished); - connect(fileTrans, SIGNAL(stateUpdated()), this, SLOT(updateChatContent())); + connect(fileTrans, SIGNAL(stateUpdated()), chatWidget, SLOT(updateChatContent())); - messages.append(new FileTransferAction(fileTrans, Widget::getInstance()->getUsername(), QTime::currentTime().toString("hh:mm"))); - updateChatContent(); + QString name = Widget::getInstance()->getUsername(); + if (name == previousName) + name = ""; + previousName = Widget::getInstance()->getUsername(); + + chatWidget->insertMessage(new FileTransferAction(fileTrans, name, QTime::currentTime().toString("hh:mm"), true)); } void ChatForm::onFileRecvRequest(ToxFile file) @@ -118,7 +122,7 @@ void ChatForm::onFileRecvRequest(ToxFile file) connect(Widget::getInstance()->getCore(), &Core::fileTransferInfo, fileTrans, &FileTransferInstance::onFileTransferInfo); connect(Widget::getInstance()->getCore(), &Core::fileTransferCancelled, fileTrans, &FileTransferInstance::onFileTransferCancelled); connect(Widget::getInstance()->getCore(), &Core::fileTransferFinished, fileTrans, &FileTransferInstance::onFileTransferFinished); - connect(fileTrans, SIGNAL(stateUpdated()), this, SLOT(updateChatContent())); + connect(fileTrans, SIGNAL(stateUpdated()), chatWidget, SLOT(updateChatContent())); Widget* w = Widget::getInstance(); if (!w->isFriendWidgetCurActiveWidget(f)|| w->getIsWindowMinimized() || !w->isActiveWindow()) @@ -128,8 +132,12 @@ void ChatForm::onFileRecvRequest(ToxFile file) f->widget->updateStatusLight(); } - messages.append(new FileTransferAction(fileTrans, f->getName(), QTime::currentTime().toString("hh:mm"))); - updateChatContent(); + QString name = f->getName(); + if (name == previousName) + name = ""; + previousName = f->getName(); + + chatWidget->insertMessage(new FileTransferAction(fileTrans, name, QTime::currentTime().toString("hh:mm"), false)); } void ChatForm::onAvInvite(int FriendId, int CallId, bool video) @@ -435,6 +443,4 @@ void ChatForm::onFileTansBtnClicked(QString widgetName, QString buttonName) it.value()->pressFromHtml(buttonName); else qDebug() << "no filetransferwidget: " << id; - -// QMessageBox::information(nullptr, message, message); } diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index d200963ef..3b8fd20e2 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -16,9 +16,7 @@ #include "genericchatform.h" #include "ui_mainwindow.h" -#include #include -#include #include "smileypack.h" #include "widget/emoticonswidget.h" #include "style.h" @@ -28,7 +26,6 @@ GenericChatForm::GenericChatForm(QObject *parent) : QObject(parent) { - lockSliderToBottom = true; curRow = 0; mainWidget = new QWidget(); headWidget = new QWidget(); @@ -40,9 +37,9 @@ GenericChatForm::GenericChatForm(QObject *parent) : QVBoxLayout *mainLayout = new QVBoxLayout(); QVBoxLayout *footButtonsSmall = new QVBoxLayout(), *volMicLayout = new QVBoxLayout(); - newChatForm = new ChatAreaWidget(); - newChatForm->document()->setDefaultStyleSheet(Style::get(":ui/chatArea/innerStyle.css")); - newChatForm->setStyleSheet(Style::get(":/ui/chatArea/chatArea.css")); + chatWidget = new ChatAreaWidget(); + chatWidget->document()->setDefaultStyleSheet(Style::get(":ui/chatArea/innerStyle.css")); + chatWidget->setStyleSheet(Style::get(":/ui/chatArea/chatArea.css")); msgEdit = new ChatTextEdit(); @@ -102,7 +99,7 @@ GenericChatForm::GenericChatForm(QObject *parent) : micButton->setStyleSheet(micButtonStylesheet); mainWidget->setLayout(mainLayout); - mainLayout->addWidget(newChatForm); + mainLayout->addWidget(chatWidget); mainLayout->addLayout(mainFootLayout); mainLayout->setMargin(0); @@ -136,7 +133,7 @@ GenericChatForm::GenericChatForm(QObject *parent) : emoteButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); connect(emoteButton, SIGNAL(clicked()), this, SLOT(onEmoteButtonClicked())); - connect(newChatForm, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); + connect(chatWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onChatContextMenuRequested(QPoint))); } void GenericChatForm::setName(const QString &newName) @@ -173,7 +170,7 @@ void GenericChatForm::onSaveLogClicked() return; QString log; - log = newChatForm->toPlainText(); + log = chatWidget->toPlainText(); file.write(log.toUtf8()); file.close(); @@ -182,19 +179,18 @@ void GenericChatForm::onSaveLogClicked() void GenericChatForm::addMessage(QString author, QString message, QDateTime datetime) { QString date = datetime.toString(Settings::getInstance().getTimestampFormat()); + bool isMe = (author == Widget::getInstance()->getUsername()); + if (previousName == author) - messages.append(new MessageAction("", message, date)); - else messages.append(new MessageAction(author , message, date)); + chatWidget->insertMessage(new MessageAction("", message, date, isMe)); + else chatWidget->insertMessage(new MessageAction(author , message, date, isMe)); previousName = author; - updateChatContent(); } GenericChatForm::~GenericChatForm() { delete mainWidget; delete headWidget; - for (ChatAction *it : messages) - delete it; } void GenericChatForm::onEmoteButtonClicked() @@ -223,27 +219,3 @@ void GenericChatForm::onEmoteInsertRequested(QString str) msgEdit->setFocus(); // refocus so that we can continue typing } - -QString GenericChatForm::getHtmledMessages() -{ - QString res("\n"); - - for (ChatAction *it : messages) - { - res += it->getHtml(); - } - res += "
"; - return res; -} - -void GenericChatForm::updateChatContent() -{ - QScrollBar* scroll = newChatForm->verticalScrollBar(); - lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); - - newChatForm->setHtml(getHtmledMessages()); - if (lockSliderToBottom) - sliderPosition = scroll->maximum(); - - scroll->setValue(sliderPosition); -} diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h index a6ef6d8f5..10f7a52f0 100644 --- a/widget/form/genericchatform.h +++ b/widget/form/genericchatform.h @@ -18,19 +18,15 @@ #define GENERICCHATFORM_H #include -#include #include -#include #include #include #include #include #include -#include #include "widget/chatareawidget.h" #include "widget/tool/chattextedit.h" -#include "widget/tool/chataction.h" // Spacing in px inserted when the author of the last message changes #define AUTHOR_CHANGE_SPACING 5 @@ -60,7 +56,6 @@ protected slots: void onSaveLogClicked(); void onEmoteButtonClicked(); void onEmoteInsertRequested(QString str); - void updateChatContent(); protected: QLabel *nameLabel, *avatarLabel; @@ -70,15 +65,8 @@ protected: ChatTextEdit *msgEdit; QPushButton *sendButton; QString previousName; - ChatAreaWidget *newChatForm; + ChatAreaWidget *chatWidget; int curRow; - bool lockSliderToBottom; - int sliderPosition; - - QList messages; - -private: - QString getHtmledMessages(); }; #endif // GENERICCHATFORM_H diff --git a/widget/tool/chataction.cpp b/widget/tool/chataction.cpp index 4735b3aa5..c1db67b46 100644 --- a/widget/tool/chataction.cpp +++ b/widget/tool/chataction.cpp @@ -41,8 +41,10 @@ QString ChatAction::QImage2base64(const QImage &img) QString ChatAction::wrapName(const QString &name) { - QString res = "
" + name + "
" + name + "
" + name + "
\n"; + res = "
\n"; res += ""; - res += "
\n"; + res = "
\n"; res += "\n"; - res += "\n"; - res += insertMiniature(); + res += insertMiniature(type); res += "\n"; res += "\n"; res += "\n"; res += "
\n"; - res += "
" + imgAstr + "
\n"; - res += "
\n"; res += "
"; res += content; res += "
\n"; res += "
\n"; - res += "
" + imgBstr + "
\n"; + res += "
" + imgAstr + "
" + imgBstr+ "
\n"; res += "
\n"; diff --git a/filetransferinstance.h b/filetransferinstance.h index 2306129ee..ff5d85937 100644 --- a/filetransferinstance.h +++ b/filetransferinstance.h @@ -57,7 +57,7 @@ private: QString QImage2base64(const QImage &img); QString drawButtonlessForm(const QString &type); QString draw2ButtonsForm(const QString &type, const QImage &imgA, const QImage &imgB); - QString insertMiniature(); + QString insertMiniature(const QString &type); QString wrapIntoForm(const QString &content, const QString &type, const QString &imgAstr, const QString &imgBstr); private: diff --git a/ui/fileTransferInstance/acceptFileButton.png b/ui/fileTransferInstance/acceptFileButton.png index a3d1f1c005d78e9832a59e1d2a1043d54c7ad0b4..b072344edf21d190098126c8e8347f186f5f262a 100644 GIT binary patch delta 406 zcmV;H0crl~1Hl837aSZ21^@s6lq3|;00006VoOIv00000008+zyMK{0A%6}iGV3#6 z7XSbOPDw;TR7l6|)jvx@Q5eVZ?=?ZwA(X(IrY%8pLxY1tMJ5-7Jd)f^zv&L)mjhH= z6(l6`^&C6ih;Bd=sdcKfdQFz>9wI9Td?;_MF0APWG?Cl#H4+lr%Wq*^HW`;q2G9*? zX3`xf+>}$KikCFL>SF^#`{V}#@YsE%%Sqk9NX^(CC|ngUW}{x%sLzT(5=J9!AZj#n z5(~ylCIfG96br^rC*F+ze-V%c5ov#(F7XSbN07*qoM6N<$g2h>} AVgLXD delta 448 zcmV;x0YCo11L^~i7aS-E1^@s63(rw&00006VoOIv0RI600RN!9r<0L0A%6z|2!FE^ zfB*micS%G+R7l6|*S$+ZQ5eVZ?=``Q-Wo2>>L>#i-tmPjIZO{H0u7qJ>__}#m#+P$-1!P(!5u5 zqxHl%VH^lNeLZsVcFtS*MLOazI|+F9Se{xzK9xs(-^vq56)1z)LB^ zrh7*+&=)Dz3sjpGrY$aZX7~9PKbf0clnnGmlKEQ%1U6;@*v$^?W(R;|pl?qaZIQct zoOt$%@^5KmVBnl|Apn=fLn41I85n998*P!B?4@==YKVp?o4OiEN)05YG*Sb?N+ZV+ qUo@vv@C1huU-WG3cNy2PU+h2fa-GXkFF)u20000dc!zDTt?EaTgZDTK%n8_`p~xu3f4^XbhQe2XF1N&;)#A>&31Jzqs$65j)M2LrTc9^s;cXS z^A`V~woF`ZNAeuL?WNLJE?r%4nDw;5_vJDt%5~RChp5I}UqA20)lb(R&5>?Q=1hra r%JfoT;#8U7!1VKT!V$@p{3`MCHrs`7UHx+I9LQmwu6{1-oD!M!rV)5}O=J;Y>?EaSSWbNLB#dq)iKw5i3Jx-#o^oj|%cto6>x`z7?|)ry3tpXL`);YAM3%yHDUWbw jK@WvS79k)J;=Yf0zmQP;rzfYvKrZrh^>bP0l+XkKS6WDP delta 214 zcmV;{04e|F0fGXM7aS-E1^@s63(rw&00006VoOIv0LTDN08YzB)HsndA%6!p34y4x zV*mgEk4Z#9R7l6|*Rc_UFbqcFCn_=neP&<Cs~b+s%02D-~lAy3bY)MRlp5+0v8U>D&U1vR#x=&m|(9dZ{P;(NW!_MT#-A{ zMj!|gB1DJ~Awq-*IS=xSKrcQK$Q*%8z~+kdIj_LzeqDXeZ{Y4Vkwtv5|2)hWzG4cQ QI{*Lx07*qoM6N<$f}$Bu>Hq)$ diff --git a/ui/fileTransferInstance/emptyRGreenFileButton.png b/ui/fileTransferInstance/emptyRGreenFileButton.png index a4725df5a06cd9817f9aa14894b9d731355fc642..b95d87ae2d71965857eb418be279e537f5f3726e 100644 GIT binary patch delta 172 zcmeBUy1_U>Ttp5(8JIAkcLzIa+slu_2n6{?5#uGsI&@4fBvtx4~B zcz7mf=6c=>+0E)dGvh_`m6c`O&kTTILx8cUp@G4jq=bYU=MEe&s9bfoX}JL>!#rc* VIz`b_i$QMiboFC(S?83{1OT}fK~w+$ delta 226 zcmcb?*vB+MTtnc6VX;4}uH!E}uNnSh1en(3s=tUooKMY)==* z5Rc<;uPgF3I|w*jJim;I&ndNk!@lhfTe=$FI-Xb+_D1)EOmo&b20jtard@Ld&(>H! zN>$4?Tiu?e>dS4wWP5>CetGQ!k8r*_4dNfxw!czrl+kYZ&X>x0zVsT;6uz5W3nscT zypuW+%6!sPfXDENfU`B2uGlbTgZYL)%D%%M-7E87`|eC P0kYoH)z4*}Q$iB}7Tr9a delta 224 zcmV<603ZL;0gM8W7aS-E1^@s63(rw&00006VoOIv0LTDN08YzB)HsndA%6!p8*&lD zD*ylhnMp)JR7l6|*P#)EKoCID&rJjrl1TKmfVnCX87ze$LltXiff|UW25^aD20`5I zip+ky;?3@yxnfG`L!LHZ21cNdBFjDqUm=P~6}VMFxON&R6v7 ai~R*`4kE0F^X#ku00007`v^lNnF9D5*K; zM=tl%n>QOTm`|2iXV~9%zhOg^)F`Qm!conO!Vya9o+f^P^bFFN6YC5Dfh+5upeP?$ zXRyw+Ld5WX|LxRgJ|Jn=kOD}$hQvS~bXdU}IJAcG+bsezAO#X2e;H4iRx`TfDFyQY O0000bL3kd`93O44N z+Es6mFi8kOq<4$^t^eVZyUYFa|6BcS=R!V_z#dot(=dqQTfrv32%rXxfJ1-V>8e2P z;{vlAWaW5WuaW^}8?|wPfq!ZQpsfR`=s<)H1cMkvU7UBtVReKjeAe-j&2jZms~4Lz zN-a{EFxicNM?B%<2_M%fJU1n$fG2$O@CNz&&zQ;t3k!M9o+pI!iBu+}GWm$8o>t7m z8^j=AE=M|$y$)od8p(jEYGfD&QEV$bK`#uV`NvkD*NS}wu}VNeB@b&cHvj+t07*qo IM6N<$f}Mwj(EtDd diff --git a/ui/fileTransferInstance/resumeFileButton.png b/ui/fileTransferInstance/resumeFileButton.png index ec97328e98e281c5dfe77ff8f29bc577d3d34c0a..4bf1efd12a9b8c85874542b7633c3f62ecc6d303 100644 GIT binary patch delta 200 zcmV;(05|`U0`vip7Z@A}1ONa4J}ul^00002VoOIv0063uBQlXMA%6}i30gR|GXMYp zg-Jv~R5;7!)4K_PFcgL1KVm@19@)cTY+c6I1)LzId!%=SppZfv5mXdz8U=56ijO=_ zqL!scHW}hcB$J$!A3Vz}Cq=@>@?)$pc>I8w1j2== zkACEY$M5CDNy$VjB_$1GCR(AUyHt61OL!bDBftuFC>!jez>$Ig0000fo+Ip$G8=e+qzubYh5^`sGJCjZ1PdgJq(DJJNW`zB z@awMlbkd!5&e{+EGveu}T@R2&kvRjEYrqhnf>(Rjy3Cy}1}z0omB39WrB2Q|ArUpF zb$P|&@xQH65_sOWkx4{BR7l6&)!!?FQ5?td_w<-OL)(aEHsoTPS}PI?C9RCMlzT-fH(dKaxb%O} zk|olNrAPXDCH3T)er04z2G2{!|AH3O-huA$ChRwEnC z^v!+g8|#^1EwagoFII65r5Z9Dm}jzgny@Dd!1=?e1uP9L<97#eDJs{`S3gJYUv3F| zqWIdnSqP;72f8Sd45jhA1860UyF#|UotP_M2&M3~b(0=k!H@i-r51cn|S3UpQ#Fb>sir75kneQTS$Q}^qR)jw3D%(36h~S9;cT#@rsZF zRdJIDCK1xGj`YV!d5W}>#z{VdE_4#XWLX%f2vtSmU85FIe#t@_Rv4n*SbfOl(*-U? z<*tzZbjjwVQE!Zk$1}>uME&#WQUJz#r))*u0fv5yQa_`~ QssI2007*qoM6N<$f_|mfXaE2J delta 515 zcmV+e0{s1i1g!*+7aS-E1^@s63(rw&00006VoOIv0RI600RN!9r<0L0A%6z}4v))+ z^Z)<>x=BPqR7l6|*S~8MVI0Tt_j8HOC8p#Th5RO3NGb$H2d9vx7)WC);?zm#Q0Y+G zKSt@KL;eVV1sz1pPzNUm8?6dysVE_BsV1RG&cWokA~bE1yP@1?JC1u^e4ppTaVOAZ zYKw5)!h-PA)Qs$L6Eftn%&P%W#vt+JAlyz^!l|zaz-K zOAAcTxqkhul#*YFrtvdanpD0@IbGLgb}~ke*qNXgXdLD6)FG#002ovPDHLk FV1k5y@8tjh From 39ba354651dd6cfcfccd39599a1e0c36ee4e20dc Mon Sep 17 00:00:00 2001 From: krepa098 Date: Tue, 9 Sep 2014 18:09:51 +0200 Subject: [PATCH 18/46] use "white-space: nowrap" for div.date --- ui/chatArea/innerStyle.css | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/chatArea/innerStyle.css b/ui/chatArea/innerStyle.css index 5a1de4a94..61380b073 100644 --- a/ui/chatArea/innerStyle.css +++ b/ui/chatArea/innerStyle.css @@ -19,6 +19,7 @@ div.message { div.date { color: #000000; padding-left: 3px; + white-space: nowrap; } div.quote { From ddf955afd32d151811ea3a9189a34fd766bb711d Mon Sep 17 00:00:00 2001 From: krepa098 Date: Tue, 9 Sep 2014 18:28:07 +0200 Subject: [PATCH 19/46] fixed #255 --- widget/form/chatform.cpp | 2 +- widget/form/chatform.h | 2 +- widget/form/genericchatform.cpp | 3 +-- widget/form/genericchatform.h | 4 +++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/widget/form/chatform.cpp b/widget/form/chatform.cpp index dc9e3f410..229d6c8d4 100644 --- a/widget/form/chatform.cpp +++ b/widget/form/chatform.cpp @@ -29,7 +29,7 @@ ChatForm::ChatForm(Friend* chatFriend) nameLabel->setText(f->getName()); avatarLabel->setPixmap(QPixmap(":/img/contact_dark.png")); - statusMessageLabel = new QLabel(); + statusMessageLabel = new CroppingLabel(); netcam = new NetCamView(); headTextLayout->addWidget(statusMessageLabel); diff --git a/widget/form/chatform.h b/widget/form/chatform.h index 1527a701b..9407f1c11 100644 --- a/widget/form/chatform.h +++ b/widget/form/chatform.h @@ -68,7 +68,7 @@ private slots: private: Friend* f; - QLabel *statusMessageLabel; + CroppingLabel *statusMessageLabel; NetCamView* netcam; bool audioInputFlag; int callId; diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index 3b8fd20e2..105aa806a 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -30,7 +30,7 @@ GenericChatForm::GenericChatForm(QObject *parent) : mainWidget = new QWidget(); headWidget = new QWidget(); - nameLabel = new QLabel(); + nameLabel = new CroppingLabel(); avatarLabel = new QLabel(); QHBoxLayout *headLayout = new QHBoxLayout(), *mainFootLayout = new QHBoxLayout(); headTextLayout = new QVBoxLayout(); @@ -115,7 +115,6 @@ GenericChatForm::GenericChatForm(QObject *parent) : headWidget->setLayout(headLayout); headLayout->addWidget(avatarLabel); headLayout->addLayout(headTextLayout); - headLayout->addStretch(); headLayout->addLayout(volMicLayout); headLayout->addWidget(callButton); headLayout->addWidget(videoButton); diff --git a/widget/form/genericchatform.h b/widget/form/genericchatform.h index 10f7a52f0..d8b20281d 100644 --- a/widget/form/genericchatform.h +++ b/widget/form/genericchatform.h @@ -25,6 +25,7 @@ #include #include +#include "widget/croppinglabel.h" #include "widget/chatareawidget.h" #include "widget/tool/chattextedit.h" @@ -58,7 +59,8 @@ protected slots: void onEmoteInsertRequested(QString str); protected: - QLabel *nameLabel, *avatarLabel; + CroppingLabel *nameLabel; + QLabel *avatarLabel; QWidget *mainWidget, *headWidget; QPushButton *fileButton, *emoteButton, *callButton, *videoButton, *volButton, *micButton; QVBoxLayout *headTextLayout; From a39339e06f888aba40920b2f704f01ceddb22f44 Mon Sep 17 00:00:00 2001 From: krepa098 Date: Tue, 9 Sep 2014 18:29:03 +0200 Subject: [PATCH 20/46] cleanup --- widget/form/genericchatform.cpp | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/widget/form/genericchatform.cpp b/widget/form/genericchatform.cpp index 105aa806a..fcffb2385 100644 --- a/widget/form/genericchatform.cpp +++ b/widget/form/genericchatform.cpp @@ -72,29 +72,11 @@ GenericChatForm::GenericChatForm(QObject *parent) : videoButton->setObjectName("green"); videoButton->setStyleSheet(Style::get(":/ui/videoButton/videoButton.css")); - QString volButtonStylesheet = ""; - try - { - QFile f(":/ui/volButton/volButton.css"); - f.open(QFile::ReadOnly | QFile::Text); - QTextStream volButtonStylesheetStream(&f); - volButtonStylesheet = volButtonStylesheetStream.readAll(); - } - catch (int e) {} - + QString volButtonStylesheet = Style::get(":/ui/volButton/volButton.css"); volButton->setObjectName("green"); volButton->setStyleSheet(volButtonStylesheet); - QString micButtonStylesheet = ""; - try - { - QFile f(":/ui/micButton/micButton.css"); - f.open(QFile::ReadOnly | QFile::Text); - QTextStream micButtonStylesheetStream(&f); - micButtonStylesheet = micButtonStylesheetStream.readAll(); - } - catch (int e) {} - + QString micButtonStylesheet = Style::get(":/ui/micButton/micButton.css"); micButton->setObjectName("green"); micButton->setStyleSheet(micButtonStylesheet); From 2f749d54844c7de8e335051e2baed93241c3b830 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 3 Sep 2014 12:54:41 +0200 Subject: [PATCH 21/46] inital commit for INSTALL.md --- INSTALL.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 INSTALL.md diff --git a/INSTALL.md b/INSTALL.md new file mode 100644 index 000000000..f733f4af6 --- /dev/null +++ b/INSTALL.md @@ -0,0 +1,40 @@ +###Dependencies + +| Name | Version | Modules | +|--------------|-------------|-------------------------------- | +| Qt | >= 5.2.0 | core, gui, network, widget, xml | +| GCC/MinGW | >= 4.6 | C++11 enabled | +| Tox Core | most recent | core, av | +| OpenCV | >= 2.4.9 | core, highgui | +| OpenAL Soft | >= 1.16.0 | | + +###Windows + +## Qt + +Download the Qt online installer for Windows from [qt-project.org](http://qt-project.org/downloads). +While installation you have to assemble your Qt toolchain. Take the most recent version of Qt compiled with MinGW. +Select "Tools" to install the MinGW compiler package itself alongside Qt. By doing this you don't have to bother with installing one manually. +The following steps assumes that Qt is installed at "C:\Qt". If you decide to choose another location, replace corresponding parts. + +## MinGW + +If you installed MinGW alongside Qt you can skip this step. + +Download the MinGW installer for Windows from [sourceforge.net](http://sourceforge.net/projects/mingw/files/Installer/). +Make sure to install MSYS (a minimalistic set of unix tools for windows) and TODO. + +## System Path + +For some tasks it might be useful to use the Windows terminal. Thus you should add Qt/MinGW binaries to the system path to easily use them. +Open Control Panel -> System -> Advanced Settings -> .... TODO + +## Cloning the Repository + +Clone the repository (https://github.com/tux3/qTox.git) with your prefered Git client. [SmartGit](http://www.syntevo.com/smartgit/) is very nice for this task. + +## Tox Core + +[jenkins.libtoxcore.so](http://jenkins.libtoxcore.so/job/libtoxcore-win32-i686/lastSuccessfulBuild/artifact/libtoxcore-win32-i686.zip) provides a prebuild package of Tox Core. +Download this package and extract its content to "path/to/qTox/libs". You may have to create the folder "libs". + From 9306887b553735a669dccfabcf3e2c625c404f36 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 3 Sep 2014 13:02:38 +0200 Subject: [PATCH 22/46] some fixes --- INSTALL.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index f733f4af6..67334c26b 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -8,33 +8,34 @@ | OpenCV | >= 2.4.9 | core, highgui | | OpenAL Soft | >= 1.16.0 | | -###Windows +##Windows -## Qt +### Qt Download the Qt online installer for Windows from [qt-project.org](http://qt-project.org/downloads). While installation you have to assemble your Qt toolchain. Take the most recent version of Qt compiled with MinGW. Select "Tools" to install the MinGW compiler package itself alongside Qt. By doing this you don't have to bother with installing one manually. -The following steps assumes that Qt is installed at "C:\Qt". If you decide to choose another location, replace corresponding parts. +The following steps assumes that Qt is installed at "C:\Qt". If you decided to choose another location, replace corresponding parts. -## MinGW +### MinGW If you installed MinGW alongside Qt you can skip this step. Download the MinGW installer for Windows from [sourceforge.net](http://sourceforge.net/projects/mingw/files/Installer/). -Make sure to install MSYS (a minimalistic set of unix tools for windows) and TODO. +Make sure to install MSYS (a minimalistic set of Unix tools for Windows) and TODO. -## System Path +### System Path -For some tasks it might be useful to use the Windows terminal. Thus you should add Qt/MinGW binaries to the system path to easily use them. +For some tasks it might be useful to use the Windows terminal. Thus you should add Qt/MinGW binaries to the system path to make them globally accessible. Open Control Panel -> System -> Advanced Settings -> .... TODO -## Cloning the Repository +### Cloning the Repository Clone the repository (https://github.com/tux3/qTox.git) with your prefered Git client. [SmartGit](http://www.syntevo.com/smartgit/) is very nice for this task. +The following steps assumes that you cloned the repository at "C:\qTox". If you decided to choose another location, replace corresponding parts. -## Tox Core +### Tox Core -[jenkins.libtoxcore.so](http://jenkins.libtoxcore.so/job/libtoxcore-win32-i686/lastSuccessfulBuild/artifact/libtoxcore-win32-i686.zip) provides a prebuild package of Tox Core. -Download this package and extract its content to "path/to/qTox/libs". You may have to create the folder "libs". +[jenkins.libtoxcore.so](http://jenkins.libtoxcore.so/job/libtoxcore-win32-i686/lastSuccessfulBuild/artifact/libtoxcore-win32-i686.zip) +provides a prebuild package of Tox Core. Download this package and extract its content to "C:\qTox\libs". You may have to create the folder "libs". From 7ff563e6f100b91330314b56d6d71e54142fd269 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 3 Sep 2014 13:37:29 +0200 Subject: [PATCH 23/46] opencv/openal with TODOs --- INSTALL.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 67334c26b..8935e7f8f 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -8,7 +8,7 @@ | OpenCV | >= 2.4.9 | core, highgui | | OpenAL Soft | >= 1.16.0 | | -##Windows +## Windows ### Qt @@ -37,5 +37,20 @@ The following steps assumes that you cloned the repository at "C:\qTox". If you ### Tox Core [jenkins.libtoxcore.so](http://jenkins.libtoxcore.so/job/libtoxcore-win32-i686/lastSuccessfulBuild/artifact/libtoxcore-win32-i686.zip) -provides a prebuild package of Tox Core. Download this package and extract its content to "C:\qTox\libs". You may have to create the folder "libs". +provides a prebuild package of Tox Core. Download this package and extract its content to "C:\qTox\libs". You may have to create the directory "libs". +If you prefer to compile Tox Core on your own follow the instructions at https://github.com/irungentoo/toxcore/blob/master/INSTALL.md#windows + +### OpenCV + +Unfortunately there are no prebuild packages for OpenCV compiled with MinGW. Thus you have to create your own. +First of all download and install the most recent version of CMake from [cmake.org](http://www.cmake.org/cmake/resources/software.html). +Afterwards download the sources of OpenCV from [sourceforge.net](http://sourceforge.net/projects/opencvlibrary/) and extract its content to "C:\qTox\libs". +Create a new directory named "opencv-build" in "C:\qTox\libs". Now you should have the two directories "opencv-x.y.z" where x.y.z is the version of OpenCV and "opencv-build" inside your "C:\qTox\libs" directory. +Run CMake Gui and TODO CHECK FOR MSYS MAKE FILES. + +### OpenAL Soft + +Unlike OpenCV, prebuild packages of OpenAL Soft compiled with MinGW are provided at [http://kcat.strangesoft.net](http://kcat.strangesoft.net/openal.html#download). +Download the most recent version and extract its content to "C:\qTox\libs". Copy the directory "AL" located at "C:\qTox\libs\openal-soft-x.y.z-bin" to "C:\qTox\libs\include" where x.y.z is the version of OpenAL. +Copy the file "soft_oal.dll" located at "C:\qTox\libs\openal-soft-x.y.z-bin\bin\Win32\soft_oal.dll" to "C:\qTox\libs\lib". From d6d1b2b48168dc464f1d06b3ea74bbc15027e3dc Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 3 Sep 2014 13:40:15 +0200 Subject: [PATCH 24/46] minor fix --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 8935e7f8f..35ced2a47 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -44,7 +44,7 @@ If you prefer to compile Tox Core on your own follow the instructions at https:/ Unfortunately there are no prebuild packages for OpenCV compiled with MinGW. Thus you have to create your own. First of all download and install the most recent version of CMake from [cmake.org](http://www.cmake.org/cmake/resources/software.html). -Afterwards download the sources of OpenCV from [sourceforge.net](http://sourceforge.net/projects/opencvlibrary/) and extract its content to "C:\qTox\libs". +Afterwards download the source archive of OpenCV from [sourceforge.net](http://sourceforge.net/projects/opencvlibrary/) and extract its content to "C:\qTox\libs". Create a new directory named "opencv-build" in "C:\qTox\libs". Now you should have the two directories "opencv-x.y.z" where x.y.z is the version of OpenCV and "opencv-build" inside your "C:\qTox\libs" directory. Run CMake Gui and TODO CHECK FOR MSYS MAKE FILES. From 36d9d753bfcc8809c34a0f3a10f568f8be0cbc5c Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 3 Sep 2014 14:22:00 +0200 Subject: [PATCH 25/46] added linux --- INSTALL.md | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index 35ced2a47..c3eaa68e6 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -54,3 +54,86 @@ Unlike OpenCV, prebuild packages of OpenAL Soft compiled with MinGW are provided Download the most recent version and extract its content to "C:\qTox\libs". Copy the directory "AL" located at "C:\qTox\libs\openal-soft-x.y.z-bin" to "C:\qTox\libs\include" where x.y.z is the version of OpenAL. Copy the file "soft_oal.dll" located at "C:\qTox\libs\openal-soft-x.y.z-bin\bin\Win32\soft_oal.dll" to "C:\qTox\libs\lib". +## Linux + +## Git + +In order to clone the qTox repository you need Git. + +Debian: +```bash +sudo apt-get install git +``` + +Ubuntu: +```bash +sudo apt-get install git +``` + +Arch Linux: +```bash +sudo pacman -S git +``` + +Fedora: +```bash +yum install git +``` + +### GCC and Qt + +Debian: +```bash +sudo apt-get install build-essential qt5-qmake qt5-default +``` + +Ubuntu: +```bash +sudo apt-get install build-essential qt5-qmake qt5-default +``` + +Arch Linux: +```bash +sudo pacman -S base-devel qt5 +``` + +Fedora: +```bash +yum groupinstall "Development Tools" +yum install qt-devel qt-doc qt-creator +``` + +### Cloning the Repository + +Open a new Terminal and change to a directory of your choice. To clone the repository use: +```bash +git clone https://github.com/tux3/qTox.git qTox +``` + +The following steps assumes that you cloned the repository at "/home/user/qTox". If you decided to choose another location, replace corresponding parts. + +### Tox Core + +First of all install the dependencies of Tox Core. + +Debian: +```bash +sudo apt-get install libtool autotools-dev automake checkinstall check yasm libopus-dev libvpx-dev +``` + +Ubuntu: +```bash +sudo apt-get install libtool autotools-dev automake checkinstall check yasm libopus-dev libvpx-dev +``` + +Arch Linux: (Arch Linux provides the package "tox-git" in AUR) +```bash +sudo pacman -S yasm opus vpx +``` + +Fedora: +```bash +yum install libtool autoconf automake check check-devel +``` +Now you can either follow the instructions at https://github.com/irungentoo/toxcore/blob/master/INSTALL.md#unix or use the "bootstrap.sh" script located at "/home/user/qTox". +The script will automatically download and install Tox Core and libsodium to "/home/user/qTox/libs" From f3761078a7b01803b02e49c881ec2fdaf5cb1fe5 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 3 Sep 2014 14:22:43 +0200 Subject: [PATCH 26/46] minor fix --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index c3eaa68e6..dd485558c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -56,7 +56,7 @@ Copy the file "soft_oal.dll" located at "C:\qTox\libs\openal-soft-x.y.z-bin\bin\ ## Linux -## Git +### Git In order to clone the qTox repository you need Git. From cc0096a1ef3fabb8386f37a53164766476adbfe4 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 3 Sep 2014 14:40:18 +0200 Subject: [PATCH 27/46] more fixes --- INSTALL.md | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index dd485558c..b60b549b8 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -55,6 +55,7 @@ Download the most recent version and extract its content to "C:\qTox\libs". Copy Copy the file "soft_oal.dll" located at "C:\qTox\libs\openal-soft-x.y.z-bin\bin\Win32\soft_oal.dll" to "C:\qTox\libs\lib". ## Linux +Most of the dependencies should be available through your package manger. ### Git @@ -80,6 +81,15 @@ Fedora: yum install git ``` +### Cloning the Repository + +Open a new Terminal and change to a directory of your choice. To clone the repository use: +```bash +git clone https://github.com/tux3/qTox.git qTox +``` + +The following steps assumes that you cloned the repository at "/home/user/qTox". If you decided to choose another location, replace corresponding parts. + ### GCC and Qt Debian: @@ -103,15 +113,6 @@ yum groupinstall "Development Tools" yum install qt-devel qt-doc qt-creator ``` -### Cloning the Repository - -Open a new Terminal and change to a directory of your choice. To clone the repository use: -```bash -git clone https://github.com/tux3/qTox.git qTox -``` - -The following steps assumes that you cloned the repository at "/home/user/qTox". If you decided to choose another location, replace corresponding parts. - ### Tox Core First of all install the dependencies of Tox Core. @@ -135,5 +136,31 @@ Fedora: ```bash yum install libtool autoconf automake check check-devel ``` + Now you can either follow the instructions at https://github.com/irungentoo/toxcore/blob/master/INSTALL.md#unix or use the "bootstrap.sh" script located at "/home/user/qTox". -The script will automatically download and install Tox Core and libsodium to "/home/user/qTox/libs" +The script will automatically download and install Tox Core and libsodium to "/home/user/qTox/libs": +```bash +./bootstrap.sh # use -h or --help for more information +``` + +### OpenCV and OpanAL Soft + +Debian: +```bash +sudo apt-get install libopenal-dev libopencv-dev +``` + +Ubuntu: +```bash +sudo apt-get install libopenal-dev libopencv-dev +``` + +Arch Linux: +```bash +sudo pacman -S opencv openal +``` + +Fedora: +```bash +yum install opencv-devel openal-soft-devel +``` From 5e738bc355d2e66656a2ea0e8ea056cfe1d43ba8 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 3 Sep 2014 14:52:09 +0200 Subject: [PATCH 28/46] improved --- INSTALL.md | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index b60b549b8..4ba8fe603 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -90,27 +90,27 @@ git clone https://github.com/tux3/qTox.git qTox The following steps assumes that you cloned the repository at "/home/user/qTox". If you decided to choose another location, replace corresponding parts. -### GCC and Qt +### GCC, Qt, OpenCV and OpanAL Soft Debian: ```bash -sudo apt-get install build-essential qt5-qmake qt5-default +sudo apt-get install build-essential qt5-qmake qt5-default libopenal-dev libopencv-dev ``` Ubuntu: ```bash -sudo apt-get install build-essential qt5-qmake qt5-default +sudo apt-get install build-essential qt5-qmake qt5-default libopenal-dev libopencv-dev ``` Arch Linux: ```bash -sudo pacman -S base-devel qt5 +sudo pacman -S base-devel qt5 opencv openal ``` Fedora: ```bash yum groupinstall "Development Tools" -yum install qt-devel qt-doc qt-creator +yum install qt-devel qt-doc qt-creator opencv-devel openal-soft-devel ``` ### Tox Core @@ -142,25 +142,3 @@ The script will automatically download and install Tox Core and libsodium to "/h ```bash ./bootstrap.sh # use -h or --help for more information ``` - -### OpenCV and OpanAL Soft - -Debian: -```bash -sudo apt-get install libopenal-dev libopencv-dev -``` - -Ubuntu: -```bash -sudo apt-get install libopenal-dev libopencv-dev -``` - -Arch Linux: -```bash -sudo pacman -S opencv openal -``` - -Fedora: -```bash -yum install opencv-devel openal-soft-devel -``` From 2b5c6af80528cdf78d80ae2dfe6d4418d341df1d Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 3 Sep 2014 14:56:45 +0200 Subject: [PATCH 29/46] improved --- INSTALL.md | 1 + 1 file changed, 1 insertion(+) diff --git a/INSTALL.md b/INSTALL.md index 4ba8fe603..0f1c549b9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -140,5 +140,6 @@ yum install libtool autoconf automake check check-devel Now you can either follow the instructions at https://github.com/irungentoo/toxcore/blob/master/INSTALL.md#unix or use the "bootstrap.sh" script located at "/home/user/qTox". The script will automatically download and install Tox Core and libsodium to "/home/user/qTox/libs": ```bash +cd /home/user/qTox ./bootstrap.sh # use -h or --help for more information ``` From e348a339dc7304a4dd3ab26a079e9a4d90d7ed7e Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 3 Sep 2014 14:59:00 +0200 Subject: [PATCH 30/46] improved --- INSTALL.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 0f1c549b9..92ba6e1f8 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,4 +1,4 @@ -###Dependencies +##Dependencies | Name | Version | Modules | |--------------|-------------|-------------------------------- | @@ -8,39 +8,39 @@ | OpenCV | >= 2.4.9 | core, highgui | | OpenAL Soft | >= 1.16.0 | | -## Windows +##Windows -### Qt +###Qt Download the Qt online installer for Windows from [qt-project.org](http://qt-project.org/downloads). While installation you have to assemble your Qt toolchain. Take the most recent version of Qt compiled with MinGW. Select "Tools" to install the MinGW compiler package itself alongside Qt. By doing this you don't have to bother with installing one manually. The following steps assumes that Qt is installed at "C:\Qt". If you decided to choose another location, replace corresponding parts. -### MinGW +###MinGW If you installed MinGW alongside Qt you can skip this step. Download the MinGW installer for Windows from [sourceforge.net](http://sourceforge.net/projects/mingw/files/Installer/). Make sure to install MSYS (a minimalistic set of Unix tools for Windows) and TODO. -### System Path +###System Path For some tasks it might be useful to use the Windows terminal. Thus you should add Qt/MinGW binaries to the system path to make them globally accessible. Open Control Panel -> System -> Advanced Settings -> .... TODO -### Cloning the Repository +###Cloning the Repository Clone the repository (https://github.com/tux3/qTox.git) with your prefered Git client. [SmartGit](http://www.syntevo.com/smartgit/) is very nice for this task. The following steps assumes that you cloned the repository at "C:\qTox". If you decided to choose another location, replace corresponding parts. -### Tox Core +###Tox Core [jenkins.libtoxcore.so](http://jenkins.libtoxcore.so/job/libtoxcore-win32-i686/lastSuccessfulBuild/artifact/libtoxcore-win32-i686.zip) provides a prebuild package of Tox Core. Download this package and extract its content to "C:\qTox\libs". You may have to create the directory "libs". If you prefer to compile Tox Core on your own follow the instructions at https://github.com/irungentoo/toxcore/blob/master/INSTALL.md#windows -### OpenCV +###OpenCV Unfortunately there are no prebuild packages for OpenCV compiled with MinGW. Thus you have to create your own. First of all download and install the most recent version of CMake from [cmake.org](http://www.cmake.org/cmake/resources/software.html). @@ -48,16 +48,16 @@ Afterwards download the source archive of OpenCV from [sourceforge.net](http://s Create a new directory named "opencv-build" in "C:\qTox\libs". Now you should have the two directories "opencv-x.y.z" where x.y.z is the version of OpenCV and "opencv-build" inside your "C:\qTox\libs" directory. Run CMake Gui and TODO CHECK FOR MSYS MAKE FILES. -### OpenAL Soft +###OpenAL Soft Unlike OpenCV, prebuild packages of OpenAL Soft compiled with MinGW are provided at [http://kcat.strangesoft.net](http://kcat.strangesoft.net/openal.html#download). Download the most recent version and extract its content to "C:\qTox\libs". Copy the directory "AL" located at "C:\qTox\libs\openal-soft-x.y.z-bin" to "C:\qTox\libs\include" where x.y.z is the version of OpenAL. Copy the file "soft_oal.dll" located at "C:\qTox\libs\openal-soft-x.y.z-bin\bin\Win32\soft_oal.dll" to "C:\qTox\libs\lib". -## Linux +##Linux Most of the dependencies should be available through your package manger. -### Git +###Git In order to clone the qTox repository you need Git. @@ -81,7 +81,7 @@ Fedora: yum install git ``` -### Cloning the Repository +###Cloning the Repository Open a new Terminal and change to a directory of your choice. To clone the repository use: ```bash @@ -90,7 +90,7 @@ git clone https://github.com/tux3/qTox.git qTox The following steps assumes that you cloned the repository at "/home/user/qTox". If you decided to choose another location, replace corresponding parts. -### GCC, Qt, OpenCV and OpanAL Soft +###GCC, Qt, OpenCV and OpanAL Soft Debian: ```bash @@ -113,7 +113,7 @@ yum groupinstall "Development Tools" yum install qt-devel qt-doc qt-creator opencv-devel openal-soft-devel ``` -### Tox Core +###Tox Core First of all install the dependencies of Tox Core. From de4bf392a9398b94de6e24624e98cb5f2126a3f3 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 3 Sep 2014 18:36:00 +0200 Subject: [PATCH 31/46] Update INSTALL.md fixed some todos, grammar --- INSTALL.md | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 92ba6e1f8..cf62fd839 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -13,26 +13,28 @@ ###Qt Download the Qt online installer for Windows from [qt-project.org](http://qt-project.org/downloads). -While installation you have to assemble your Qt toolchain. Take the most recent version of Qt compiled with MinGW. -Select "Tools" to install the MinGW compiler package itself alongside Qt. By doing this you don't have to bother with installing one manually. -The following steps assumes that Qt is installed at "C:\Qt". If you decided to choose another location, replace corresponding parts. +While installation you have to assemble your Qt toolchain. Take the most recent version of Qt compiled with MinGW. +Although the installer provides its own bundled MinGW compiler Toolchain its recommend installing it separately because Qt is missing MSYS which is needed to compile and install OpenCV and OpenAL. Thus you can - if needed - deselect the tab "Tools". +The following steps assume that Qt is installed at "C:\Qt". If you decided to choose another location, replace corresponding parts. ###MinGW -If you installed MinGW alongside Qt you can skip this step. - Download the MinGW installer for Windows from [sourceforge.net](http://sourceforge.net/projects/mingw/files/Installer/). -Make sure to install MSYS (a minimalistic set of Unix tools for Windows) and TODO. +Make sure to install MSYS (a set of Unix tools for Windows). +The following steps assume that MinGW is installed at "C:\MinGW". If you decided to choose another location, replace corresponding parts. -###System Path +###Setting up Path -For some tasks it might be useful to use the Windows terminal. Thus you should add Qt/MinGW binaries to the system path to make them globally accessible. -Open Control Panel -> System -> Advanced Settings -> .... TODO +Add MinGW/MSYS binaries to the system path to make them globally accessible. +Open Control Panel -> System and Security -> System -> Advanced system settings -> Environment Variables... +In the second box search for the PATH variable and press Edit... +The input box "Variable value:" should already contain some directories. Each directory is separated with a semicolon. +Extend the input box by adding ";C:\MinGW\bin;C:\MinGW\msys\1.0\bin". The very first semicolon must only be added if it is missing. ###Cloning the Repository -Clone the repository (https://github.com/tux3/qTox.git) with your prefered Git client. [SmartGit](http://www.syntevo.com/smartgit/) is very nice for this task. -The following steps assumes that you cloned the repository at "C:\qTox". If you decided to choose another location, replace corresponding parts. +Clone the repository (https://github.com/tux3/qTox.git) with your preferred Git client. [SmartGit](http://www.syntevo.com/smartgit/) is very nice for this task. +The following steps assume that you cloned the repository at "C:\qTox". If you decided to choose another location, replace corresponding parts. ###Tox Core @@ -42,17 +44,17 @@ If you prefer to compile Tox Core on your own follow the instructions at https:/ ###OpenCV -Unfortunately there are no prebuild packages for OpenCV compiled with MinGW. Thus you have to create your own. -First of all download and install the most recent version of CMake from [cmake.org](http://www.cmake.org/cmake/resources/software.html). -Afterwards download the source archive of OpenCV from [sourceforge.net](http://sourceforge.net/projects/opencvlibrary/) and extract its content to "C:\qTox\libs". -Create a new directory named "opencv-build" in "C:\qTox\libs". Now you should have the two directories "opencv-x.y.z" where x.y.z is the version of OpenCV and "opencv-build" inside your "C:\qTox\libs" directory. -Run CMake Gui and TODO CHECK FOR MSYS MAKE FILES. +Unfortunately there are no prebuild packages for OpenCV compiled with MinGW. Thus, you have to create your own. +First of all download and install the most recent version of CMake from +[cmake.org](http://www.cmake.org/cmake/resources/software.html). +Afterwards download the source archive of OpenCV from [http://opencv.org](http://opencv.org/downloads.html). It's recommended to download the Linux/Mac package because the Windows package is bloated with useless binaries. The Linux/Mac package only contains the sources and works perfectly on Windows. +Extract the content of the source archive to "C:\qTox\libs". Furthermore, create a new directory named "opencv-build" in "C:\qTox\libs". +Now you should have the two directories "opencv-x.y.z" where x.y.z is the version of OpenCV and "opencv-build" inside your "C:\qTox\libs" directory. +Run CMake (cmake-gui) and set up the input boxes "Where is the source code:" and "Where to build the binaries" with "C:\qTox\libs\opencv-x.y.z" and "C:\qTox\libs\opencv-build". Press configure and choose "MSYS Makefiles" in the drop down menu and "Use default native compilers". Press "Finish" to start configuration. TODO ###OpenAL Soft -Unlike OpenCV, prebuild packages of OpenAL Soft compiled with MinGW are provided at [http://kcat.strangesoft.net](http://kcat.strangesoft.net/openal.html#download). -Download the most recent version and extract its content to "C:\qTox\libs". Copy the directory "AL" located at "C:\qTox\libs\openal-soft-x.y.z-bin" to "C:\qTox\libs\include" where x.y.z is the version of OpenAL. -Copy the file "soft_oal.dll" located at "C:\qTox\libs\openal-soft-x.y.z-bin\bin\Win32\soft_oal.dll" to "C:\qTox\libs\lib". + ##Linux Most of the dependencies should be available through your package manger. From e14bd8350baebcd133cfbc8c2ca894e72245bdb8 Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 4 Sep 2014 13:04:53 +0200 Subject: [PATCH 32/46] Update INSTALL.md improved --- INSTALL.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index cf62fd839..ede2a98d2 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -59,8 +59,7 @@ Run CMake (cmake-gui) and set up the input boxes "Where is the source code:" and ##Linux Most of the dependencies should be available through your package manger. -###Git - +###Cloning the Repository In order to clone the qTox repository you need Git. Debian: @@ -83,10 +82,9 @@ Fedora: yum install git ``` -###Cloning the Repository - -Open a new Terminal and change to a directory of your choice. To clone the repository use: +Afterwards open a new Terminal, change to a directory of your choice and clone the repository: ```bash +cd /home/user/qTox git clone https://github.com/tux3/qTox.git qTox ``` From 0e56ee5e5fc046854abbb1b1fa446ebb2603042a Mon Sep 17 00:00:00 2001 From: Marcel Date: Thu, 4 Sep 2014 20:00:19 +0200 Subject: [PATCH 33/46] Update INSTALL.md improved --- INSTALL.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index ede2a98d2..c06428020 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -48,9 +48,18 @@ Unfortunately there are no prebuild packages for OpenCV compiled with MinGW. Thu First of all download and install the most recent version of CMake from [cmake.org](http://www.cmake.org/cmake/resources/software.html). Afterwards download the source archive of OpenCV from [http://opencv.org](http://opencv.org/downloads.html). It's recommended to download the Linux/Mac package because the Windows package is bloated with useless binaries. The Linux/Mac package only contains the sources and works perfectly on Windows. -Extract the content of the source archive to "C:\qTox\libs". Furthermore, create a new directory named "opencv-build" in "C:\qTox\libs". +Extract the content of the source archive to "C:\qTox\libs". Furthermore, create a new directory named "opencv-build" in "C:\qTox\libs". Now you should have the two directories "opencv-x.y.z" where x.y.z is the version of OpenCV and "opencv-build" inside your "C:\qTox\libs" directory. -Run CMake (cmake-gui) and set up the input boxes "Where is the source code:" and "Where to build the binaries" with "C:\qTox\libs\opencv-x.y.z" and "C:\qTox\libs\opencv-build". Press configure and choose "MSYS Makefiles" in the drop down menu and "Use default native compilers". Press "Finish" to start configuration. TODO + +Run CMake (cmake-gui) and set up the input boxes "Where is the source code:" and "Where to build the binaries" with "C:\qTox\libs\opencv-x.y.z" and "C:\qTox\libs\opencv-build". Press configure and choose "MSYS Makefiles" in the drop down menu and "Use default native compilers". To start initial configuration press Finish. Given that qTox only needs some components of OpenCV it's recommended to disable not required modules. Furthermore, this will decrease compilation time of OpenCV dramatically. Each module begins with "BUILD_opencv_" and can be disabled by deselecting its entry. Use the "Search" input box for convenience. Disable all modules except of "core", "highgui" and "imgproc" (highgui depends on imgproc and will automatically be disabled if imgproc is disabled). For maximum performance search for "CMAKE_BUILD_TYPE" and select "Release". Finally, make sure "CMAKE_INSTALL_PREFIX" points to "C:\qTox\libs\opencv-build\install" (should be by default). To update the configuration press Configure again. Afterwards press Generate to create the Makefiles. + +Open a new command prompt within "C:\qTox\libs\opencv-build" (HINT: Use shift + right click on the directory within Windows explorer and use "Open command window here"). Compile and install OpenCV with the following command. It's not recommended to use -j for multicore compilation, because it freezes the terminal from time to time. +```bash +make +make install +``` + +After OpenCV was successfully installed to "C:\qTox\libs\opencv-build\install" copy the dlls "libopencv_core249.dll", "libopencv_highgui249.dll" and "libopencv_imgproc249.dll" located at "C:\qTox\libs\opencv-build\install\x86\mingw\bin" to "C:\qTox\libs\lib". Afterwards copy the content of the directory "C:\qTox\libs\opencv-build\install\include" to "C:\qTox\libs\include". Finally, you have to patch the file "C:\qTox\libs\include\opencv2\opencv.hpp" because it includes all modules of OpenCV regardless of your configuration. ###OpenAL Soft From 7f7299fefb2a641e9cb60be25eadef54a58d2b94 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 7 Sep 2014 19:00:32 +0200 Subject: [PATCH 34/46] Update INSTALL.md improved --- INSTALL.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index c06428020..18513ce23 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -47,19 +47,19 @@ If you prefer to compile Tox Core on your own follow the instructions at https:/ Unfortunately there are no prebuild packages for OpenCV compiled with MinGW. Thus, you have to create your own. First of all download and install the most recent version of CMake from [cmake.org](http://www.cmake.org/cmake/resources/software.html). -Afterwards download the source archive of OpenCV from [http://opencv.org](http://opencv.org/downloads.html). It's recommended to download the Linux/Mac package because the Windows package is bloated with useless binaries. The Linux/Mac package only contains the sources and works perfectly on Windows. +Afterwards download the most recent, stable source archive of OpenCV from [http://opencv.org](http://opencv.org/downloads.html). It's recommended to download the Linux/Mac package because the Windows package is bloated with useless binaries. The Linux/Mac package only contains the sources and works perfectly on Windows. Extract the content of the source archive to "C:\qTox\libs". Furthermore, create a new directory named "opencv-build" in "C:\qTox\libs". Now you should have the two directories "opencv-x.y.z" where x.y.z is the version of OpenCV and "opencv-build" inside your "C:\qTox\libs" directory. Run CMake (cmake-gui) and set up the input boxes "Where is the source code:" and "Where to build the binaries" with "C:\qTox\libs\opencv-x.y.z" and "C:\qTox\libs\opencv-build". Press configure and choose "MSYS Makefiles" in the drop down menu and "Use default native compilers". To start initial configuration press Finish. Given that qTox only needs some components of OpenCV it's recommended to disable not required modules. Furthermore, this will decrease compilation time of OpenCV dramatically. Each module begins with "BUILD_opencv_" and can be disabled by deselecting its entry. Use the "Search" input box for convenience. Disable all modules except of "core", "highgui" and "imgproc" (highgui depends on imgproc and will automatically be disabled if imgproc is disabled). For maximum performance search for "CMAKE_BUILD_TYPE" and select "Release". Finally, make sure "CMAKE_INSTALL_PREFIX" points to "C:\qTox\libs\opencv-build\install" (should be by default). To update the configuration press Configure again. Afterwards press Generate to create the Makefiles. -Open a new command prompt within "C:\qTox\libs\opencv-build" (HINT: Use shift + right click on the directory within Windows explorer and use "Open command window here"). Compile and install OpenCV with the following command. It's not recommended to use -j for multicore compilation, because it freezes the terminal from time to time. +Open a new command prompt within "C:\qTox\libs\opencv-build" (HINT: Use shift + right click -> "Open command window here" on the directory within Windows Explorer). Compile and install OpenCV with the following command. It's not recommended to use -j for multicore compilation, because it freezes the terminal from time to time. ```bash make make install ``` -After OpenCV was successfully installed to "C:\qTox\libs\opencv-build\install" copy the dlls "libopencv_core249.dll", "libopencv_highgui249.dll" and "libopencv_imgproc249.dll" located at "C:\qTox\libs\opencv-build\install\x86\mingw\bin" to "C:\qTox\libs\lib". Afterwards copy the content of the directory "C:\qTox\libs\opencv-build\install\include" to "C:\qTox\libs\include". Finally, you have to patch the file "C:\qTox\libs\include\opencv2\opencv.hpp" because it includes all modules of OpenCV regardless of your configuration. +After OpenCV was successfully installed to "C:\qTox\libs\opencv-build\install" copy the dlls "libopencv_core249.dll", "libopencv_highgui249.dll" and "libopencv_imgproc249.dll" located at "C:\qTox\libs\opencv-build\install\x86\mingw\bin" to "C:\qTox\libs\lib". Afterwards copy the content of the directory "C:\qTox\libs\opencv-build\install\include" to "C:\qTox\libs\include". Finally, you have to patch the file "C:\qTox\libs\include\opencv2\opencv.hpp" because it includes all modules of OpenCV regardless of your configuration. Open this file with your preferred text editor and remove all includes except of "opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/imgproc.hpp", "opencv2/highgui/highgui_c.h" and "opencv2/highgui/highgui.hpp". OpenCV is now ready. Feel free to delete the directories "opencv-x.y.z" and "opencv-build", but you don't need to. ###OpenAL Soft From af100c64ac59d617922c44f134953c7d22c471b9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 7 Sep 2014 19:21:18 +0200 Subject: [PATCH 35/46] Update INSTALL.md OpenAL Soft --- INSTALL.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 18513ce23..783df5250 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -62,8 +62,12 @@ make install After OpenCV was successfully installed to "C:\qTox\libs\opencv-build\install" copy the dlls "libopencv_core249.dll", "libopencv_highgui249.dll" and "libopencv_imgproc249.dll" located at "C:\qTox\libs\opencv-build\install\x86\mingw\bin" to "C:\qTox\libs\lib". Afterwards copy the content of the directory "C:\qTox\libs\opencv-build\install\include" to "C:\qTox\libs\include". Finally, you have to patch the file "C:\qTox\libs\include\opencv2\opencv.hpp" because it includes all modules of OpenCV regardless of your configuration. Open this file with your preferred text editor and remove all includes except of "opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/imgproc.hpp", "opencv2/highgui/highgui_c.h" and "opencv2/highgui/highgui.hpp". OpenCV is now ready. Feel free to delete the directories "opencv-x.y.z" and "opencv-build", but you don't need to. ###OpenAL Soft - - +As for OpenCV there are no prebuild packages of OpenAL Softe compiled with MinGW, but the installation process is very similar to OpenCV. Download the most recent source archive of OpenAL Soft from [http://kcat.strangesoft.net](http://kcat.strangesoft.net/openal.html#download). Extract its content to "C:\qTox\libs". Besides the source folder itself you'll find the file "pax_global_header". It is not required and can be deleted. Create the directory "openal-build" next to source folder. Now you should have the two directories "openal-soft-x.y.z" where x.y.z is the version of OpenAL and "openal-build" inside your "C:\qTox\libs" directory. Run CMake (cmake-gui) and setup the source and build location. Run the initial configuration and use "MSYS Makefiles" with "Use default native compilers". The only thing you need to configure is "CMAKE_INSTALL_PREFIX" which does not point to "C:\qTox\libs\openal-build\install" by default. Configure the project and generate the Makefiles. Compile and install OpenAL soft with: +```bash +make +make install +``` +Copy the dll "OpenAL32.dll" located at "C:\qTox\libs\openal-build\install\bin" to "C:\qTox\libs\lib". Finally, copy the directory "AL" located at "C:\qTox\libs\openal-build\install\include" to "C:\qTox\libs\include". Unlike OpenCV you don't need to patch any files. Feel free to delete the directories "openal-soft-x.y.z" and "openal-build", but you don't need to. ##Linux Most of the dependencies should be available through your package manger. From 598f4948b8faf266de0ec663c91de9b6aa156af2 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 7 Sep 2014 19:31:49 +0200 Subject: [PATCH 36/46] Update INSTALL.md improved --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 783df5250..979aeea18 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -59,7 +59,7 @@ make make install ``` -After OpenCV was successfully installed to "C:\qTox\libs\opencv-build\install" copy the dlls "libopencv_core249.dll", "libopencv_highgui249.dll" and "libopencv_imgproc249.dll" located at "C:\qTox\libs\opencv-build\install\x86\mingw\bin" to "C:\qTox\libs\lib". Afterwards copy the content of the directory "C:\qTox\libs\opencv-build\install\include" to "C:\qTox\libs\include". Finally, you have to patch the file "C:\qTox\libs\include\opencv2\opencv.hpp" because it includes all modules of OpenCV regardless of your configuration. Open this file with your preferred text editor and remove all includes except of "opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/imgproc.hpp", "opencv2/highgui/highgui_c.h" and "opencv2/highgui/highgui.hpp". OpenCV is now ready. Feel free to delete the directories "opencv-x.y.z" and "opencv-build", but you don't need to. +After OpenCV was successfully installed to "C:\qTox\libs\opencv-build\install" copy the dlls "libopencv_coreXYZ.dll", "libopencv_highguiXYZ.dll" and "libopencv_imgprocXYZ.dll" located at "C:\qTox\libs\opencv-build\install\x86\mingw\bin" to "C:\qTox\libs\lib", where XYZ is any version number. Rename the files and remove XYZ. Afterwards copy the content of the directory "C:\qTox\libs\opencv-build\install\include" to "C:\qTox\libs\include". Finally, you have to patch the file "C:\qTox\libs\include\opencv2\opencv.hpp" because it includes all modules of OpenCV regardless of your configuration. Open this file with your preferred text editor and remove all includes except of "opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/imgproc.hpp", "opencv2/highgui/highgui_c.h" and "opencv2/highgui/highgui.hpp". OpenCV is now ready. Feel free to delete the directories "opencv-x.y.z" and "opencv-build", but you don't need to. ###OpenAL Soft As for OpenCV there are no prebuild packages of OpenAL Softe compiled with MinGW, but the installation process is very similar to OpenCV. Download the most recent source archive of OpenAL Soft from [http://kcat.strangesoft.net](http://kcat.strangesoft.net/openal.html#download). Extract its content to "C:\qTox\libs". Besides the source folder itself you'll find the file "pax_global_header". It is not required and can be deleted. Create the directory "openal-build" next to source folder. Now you should have the two directories "openal-soft-x.y.z" where x.y.z is the version of OpenAL and "openal-build" inside your "C:\qTox\libs" directory. Run CMake (cmake-gui) and setup the source and build location. Run the initial configuration and use "MSYS Makefiles" with "Use default native compilers". The only thing you need to configure is "CMAKE_INSTALL_PREFIX" which does not point to "C:\qTox\libs\openal-build\install" by default. Configure the project and generate the Makefiles. Compile and install OpenAL soft with: From 9ebca88e11f7df803768798f6d7295f07b352974 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 7 Sep 2014 19:35:30 +0200 Subject: [PATCH 37/46] Update INSTALL.md improved --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 979aeea18..57badbb42 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -59,7 +59,7 @@ make make install ``` -After OpenCV was successfully installed to "C:\qTox\libs\opencv-build\install" copy the dlls "libopencv_coreXYZ.dll", "libopencv_highguiXYZ.dll" and "libopencv_imgprocXYZ.dll" located at "C:\qTox\libs\opencv-build\install\x86\mingw\bin" to "C:\qTox\libs\lib", where XYZ is any version number. Rename the files and remove XYZ. Afterwards copy the content of the directory "C:\qTox\libs\opencv-build\install\include" to "C:\qTox\libs\include". Finally, you have to patch the file "C:\qTox\libs\include\opencv2\opencv.hpp" because it includes all modules of OpenCV regardless of your configuration. Open this file with your preferred text editor and remove all includes except of "opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/imgproc.hpp", "opencv2/highgui/highgui_c.h" and "opencv2/highgui/highgui.hpp". OpenCV is now ready. Feel free to delete the directories "opencv-x.y.z" and "opencv-build", but you don't need to. +After OpenCV was successfully installed to "C:\qTox\libs\opencv-build\install" copy the dlls "libopencv_coreXYZ.dll", "libopencv_highguiXYZ.dll" and "libopencv_imgprocXYZ.dll" located at "C:\qTox\libs\opencv-build\install\x86\mingw\bin" to "C:\qTox\libs\lib", where XYZ is the version number. Rename the files and remove XYZ. Afterwards copy the content of the directory "C:\qTox\libs\opencv-build\install\include" to "C:\qTox\libs\include". Finally, you have to patch the file "C:\qTox\libs\include\opencv2\opencv.hpp" because it includes all modules of OpenCV regardless of your configuration. Open this file with your preferred text editor and remove all includes except of "opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/imgproc.hpp", "opencv2/highgui/highgui_c.h" and "opencv2/highgui/highgui.hpp". OpenCV is now ready. Feel free to delete the directories "opencv-x.y.z" and "opencv-build", but you don't need to. ###OpenAL Soft As for OpenCV there are no prebuild packages of OpenAL Softe compiled with MinGW, but the installation process is very similar to OpenCV. Download the most recent source archive of OpenAL Soft from [http://kcat.strangesoft.net](http://kcat.strangesoft.net/openal.html#download). Extract its content to "C:\qTox\libs". Besides the source folder itself you'll find the file "pax_global_header". It is not required and can be deleted. Create the directory "openal-build" next to source folder. Now you should have the two directories "openal-soft-x.y.z" where x.y.z is the version of OpenAL and "openal-build" inside your "C:\qTox\libs" directory. Run CMake (cmake-gui) and setup the source and build location. Run the initial configuration and use "MSYS Makefiles" with "Use default native compilers". The only thing you need to configure is "CMAKE_INSTALL_PREFIX" which does not point to "C:\qTox\libs\openal-build\install" by default. Configure the project and generate the Makefiles. Compile and install OpenAL soft with: From 7c818753b380810f48e59798b6277c7ca8c55ab9 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 7 Sep 2014 19:57:13 +0200 Subject: [PATCH 38/46] Update INSTALL.md --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 57badbb42..ffb1eda8c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -51,7 +51,7 @@ Afterwards download the most recent, stable source archive of OpenCV from [http: Extract the content of the source archive to "C:\qTox\libs". Furthermore, create a new directory named "opencv-build" in "C:\qTox\libs". Now you should have the two directories "opencv-x.y.z" where x.y.z is the version of OpenCV and "opencv-build" inside your "C:\qTox\libs" directory. -Run CMake (cmake-gui) and set up the input boxes "Where is the source code:" and "Where to build the binaries" with "C:\qTox\libs\opencv-x.y.z" and "C:\qTox\libs\opencv-build". Press configure and choose "MSYS Makefiles" in the drop down menu and "Use default native compilers". To start initial configuration press Finish. Given that qTox only needs some components of OpenCV it's recommended to disable not required modules. Furthermore, this will decrease compilation time of OpenCV dramatically. Each module begins with "BUILD_opencv_" and can be disabled by deselecting its entry. Use the "Search" input box for convenience. Disable all modules except of "core", "highgui" and "imgproc" (highgui depends on imgproc and will automatically be disabled if imgproc is disabled). For maximum performance search for "CMAKE_BUILD_TYPE" and select "Release". Finally, make sure "CMAKE_INSTALL_PREFIX" points to "C:\qTox\libs\opencv-build\install" (should be by default). To update the configuration press Configure again. Afterwards press Generate to create the Makefiles. +Run CMake (cmake-gui) and set up the input boxes "Where is the source code:" and "Where to build the binaries" with "C:\qTox\libs\opencv-x.y.z" and "C:\qTox\libs\opencv-build". Press configure and choose "MSYS Makefiles" in the drop down menu with "Use default native compilers". To start initial configuration press Finish. Given that qTox only needs some components of OpenCV it's recommended to disable not required modules. Furthermore, this will decrease compilation time of OpenCV dramatically. Each module begins with "BUILD_opencv_" and can be disabled by deselecting its entry. Use the "Search" input box for convenience. Disable all modules except of "core", "highgui" and "imgproc" (highgui depends on imgproc and will automatically be disabled if imgproc is disabled). For maximum performance search for "CMAKE_BUILD_TYPE" and select "Release". Finally, make sure "CMAKE_INSTALL_PREFIX" points to "C:\qTox\libs\opencv-build\install" (should be by default). To update the configuration press Configure again. Afterwards press Generate to create the Makefiles. Open a new command prompt within "C:\qTox\libs\opencv-build" (HINT: Use shift + right click -> "Open command window here" on the directory within Windows Explorer). Compile and install OpenCV with the following command. It's not recommended to use -j for multicore compilation, because it freezes the terminal from time to time. ```bash From f67831b4dccf71af542f8c6a5cf59f9c2d43a12a Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 8 Sep 2014 00:33:34 +0200 Subject: [PATCH 39/46] Update INSTALL.md use direct version of opencv --- INSTALL.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index ffb1eda8c..484c80cbb 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -47,11 +47,11 @@ If you prefer to compile Tox Core on your own follow the instructions at https:/ Unfortunately there are no prebuild packages for OpenCV compiled with MinGW. Thus, you have to create your own. First of all download and install the most recent version of CMake from [cmake.org](http://www.cmake.org/cmake/resources/software.html). -Afterwards download the most recent, stable source archive of OpenCV from [http://opencv.org](http://opencv.org/downloads.html). It's recommended to download the Linux/Mac package because the Windows package is bloated with useless binaries. The Linux/Mac package only contains the sources and works perfectly on Windows. +Afterwards download OpenCV in version 2.4.9 from [sourceforge.net](http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip/download). Extract the content of the source archive to "C:\qTox\libs". Furthermore, create a new directory named "opencv-build" in "C:\qTox\libs". -Now you should have the two directories "opencv-x.y.z" where x.y.z is the version of OpenCV and "opencv-build" inside your "C:\qTox\libs" directory. +Now you should have the two directories "opencv-2.4.9" and "opencv-build" inside your "C:\qTox\libs" directory. -Run CMake (cmake-gui) and set up the input boxes "Where is the source code:" and "Where to build the binaries" with "C:\qTox\libs\opencv-x.y.z" and "C:\qTox\libs\opencv-build". Press configure and choose "MSYS Makefiles" in the drop down menu with "Use default native compilers". To start initial configuration press Finish. Given that qTox only needs some components of OpenCV it's recommended to disable not required modules. Furthermore, this will decrease compilation time of OpenCV dramatically. Each module begins with "BUILD_opencv_" and can be disabled by deselecting its entry. Use the "Search" input box for convenience. Disable all modules except of "core", "highgui" and "imgproc" (highgui depends on imgproc and will automatically be disabled if imgproc is disabled). For maximum performance search for "CMAKE_BUILD_TYPE" and select "Release". Finally, make sure "CMAKE_INSTALL_PREFIX" points to "C:\qTox\libs\opencv-build\install" (should be by default). To update the configuration press Configure again. Afterwards press Generate to create the Makefiles. +Run CMake (cmake-gui) and set up the input boxes "Where is the source code:" and "Where to build the binaries" with "C:\qTox\libs\opencv-2.4.9" and "C:\qTox\libs\opencv-build". Press configure and choose "MSYS Makefiles" in the drop down menu with "Use default native compilers". To start initial configuration press Finish. Given that qTox only needs some components of OpenCV it's recommended to disable not required modules. Furthermore, this will decrease compilation time of OpenCV dramatically. Each module begins with "BUILD_opencv_" and can be disabled by deselecting its entry. Use the "Search" input box for convenience. Disable all modules except of "core", "highgui" and "imgproc" (highgui depends on imgproc and will automatically be disabled if imgproc is disabled). For maximum performance search for "CMAKE_BUILD_TYPE" and set this value to "Release". Finally, make sure "CMAKE_INSTALL_PREFIX" points to "C:\qTox\libs\opencv-build\install" (should be by default). To update the configuration press Configure again. To generate the Makefiles press Generate. Open a new command prompt within "C:\qTox\libs\opencv-build" (HINT: Use shift + right click -> "Open command window here" on the directory within Windows Explorer). Compile and install OpenCV with the following command. It's not recommended to use -j for multicore compilation, because it freezes the terminal from time to time. ```bash @@ -59,7 +59,7 @@ make make install ``` -After OpenCV was successfully installed to "C:\qTox\libs\opencv-build\install" copy the dlls "libopencv_coreXYZ.dll", "libopencv_highguiXYZ.dll" and "libopencv_imgprocXYZ.dll" located at "C:\qTox\libs\opencv-build\install\x86\mingw\bin" to "C:\qTox\libs\lib", where XYZ is the version number. Rename the files and remove XYZ. Afterwards copy the content of the directory "C:\qTox\libs\opencv-build\install\include" to "C:\qTox\libs\include". Finally, you have to patch the file "C:\qTox\libs\include\opencv2\opencv.hpp" because it includes all modules of OpenCV regardless of your configuration. Open this file with your preferred text editor and remove all includes except of "opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/imgproc.hpp", "opencv2/highgui/highgui_c.h" and "opencv2/highgui/highgui.hpp". OpenCV is now ready. Feel free to delete the directories "opencv-x.y.z" and "opencv-build", but you don't need to. +After OpenCV was successfully installed to "C:\qTox\libs\opencv-build\install" copy the dlls "libopencv_core249.dll", "libopencv_highgui249.dll" and "libopencv_imgproc249.dll" located at "C:\qTox\libs\opencv-build\install\x86\mingw\bin" to "C:\qTox\libs\lib". Afterwards copy the content of the directory "C:\qTox\libs\opencv-build\install\include" to "C:\qTox\libs\include". Finally, you have to patch the file "C:\qTox\libs\include\opencv2\opencv.hpp" because it includes all modules of OpenCV regardless of your configuration. Open this file with your preferred text editor and remove all includes except of "opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/imgproc.hpp", "opencv2/highgui/highgui_c.h" and "opencv2/highgui/highgui.hpp". OpenCV is now ready to use. Feel free to delete the directories "opencv-2.4.9" and "opencv-build", but you don't need to. ###OpenAL Soft As for OpenCV there are no prebuild packages of OpenAL Softe compiled with MinGW, but the installation process is very similar to OpenCV. Download the most recent source archive of OpenAL Soft from [http://kcat.strangesoft.net](http://kcat.strangesoft.net/openal.html#download). Extract its content to "C:\qTox\libs". Besides the source folder itself you'll find the file "pax_global_header". It is not required and can be deleted. Create the directory "openal-build" next to source folder. Now you should have the two directories "openal-soft-x.y.z" where x.y.z is the version of OpenAL and "openal-build" inside your "C:\qTox\libs" directory. Run CMake (cmake-gui) and setup the source and build location. Run the initial configuration and use "MSYS Makefiles" with "Use default native compilers". The only thing you need to configure is "CMAKE_INSTALL_PREFIX" which does not point to "C:\qTox\libs\openal-build\install" by default. Configure the project and generate the Makefiles. Compile and install OpenAL soft with: From e6608d5eee2df061c630496a0ec8b2ce3a1eb1e2 Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 8 Sep 2014 00:35:22 +0200 Subject: [PATCH 40/46] Update INSTALL.md improved --- INSTALL.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 484c80cbb..7882f82ec 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -47,8 +47,7 @@ If you prefer to compile Tox Core on your own follow the instructions at https:/ Unfortunately there are no prebuild packages for OpenCV compiled with MinGW. Thus, you have to create your own. First of all download and install the most recent version of CMake from [cmake.org](http://www.cmake.org/cmake/resources/software.html). -Afterwards download OpenCV in version 2.4.9 from [sourceforge.net](http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip/download). -Extract the content of the source archive to "C:\qTox\libs". Furthermore, create a new directory named "opencv-build" in "C:\qTox\libs". +Afterwards download OpenCV in version 2.4.9 from [sourceforge.net](http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip/download) and extract the content of the source archive to "C:\qTox\libs". Furthermore, create a new directory named "opencv-build" in "C:\qTox\libs". Now you should have the two directories "opencv-2.4.9" and "opencv-build" inside your "C:\qTox\libs" directory. Run CMake (cmake-gui) and set up the input boxes "Where is the source code:" and "Where to build the binaries" with "C:\qTox\libs\opencv-2.4.9" and "C:\qTox\libs\opencv-build". Press configure and choose "MSYS Makefiles" in the drop down menu with "Use default native compilers". To start initial configuration press Finish. Given that qTox only needs some components of OpenCV it's recommended to disable not required modules. Furthermore, this will decrease compilation time of OpenCV dramatically. Each module begins with "BUILD_opencv_" and can be disabled by deselecting its entry. Use the "Search" input box for convenience. Disable all modules except of "core", "highgui" and "imgproc" (highgui depends on imgproc and will automatically be disabled if imgproc is disabled). For maximum performance search for "CMAKE_BUILD_TYPE" and set this value to "Release". Finally, make sure "CMAKE_INSTALL_PREFIX" points to "C:\qTox\libs\opencv-build\install" (should be by default). To update the configuration press Configure again. To generate the Makefiles press Generate. From a37785cce865000f13a9e5352774641be360c8ee Mon Sep 17 00:00:00 2001 From: retux Date: Mon, 8 Sep 2014 00:41:21 +0200 Subject: [PATCH 41/46] fixed pro file for windows --- qtox.pro | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/qtox.pro b/qtox.pro index 05f1c16ce..607d25791 100644 --- a/qtox.pro +++ b/qtox.pro @@ -44,21 +44,24 @@ contains(JENKINS,YES) { # Rules for Windows, Mac OSX, and Linux win32 { - LIBS += $$PWD/libs/lib/libtoxav.a $$PWD/libs/lib/libopus.a $$PWD/libs/lib/libvpx.a $$PWD/libs/lib/libopenal32.a $$PWD/libs/lib/libtoxcore.a -lws2_32 $$PWD/libs/lib/libsodium.a -lpthread -liphlpapi -} macx { - LIBS += -L$$PWD/libs/lib/ -ltoxcore -ltoxav -lsodium -lvpx -framework OpenAL -lopencv_core -lopencv_highgui + LIBS += -L$$PWD/libs/lib -llibopencv_core249 -llibopencv_highgui249 -llibopencv_imgproc249 -lOpenAL32 + LIBS += $$PWD/libs/lib/libtoxav.a $$PWD/libs/lib/libopus.a $$PWD/libs/lib/libvpx.a $$PWD/libs/lib/libtoxcore.a -lws2_32 $$PWD/libs/lib/libsodium.a -lpthread -liphlpapi } else { - # If we're building a package, static link libtox[core,av] and libsodium, since they are not provided by any package - contains(STATICPKG, YES) { - target.path = /usr/bin - INSTALLS += target - LIBS += -L$$PWD/libs/lib/ -Wl,-Bstatic -ltoxcore -ltoxav -lsodium -Wl,-Bdynamic -lopus -lvpx -lopenal -lopencv_core -lopencv_highgui + macx { + LIBS += -L$$PWD/libs/lib/ -ltoxcore -ltoxav -lsodium -lvpx -framework OpenAL -lopencv_core -lopencv_highgui } else { - LIBS += -L$$PWD/libs/lib/ -ltoxcore -ltoxav -lvpx -lopenal -lopencv_core -lopencv_highgui - } + # If we're building a package, static link libtox[core,av] and libsodium, since they are not provided by any package + contains(STATICPKG, YES) { + target.path = /usr/bin + INSTALLS += target + LIBS += -L$$PWD/libs/lib/ -Wl,-Bstatic -ltoxcore -ltoxav -lsodium -Wl,-Bdynamic -lopus -lvpx -lopenal -lopencv_core -lopencv_highgui + } else { + LIBS += -L$$PWD/libs/lib/ -ltoxcore -ltoxav -lvpx -lopenal -lopencv_core -lopencv_highgui + } - contains(JENKINS, YES) { - LIBS = ./libs/lib/libtoxav.a ./libs/lib/libvpx.a ./libs/lib/libopus.a ./libs/lib/libtoxcore.a ./libs/lib/libsodium.a -lopencv_core -lopencv_highgui -lopenal + contains(JENKINS, YES) { + LIBS = ./libs/lib/libtoxav.a ./libs/lib/libvpx.a ./libs/lib/libopus.a ./libs/lib/libtoxcore.a ./libs/lib/libsodium.a -lopencv_core -lopencv_highgui -lopenal + } } } From d9ef2db89b3db5de339b2f10581f9011d18d263c Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 8 Sep 2014 00:48:12 +0200 Subject: [PATCH 42/46] Update INSTALL.md --- INSTALL.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 7882f82ec..26576b81c 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -61,7 +61,7 @@ make install After OpenCV was successfully installed to "C:\qTox\libs\opencv-build\install" copy the dlls "libopencv_core249.dll", "libopencv_highgui249.dll" and "libopencv_imgproc249.dll" located at "C:\qTox\libs\opencv-build\install\x86\mingw\bin" to "C:\qTox\libs\lib". Afterwards copy the content of the directory "C:\qTox\libs\opencv-build\install\include" to "C:\qTox\libs\include". Finally, you have to patch the file "C:\qTox\libs\include\opencv2\opencv.hpp" because it includes all modules of OpenCV regardless of your configuration. Open this file with your preferred text editor and remove all includes except of "opencv2/core/core_c.h", "opencv2/core/core.hpp", "opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/imgproc.hpp", "opencv2/highgui/highgui_c.h" and "opencv2/highgui/highgui.hpp". OpenCV is now ready to use. Feel free to delete the directories "opencv-2.4.9" and "opencv-build", but you don't need to. ###OpenAL Soft -As for OpenCV there are no prebuild packages of OpenAL Softe compiled with MinGW, but the installation process is very similar to OpenCV. Download the most recent source archive of OpenAL Soft from [http://kcat.strangesoft.net](http://kcat.strangesoft.net/openal.html#download). Extract its content to "C:\qTox\libs". Besides the source folder itself you'll find the file "pax_global_header". It is not required and can be deleted. Create the directory "openal-build" next to source folder. Now you should have the two directories "openal-soft-x.y.z" where x.y.z is the version of OpenAL and "openal-build" inside your "C:\qTox\libs" directory. Run CMake (cmake-gui) and setup the source and build location. Run the initial configuration and use "MSYS Makefiles" with "Use default native compilers". The only thing you need to configure is "CMAKE_INSTALL_PREFIX" which does not point to "C:\qTox\libs\openal-build\install" by default. Configure the project and generate the Makefiles. Compile and install OpenAL soft with: +As for OpenCV there are no prebuild packages of OpenAL Softe compiled with MinGW, but the installation process is very similar to OpenCV. Download the most recent source archive of OpenAL Soft from [http://kcat.strangesoft.net](http://kcat.strangesoft.net/openal.html#download). Extract its content to "C:\qTox\libs". Besides the source folder itself you'll find the file "pax_global_header". It is not required and can be deleted. Create the directory "openal-build" next to source folder. Now you should have the two directories "openal-soft-x.y.z" where x.y.z is the version of OpenAL and "openal-build" inside your "C:\qTox\libs" directory. Run CMake (cmake-gui) and setup the source and build location. Run the initial configuration and use "MSYS Makefiles" with "Use default native compilers". The only thing you need to configure is "CMAKE_INSTALL_PREFIX" which does not point to "C:\qTox\libs\openal-build\install" by default. Configure the project and generate the Makefiles. Compile and install OpenAL Soft with: ```bash make make install @@ -86,7 +86,7 @@ sudo apt-get install git Arch Linux: ```bash -sudo pacman -S git +sudo pacman -S --needed git ``` Fedora: @@ -116,7 +116,7 @@ sudo apt-get install build-essential qt5-qmake qt5-default libopenal-dev libopen Arch Linux: ```bash -sudo pacman -S base-devel qt5 opencv openal +sudo pacman -S --needed base-devel qt5 opencv openal ``` Fedora: @@ -141,7 +141,7 @@ sudo apt-get install libtool autotools-dev automake checkinstall check yasm libo Arch Linux: (Arch Linux provides the package "tox-git" in AUR) ```bash -sudo pacman -S yasm opus vpx +sudo pacman -S --needed yasm opus vpx ``` Fedora: From 18c36145bdfbfffd0813ac82c5050b9861f70277 Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 8 Sep 2014 00:59:31 +0200 Subject: [PATCH 43/46] Update INSTALL.md added section "Building packages" --- INSTALL.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index 26576b81c..26220b1be 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -155,3 +155,12 @@ The script will automatically download and install Tox Core and libsodium to "/h cd /home/user/qTox ./bootstrap.sh # use -h or --help for more information ``` + +##Building packages + +qTox now has the experimental and probably-dodgy ability to package itself (in .deb +form natively, and .rpm form with alien). + +After installing the required dependencies, run `bootstrap.sh` and then run the +`buildPackages.sh` script, found in the tools folder. It will automatically get the +packages necessary for building .debs, so be prepared to type your password for sudo. From 9e5c0456d3e1d84d2e62be3f61798145ae5fdbcb Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 8 Sep 2014 01:01:31 +0200 Subject: [PATCH 44/46] Update README.md use INSTALL.md --- README.md | 100 ++---------------------------------------------------- 1 file changed, 2 insertions(+), 98 deletions(-) diff --git a/README.md b/README.md index 6264fbf25..6bc803bb5 100644 --- a/README.md +++ b/README.md @@ -28,102 +28,6 @@ This client runs on Windows, Linux and Mac natively.
-

Compiling on GNU-Linux

-

Acquiring dependencies

-Compiling qTox requires several dependencies, however these are easily installable -with your system's package manager. The step-by-step instructions assume Debian-style apt, but -it should be easy enough to get equivalent packages with yum or pacman. +##Documentation: -First, we need Qt 5.2 with a C++11 compatible compiler: -```bash -sudo apt-get install build-essential qt5-qmake qt5-default -``` - -toxcore and toxav, the client-agnostic network code for Tox, has several dependencies -of its own (see its installation guide for more details): -```bash -sudo apt-get install libtool autotools-dev automake checkinstall check git yasm libopus-dev libvpx-dev -``` - -Finally, qTox itself requires OpenAL and OpenCV: -```bash -sudo apt-get install libopenal-dev libopencv-dev -``` - -

Compilation

- -Having acquired all the dependencies, the following commands should get and compile qTox: - -```bash -wget -O qtox.tgz https://github.com/tux3/qTox/archive/master.tar.gz -tar xvf qtox.tgz -cd qTox-master -./bootstrap.sh # This will automagically download and compile libsodium, toxcore, and toxav -qmake -make # Should compile to "qtox" -``` - -And that's it! - -

Building packages

- -qTox now has the experimental and probably-dodgy ability to package itself (in .deb -form natively, and .rpm form with alien). - -After installing the required dependencies, run `bootstrap.sh` and then run the -`buildPackages.sh` script, found in the tools folder. It will automatically get the -packages necessary for building .debs, so be prepared to type your password for sudo. - -

OSX Easy Install

- -Since https://github.com/ReDetection/homebrew-qtox you can easily install qtox with homebrew -```bash -brew install --HEAD ReDetection/qtox/qtox -``` - -

OSX Full Install Guide

- -This guide is intended for people who wish to use an existing or new ProjectTox-Core installation separate to the bundled installation with qTox, if you do not wish to use a separate installation you can skip to the section titled 'Final Steps'. - -Installation on OSX, isn't quite straight forward, here is a quick guide on how to install; - -The first thing you need to do is install ProjectTox-Core with a/v support. Refer to the INSTALL guide in the ProjectTox-Core github repo. - -Next you need to download QtTools (http://qt-project.org/downloads), at the time of writing this is at version 5.3.0. -Make sure you deselect all the unnecessary components from the 5.3 checkbox (iOS/Android libs) otherwise you will end up with a very large download. - -Once that is installed you will most likely need to set the path for qmake. To do this, open up terminal and paste in the following; - -```bash -export PATH=/location/to/qmake/binary:$PATH -``` - -For myself, the qmake binary was located in /Users/mouseym/Qt/5.3/clang_64/bin/. - -This is not a permanent change, it will revert when you close the terminal window, to add it permanently you will need to add echo the above line to your .profile/.bash_profile. - -Once this is installed, do the following; - -```bash -git clone https://github.com/tux3/qTox -cd toxgui -qmake -``` - -Now, we need to create a symlink to /usr/local/lib/ and /usr/local/include/ -``` -mkdir -p $HOME/qTox/libs -sudo ln -s /usr/local/lib $HOME/qTox/libs/lib -sudo ln -s /usr/local/include $HOME/qTox/libs/include -``` -
Final Steps
- -The final step is to run -```bash -make -``` -in the qTox directory, or if you are using the bundled tox core installation, you can use -```bash -./bootstrap.sh -``` -Assuming all went well you should now have a qTox.app file within the directory. Double click and it should open! +[Compiling](/INSTALL.md) From 8b7b6dd08cc5627e17771d1c36c6567e6f70b981 Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 8 Sep 2014 01:03:05 +0200 Subject: [PATCH 45/46] Update INSTALL.md typo --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 26220b1be..f53adbeb4 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -14,7 +14,7 @@ Download the Qt online installer for Windows from [qt-project.org](http://qt-project.org/downloads). While installation you have to assemble your Qt toolchain. Take the most recent version of Qt compiled with MinGW. -Although the installer provides its own bundled MinGW compiler Toolchain its recommend installing it separately because Qt is missing MSYS which is needed to compile and install OpenCV and OpenAL. Thus you can - if needed - deselect the tab "Tools". +Although the installer provides its own bundled MinGW compiler toolchain its recommend installing it separately because Qt is missing MSYS which is needed to compile and install OpenCV and OpenAL. Thus you can - if needed - deselect the tab "Tools". The following steps assume that Qt is installed at "C:\Qt". If you decided to choose another location, replace corresponding parts. ###MinGW From 3f35a5a48d557d87315783977d1e1f8da2471111 Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Tue, 9 Sep 2014 22:36:34 +0200 Subject: [PATCH 46/46] Fix #266 --- widget/chatareawidget.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/widget/chatareawidget.cpp b/widget/chatareawidget.cpp index e3d021dd7..9f8633b97 100644 --- a/widget/chatareawidget.cpp +++ b/widget/chatareawidget.cpp @@ -25,6 +25,7 @@ ChatAreaWidget::ChatAreaWidget(QWidget *parent) : setReadOnly(true); viewport()->setCursor(Qt::ArrowCursor); setContextMenuPolicy(Qt::CustomContextMenu); + setUndoRedoEnabled(false); } ChatAreaWidget::~ChatAreaWidget() @@ -82,7 +83,11 @@ void ChatAreaWidget::insertMessage(ChatAction *msgAction) return; messages.append(msgAction); - updateChatContent(); + //updateChatContent(); + + moveCursor(QTextCursor::End); + moveCursor(QTextCursor::PreviousCell); + insertHtml(msgAction->getHtml()); } void ChatAreaWidget::updateChatContent() @@ -90,7 +95,9 @@ void ChatAreaWidget::updateChatContent() QScrollBar* scroll = verticalScrollBar(); lockSliderToBottom = scroll && scroll->value() == scroll->maximum(); + setUpdatesEnabled(false); setHtml(getHtmledMessages()); + setUpdatesEnabled(true); if (lockSliderToBottom) sliderPosition = scroll->maximum();