mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Allow user to open all transferred files, but warn for executable files
This commit is contained in:
parent
0cffcef322
commit
ad1852622f
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "src/core.h"
|
||||
#include "src/misc/style.h"
|
||||
#include "src/widget/widget.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QFileDialog>
|
||||
|
@ -326,7 +327,6 @@ void FileTransferWidget::onFileTransferFinished(ToxFile file)
|
|||
|
||||
ui->topButton->setIcon(QIcon(":/ui/fileTransferInstance/yes.svg"));
|
||||
ui->topButton->setObjectName("ok");
|
||||
ui->topButton->setEnabled(openExtensions.contains(QFileInfo(file.fileName).suffix()));
|
||||
ui->topButton->show();
|
||||
|
||||
ui->bottomButton->setIcon(QIcon(":/ui/fileTransferInstance/dir.svg"));
|
||||
|
@ -431,11 +431,12 @@ void FileTransferWidget::handleButton(QPushButton *btn)
|
|||
|
||||
if(btn->objectName() == "ok")
|
||||
{
|
||||
if (Widget::confirmExecutableOpen(QFileInfo(fileInfo.filePath)))
|
||||
QDesktopServices::openUrl(QUrl("file://" + fileInfo.filePath, QUrl::TolerantMode));
|
||||
}
|
||||
else if (btn->objectName() == "dir")
|
||||
{
|
||||
QString dirPath = QDir(QFileInfo(fileInfo.filePath).dir()).path();
|
||||
QString dirPath = QFileInfo(fileInfo.filePath).dir().path();
|
||||
QDesktopServices::openUrl(QUrl("file://" + dirPath, QUrl::TolerantMode));
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include "filesform.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "src/widget/widget.h"
|
||||
#include <QFileInfo>
|
||||
#include <QUrl>
|
||||
#include <QDebug>
|
||||
|
@ -80,6 +81,10 @@ void FilesForm::onFileUploadComplete(const QString& path)
|
|||
void FilesForm::onFileActivated(QListWidgetItem* item)
|
||||
{
|
||||
ListWidgetItem* tmp = dynamic_cast<ListWidgetItem*> (item);
|
||||
|
||||
if (!Widget::confirmExecutableOpen(QFileInfo(tmp->path)))
|
||||
return;
|
||||
|
||||
QUrl url = QUrl::fromLocalFile(tmp->path);
|
||||
qDebug() << "Opening '" << url << "'";
|
||||
QDesktopServices::openUrl(url);
|
||||
|
|
|
@ -498,6 +498,19 @@ void Widget::onTransferClicked()
|
|||
activeChatroomWidget = nullptr;
|
||||
}
|
||||
|
||||
bool Widget::confirmExecutableOpen(const QFileInfo file)
|
||||
{
|
||||
if (file.isExecutable())
|
||||
{
|
||||
if(!GUI::askQuestion(tr("Executable file", "popup title"), tr("You have asked qTox to open an executable file. Executable files can potentially damage your computer. Are you sure want to open this file?", "popup text"), false, true))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Widget::onIconClick(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
switch (reason)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <QMainWindow>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMessageBox>
|
||||
#include <QFileInfo>
|
||||
#include "form/addfriendform.h"
|
||||
#include "form/settingswidget.h"
|
||||
#include "form/settings/identityform.h"
|
||||
|
@ -69,6 +70,8 @@ public:
|
|||
virtual void changeEvent(QEvent *event);
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
|
||||
static bool confirmExecutableOpen(const QFileInfo file);
|
||||
|
||||
void clearAllReceipts();
|
||||
void reloadHistory();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user