#include <KLocalizedString>
// Qt toolkit headers.
+#include <QDebug>
#include <QMimeDatabase>
#include <QPushButton>
#include <QShortcut>
saveDialogUi.setupUi(this);
// Get handles for the widgets.
+ QGraphicsView *mimeGraphicsViewPointer = saveDialogUi.mimeGraphicsView;
QLabel *urlLabelPointer = saveDialogUi.urlLabel;
QLabel *filetypeLabelPointer = saveDialogUi.fileTypeLabel;
QLabel *mimeTypeLabelPointer = saveDialogUi.mimeTypeLabel;
// Get the URL and the suggested file name.
downloadUrl = downloadItemPointer->url();
suggestedFileName = downloadItemPointer->suggestedFileName();
- QString mimeType = downloadItemPointer->mimeType();
+ QString mimeTypeString = downloadItemPointer->mimeType();
// Get a MIME type database.
QMimeDatabase mimeDatabase;
+ // Get the MIME type.
+ QMimeType mimeType = mimeDatabase.mimeTypeForName(mimeTypeString);
+
+ // Get the MIME type icon.
+ QIcon mimeTypeIcon = QIcon::fromTheme(mimeType.iconName());
+
+ // Create a graphics scene.
+ QGraphicsScene *mimeGraphicsScenePointer = new QGraphicsScene(this);
+
+ // Set the graphics scene.
+ mimeGraphicsViewPointer->setScene(mimeGraphicsScenePointer);
+
+ // Set the background of the graphics view to be the same as the window
+ mimeGraphicsViewPointer->setBackgroundRole(QPalette::Window);
+
+ // Add the MIME type icon to the scene.
+ mimeGraphicsScenePointer->addPixmap(mimeTypeIcon.pixmap(64, 64));
+
// Populate the labels.
urlLabelPointer->setText("<b>" + downloadUrl.toString() + "</b>");
- filetypeLabelPointer->setText("<b>" + mimeDatabase.mimeTypeForName(mimeType).comment() + "</b>");
- mimeTypeLabelPointer->setText("<b>" + mimeType + "</b>");
+ filetypeLabelPointer->setText("<b>" + mimeType.comment() + "</b>");
+ mimeTypeLabelPointer->setText("<b>" + mimeTypeString + "</b>");
// Populate the download size label.
if (downloadItemPointer->totalBytes() == -1) // The file size is unknown.
<string>File details</string>
</property>
- <!-- Labels. -->
- <layout class="QFormLayout">
- <!-- URL. -->
- <item row="0" column="0">
- <widget class="QLabel">
- <property name="text">
- <string>URL:</string>
+ <layout class="QHBoxLayout">
+ <!-- Icon. -->
+ <item>
+ <widget class="QGraphicsView" name="mimeGraphicsView">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
</property>
- </widget>
- </item>
-
- <item row="0" column="1">
- <widget class="QLabel" name="urlLabel">
- <property name="textFormat">
- <enum>Qt::RichText</enum>
- </property>
- </widget>
- </item>
-
- <!-- File type. -->
- <item row="1" column="0">
- <widget class="QLabel">
- <property name="text">
- <string>File type:</string>
- </property>
- </widget>
- </item>
-
- <item row="1" column="1">
- <widget class="QLabel" name="fileTypeLabel">
- <property name="textFormat">
- <enum>Qt::RichText</enum>
- </property>
- </widget>
- </item>
-
- <!-- MIME type. -->
- <item row="2" column="0">
- <widget class="QLabel">
- <property name="text">
- <string>MIME type:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="mimeTypeLabel">
- <property name="textFormat">
- <enum>Qt::RichText</enum>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
- <!-- Size. -->
- <item row="3" column="0">
- <widget class="QLabel">
- <property name="text">
- <string>Size:</string>
- </property>
- </widget>
- </item>
-
- <item row="3" column="1">
- <widget class="QLabel" name="sizeLabel">
- <property name="textFormat">
- <enum>Qt::RichText</enum>
- </property>
- </widget>
+ <!-- Text. -->
+ <item>
+ <layout class="QFormLayout">
+ <!-- URL. -->
+ <item row="0" column="0">
+ <widget class="QLabel">
+ <property name="text">
+ <string>URL:</string>
+ </property>
+ </widget>
+ </item>
+
+ <item row="0" column="1">
+ <widget class="QLabel" name="urlLabel">
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ </widget>
+ </item>
+
+ <!-- File type. -->
+ <item row="1" column="0">
+ <widget class="QLabel">
+ <property name="text">
+ <string>File type:</string>
+ </property>
+ </widget>
+ </item>
+
+ <item row="1" column="1">
+ <widget class="QLabel" name="fileTypeLabel">
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ </widget>
+ </item>
+
+ <!-- MIME type. -->
+ <item row="2" column="0">
+ <widget class="QLabel">
+ <property name="text">
+ <string>MIME type:</string>
+ </property>
+ </widget>
+ </item>
+
+ <item row="2" column="1">
+ <widget class="QLabel" name="mimeTypeLabel">
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ </widget>
+ </item>
+
+ <!-- Size. -->
+ <item row="3" column="0">
+ <widget class="QLabel">
+ <property name="text">
+ <string>Size:</string>
+ </property>
+ </widget>
+ </item>
+
+ <item row="3" column="1">
+ <widget class="QLabel" name="sizeLabel">
+ <property name="textFormat">
+ <enum>Qt::RichText</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>