Browse Source

Fix deletionconfirmationdlg position

Fix autoexpandabledialog position
Fix previewselect position
adaptive-webui-19844
Chocobo1 9 years ago
parent
commit
46abe42a54
  1. 31
      src/gui/autoexpandabledialog.cpp
  2. 2
      src/gui/autoexpandabledialog.h
  3. 68
      src/gui/autoexpandabledialog.ui
  4. 5
      src/gui/deletionconfirmationdlg.h
  5. 9
      src/gui/preview.ui
  6. 4
      src/gui/previewselect.cpp
  7. 5
      src/gui/transferlistwidget.cpp

31
src/gui/autoexpandabledialog.cpp

@ -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);
} }

2
src/gui/autoexpandabledialog.h

@ -43,7 +43,7 @@ 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,

68
src/gui/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">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item> </item>
<item> <item>
<widget class="QLineEdit" name="textEdit"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="toolTip"> <property name="standardButtons">
<string notr="true"/> <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
<property name="text">
<string notr="true"/>
</property> </property>
</widget> </widget>
</item> </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/>

5
src/gui/deletionconfirmationdlg.h

@ -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;

9
src/gui/preview.ui

@ -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>

4
src/gui/previewselect.cpp

@ -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();
} }

5
src/gui/transferlistwidget.cpp

@ -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…
Cancel
Save