From ef01088411439550eab1500b7f18a90abce289fc Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 25 Sep 2010 19:26:45 +0000 Subject: [PATCH] Limit torrent addition dialog width --- src/torrentadditiondlg.cpp | 23 +++++++++++++++++++++++ src/torrentadditiondlg.h | 1 + 2 files changed, 24 insertions(+) diff --git a/src/torrentadditiondlg.cpp b/src/torrentadditiondlg.cpp index 9b744e685..ab657abc0 100644 --- a/src/torrentadditiondlg.cpp +++ b/src/torrentadditiondlg.cpp @@ -125,6 +125,22 @@ void torrentAdditionDialog::renameTorrentNameInModel(QString file_path) { PropListModel->setData(PropListModel->index(0, 0), file_path.split("/", QString::SkipEmptyParts).last()); } +void torrentAdditionDialog::limitDialogWidth() { + int scrn = 0; + const QWidget *w = this->window(); + + if(w) + scrn = QApplication::desktop()->screenNumber(w); + else if(QApplication::desktop()->isVirtualDesktop()) + scrn = QApplication::desktop()->screenNumber(QCursor::pos()); + else + scrn = QApplication::desktop()->screenNumber(this); + + QRect desk(QApplication::desktop()->availableGeometry(scrn)); + int max_width = desk.width(); + setMaximumWidth(max_width); +} + void torrentAdditionDialog::hideTorrentContent() { // Disable useless widgets hidden_height += torrentContentList->height(); @@ -167,6 +183,8 @@ void torrentAdditionDialog::showLoadMagnetURI(QString magnet_uri) { // No need to display torrent content hideTorrentContent(); + // Limit dialog width + limitDialogWidth(); } void torrentAdditionDialog::showLoad(QString filePath, QString from_url) { @@ -260,6 +278,11 @@ void torrentAdditionDialog::showLoad(QString filePath, QString from_url) { // Hide useless widgets if(t->num_files() <= 1) hideTorrentContent(); + + // No need to display torrent content + hideTorrentContent(); + // Limit dialog width + limitDialogWidth(); } void torrentAdditionDialog::displayContentListMenu(const QPoint&) { diff --git a/src/torrentadditiondlg.h b/src/torrentadditiondlg.h index 289f69b8d..e3d1aba6f 100644 --- a/src/torrentadditiondlg.h +++ b/src/torrentadditiondlg.h @@ -82,6 +82,7 @@ public slots: void on_OkButton_clicked(); void renameTorrentNameInModel(QString file_path); void hideTorrentContent(); + void limitDialogWidth(); void saveTruncatedPathHistory(); void loadSavePathHistory(); void updateLabelInSavePath(QString label);