Index: ktorrent/dialogs/importdialog.cpp =================================================================== --- ktorrent/dialogs/importdialog.cpp +++ ktorrent/dialogs/importdialog.cpp @@ -55,7 +55,7 @@ setupUi(this); KUrlRequester* r = m_torrent_url; r->setMode(KFile::File | KFile::LocalOnly); - r->setFilter(kt::TorrentFileFilter(true)); + r->setFilter(kt::TorrentFileFilterKFileDialog(true)); r = m_data_url; r->setMode(KFile::File | KFile::Directory | KFile::LocalOnly); Index: ktorrent/dialogs/torrentcreatordlg.h =================================================================== --- ktorrent/dialogs/torrentcreatordlg.h +++ ktorrent/dialogs/torrentcreatordlg.h @@ -70,6 +70,10 @@ void accept() override; void reject() override; + void setDialogMode(); + + void selectFile();// required for radio button for new torrent creation + void selectDirectory(); private: void loadGroups(); Index: ktorrent/dialogs/torrentcreatordlg.cpp =================================================================== --- ktorrent/dialogs/torrentcreatordlg.cpp +++ ktorrent/dialogs/torrentcreatordlg.cpp @@ -54,12 +54,18 @@ adjustSize(); loadGroups(); - m_url->setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly | KFile::Directory); + //m_url->setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly | KFile::Directory); + //by default set directory + m_url->setMode(KFile::ExistingOnly | KFile::LocalOnly | KFile::Directory); + m_directory->setChecked(true); m_dht_tab->setEnabled(false); connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); + connect(m_directory, &QRadioButton::clicked, this, &TorrentCreatorDlg::selectDirectory); + connect(m_file, &QRadioButton::clicked, this, &TorrentCreatorDlg::selectFile); + connect(m_dht, &QCheckBox::toggled, this, &TorrentCreatorDlg::dhtToggled); // tracker box stuff @@ -428,4 +434,14 @@ m_progress->setValue(mktor->getCurrentChunk()); } + void TorrentCreatorDlg::selectFile() + { + m_url->setMode(KFile::File | KFile::ExistingOnly | KFile::LocalOnly); + } + + void TorrentCreatorDlg::selectDirectory() + { + m_url->setMode(KFile::ExistingOnly | KFile::LocalOnly | KFile::Directory); + } + } Index: ktorrent/dialogs/torrentcreatordlg.ui =================================================================== --- ktorrent/dialogs/torrentcreatordlg.ui +++ ktorrent/dialogs/torrentcreatordlg.ui @@ -6,8 +6,8 @@ 0 0 - 474 - 646 + 420 + 710 @@ -15,26 +15,46 @@ - - + + File or directory to create torrent from: - - - - - - - 0 - 0 - - - - - 0 - 0 - - + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + + + + Directory + + + + + + + File + + + + + + Index: libktcore/interfaces/functions.h =================================================================== --- libktcore/interfaces/functions.h +++ libktcore/interfaces/functions.h @@ -37,6 +37,12 @@ /// Get the filter string for torrent files used file dialogs KTCORE_EXPORT QString TorrentFileFilter(bool all_files_included); + /// Get the filter string for torrent files used file dialogs + /// here is a workarround, related to KFileDialog requested filters + /// https://bugs.kde.org/show_bug.cgi?id=369542 + /// https://bugs.kde.org/show_bug.cgi?id=383311 + KTCORE_EXPORT QString TorrentFileFilterKFileDialog(bool all_files_included); + } #endif Index: libktcore/interfaces/functions.cpp =================================================================== --- libktcore/interfaces/functions.cpp +++ libktcore/interfaces/functions.cpp @@ -185,5 +185,16 @@ return ret; } + QString TorrentFileFilterKFileDialog(bool all_files_included) + { + QString ret = i18n("Torrents") + QLatin1String(" *.torrent"); + if (all_files_included) { + ret += QLatin1String("\n"); + ret += i18n("All files") + QLatin1String(" *.*"); + } + return ret; + } + + }