void GetFolder( QPointer<QWidget> parent, const QString &caption, const QString &initialPath, Fn<void(QString &&result)> callback, Fn<void()> failed) { InvokeQueued(QApplication::instance(), [=] { auto files = QStringList(); auto remoteContent = QByteArray(); PreventWindowActivation(); const auto success = Platform::FileDialog::Get( parent, files, remoteContent, caption, QString(), FileDialog::internal::Type::ReadFolder, initialPath); if (success && !files.isEmpty() && !files[0].isEmpty()) { if (callback) { callback(std::move(files[0])); } } else if (failed) { failed(); } }); }
void GetOpenPaths( QPointer<QWidget> parent, const QString &caption, const QString &filter, Fn<void(OpenResult &&result)> callback, Fn<void()> failed) { InvokeQueued(QApplication::instance(), [=] { auto files = QStringList(); auto remoteContent = QByteArray(); PreventWindowActivation(); const auto success = Platform::FileDialog::Get( parent, files, remoteContent, caption, filter, FileDialog::internal::Type::ReadFiles); if (success && (!files.isEmpty() || !remoteContent.isEmpty())) { if (callback) { auto result = OpenResult(); result.paths = files; result.remoteContent = remoteContent; callback(std::move(result)); } } else if (failed) { failed(); } }); }
void OpenWith(const QString &filepath, QPoint menuPosition) { InvokeQueued(QApplication::instance(), [=] { if (!Platform::File::UnsafeShowOpenWithDropdown(filepath, menuPosition)) { if (!Platform::File::UnsafeShowOpenWith(filepath)) { Platform::File::UnsafeLaunch(filepath); } } }); }
void GetWritePath( QPointer<QWidget> parent, const QString &caption, const QString &filter, const QString &initialPath, Fn<void(QString &&result)> callback, Fn<void()> failed) { InvokeQueued(QApplication::instance(), [=] { auto file = QString(); if (filedialogGetSaveFile(parent, file, caption, filter, initialPath)) { if (callback) { callback(std::move(file)); } } else if (failed) { failed(); } }); }
void PeerListWidget::mousePressReleased(Qt::MouseButton button) { repaintRow(_pressed); auto pressed = std::exchange(_pressed, -1); auto pressedRemove = base::take(_pressedRemove); if (pressed >= 0 && pressed < _items.size()) { if (auto &ripple = _items[pressed]->ripple) { ripple->lastStop(); } if (pressed == _selected && pressedRemove == _selectedRemove && button == Qt::LeftButton) { InvokeQueued(this, [this, pressedRemove, peer = _items[pressed]->peer] { if (auto &callback = (pressedRemove ? _removedCallback : _selectedCallback)) { callback(peer); } }); } } setCursor(_selectedRemove ? style::cur_pointer : style::cur_default); repaintSelectedRow(); }
void AbstractBox::refreshLang() { refreshTitle(); refreshAdditionalTitle(); InvokeQueued(this, [this] { updateButtonsPositions(); }); }
void WarningWidget::refreshLang() { InvokeQueued(this, [this] { updateControlsGeometry(); }); }