mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 04:54:18 +00:00
Fix deletionconfirmationdlg position
Fix autoexpandabledialog position Fix previewselect position
This commit is contained in:
parent
a902eb6b2b
commit
46abe42a54
@ -72,7 +72,6 @@ void AutoExpandableDialog::showEvent(QShowEvent *e) {
|
|||||||
// NOTE: For some strange reason QFontMetrics gets more accurate
|
// NOTE: For some strange reason QFontMetrics gets more accurate
|
||||||
// when called from showEvent. Only 6 symbols off instead of 11 symbols off.
|
// when called from showEvent. Only 6 symbols off instead of 11 symbols off.
|
||||||
int textW = ui->textEdit->fontMetrics().width(ui->textEdit->text()) + 4;
|
int textW = ui->textEdit->fontMetrics().width(ui->textEdit->text()) + 4;
|
||||||
int screenW = QApplication::desktop()->width() / 4;
|
|
||||||
int wd = textW;
|
int wd = textW;
|
||||||
|
|
||||||
if (!windowTitle().isEmpty()) {
|
if (!windowTitle().isEmpty()) {
|
||||||
@ -87,35 +86,9 @@ void AutoExpandableDialog::showEvent(QShowEvent *e) {
|
|||||||
wd = _w;
|
wd = _w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Now resize the dialog to fit the contents
|
// Now resize the dialog to fit the contents
|
||||||
// Maximum value is whichever is smaller:
|
// max width of text from either of: label, title, textedit
|
||||||
// 1. screen width / 4
|
|
||||||
// 2. max width of text from either of: label, title, textedit
|
|
||||||
// If the value is less than dialog default size default size is used
|
// If the value is less than dialog default size default size is used
|
||||||
wd = textW < screenW ? textW : screenW;
|
|
||||||
if (wd > width())
|
if (wd > width())
|
||||||
resize(width() - ui->horizontalLayout->sizeHint().width() + wd, height());
|
resize(width() - ui->verticalLayout->sizeHint().width() + wd, height());
|
||||||
|
|
||||||
// Use old dialog behavior: prohibit resizing the dialog
|
|
||||||
setFixedHeight(height());
|
|
||||||
|
|
||||||
// Update geometry: center on screen
|
|
||||||
QDesktopWidget *desk = QApplication::desktop();
|
|
||||||
MainWindow *wnd = qobject_cast<MainWindow*>(QApplication::activeWindow());
|
|
||||||
QPoint p = QCursor::pos();
|
|
||||||
|
|
||||||
int screenNum = 0;
|
|
||||||
if (wnd == 0)
|
|
||||||
screenNum = desk->screenNumber(p);
|
|
||||||
else if (!wnd->isHidden())
|
|
||||||
screenNum = desk->screenNumber(wnd);
|
|
||||||
else
|
|
||||||
screenNum = desk->screenNumber(p);
|
|
||||||
|
|
||||||
QRect screenRes = desk->screenGeometry(screenNum);
|
|
||||||
|
|
||||||
QRect geom = geometry();
|
|
||||||
geom.moveCenter(QPoint(screenRes.width() / 2, screenRes.height() / 2));
|
|
||||||
setGeometry(geom);
|
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,9 @@ class AutoExpandableDialog;
|
|||||||
|
|
||||||
class AutoExpandableDialog : public QDialog {
|
class AutoExpandableDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AutoExpandableDialog(QWidget *parent = 0);
|
explicit AutoExpandableDialog(QWidget *parent);
|
||||||
~AutoExpandableDialog();
|
~AutoExpandableDialog();
|
||||||
|
|
||||||
static QString getText(QWidget *parent, const QString& title, const QString& label,
|
static QString getText(QWidget *parent, const QString& title, const QString& label,
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent *e);
|
void showEvent(QShowEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::AutoExpandableDialog *ui;
|
Ui::AutoExpandableDialog *ui;
|
||||||
};
|
};
|
||||||
|
@ -7,79 +7,23 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>222</width>
|
<width>222</width>
|
||||||
<height>94</height>
|
<height>105</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string notr="true">Dialog</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer">
|
<widget class="QLabel" name="textLabel"/>
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="textLabel">
|
<widget class="QLineEdit" name="textEdit"/>
|
||||||
<property name="toolTip">
|
</item>
|
||||||
<string notr="true"/>
|
<item>
|
||||||
</property>
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="text">
|
<property name="standardButtons">
|
||||||
<string notr="true"/>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="textEdit">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -54,7 +54,6 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
|
|||||||
lbl_warn->setFixedWidth(lbl_warn->height());
|
lbl_warn->setFixedWidth(lbl_warn->height());
|
||||||
rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked"));
|
rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked"));
|
||||||
|
|
||||||
move(Utils::Misc::screenCenter(this));
|
|
||||||
checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault());
|
checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault());
|
||||||
connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState()));
|
connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState()));
|
||||||
buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
|
buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
|
||||||
@ -64,8 +63,8 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
|
|||||||
return checkPermDelete->isChecked();
|
return checkPermDelete->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool askForDeletionConfirmation(bool& deleteLocalFiles, const int& size, const QString& name) {
|
static bool askForDeletionConfirmation(QWidget *parent, bool& deleteLocalFiles, const int& size, const QString& name) {
|
||||||
DeletionConfirmationDlg dlg(NULL, size, name, deleteLocalFiles);
|
DeletionConfirmationDlg dlg(parent, size, name, deleteLocalFiles);
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
deleteLocalFiles = dlg.shouldDeleteLocalFiles();
|
deleteLocalFiles = dlg.shouldDeleteLocalFiles();
|
||||||
return true;
|
return true;
|
||||||
|
@ -16,18 +16,9 @@
|
|||||||
<layout class="QVBoxLayout">
|
<layout class="QVBoxLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>42</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>The following files support previewing, please select one of them:</string>
|
<string>The following files support previewing, please select one of them:</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
|
||||||
</property>
|
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -83,7 +83,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!previewListModel->rowCount()) {
|
if (!previewListModel->rowCount()) {
|
||||||
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
QMessageBox::critical(this->parentWidget(), tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString)));
|
connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString)));
|
||||||
@ -120,7 +120,7 @@ void PreviewSelect::on_previewButton_clicked() {
|
|||||||
if (QFile::exists(path))
|
if (QFile::exists(path))
|
||||||
emit readyToPreviewFile(path);
|
emit readyToPreviewFile(path);
|
||||||
else
|
else
|
||||||
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
QMessageBox::critical(this->parentWidget(), tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +328,7 @@ void TransferListWidget::deleteSelectedTorrents(bool deleteLocalFiles)
|
|||||||
if (torrents.empty()) return;
|
if (torrents.empty()) return;
|
||||||
|
|
||||||
if (Preferences::instance()->confirmTorrentDeletion()
|
if (Preferences::instance()->confirmTorrentDeletion()
|
||||||
&& !DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
&& !DeletionConfirmationDlg::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||||
return;
|
return;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
||||||
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
||||||
@ -344,8 +344,9 @@ void TransferListWidget::deleteVisibleTorrents()
|
|||||||
|
|
||||||
bool deleteLocalFiles = false;
|
bool deleteLocalFiles = false;
|
||||||
if (Preferences::instance()->confirmTorrentDeletion()
|
if (Preferences::instance()->confirmTorrentDeletion()
|
||||||
&& !DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
&& !DeletionConfirmationDlg::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
||||||
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user