mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 20:44:15 +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
|
||||
// when called from showEvent. Only 6 symbols off instead of 11 symbols off.
|
||||
int textW = ui->textEdit->fontMetrics().width(ui->textEdit->text()) + 4;
|
||||
int screenW = QApplication::desktop()->width() / 4;
|
||||
int wd = textW;
|
||||
|
||||
if (!windowTitle().isEmpty()) {
|
||||
@ -87,35 +86,9 @@ void AutoExpandableDialog::showEvent(QShowEvent *e) {
|
||||
wd = _w;
|
||||
}
|
||||
|
||||
|
||||
// Now resize the dialog to fit the contents
|
||||
// Maximum value is whichever is smaller:
|
||||
// 1. screen width / 4
|
||||
// 2. max width of text from either of: label, title, textedit
|
||||
// max width of text from either of: label, title, textedit
|
||||
// If the value is less than dialog default size default size is used
|
||||
wd = textW < screenW ? textW : screenW;
|
||||
if (wd > width())
|
||||
resize(width() - ui->horizontalLayout->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);
|
||||
resize(width() - ui->verticalLayout->sizeHint().width() + wd, height());
|
||||
}
|
||||
|
@ -41,9 +41,9 @@ class AutoExpandableDialog;
|
||||
|
||||
class AutoExpandableDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
explicit AutoExpandableDialog(QWidget *parent = 0);
|
||||
explicit AutoExpandableDialog(QWidget *parent);
|
||||
~AutoExpandableDialog();
|
||||
|
||||
static QString getText(QWidget *parent, const QString& title, const QString& label,
|
||||
@ -52,7 +52,7 @@ public:
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *e);
|
||||
|
||||
|
||||
private:
|
||||
Ui::AutoExpandableDialog *ui;
|
||||
};
|
||||
|
@ -7,79 +7,23 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>222</width>
|
||||
<height>94</height>
|
||||
<height>105</height>
|
||||
</rect>
|
||||
</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">
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QLabel" name="textLabel"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="textLabel">
|
||||
<property name="toolTip">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"/>
|
||||
<widget class="QLineEdit" name="textEdit"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
@ -54,7 +54,6 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
|
||||
lbl_warn->setFixedWidth(lbl_warn->height());
|
||||
rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked"));
|
||||
|
||||
move(Utils::Misc::screenCenter(this));
|
||||
checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault());
|
||||
connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState()));
|
||||
buttonBox->button(QDialogButtonBox::Cancel)->setFocus();
|
||||
@ -64,8 +63,8 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg {
|
||||
return checkPermDelete->isChecked();
|
||||
}
|
||||
|
||||
static bool askForDeletionConfirmation(bool& deleteLocalFiles, const int& size, const QString& name) {
|
||||
DeletionConfirmationDlg dlg(NULL, size, name, deleteLocalFiles);
|
||||
static bool askForDeletionConfirmation(QWidget *parent, bool& deleteLocalFiles, const int& size, const QString& name) {
|
||||
DeletionConfirmationDlg dlg(parent, size, name, deleteLocalFiles);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
deleteLocalFiles = dlg.shouldDeleteLocalFiles();
|
||||
return true;
|
||||
|
@ -16,18 +16,9 @@
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>42</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>The following files support previewing, please select one of them:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
@ -83,7 +83,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString)));
|
||||
@ -120,7 +120,7 @@ void PreviewSelect::on_previewButton_clicked() {
|
||||
if (QFile::exists(path))
|
||||
emit readyToPreviewFile(path);
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -328,7 +328,7 @@ void TransferListWidget::deleteSelectedTorrents(bool deleteLocalFiles)
|
||||
if (torrents.empty()) return;
|
||||
|
||||
if (Preferences::instance()->confirmTorrentDeletion()
|
||||
&& !DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||
&& !DeletionConfirmationDlg::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||
return;
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
||||
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
||||
@ -344,8 +344,9 @@ void TransferListWidget::deleteVisibleTorrents()
|
||||
|
||||
bool deleteLocalFiles = false;
|
||||
if (Preferences::instance()->confirmTorrentDeletion()
|
||||
&& !DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||
&& !DeletionConfirmationDlg::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name()))
|
||||
return;
|
||||
|
||||
foreach (BitTorrent::TorrentHandle *const torrent, torrents)
|
||||
BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user