Mercurial > hg > easaier-soundaccess
comparison widgets/RelatedMediaWidget.cpp @ 154:1b8f08375391
add the RelatedMediaWidget in the InfoWidget
author | lbajardsilogic |
---|---|
date | Thu, 15 Nov 2007 10:46:57 +0000 |
parents | 98df77b4f041 |
children | 708c00883180 |
comparison
equal
deleted
inserted
replaced
153:98df77b4f041 | 154:1b8f08375391 |
---|---|
11 COPYING included with this distribution for more information . | 11 COPYING included with this distribution for more information . |
12 */ | 12 */ |
13 | 13 |
14 #include "RelatedMediaWidget.h" | 14 #include "RelatedMediaWidget.h" |
15 | 15 |
16 #include <QScrollArea> | |
17 #include <QLayoutItem> | 16 #include <QLayoutItem> |
18 #include <QLinearGradient> | 17 #include <QLinearGradient> |
19 | 18 |
20 #include <iostream> | 19 #include <iostream> |
21 | 20 |
22 #include "sv/main/MainWindow.h" | 21 #include "sv/main/MainWindow.h" |
22 #include "AdvancedToolBox.h" | |
23 | 23 |
24 RelatedMediaWidget::RelatedMediaWidget() : QWidget() , | 24 RelatedMediaWidget::RelatedMediaWidget() : QWidget() , |
25 m_nbRelMedia(0), | 25 m_nbRelMedia(0), |
26 m_painter(0) | 26 m_painter(0), |
27 m_relMediaMaxHeight(150) | |
27 { | 28 { |
28 m_relMediaLayout = new QGridLayout; | 29 m_relMediaLayout = new QGridLayout; |
29 | 30 |
30 QWidget *mediaWidget = new QWidget; | 31 QWidget *mediaWidget = new QWidget; |
31 mediaWidget->setLayout(m_relMediaLayout); | 32 mediaWidget->setLayout(m_relMediaLayout); |
32 | 33 |
33 QScrollArea * scrollArea = new QScrollArea; | 34 m_scrollArea = new QScrollArea; |
34 scrollArea->setWidget(mediaWidget); | 35 m_scrollArea->setWidget(mediaWidget); |
35 scrollArea->setWidgetResizable(true); | 36 m_scrollArea->setWidgetResizable(true); |
37 m_scrollArea->setMinimumHeight(m_relMediaMaxHeight + 50); | |
38 | |
39 AdvancedToolBox * toolBox= new AdvancedToolBox; | |
40 toolBox->addItem("Related Media", m_scrollArea); | |
36 | 41 |
37 QVBoxLayout *mainLayout = new QVBoxLayout; | 42 QVBoxLayout *mainLayout = new QVBoxLayout; |
38 mainLayout->addWidget(scrollArea); | 43 mainLayout->addWidget(toolBox); |
44 mainLayout->setSpacing(0); | |
45 mainLayout->setMargin(0); | |
39 | 46 |
40 setLayout(mainLayout); | 47 setLayout(mainLayout); |
41 } | 48 } |
42 | 49 |
43 RelatedMediaWidget::~RelatedMediaWidget() | 50 RelatedMediaWidget::~RelatedMediaWidget() |
58 QString imageSource; | 65 QString imageSource; |
59 QString extension = filename.right(filename.length() - (filename.lastIndexOf('.') + 1)); | 66 QString extension = filename.right(filename.length() - (filename.lastIndexOf('.') + 1)); |
60 | 67 |
61 int width; | 68 int width; |
62 int height; | 69 int height; |
63 int maxHeight = 150; | 70 |
64 | |
65 if (extension == "pdf") | 71 if (extension == "pdf") |
66 { | 72 { |
67 imageSource = ":icons/icon_pdf.png"; | 73 imageSource = ":icons/icon_pdf.png"; |
68 } else | 74 } else |
69 { | 75 { |
70 imageSource = filename; | 76 imageSource = filename; |
71 } | 77 } |
72 | 78 |
73 QPixmap image(imageSource); | 79 QPixmap image(imageSource); |
74 if (image.height() > maxHeight) | 80 if (image.height() > m_relMediaMaxHeight) |
75 { | 81 { |
76 height = maxHeight; | 82 height = m_relMediaMaxHeight; |
77 width = image.width() * maxHeight / image.height(); | 83 width = image.width() * m_relMediaMaxHeight / image.height(); |
78 } else | 84 } else |
79 { | 85 { |
80 height = image.height(); | 86 height = image.height(); |
81 width = image.width(); | 87 width = image.width(); |
82 } | 88 } |