33 #include <QHeaderView>
34 #include <QMessageBox>
35 #include <QPushButton>
37 #include <QStandardItemModel>
45 #include "ui_previewselectdialog.h"
48 #define SETTINGS_KEY(name) "PreviewSelectDialog/" name
55 #
if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
56 , m_storeTreeHeaderState(
"GUI/Qt6/" SETTINGS_KEY(
"HeaderState"))
63 m_ui->label->setText(tr(
"The following files from torrent \"%1\" support previewing, please select one of them:")
66 m_ui->buttonBox->button(QDialogButtonBox::Ok)->setText(tr(
"Preview"));
68 connect(
m_ui->buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject);
81 unused.setVerticalHeader(
m_ui->previewList->header());
82 m_ui->previewList->header()->setParent(
m_ui->previewList);
83 unused.setVerticalHeader(
new QHeaderView(Qt::Horizontal));
92 for (
int i = 0; i < torrent->
filesCount(); ++i)
107 m_ui->previewList->header()->setSortIndicator(0, Qt::AscendingOrder);
108 m_ui->previewList->selectionModel()->select(
m_previewListModel->index(0,
NAME), QItemSelectionModel::Select | QItemSelectionModel::Rows);
123 const QModelIndexList selectedIndexes =
m_ui->previewList->selectionModel()->selectedRows(
FILE_INDEX);
124 if (selectedIndexes.isEmpty())
return;
130 const int fileIndex = selectedIndexes.at(0).data().toInt();
133 if (!QFile::exists(path))
136 QWidget *parent = isSingleFile ? this->parentWidget() :
this;
137 QMessageBox::critical(parent, tr(
"Preview impossible")
171 if (event->spontaneous())
173 QDialog::showEvent(event);
181 const int nameSize = (
m_ui->previewList->size().width() * 0.6);
182 m_ui->previewList->header()->resizeSection(0, nameSize);
QBITTORRENT_HAS_EXECINFO_H if(NOT QBITTORRENT_HAS_EXECINFO_H) message(FATAL_ERROR "execinfo.h header file not found.\n" "Please either disable the STACKTRACE feature or use a libc that has this header file
virtual int filesCount() const =0
virtual qlonglong fileSize(int index) const =0
virtual QString filePath(int index) const =0
virtual void flushCache() const =0
virtual QVector< qreal > filesProgress() const =0
virtual QString actualStorageLocation() const =0
virtual QString actualFilePath(int index) const =0
virtual QString name() const =0
static Preferences * instance()
bool useAlternatingRowColors() const
SettingValue< QByteArray > m_storeTreeHeaderState
void readyToPreviewFile(QString) const
PreviewListDelegate * m_listDelegate
void previewButtonClicked()
void showEvent(QShowEvent *event) override
QStandardItemModel * m_previewListModel
bool m_headerStateInitialized
SettingValue< QSize > m_storeDialogSize
PreviewSelectDialog(QWidget *parent, const BitTorrent::Torrent *torrent)
Ui::PreviewSelectDialog * m_ui
const BitTorrent::Torrent * m_torrent
T get(const T &defaultValue={}) const
QString fileName(const QString &filePath)
QString toNativePath(const QString &path)
void resize(QWidget *widget, const QSize &newSize={})
bool isPreviewable(const QString &filename)
#define SETTINGS_KEY(name)