1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(widget): remove usage of Core::getInstance

This commit is contained in:
sudden6 2020-05-01 14:55:41 +02:00
parent 728621f627
commit c1ec6bc649
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
2 changed files with 5 additions and 4 deletions

View File

@ -107,8 +107,9 @@ bool tryRemoveFile(const QString& filepath)
tmp.remove(); tmp.remove();
return writable; return writable;
} }
} // namespace
void acceptFileTransfer(const ToxFile& file, const QString& path) void Widget::acceptFileTransfer(const ToxFile& file, const QString& path)
{ {
QString filepath; QString filepath;
int number = 0; int number = 0;
@ -127,13 +128,12 @@ void acceptFileTransfer(const ToxFile& file, const QString& path)
// Do not automatically accept the file-transfer if the path is not writable. // Do not automatically accept the file-transfer if the path is not writable.
// The user can still accept it manually. // The user can still accept it manually.
if (tryRemoveFile(filepath)) { if (tryRemoveFile(filepath)) {
CoreFile* coreFile = Core::getInstance()->getCoreFile(); CoreFile* coreFile = core->getCoreFile();
coreFile->acceptFileRecvRequest(file.friendId, file.fileNum, filepath); coreFile->acceptFileRecvRequest(file.friendId, file.fileNum, filepath);
} else { } else {
qWarning() << "Cannot write to " << filepath; qWarning() << "Cannot write to " << filepath;
} }
} }
} // namespace
Widget* Widget::instance{nullptr}; Widget* Widget::instance{nullptr};
@ -1077,7 +1077,7 @@ void Widget::dispatchFile(ToxFile file)
if (file.status == ToxFile::INITIALIZING && file.direction == ToxFile::RECEIVING) { if (file.status == ToxFile::INITIALIZING && file.direction == ToxFile::RECEIVING) {
auto sender = auto sender =
(file.direction == ToxFile::SENDING) ? Core::getInstance()->getSelfPublicKey() : pk; (file.direction == ToxFile::SENDING) ? core->getSelfPublicKey() : pk;
const Settings& settings = Settings::getInstance(); const Settings& settings = Settings::getInstance();
QString autoAcceptDir = settings.getAutoAcceptDir(f->getPublicKey()); QString autoAcceptDir = settings.getAutoAcceptDir(f->getPublicKey());

View File

@ -275,6 +275,7 @@ private:
void openDialog(GenericChatroomWidget* widget, bool newWindow); void openDialog(GenericChatroomWidget* widget, bool newWindow);
void playNotificationSound(IAudioSink::Sound sound, bool loop = false); void playNotificationSound(IAudioSink::Sound sound, bool loop = false);
void cleanupNotificationSound(); void cleanupNotificationSound();
void acceptFileTransfer(const ToxFile &file, const QString &path);
private: private:
std::unique_ptr<QSystemTrayIcon> icon; std::unique_ptr<QSystemTrayIcon> icon;