From 6f5d32eddf3786cfe8d50aac57d33c6b5b743285 Mon Sep 17 00:00:00 2001 From: "S. Razi Alavizadeh" Date: Sat, 29 Dec 2012 11:31:01 +0330 Subject: [PATCH] Fixed problem of setting listWidget's height from recent commit: f27137f8ae --- src/lib/webview/siteinfo.cpp | 17 +++++++++++++---- src/lib/webview/siteinfo.h | 3 +++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/lib/webview/siteinfo.cpp b/src/lib/webview/siteinfo.cpp index d4dfa6f42..61d195ce1 100644 --- a/src/lib/webview/siteinfo.cpp +++ b/src/lib/webview/siteinfo.cpp @@ -34,6 +34,7 @@ #include #include #include +#include QString SiteInfo::showCertInfo(const QString &string) { @@ -50,12 +51,13 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent) , ui(new Ui::SiteInfo) , m_certWidget(0) , m_view(view) + , m_delegate(0) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); - ListItemDelegate* delegate = new ListItemDelegate(24, ui->listWidget); - ui->listWidget->setItemDelegate(delegate); + m_delegate = new ListItemDelegate(24, ui->listWidget); + ui->listWidget->setItemDelegate(m_delegate); ui->listWidget->item(0)->setIcon(QIcon::fromTheme("document-properties", QIcon(":/icons/preferences/document-properties.png"))); ui->listWidget->item(1)->setIcon(QIcon::fromTheme("applications-graphics", QIcon(":/icons/preferences/applications-graphics.png"))); @@ -63,8 +65,6 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent) ui->listWidget->item(3)->setIcon(QIcon::fromTheme("dialog-password", QIcon(":/icons/preferences/dialog-password.png"))); ui->listWidget->item(0)->setSelected(true); - ui->listWidget->setFixedHeight(delegate->itemHeight()); - WebPage* webPage = view->page(); QWebFrame* frame = view->page()->mainFrame(); QString title = view->title(); @@ -175,6 +175,8 @@ SiteInfo::SiteInfo(WebView* view, QWidget* parent) ui->treeImages->sortByColumn(-1); ui->treeTags->sortByColumn(-1); + + QTimer::singleShot(0, this, SLOT(heightChange())); } void SiteInfo::imagesCustomContextMenuRequested(const QPoint &p) @@ -245,6 +247,13 @@ void SiteInfo::downloadImage() } } +void SiteInfo::heightChange() +{ + if (m_delegate) { + ui->listWidget->setFixedHeight(m_delegate->itemHeight()); + } +} + void SiteInfo::showImagePreview(QTreeWidgetItem* item) { if (!item) { diff --git a/src/lib/webview/siteinfo.h b/src/lib/webview/siteinfo.h index b8f2f775d..a55fea0a2 100644 --- a/src/lib/webview/siteinfo.h +++ b/src/lib/webview/siteinfo.h @@ -33,6 +33,7 @@ class QTreeWidgetItem; class WebView; class CertificateInfoWidget; +class ListItemDelegate; class QT_QUPZILLA_EXPORT SiteInfo : public QDialog { @@ -52,11 +53,13 @@ private slots: void imagesCustomContextMenuRequested(const QPoint &p); void copyActionData(); void downloadImage(); + void heightChange(); private: Ui::SiteInfo* ui; CertificateInfoWidget* m_certWidget; WebView* m_view; + ListItemDelegate* m_delegate; QPixmap m_activePixmap; QUrl m_baseUrl;