Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add 'Open Location' button to the download manager.

  • Loading branch information...
commit f63d6c61435ecd8c02f5cbba105575ec68f32ebe 1 parent 160583f
@gzsombor authored
View
78 src/downloaditem.ui
@@ -1,62 +1,63 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
<class>DownloadItem</class>
- <widget class="QWidget" name="DownloadItem" >
- <property name="geometry" >
+ <widget class="QWidget" name="DownloadItem">
+ <property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>423</width>
- <height>110</height>
+ <height>113</height>
</rect>
</property>
- <layout class="QHBoxLayout" name="horizontalLayout" >
- <property name="margin" >
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="margin">
<number>0</number>
</property>
<item>
- <widget class="QLabel" name="fileIcon" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
+ <widget class="QLabel" name="fileIcon">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="text" >
+ <property name="text">
<string>Ico</string>
</property>
</widget>
</item>
<item>
- <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="SqueezeLabel" native="1" name="fileNameLabel" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
+ <widget class="SqueezeLabel" name="fileNameLabel" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="text" stdset="0" >
+ <property name="text" stdset="0">
<string>Filename</string>
</property>
</widget>
</item>
<item>
- <widget class="QProgressBar" name="progressBar" >
- <property name="value" >
+ <widget class="QProgressBar" name="progressBar">
+ <property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
- <widget class="SqueezeLabel" native="1" name="downloadInfoLabel" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Preferred" hsizetype="Minimum" >
+ <widget class="SqueezeLabel" name="downloadInfoLabel" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="text" stdset="0" >
+ <property name="text" stdset="0">
<string/>
</property>
</widget>
@@ -64,13 +65,13 @@
</layout>
</item>
<item>
- <layout class="QVBoxLayout" name="verticalLayout" >
+ <layout class="QVBoxLayout" name="verticalLayout">
<item>
- <spacer name="verticalSpacer" >
- <property name="orientation" >
+ <spacer name="verticalSpacer">
+ <property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeHint" stdset="0" >
+ <property name="sizeHint" stdset="0">
<size>
<width>17</width>
<height>1</height>
@@ -79,35 +80,42 @@
</spacer>
</item>
<item>
- <widget class="QPushButton" name="tryAgainButton" >
- <property name="enabled" >
+ <widget class="QPushButton" name="tryAgainButton">
+ <property name="enabled">
<bool>false</bool>
</property>
- <property name="text" >
+ <property name="text">
<string>Try Again</string>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="stopButton" >
- <property name="text" >
+ <widget class="QPushButton" name="stopButton">
+ <property name="text">
<string>Stop</string>
</property>
</widget>
</item>
<item>
- <widget class="QPushButton" name="openButton" >
- <property name="text" >
+ <widget class="QPushButton" name="openButton">
+ <property name="text">
<string>Open</string>
</property>
</widget>
</item>
<item>
- <spacer name="verticalSpacer_2" >
- <property name="orientation" >
+ <widget class="QPushButton" name="openLocationButton">
+ <property name="text">
+ <string>Open Location</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
<enum>Qt::Vertical</enum>
</property>
- <property name="sizeHint" stdset="0" >
+ <property name="sizeHint" stdset="0">
<size>
<width>17</width>
<height>5</height>
View
10 src/downloadmanager.cpp
@@ -108,6 +108,7 @@ DownloadItem::DownloadItem(QNetworkReply *reply, bool requestFileName, QWidget *
tryAgainButton->hide();
connect(stopButton, SIGNAL(clicked()), this, SLOT(stop()));
connect(openButton, SIGNAL(clicked()), this, SLOT(open()));
+ connect(openLocationButton, SIGNAL(clicked()), this, SLOT(openLocation()));
connect(tryAgainButton, SIGNAL(clicked()), this, SLOT(tryAgain()));
if (!requestFileName) {
@@ -128,6 +129,7 @@ void DownloadItem::init()
m_finishedDownloading = false;
openButton->setEnabled(false);
+ openLocationButton->setEnabled(false);
// attach to the m_reply
m_url = m_reply->url();
@@ -260,6 +262,13 @@ void DownloadItem::open()
QDesktopServices::openUrl(url);
}
+void DownloadItem::openLocation()
+{
+ QFileInfo info(m_output);
+ QUrl url = QUrl::fromLocalFile(info.absoluteDir().absolutePath());
+ QDesktopServices::openUrl(url);
+}
+
void DownloadItem::tryAgain()
{
if (!tryAgainButton->isEnabled())
@@ -447,6 +456,7 @@ void DownloadItem::finished()
stopButton->setEnabled(false);
stopButton->hide();
openButton->setEnabled(true);
+ openLocationButton->setEnabled(true);
m_output.close();
updateInfoLabel();
emit statusChanged();
View
1  src/downloadmanager.h
@@ -100,6 +100,7 @@ private slots:
void stop();
void tryAgain();
void open();
+ void openLocation();
void downloadReadyRead();
void error(QNetworkReply::NetworkError code);
Please sign in to comment.
Something went wrong with that request. Please try again.