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
|
||||
|
||||
QMAKE_CXXFLAGS += -fno-exceptions
|
||||
QMAKE_CXXFLAGS += -fno-exceptions -fno-rtti
|
||||
|
||||
# Rules for creating/updating {ts|qm}-files
|
||||
include(translations/i18n.pri)
|
||||
|
|
|
@ -18,19 +18,31 @@
|
|||
*/
|
||||
|
||||
#include "chatlinecontentproxy.h"
|
||||
#include "src/chatlog/content/filetransferwidget.h"
|
||||
#include <QLayout>
|
||||
#include <QWidget>
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
|
||||
ChatLineContentProxy::ChatLineContentProxy(QWidget* widget, int minWidth, float widthInPercent)
|
||||
: widthMin(minWidth)
|
||||
, widthPercent(widthInPercent)
|
||||
ChatLineContentProxy::ChatLineContentProxy(QWidget* widget, ChatLineContentProxyType type, int minWidth, float widthInPercent)
|
||||
: widthPercent(widthInPercent)
|
||||
, widthMin(minWidth)
|
||||
, widgetType{type}
|
||||
{
|
||||
proxy = new QGraphicsProxyWidget(this);
|
||||
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 result = proxy->boundingRect();
|
||||
|
@ -58,3 +70,8 @@ void ChatLineContentProxy::setWidth(qreal width)
|
|||
{
|
||||
proxy->widget()->setFixedWidth(qMax(static_cast<int>(width*widthPercent), widthMin));
|
||||
}
|
||||
|
||||
ChatLineContentProxy::ChatLineContentProxyType ChatLineContentProxy::getWidgetType() const
|
||||
{
|
||||
return widgetType;
|
||||
}
|
||||
|
|
|
@ -23,10 +23,21 @@
|
|||
#include <QGraphicsProxyWidget>
|
||||
#include "chatlinecontent.h"
|
||||
|
||||
class FileTransferWidget;
|
||||
|
||||
class ChatLineContentProxy : public ChatLineContent
|
||||
{
|
||||
public:
|
||||
// Type tag to avoid dynamic_cast of contained QWidget*
|
||||
enum ChatLineContentProxyType
|
||||
{
|
||||
GenericType,
|
||||
FileTransferWidgetType=0,
|
||||
};
|
||||
|
||||
public:
|
||||
ChatLineContentProxy(QWidget* widget, int minWidth, float widthInPercent = 1.0f);
|
||||
ChatLineContentProxy(FileTransferWidget* widget, int minWidth, float widthInPercent = 1.0f);
|
||||
|
||||
virtual QRectF boundingRect() const;
|
||||
virtual void setWidth(qreal width);
|
||||
|
@ -34,11 +45,16 @@ public:
|
|||
virtual qreal getAscent() const;
|
||||
|
||||
QWidget* getWidget() const;
|
||||
ChatLineContentProxyType getWidgetType() const;
|
||||
|
||||
protected:
|
||||
ChatLineContentProxy(QWidget* widget, ChatLineContentProxyType type, int minWidth, float widthInPercent);
|
||||
|
||||
private:
|
||||
QGraphicsProxyWidget* proxy;
|
||||
int widthMin;
|
||||
float widthPercent;
|
||||
int widthMin;
|
||||
const ChatLineContentProxyType widgetType;
|
||||
};
|
||||
|
||||
#endif // CHATLINECONTENTPROXY_H
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <QScreen>
|
||||
#include <QTemporaryFile>
|
||||
#include <QGuiApplication>
|
||||
#include <QStyle>
|
||||
#include <cassert>
|
||||
#include "chatform.h"
|
||||
#include "src/core/core.h"
|
||||
#include "src/friend.h"
|
||||
|
@ -226,14 +228,10 @@ void ChatForm::onFileRecvRequest(ToxFile file)
|
|||
if (!Settings::getInstance().getAutoAcceptDir(f->getToxId()).isEmpty()
|
||||
|| Settings::getInstance().getAutoSaveEnabled())
|
||||
{
|
||||
ChatLineContentProxy* proxy = dynamic_cast<ChatLineContentProxy*>(msg->getContent(1));
|
||||
if (proxy)
|
||||
{
|
||||
FileTransferWidget* tfWidget = dynamic_cast<FileTransferWidget*>(proxy->getWidget());
|
||||
|
||||
if (tfWidget)
|
||||
tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxId()));
|
||||
}
|
||||
ChatLineContentProxy* proxy = static_cast<ChatLineContentProxy*>(msg->getContent(1));
|
||||
assert(proxy->getWidgetType() == ChatLineContentProxy::FileTransferWidgetType);
|
||||
FileTransferWidget* tfWidget = static_cast<FileTransferWidget*>(proxy->getWidget());
|
||||
tfWidget->autoAcceptTransfer(Settings::getInstance().getAutoAcceptDir(f->getToxId()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -979,10 +977,8 @@ void ChatForm::setFriendTyping(bool isTyping)
|
|||
{
|
||||
chatWidget->setTypingNotificationVisible(isTyping);
|
||||
|
||||
Text* text = dynamic_cast<Text*>(chatWidget->getTypingNotification()->getContent(1));
|
||||
|
||||
if (text)
|
||||
text->setText("<div class=typing>" + QString("%1 is typing").arg(f->getDisplayedName()) + "</div>");
|
||||
Text* text = static_cast<Text*>(chatWidget->getTypingNotification()->getContent(1));
|
||||
text->setText("<div class=typing>" + QString("%1 is typing").arg(f->getDisplayedName()) + "</div>");
|
||||
}
|
||||
|
||||
void ChatForm::show(Ui::MainWindow &ui)
|
||||
|
|
|
@ -22,12 +22,9 @@
|
|||
#include "src/widget/widget.h"
|
||||
#include "src/widget/translator.h"
|
||||
#include <QFileInfo>
|
||||
#include <QUrl>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
|
||||
FilesForm::FilesForm()
|
||||
: QObject()
|
||||
: QObject(), doneIcon(":/ui/fileTransferWidget/fileDone.svg")
|
||||
{
|
||||
head = new QWidget();
|
||||
QFont bold;
|
||||
|
@ -42,8 +39,8 @@ FilesForm::FilesForm()
|
|||
main.addTab(recvd, QString());
|
||||
main.addTab(sent, QString());
|
||||
|
||||
connect(sent, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(onFileActivated(QListWidgetItem*)));
|
||||
connect(recvd, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(onFileActivated(QListWidgetItem*)));
|
||||
connect(sent, &QListWidget::itemActivated, this, &FilesForm::onFileActivated);
|
||||
connect(recvd, &QListWidget::itemActivated, this, &FilesForm::onFileActivated);
|
||||
|
||||
retranslateUi();
|
||||
Translator::registerHandler(std::bind(&FilesForm::retranslateUi, this), this);
|
||||
|
@ -67,15 +64,15 @@ void FilesForm::show(Ui::MainWindow& ui)
|
|||
|
||||
void FilesForm::onFileDownloadComplete(const QString& path)
|
||||
{
|
||||
ListWidgetItem* tmp = new ListWidgetItem(QIcon(":/ui/fileTransferWidget/fileDone.svg"), QFileInfo(path).fileName());
|
||||
tmp->path = path;
|
||||
QListWidgetItem* tmp = new QListWidgetItem(doneIcon, QFileInfo(path).fileName());
|
||||
tmp->setData(Qt::UserRole, path);
|
||||
recvd->addItem(tmp);
|
||||
}
|
||||
|
||||
void FilesForm::onFileUploadComplete(const QString& path)
|
||||
{
|
||||
ListWidgetItem* tmp = new ListWidgetItem(QIcon(":/ui/fileTransferWidget/fileDone.svg"), QFileInfo(path).fileName());
|
||||
tmp->path = path;
|
||||
QListWidgetItem* tmp = new QListWidgetItem(doneIcon, QFileInfo(path).fileName());
|
||||
tmp->setData(Qt::UserRole, path);
|
||||
sent->addItem(tmp);
|
||||
}
|
||||
|
||||
|
@ -84,11 +81,9 @@ void FilesForm::onFileUploadComplete(const QString& path)
|
|||
// 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
|
||||
// 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(tmp->path));
|
||||
Widget::confirmExecutableOpen(QFileInfo(item->data(Qt::UserRole).toString()));
|
||||
}
|
||||
|
||||
void FilesForm::retranslateUi()
|
||||
|
|
|
@ -51,22 +51,11 @@ private:
|
|||
|
||||
private:
|
||||
QWidget* head;
|
||||
QIcon doneIcon;
|
||||
QLabel headLabel;
|
||||
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;
|
||||
QListWidget* sent, * recvd;
|
||||
|
||||
};
|
||||
|
||||
class ListWidgetItem : public QListWidgetItem
|
||||
{
|
||||
using QListWidgetItem::QListWidgetItem;
|
||||
public:
|
||||
QString path;
|
||||
};
|
||||
|
||||
#endif // FILESFORM_H
|
||||
|
|
|
@ -360,7 +360,7 @@ void GenericChatForm::onSaveLogClicked()
|
|||
auto lines = chatWidget->getLines();
|
||||
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* leftCol = l->getContent(0);
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <QInputDialog>
|
||||
#include <QFileDialog>
|
||||
#include <QBuffer>
|
||||
#include <QMessageBox>
|
||||
|
||||
ProfileForm::ProfileForm(QWidget *parent) :
|
||||
QWidget{parent}, qr{nullptr}
|
||||
|
|
|
@ -115,24 +115,22 @@ QList<GenericChatroomWidget*> FriendListWidget::getAllFriends()
|
|||
return friends;
|
||||
}
|
||||
|
||||
void FriendListWidget::moveWidget(QWidget *w, Status s)
|
||||
void FriendListWidget::moveWidget(FriendWidget *w, Status s)
|
||||
{
|
||||
QVBoxLayout* l = getFriendLayout(s);
|
||||
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++)
|
||||
{
|
||||
FriendWidget* w1 = dynamic_cast<FriendWidget*>(l->itemAt(i)->widget());
|
||||
if (w1 != NULL)
|
||||
FriendWidget* w1 = static_cast<FriendWidget*>(l->itemAt(i)->widget());
|
||||
Friend* f = FriendList::findFriend(w1->friendId);
|
||||
if (f->getDisplayedName().localeAwareCompare(g->getDisplayedName()) > 0)
|
||||
{
|
||||
Friend* f = FriendList::findFriend(w1->friendId);
|
||||
if (f->getDisplayedName().localeAwareCompare(g->getDisplayedName()) > 0)
|
||||
{
|
||||
l->insertWidget(i,w);
|
||||
return;
|
||||
}
|
||||
l->insertWidget(i,w);
|
||||
return;
|
||||
}
|
||||
}
|
||||
static_assert(std::is_same<decltype(w), FriendWidget*>(), "The layout must only contain FriendWidget*");
|
||||
l->addWidget(w);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
class QVBoxLayout;
|
||||
class QGridLayout;
|
||||
class QPixmap;
|
||||
struct FriendWidget;
|
||||
|
||||
class FriendListWidget : public QWidget
|
||||
{
|
||||
|
@ -44,7 +45,7 @@ signals:
|
|||
|
||||
public slots:
|
||||
void onGroupchatPositionChanged(bool top);
|
||||
void moveWidget(QWidget *w, Status s);
|
||||
void moveWidget(FriendWidget *w, Status s);
|
||||
|
||||
private:
|
||||
QHash<int, QVBoxLayout*> layouts;
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
#include "src/widget/gui.h"
|
||||
#include "src/persistence/offlinemsgengine.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 <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
|
|
@ -22,12 +22,7 @@
|
|||
|
||||
#include <QMainWindow>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMessageBox>
|
||||
#include <QFileInfo>
|
||||
#include "form/addfriendform.h"
|
||||
#include "form/settingswidget.h"
|
||||
#include "form/profileform.h"
|
||||
#include "form/filesform.h"
|
||||
#include "src/core/corestructs.h"
|
||||
|
||||
#define PIXELS_TO_ACT 7
|
||||
|
@ -48,6 +43,10 @@ class FriendListWidget;
|
|||
class MaskablePixmapWidget;
|
||||
class QTimer;
|
||||
class SystemTrayIcon;
|
||||
class FilesForm;
|
||||
class ProfileForm;
|
||||
class SettingsWidget;
|
||||
class AddFriendForm;
|
||||
|
||||
class Widget : public QMainWindow
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user