Browse Source

Hack around QDesktopServices::openUrl to support network shares

adaptive-webui-19844
Nick Tiskov 11 years ago
parent
commit
bd9dcf1247
  1. 8
      src/properties/propertieswidget.cpp
  2. 15
      src/transferlistwidget.cpp
  3. 3
      src/transferlistwidget.h

8
src/properties/propertieswidget.cpp

@ -419,7 +419,9 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) { @@ -419,7 +419,9 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
// Flush data
h.flush_cache();
if (QFile::exists(file_path)) {
QDesktopServices::openUrl(QUrl::fromLocalFile(file_path));
// Hack to access samba shares with QDesktopServices::openUrl
const QString p = file_path.startsWith("//") ? QString("file:") + file_path : file_path;
QDesktopServices::openUrl(QUrl::fromLocalFile(p));
} else {
QMessageBox::warning(this, tr("I/O Error"), tr("This file does not exist yet."));
}
@ -439,7 +441,9 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) { @@ -439,7 +441,9 @@ void PropertiesWidget::openDoubleClickedFile(QModelIndex index) {
// Flush data
h.flush_cache();
if (QFile::exists(file_path)) {
QDesktopServices::openUrl(QUrl::fromLocalFile(file_path));
// Hack to access samba shares with QDesktopServices::openUrl
const QString p = file_path.startsWith("//") ? QString("file:") + file_path : file_path;
QDesktopServices::openUrl(QUrl::fromLocalFile(p));
} else {
QMessageBox::warning(this, tr("I/O Error"), tr("This folder does not exist yet."));
}

15
src/transferlistwidget.cpp

@ -177,7 +177,7 @@ TorrentModel* TransferListWidget::getSourceModel() const { @@ -177,7 +177,7 @@ TorrentModel* TransferListWidget::getSourceModel() const {
}
void TransferListWidget::previewFile(QString filePath) {
QDesktopServices::openUrl(QUrl::fromLocalFile(filePath));
openUrl(filePath);
}
void TransferListWidget::setRefreshInterval(int t) {
@ -235,8 +235,8 @@ void TransferListWidget::torrentDoubleClicked(const QModelIndex& index) { @@ -235,8 +235,8 @@ void TransferListWidget::torrentDoubleClicked(const QModelIndex& index) {
}
break;
case OPEN_DEST:
QDesktopServices::openUrl(QUrl::fromLocalFile(h.root_path()));
break;
const QString path = h.root_path();
openUrl(path);
}
}
@ -439,7 +439,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const { @@ -439,7 +439,7 @@ void TransferListWidget::openSelectedTorrentsFolder() const {
qDebug("Opening path at %s", qPrintable(rootFolder));
if (!pathsList.contains(rootFolder)) {
pathsList.insert(rootFolder);
QDesktopServices::openUrl(QUrl::fromLocalFile(rootFolder));
openUrl(rootFolder);
}
}
}
@ -644,6 +644,13 @@ void TransferListWidget::askNewLabelForSelection() { @@ -644,6 +644,13 @@ void TransferListWidget::askNewLabelForSelection() {
}while(invalid);
}
bool TransferListWidget::openUrl(const QString &_path) const {
const QString path = fsutils::fromNativePath(_path);
// Hack to access samba shares with QDesktopServices::openUrl
const QString p = path.startsWith("//") ? QString("file:") + path : path;
return QDesktopServices::openUrl(QUrl::fromLocalFile(p));
}
void TransferListWidget::renameSelectedTorrent() {
const QModelIndexList selectedIndexes = selectionModel()->selectedRows();
if (selectedIndexes.size() != 1) return;

3
src/transferlistwidget.h

@ -106,6 +106,9 @@ protected slots: @@ -106,6 +106,9 @@ protected slots:
void toggleSelectedFirstLastPiecePrio() const;
void askNewLabelForSelection();
private:
bool openUrl(const QString& _path) const;
signals:
void currentTorrentChanged(const QTorrentHandle &h);

Loading…
Cancel
Save