mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
Fix addnewtorrentdialog position
Fix messageBox position
This commit is contained in:
parent
7eaa5987c8
commit
de54fa2c30
@ -409,7 +409,7 @@ void Application::processParams(const QStringList ¶ms)
|
|||||||
param = param.trimmed();
|
param = param.trimmed();
|
||||||
|
|
||||||
// Process strings indicating options specified by the user.
|
// Process strings indicating options specified by the user.
|
||||||
|
|
||||||
if (param.startsWith(QLatin1String("@savePath="))) {
|
if (param.startsWith(QLatin1String("@savePath="))) {
|
||||||
torrentParams.savePath = param.mid(10);
|
torrentParams.savePath = param.mid(10);
|
||||||
continue;
|
continue;
|
||||||
|
@ -63,7 +63,6 @@ const QString KEY_DEFAULTCATEGORY = SETTINGS_KEY("DefaultCategory");
|
|||||||
const QString KEY_TREEHEADERSTATE = SETTINGS_KEY("TreeHeaderState");
|
const QString KEY_TREEHEADERSTATE = SETTINGS_KEY("TreeHeaderState");
|
||||||
const QString KEY_WIDTH = SETTINGS_KEY("Width");
|
const QString KEY_WIDTH = SETTINGS_KEY("Width");
|
||||||
const QString KEY_EXPANDED = SETTINGS_KEY("Expanded");
|
const QString KEY_EXPANDED = SETTINGS_KEY("Expanded");
|
||||||
const QString KEY_POSITION = SETTINGS_KEY("Position");
|
|
||||||
const QString KEY_TOPLEVEL = SETTINGS_KEY("TopLevel");
|
const QString KEY_TOPLEVEL = SETTINGS_KEY("TopLevel");
|
||||||
const QString KEY_SAVEPATHHISTORY = SETTINGS_KEY("SavePathHistory");
|
const QString KEY_SAVEPATHHISTORY = SETTINGS_KEY("SavePathHistory");
|
||||||
|
|
||||||
@ -85,7 +84,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
|||||||
, m_oldIndex(0)
|
, m_oldIndex(0)
|
||||||
, m_torrentParams(inParams)
|
, m_torrentParams(inParams)
|
||||||
{
|
{
|
||||||
// TODO: set dialog file properties using m_torrentParams.filePriorities
|
// TODO: set dialog file properties using m_torrentParams.filePriorities
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
ui->lblMetaLoading->setVisible(false);
|
ui->lblMetaLoading->setVisible(false);
|
||||||
@ -99,7 +98,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
|||||||
ui->startTorrentCheckBox->setChecked(true);
|
ui->startTorrentCheckBox->setChecked(true);
|
||||||
else
|
else
|
||||||
ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused());
|
ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused());
|
||||||
|
|
||||||
ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does it job at this point
|
ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does it job at this point
|
||||||
ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault());
|
ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault());
|
||||||
ui->comboTTM->blockSignals(false);
|
ui->comboTTM->blockSignals(false);
|
||||||
@ -114,7 +113,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP
|
|||||||
ui->createSubfolderCheckBox->setChecked(false);
|
ui->createSubfolderCheckBox->setChecked(false);
|
||||||
else
|
else
|
||||||
ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder());
|
ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder());
|
||||||
|
|
||||||
ui->skipCheckingCheckBox->setChecked(m_torrentParams.skipChecking);
|
ui->skipCheckingCheckBox->setChecked(m_torrentParams.skipChecking);
|
||||||
ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never);
|
ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never);
|
||||||
|
|
||||||
@ -179,11 +178,10 @@ void AddNewTorrentDialog::loadState()
|
|||||||
{
|
{
|
||||||
m_headerState = settings()->loadValue(KEY_TREEHEADERSTATE).toByteArray();
|
m_headerState = settings()->loadValue(KEY_TREEHEADERSTATE).toByteArray();
|
||||||
int width = settings()->loadValue(KEY_WIDTH, -1).toInt();
|
int width = settings()->loadValue(KEY_WIDTH, -1).toInt();
|
||||||
if (width >= 0) {
|
QSize geo = size();
|
||||||
QRect geo = geometry();
|
geo.setWidth(width);
|
||||||
geo.setWidth(width);
|
resize(geo);
|
||||||
setGeometry(geo);
|
|
||||||
}
|
|
||||||
ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool());
|
ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +189,6 @@ void AddNewTorrentDialog::saveState()
|
|||||||
{
|
{
|
||||||
if (m_contentModel)
|
if (m_contentModel)
|
||||||
settings()->storeValue(KEY_TREEHEADERSTATE, ui->contentTreeView->header()->saveState());
|
settings()->storeValue(KEY_TREEHEADERSTATE, ui->contentTreeView->header()->saveState());
|
||||||
settings()->storeValue(KEY_POSITION, pos().y());
|
|
||||||
settings()->storeValue(KEY_WIDTH, width());
|
settings()->storeValue(KEY_WIDTH, width());
|
||||||
settings()->storeValue(KEY_EXPANDED, ui->adv_button->isChecked());
|
settings()->storeValue(KEY_EXPANDED, ui->adv_button->isChecked());
|
||||||
}
|
}
|
||||||
@ -235,13 +232,13 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath)
|
|||||||
m_filePath = torrentPath;
|
m_filePath = torrentPath;
|
||||||
|
|
||||||
if (!QFile::exists(m_filePath)) {
|
if (!QFile::exists(m_filePath)) {
|
||||||
MessageBoxRaised::critical(0, tr("I/O Error"), tr("The torrent file '%1' does not exist.").arg(Utils::Fs::toNativePath(m_filePath)));
|
MessageBoxRaised::critical(this, tr("I/O Error"), tr("The torrent file '%1' does not exist.").arg(Utils::Fs::toNativePath(m_filePath)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFileInfo fileinfo(m_filePath);
|
QFileInfo fileinfo(m_filePath);
|
||||||
if (!fileinfo.isReadable()) {
|
if (!fileinfo.isReadable()) {
|
||||||
MessageBoxRaised::critical(0, tr("I/O Error"), tr("The torrent file '%1' cannot be read from the disk. Probably you don't have enough permissions.").arg(Utils::Fs::toNativePath(m_filePath)));
|
MessageBoxRaised::critical(this, tr("I/O Error"), tr("The torrent file '%1' cannot be read from the disk. Probably you don't have enough permissions.").arg(Utils::Fs::toNativePath(m_filePath)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +246,7 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath)
|
|||||||
QString error;
|
QString error;
|
||||||
m_torrentInfo = BitTorrent::TorrentInfo::loadFromFile(m_filePath, error);
|
m_torrentInfo = BitTorrent::TorrentInfo::loadFromFile(m_filePath, error);
|
||||||
if (!m_torrentInfo.isValid()) {
|
if (!m_torrentInfo.isValid()) {
|
||||||
MessageBoxRaised::critical(0, tr("Invalid torrent"), tr("Failed to load the torrent: %1.\nError: %2", "Don't remove the '\n' characters. They insert a newline.").arg(Utils::Fs::toNativePath(m_filePath)).arg(error));
|
MessageBoxRaised::critical(this, tr("Invalid torrent"), tr("Failed to load the torrent: %1.\nError: %2", "Don't remove the '\n' characters. They insert a newline.").arg(Utils::Fs::toNativePath(m_filePath)).arg(error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,16 +258,16 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath)
|
|||||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash);
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash);
|
||||||
if (torrent) {
|
if (torrent) {
|
||||||
if (torrent->isPrivate() || m_torrentInfo.isPrivate()) {
|
if (torrent->isPrivate() || m_torrentInfo.isPrivate()) {
|
||||||
MessageBoxRaised::critical(0, tr("Already in download list"), tr("Torrent is already in download list. Trackers weren't merged because it is a private torrent."), QMessageBox::Ok);
|
MessageBoxRaised::critical(this, tr("Already in download list"), tr("Torrent is already in download list. Trackers weren't merged because it is a private torrent."), QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
torrent->addTrackers(m_torrentInfo.trackers());
|
torrent->addTrackers(m_torrentInfo.trackers());
|
||||||
torrent->addUrlSeeds(m_torrentInfo.urlSeeds());
|
torrent->addUrlSeeds(m_torrentInfo.urlSeeds());
|
||||||
MessageBoxRaised::information(0, tr("Already in download list"), tr("Torrent is already in download list. Trackers were merged."), QMessageBox::Ok);
|
MessageBoxRaised::information(this, tr("Already in download list"), tr("Torrent is already in download list. Trackers were merged."), QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MessageBoxRaised::critical(0, tr("Cannot add torrent"), tr("Cannot add this torrent. Perhaps it is already in adding state."), QMessageBox::Ok);
|
MessageBoxRaised::critical(this, tr("Cannot add torrent"), tr("Cannot add this torrent. Perhaps it is already in adding state."), QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -284,7 +281,7 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath)
|
|||||||
bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
|
bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
|
||||||
{
|
{
|
||||||
if (!magnetUri.isValid()) {
|
if (!magnetUri.isValid()) {
|
||||||
MessageBoxRaised::critical(0, tr("Invalid magnet link"), tr("This magnet link was not recognized"));
|
MessageBoxRaised::critical(this, tr("Invalid magnet link"), tr("This magnet link was not recognized"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,16 +292,16 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
|
|||||||
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash);
|
BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash);
|
||||||
if (torrent) {
|
if (torrent) {
|
||||||
if (torrent->isPrivate()) {
|
if (torrent->isPrivate()) {
|
||||||
MessageBoxRaised::critical(0, tr("Already in download list"), tr("Torrent is already in download list. Trackers weren't merged because it is a private torrent."), QMessageBox::Ok);
|
MessageBoxRaised::critical(this, tr("Already in download list"), tr("Torrent is already in download list. Trackers weren't merged because it is a private torrent."), QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
torrent->addTrackers(magnetUri.trackers());
|
torrent->addTrackers(magnetUri.trackers());
|
||||||
torrent->addUrlSeeds(magnetUri.urlSeeds());
|
torrent->addUrlSeeds(magnetUri.urlSeeds());
|
||||||
MessageBoxRaised::information(0, tr("Already in download list"), tr("Magnet link is already in download list. Trackers were merged."), QMessageBox::Ok);
|
MessageBoxRaised::information(this, tr("Already in download list"), tr("Magnet link is already in download list. Trackers were merged."), QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MessageBoxRaised::critical(0, tr("Cannot add torrent"), tr("Cannot add this torrent. Perhaps it is already in adding."), QMessageBox::Ok);
|
MessageBoxRaised::critical(this, tr("Cannot add torrent"), tr("Cannot add this torrent. Perhaps it is already in adding."), QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -317,8 +314,6 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri)
|
|||||||
|
|
||||||
setupTreeview();
|
setupTreeview();
|
||||||
TMMChanged(ui->comboTTM->currentIndex());
|
TMMChanged(ui->comboTTM->currentIndex());
|
||||||
// Set dialog position
|
|
||||||
setdialogPosition();
|
|
||||||
|
|
||||||
BitTorrent::Session::instance()->loadMetadata(magnetUri);
|
BitTorrent::Session::instance()->loadMetadata(magnetUri);
|
||||||
setMetadataProgressIndicator(true, tr("Retrieving metadata..."));
|
setMetadataProgressIndicator(true, tr("Retrieving metadata..."));
|
||||||
@ -575,28 +570,6 @@ void AddNewTorrentDialog::renameSelectedFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddNewTorrentDialog::setdialogPosition()
|
|
||||||
{
|
|
||||||
// In macOS, AddNewTorrentDialog is a sheet, not a window. Moving it
|
|
||||||
// causes very bad things to happen, especially if AddNewTorrentDialog is
|
|
||||||
// on a secondary monitor.
|
|
||||||
#ifndef Q_OS_MAC
|
|
||||||
qApp->processEvents();
|
|
||||||
QPoint center(Utils::Misc::screenCenter(this));
|
|
||||||
// Adjust y
|
|
||||||
int y = settings()->loadValue(KEY_POSITION, -1).toInt();
|
|
||||||
if (y >= 0) {
|
|
||||||
center.setY(y);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
center.ry() -= 120;
|
|
||||||
if (center.y() < 0)
|
|
||||||
center.setY(0);
|
|
||||||
}
|
|
||||||
move(center);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddNewTorrentDialog::populateSavePathComboBox()
|
void AddNewTorrentDialog::populateSavePathComboBox()
|
||||||
{
|
{
|
||||||
QString defSavePath = BitTorrent::Session::instance()->defaultSavePath();
|
QString defSavePath = BitTorrent::Session::instance()->defaultSavePath();
|
||||||
@ -608,7 +581,7 @@ void AddNewTorrentDialog::populateSavePathComboBox()
|
|||||||
foreach (const QString &savePath, settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList())
|
foreach (const QString &savePath, settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList())
|
||||||
if (QDir(savePath) != defaultSaveDir)
|
if (QDir(savePath) != defaultSaveDir)
|
||||||
ui->savePathComboBox->addItem(Utils::Fs::toNativePath(savePath), savePath);
|
ui->savePathComboBox->addItem(Utils::Fs::toNativePath(savePath), savePath);
|
||||||
|
|
||||||
if (!m_torrentParams.savePath.isEmpty())
|
if (!m_torrentParams.savePath.isEmpty())
|
||||||
setSavePath(m_torrentParams.savePath);
|
setSavePath(m_torrentParams.savePath);
|
||||||
}
|
}
|
||||||
@ -711,7 +684,7 @@ void AddNewTorrentDialog::updateMetadata(const BitTorrent::TorrentInfo &info)
|
|||||||
|
|
||||||
disconnect(this, SLOT(updateMetadata(BitTorrent::TorrentInfo)));
|
disconnect(this, SLOT(updateMetadata(BitTorrent::TorrentInfo)));
|
||||||
if (!info.isValid()) {
|
if (!info.isValid()) {
|
||||||
MessageBoxRaised::critical(0, tr("I/O Error"), ("Invalid metadata."));
|
MessageBoxRaised::critical(this, tr("I/O Error"), ("Invalid metadata."));
|
||||||
setMetadataProgressIndicator(false, tr("Invalid metadata"));
|
setMetadataProgressIndicator(false, tr("Invalid metadata"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -772,13 +745,11 @@ void AddNewTorrentDialog::setupTreeview()
|
|||||||
|
|
||||||
updateDiskSpaceLabel();
|
updateDiskSpaceLabel();
|
||||||
showAdvancedSettings(settings()->loadValue(KEY_EXPANDED, false).toBool());
|
showAdvancedSettings(settings()->loadValue(KEY_EXPANDED, false).toBool());
|
||||||
// Set dialog position
|
|
||||||
setdialogPosition();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddNewTorrentDialog::handleDownloadFailed(const QString &url, const QString &reason)
|
void AddNewTorrentDialog::handleDownloadFailed(const QString &url, const QString &reason)
|
||||||
{
|
{
|
||||||
MessageBoxRaised::critical(0, tr("Download Error"), QString("Cannot download '%1': %2").arg(url).arg(reason));
|
MessageBoxRaised::critical(this, tr("Download Error"), QString("Cannot download '%1': %2").arg(url).arg(reason));
|
||||||
this->deleteLater();
|
this->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,6 @@ private slots:
|
|||||||
void updateDiskSpaceLabel();
|
void updateDiskSpaceLabel();
|
||||||
void onSavePathChanged(int);
|
void onSavePathChanged(int);
|
||||||
void renameSelectedFile();
|
void renameSelectedFile();
|
||||||
void setdialogPosition();
|
|
||||||
void updateMetadata(const BitTorrent::TorrentInfo &info);
|
void updateMetadata(const BitTorrent::TorrentInfo &info);
|
||||||
void browseButton_clicked();
|
void browseButton_clicked();
|
||||||
void handleDownloadFailed(const QString &url, const QString &reason);
|
void handleDownloadFailed(const QString &url, const QString &reason);
|
||||||
|
@ -1163,8 +1163,9 @@ void MainWindow::on_actionOpen_triggered()
|
|||||||
// Open File Open Dialog
|
// Open File Open Dialog
|
||||||
// Note: it is possible to select more than one file
|
// Note: it is possible to select more than one file
|
||||||
const QStringList pathsList =
|
const QStringList pathsList =
|
||||||
QFileDialog::getOpenFileNames(0, tr("Open Torrent Files"), pref->getMainLastDir(),
|
QFileDialog::getOpenFileNames(this, tr("Open Torrent Files"), pref->getMainLastDir(),
|
||||||
tr("Torrent Files") + " (*.torrent)");
|
tr("Torrent Files") + " (*.torrent)");
|
||||||
|
|
||||||
const bool useTorrentAdditionDialog = AddNewTorrentDialog::isEnabled();
|
const bool useTorrentAdditionDialog = AddNewTorrentDialog::isEnabled();
|
||||||
if (!pathsList.isEmpty()) {
|
if (!pathsList.isEmpty()) {
|
||||||
foreach (QString file, pathsList) {
|
foreach (QString file, pathsList) {
|
||||||
|
@ -265,7 +265,7 @@ void SearchWidget::on_searchButton_clicked()
|
|||||||
const QString pattern = m_ui->m_searchPattern->text().trimmed();
|
const QString pattern = m_ui->m_searchPattern->text().trimmed();
|
||||||
// No search pattern entered
|
// No search pattern entered
|
||||||
if (pattern.isEmpty()) {
|
if (pattern.isEmpty()) {
|
||||||
QMessageBox::critical(0, tr("Empty search pattern"), tr("Please type a search pattern first"));
|
QMessageBox::critical(this, tr("Empty search pattern"), tr("Please type a search pattern first"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user