Browse Source

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

reviewable/pr6124/r5
sudden6 5 years ago
parent
commit
c1ec6bc649
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
  1. 8
      src/widget/widget.cpp
  2. 1
      src/widget/widget.h

8
src/widget/widget.cpp

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

1
src/widget/widget.h

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

Loading…
Cancel
Save