mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Disable RTTI
This commit is contained in:
parent
bdec0557dc
commit
443df45d21
2
qtox.pro
2
qtox.pro
|
@ -37,7 +37,7 @@ FORMS += \
|
||||||
|
|
||||||
CONFIG += c++11
|
CONFIG += c++11
|
||||||
|
|
||||||
QMAKE_CXXFLAGS += -fno-exceptions
|
QMAKE_CXXFLAGS += -fno-exceptions -fno-rtti
|
||||||
|
|
||||||
# Rules for creating/updating {ts|qm}-files
|
# Rules for creating/updating {ts|qm}-files
|
||||||
include(translations/i18n.pri)
|
include(translations/i18n.pri)
|
||||||
|
|
|
@ -18,19 +18,31 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "chatlinecontentproxy.h"
|
#include "chatlinecontentproxy.h"
|
||||||
|
#include "src/chatlog/content/filetransferwidget.h"
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
ChatLineContentProxy::ChatLineContentProxy(QWidget* widget, int minWidth, float widthInPercent)
|
ChatLineContentProxy::ChatLineContentProxy(QWidget* widget, ChatLineContentProxyType type, int minWidth, float widthInPercent)
|
||||||
: widthMin(minWidth)
|
: widthPercent(widthInPercent)
|
||||||
, widthPercent(widthInPercent)
|
, widthMin(minWidth)
|
||||||
|
, widgetType{type}
|
||||||
{
|
{
|
||||||
proxy = new QGraphicsProxyWidget(this);
|
proxy = new QGraphicsProxyWidget(this);
|
||||||
proxy->setWidget(widget);
|
proxy->setWidget(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChatLineContentProxy::ChatLineContentProxy(QWidget* widget, int minWidth, float widthInPercent)
|
||||||
|
: ChatLineContentProxy(widget, GenericType, minWidth, widthInPercent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatLineContentProxy::ChatLineContentProxy(FileTransferWidget* widget, int minWidth, float widthInPercent)
|
||||||
|
: ChatLineContentProxy(widget, FileTransferWidgetType, minWidth, widthInPercent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
QRectF ChatLineContentProxy::boundingRect() const
|
QRectF ChatLineContentProxy::boundingRect() const
|
||||||
{
|
{
|
||||||
QRectF result = proxy->boundingRect();
|
QRectF result = proxy->boundingRect();
|
||||||
|
@ -58,3 +70,8 @@ void ChatLineContentProxy::setWidth(qreal width)
|
||||||
{
|
{
|
||||||
proxy->widget()->setFixedWidth(qMax(static_cast<int>(width*widthPercent), widthMin));
|
proxy->widget()->setFixedWidth(qMax(static_cast<int>(width*widthPercent), widthMin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ChatLineContentProxy::ChatLineContentProxyType ChatLineContentProxy::getWidgetType() const
|
||||||
|
{
|
||||||
|
return widgetType;
|
||||||
|
}
|
||||||
|
|
|
@ -23,10 +23,21 @@
|
||||||
#include <QGraphicsProxyWidget>
|
#include <QGraphicsProxyWidget>
|
||||||
#include "chatlinecontent.h"
|
#include "chatlinecontent.h"
|
||||||
|
|
||||||
|
class FileTransferWidget;
|
||||||
|
|
||||||
class ChatLineContentProxy : public ChatLineContent
|
class ChatLineContentProxy : public ChatLineContent
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
// Type tag to avoid dynamic_cast of contained QWidget*
|
||||||
|
enum ChatLineContentProxyType
|
||||||
|
{
|
||||||
|
GenericType,
|
||||||
|
FileTransferWidgetType=0,
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ChatLineContentProxy(QWidget* widget, int minWidth, float widthInPercent = 1.0f);
|
ChatLineContentProxy(QWidget* widget, int minWidth, float widthInPercent = 1.0f);
|
||||||
|
ChatLineContentProxy(FileTransferWidget* widget, int minWidth, float widthInPercent = 1.0f);
|
||||||
|
|
||||||
virtual QRectF boundingRect() const;
|
virtual QRectF boundingRect() const;
|
||||||
virtual void setWidth(qreal width);
|
virtual void setWidth(qreal width);
|
||||||
|
@ -34,11 +45,16 @@ public:
|
||||||
virtual qreal getAscent() const;
|
virtual qreal getAscent() const;
|
||||||
|
|
||||||
QWidget* getWidget() const;
|
QWidget* getWidget() const;
|
||||||
|
ChatLineContentProxyType getWidgetType() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ChatLineContentProxy(QWidget* widget, ChatLineContentProxyType type, int minWidth, float widthInPercent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QGraphicsProxyWidget* proxy;
|
QGraphicsProxyWidget* proxy;
|
||||||
int widthMin;
|
|
||||||
float widthPercent;
|
float widthPercent;
|
||||||
|
int widthMin;
|
||||||
|
const ChatLineContentProxyType widgetType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHATLINECONTENTPROXY_H
|
#endif // CHATLINECONTENTPROXY_H
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
|
#include <QStyle>
|
||||||
|
#include <cassert>
|
||||||
#include "chatform.h"
|
#include "chatform.h"
|
||||||
#include "src/core/core.h"
|
#include "src/core/core.h"
|
||||||
#include "src/friend.h"
|
#include "src/friend.h"
|
||||||
|
@ -226,14 +228,10 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
||||||
if (!Settings::getInstance().getAutoAcceptDir(f->getToxId()).isEmpty()
|
if (!Settings::getInstance().getAutoAcceptDir(f->getToxId()).isEmpty()
|
||||||
|| Settings::getInstance().getAutoSaveEnabled())
|
|| Settings::getInstance().getAutoSaveEnabled())
|
||||||
{
|
{
|
||||||
ChatLineContentProxy* proxy = dynamic_cast<ChatLineContentProxy*>(msg->getContent(1));
|
ChatLineContentProxy* proxy = static_cast<ChatLineContentProxy*>(msg->getContent(1));
|
||||||
if (proxy)
|
assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType);
|
||||||
{
|
FileTransferWidget* tfWidget = static_cast<FileTransferWidget*>(proxy->getWidget());
|
||||||
FileTransferWidget* tfWidget = dynamic_cast<FileTransferWidget*>(proxy->getWidget());
|
tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxId()));
|
||||||
|
|
||||||
if (tfWidget)
|
|
||||||
tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxId()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,10 +977,8 @@ void ChatForm::setFriendTyping(bool isTyping)
|
||||||
{
|
{
|
||||||
chatWidget->setTypingNotificationVisible(isTyping);
|
chatWidget->setTypingNotificationVisible(isTyping);
|
||||||
|
|
||||||
Text* text = dynamic_cast<Text*>(chatWidget->getTypingNotification()->getContent(1));
|
Text* text = static_cast<Text*>(chatWidget->getTypingNotification()->getContent(1));
|
||||||
|
text->setText("<div class=typing>" + QString("%1 is typing").arg(f->getDisplayedName()) + "</div>");
|
||||||
if (text)
|
|
||||||
text->setText("<div class=typing>" + QString("%1 is typing").arg(f->getDisplayedName()) + "</div>");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatForm::show(Ui::MainWindow &ui)
|
void ChatForm::show(Ui::MainWindow &ui)
|
||||||
|
|
|
@ -22,12 +22,9 @@
|
||||||
#include "src/widget/widget.h"
|
#include "src/widget/widget.h"
|
||||||
#include "src/widget/translator.h"
|
#include "src/widget/translator.h"
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QUrl>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QPainter>
|
|
||||||
|
|
||||||
FilesForm::FilesForm()
|
FilesForm::FilesForm()
|
||||||
: QObject()
|
: QObject(), doneIcon(":/ui/fileTransferWidget/fileDone.svg")
|
||||||
{
|
{
|
||||||
head = new QWidget();
|
head = new QWidget();
|
||||||
QFont bold;
|
QFont bold;
|
||||||
|
@ -42,8 +39,8 @@ FilesForm::FilesForm()
|
||||||
main.addTab(recvd, QString());
|
main.addTab(recvd, QString());
|
||||||
main.addTab(sent, QString());
|
main.addTab(sent, QString());
|
||||||
|
|
||||||
connect(sent, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(onFileActivated(QListWidgetItem*)));
|
connect(sent, &QListWidget::itemActivated, this, &FilesForm::onFileActivated);
|
||||||
connect(recvd, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(onFileActivated(QListWidgetItem*)));
|
connect(recvd, &QListWidget::itemActivated, this, &FilesForm::onFileActivated);
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
Translator::registerHandler(std::bind(&FilesForm::retranslateUi, this), this);
|
Translator::registerHandler(std::bind(&FilesForm::retranslateUi, this), this);
|
||||||
|
@ -67,15 +64,15 @@ void FilesForm::show(Ui::MainWindow& ui)
|
||||||
|
|
||||||
void FilesForm::onFileDownloadComplete(const QString& path)
|
void FilesForm::onFileDownloadComplete(const QString& path)
|
||||||
{
|
{
|
||||||
ListWidgetItem* tmp = new ListWidgetItem(QIcon(":/ui/fileTransferWidget/fileDone.svg"), QFileInfo(path).fileName());
|
QListWidgetItem* tmp = new QListWidgetItem(doneIcon, QFileInfo(path).fileName());
|
||||||
tmp->path = path;
|
tmp->setData(Qt::UserRole, path);
|
||||||
recvd->addItem(tmp);
|
recvd->addItem(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesForm::onFileUploadComplete(const QString& path)
|
void FilesForm::onFileUploadComplete(const QString& path)
|
||||||
{
|
{
|
||||||
ListWidgetItem* tmp = new ListWidgetItem(QIcon(":/ui/fileTransferWidget/fileDone.svg"), QFileInfo(path).fileName());
|
QListWidgetItem* tmp = new QListWidgetItem(doneIcon, QFileInfo(path).fileName());
|
||||||
tmp->path = path;
|
tmp->setData(Qt::UserRole, path);
|
||||||
sent->addItem(tmp);
|
sent->addItem(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,11 +81,9 @@ void FilesForm::onFileUploadComplete(const QString& path)
|
||||||
// whenever they're not saved anywhere custom, thanks to the hack)
|
// whenever they're not saved anywhere custom, thanks to the hack)
|
||||||
// I could do some digging around, but for now I'm tired and others already
|
// I could do some digging around, but for now I'm tired and others already
|
||||||
// might know it without me needing to dig, so...
|
// might know it without me needing to dig, so...
|
||||||
void FilesForm::onFileActivated(QListWidgetItem* item)
|
void FilesForm::onFileActivated(QListWidgetItem *item)
|
||||||
{
|
{
|
||||||
ListWidgetItem* tmp = dynamic_cast<ListWidgetItem*> (item);
|
Widget::confirmExecutableOpen(QFileInfo(item->data(Qt::UserRole).toString()));
|
||||||
|
|
||||||
Widget::confirmExecutableOpen(QFileInfo(tmp->path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilesForm::retranslateUi()
|
void FilesForm::retranslateUi()
|
||||||
|
|
|
@ -51,22 +51,11 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWidget* head;
|
QWidget* head;
|
||||||
|
QIcon doneIcon;
|
||||||
QLabel headLabel;
|
QLabel headLabel;
|
||||||
QVBoxLayout headLayout;
|
QVBoxLayout headLayout;
|
||||||
|
|
||||||
/* If we really do go whole hog with listing in progress transers,
|
|
||||||
I should really look into the new fangled list thingy, to deactivate
|
|
||||||
specific items in the list */
|
|
||||||
QTabWidget main;
|
QTabWidget main;
|
||||||
QListWidget* sent, * recvd;
|
QListWidget* sent, * recvd;
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class ListWidgetItem : public QListWidgetItem
|
|
||||||
{
|
|
||||||
using QListWidgetItem::QListWidgetItem;
|
|
||||||
public:
|
|
||||||
QString path;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILESFORM_H
|
#endif // FILESFORM_H
|
||||||
|
|
|
@ -360,7 +360,7 @@ void GenericChatForm::onSaveLogClicked()
|
||||||
auto lines = chatWidget->getLines();
|
auto lines = chatWidget->getLines();
|
||||||
for (ChatLine::Ptr l : lines)
|
for (ChatLine::Ptr l : lines)
|
||||||
{
|
{
|
||||||
Timestamp* rightCol = dynamic_cast<Timestamp*>(l->getContent(2));
|
Timestamp* rightCol = static_cast<Timestamp*>(l->getContent(2));
|
||||||
ChatLineContent* middleCol = l->getContent(1);
|
ChatLineContent* middleCol = l->getContent(1);
|
||||||
ChatLineContent* leftCol = l->getContent(0);
|
ChatLineContent* leftCol = l->getContent(0);
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
ProfileForm::ProfileForm(QWidget *parent) :
|
ProfileForm::ProfileForm(QWidget *parent) :
|
||||||
QWidget{parent}, qr{nullptr}
|
QWidget{parent}, qr{nullptr}
|
||||||
|
|
|
@ -115,24 +115,22 @@ QList<GenericChatroomWidget*> FriendListWidget::getAllFriends()
|
||||||
return friends;
|
return friends;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FriendListWidget::moveWidget(QWidget *w, Status s)
|
void FriendListWidget::moveWidget(FriendWidget *w, Status s)
|
||||||
{
|
{
|
||||||
QVBoxLayout* l = getFriendLayout(s);
|
QVBoxLayout* l = getFriendLayout(s);
|
||||||
l->removeWidget(w);
|
l->removeWidget(w);
|
||||||
Friend* g = FriendList::findFriend(dynamic_cast<FriendWidget*>(w)->friendId);
|
Friend* g = FriendList::findFriend(w->friendId);
|
||||||
for (int i = 0; i < l->count(); i++)
|
for (int i = 0; i < l->count(); i++)
|
||||||
{
|
{
|
||||||
FriendWidget* w1 = dynamic_cast<FriendWidget*>(l->itemAt(i)->widget());
|
FriendWidget* w1 = static_cast<FriendWidget*>(l->itemAt(i)->widget());
|
||||||
if (w1 != NULL)
|
Friend* f = FriendList::findFriend(w1->friendId);
|
||||||
|
if (f->getDisplayedName().localeAwareCompare(g->getDisplayedName()) > 0)
|
||||||
{
|
{
|
||||||
Friend* f = FriendList::findFriend(w1->friendId);
|
l->insertWidget(i,w);
|
||||||
if (f->getDisplayedName().localeAwareCompare(g->getDisplayedName()) > 0)
|
return;
|
||||||
{
|
|
||||||
l->insertWidget(i,w);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static_assert(std::is_same<decltype(w), FriendWidget*>(), "The layout must only contain FriendWidget*");
|
||||||
l->addWidget(w);
|
l->addWidget(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
class QVBoxLayout;
|
class QVBoxLayout;
|
||||||
class QGridLayout;
|
class QGridLayout;
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
|
struct FriendWidget;
|
||||||
|
|
||||||
class FriendListWidget : public QWidget
|
class FriendListWidget : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -44,7 +45,7 @@ signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onGroupchatPositionChanged(bool top);
|
void onGroupchatPositionChanged(bool top);
|
||||||
void moveWidget(QWidget *w, Status s);
|
void moveWidget(FriendWidget *w, Status s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<int, QVBoxLayout*> layouts;
|
QHash<int, QVBoxLayout*> layouts;
|
||||||
|
|
|
@ -42,6 +42,10 @@
|
||||||
#include "src/widget/gui.h"
|
#include "src/widget/gui.h"
|
||||||
#include "src/persistence/offlinemsgengine.h"
|
#include "src/persistence/offlinemsgengine.h"
|
||||||
#include "src/widget/translator.h"
|
#include "src/widget/translator.h"
|
||||||
|
#include "src/widget/form/addfriendform.h"
|
||||||
|
#include "src/widget/form/filesform.h"
|
||||||
|
#include "src/widget/form/profileform.h"
|
||||||
|
#include "src/widget/form/settingswidget.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
|
@ -22,12 +22,7 @@
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QSystemTrayIcon>
|
#include <QSystemTrayIcon>
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include "form/addfriendform.h"
|
|
||||||
#include "form/settingswidget.h"
|
|
||||||
#include "form/profileform.h"
|
|
||||||
#include "form/filesform.h"
|
|
||||||
#include "src/core/corestructs.h"
|
#include "src/core/corestructs.h"
|
||||||
|
|
||||||
#define PIXELS_TO_ACT 7
|
#define PIXELS_TO_ACT 7
|
||||||
|
@ -48,6 +43,10 @@ class FriendListWidget;
|
||||||
class MaskablePixmapWidget;
|
class MaskablePixmapWidget;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class SystemTrayIcon;
|
class SystemTrayIcon;
|
||||||
|
class FilesForm;
|
||||||
|
class ProfileForm;
|
||||||
|
class SettingsWidget;
|
||||||
|
class AddFriendForm;
|
||||||
|
|
||||||
class Widget : public QMainWindow
|
class Widget : public QMainWindow
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user