aboutsummaryrefslogtreecommitdiff
path: root/lib/downloads/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'lib/downloads/widgets')
-rw-r--r--lib/downloads/widgets/downloaditemform.ui99
-rw-r--r--lib/downloads/widgets/downloaditemwidget.cpp44
-rw-r--r--lib/downloads/widgets/downloaditemwidget.h6
-rw-r--r--lib/downloads/widgets/elidedlabel.cpp72
-rw-r--r--lib/downloads/widgets/elidedlabel.h65
5 files changed, 92 insertions, 194 deletions
diff --git a/lib/downloads/widgets/downloaditemform.ui b/lib/downloads/widgets/downloaditemform.ui
index c8a4604..9b4ba12 100644
--- a/lib/downloads/widgets/downloaditemform.ui
+++ b/lib/downloads/widgets/downloaditemform.ui
@@ -7,20 +7,23 @@
<x>0</x>
<y>0</y>
<width>500</width>
- <height>128</height>
+ <height>95</height>
</rect>
</property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
+ <number>2</number>
+ </property>
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -38,47 +41,41 @@
</widget>
</item>
<item>
- <widget class="QWidget" name="detailsWidget" native="true">
- <layout class="QVBoxLayout" name="detailsLayout">
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QToolButton" name="pause_toolButton">
- <property name="text">
- <string>Pause</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="abort_toolButton">
- <property name="text">
- <string>Abort</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="status_label">
- <property name="text">
- <string>status_label</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QLabel" name="path_label">
- <property name="text">
- <string>path_label</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QToolButton" name="pause_toolButton">
+ <property name="text">
+ <string>Pause</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="abort_toolButton">
+ <property name="text">
+ <string>Abort</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="status_label">
+ <property name="text">
+ <string>status_label</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="ElidedLabel" name="path_label">
+ <property name="text">
+ <string>path_label</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
</widget>
</item>
</layout>
diff --git a/lib/downloads/widgets/downloaditemwidget.cpp b/lib/downloads/widgets/downloaditemwidget.cpp
index 2790c5c..660d8a5 100644
--- a/lib/downloads/widgets/downloaditemwidget.cpp
+++ b/lib/downloads/widgets/downloaditemwidget.cpp
@@ -15,8 +15,8 @@ DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *pa
: QWidget(parent)
, ui(new Ui::DownloadItemForm)
{
- m_item = item;
-
+ Q_CHECK_PTR(item);
+ this->item = item;
ui->setupUi(this);
{
// pause/resume icons
@@ -28,9 +28,7 @@ DownloadItemWidget::DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *pa
ui->abort_toolButton->setIcon(style()->standardIcon(QStyle::SP_MediaStop));
}
- ui->url_label->setContent(item->url().toString());
- ui->detailsWidget->hide();
-
+ ui->url_label->setText(item->url().toString());
ui->path_label->setText(item->path());
connect(item, &QWebEngineDownloadItem::stateChanged, this, &DownloadItemWidget::updateState);
@@ -52,21 +50,6 @@ DownloadItemWidget::~DownloadItemWidget()
delete ui;
}
-void DownloadItemWidget::showDetails()
-{
- ui->detailsWidget->show();
-}
-
-void DownloadItemWidget::hideDetails()
-{
- ui->detailsWidget->hide();
-}
-
-QWebEngineDownloadItem *DownloadItemWidget::item() const
-{
- return m_item;
-}
-
QString DownloadItemWidget::sizeString(int size) const
{
if(size < 1024) {
@@ -127,4 +110,25 @@ void DownloadItemWidget::updateProgress(qint64 value, qint64 total)
void DownloadItemWidget::updateFinished()
{
ui->progressBar->setValue(ui->progressBar->maximum());
+ QString tooltip = "<table>"
+ "<tr>"
+ "<th>Preview</th>"
+ "<th>Information</th>"
+ "</tr>"
+ "<tr>"
+ "<td>%1</td>"
+ "<td>"
+ "<p><b>URL</b>: %2</p>"
+ "<p><b>Path</b>: %3</p>"
+ "<p><b>MIME Type</b>: %4</p>"
+ "<p><b>Size</b>: %5</p>"
+ "</td>"
+ "</tr>"
+ "</table>";
+ if(item->mimeType().startsWith("image"))
+ tooltip = tooltip.arg("<img src='file://" + item->path() + "' alt='not available'>");
+ else
+ tooltip = tooltip.arg("not available");
+ tooltip = tooltip.arg(item->url().toString(), item->path(), item->mimeType(), sizeString(item->totalBytes()));
+ setToolTip(tooltip);
}
diff --git a/lib/downloads/widgets/downloaditemwidget.h b/lib/downloads/widgets/downloaditemwidget.h
index a772769..29a02d6 100644
--- a/lib/downloads/widgets/downloaditemwidget.h
+++ b/lib/downloads/widgets/downloaditemwidget.h
@@ -25,10 +25,6 @@ public:
explicit DownloadItemWidget(QWebEngineDownloadItem *item, QWidget *parent = 0);
~DownloadItemWidget() override;
- void showDetails();
- void hideDetails();
-
- QWebEngineDownloadItem *item() const;
QString sizeString(int size) const;
private slots:
@@ -38,7 +34,7 @@ private slots:
private:
Ui::DownloadItemForm *ui;
- QWebEngineDownloadItem *m_item;
+ QWebEngineDownloadItem *item = nullptr;
};
#endif // SMOLBOTE_DOWNLOADITEMFORM_H
diff --git a/lib/downloads/widgets/elidedlabel.cpp b/lib/downloads/widgets/elidedlabel.cpp
index f5db921..d898da0 100644
--- a/lib/downloads/widgets/elidedlabel.cpp
+++ b/lib/downloads/widgets/elidedlabel.cpp
@@ -1,58 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
/*
* This file is part of smolbote. It's copyrighted by the contributors recorded
* in the version control history of the file, available from its original
* location: https://neueland.iserlohn-fortress.net/smolbote.hg
*
- * SPDX-License-Identifier: BSD-3-Clause
+ * SPDX-License-Identifier: GPL-3.0
*/
#include "elidedlabel.h"
@@ -62,23 +13,26 @@
ElidedLabel::ElidedLabel(QWidget *parent)
: QLabel(parent)
- , elided(false)
- , content("elided_label")
{
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
}
-void ElidedLabel::setContent(const QString &newText)
+void ElidedLabel::setText(const QString &text)
{
- content = newText;
- setText(newText);
+ setToolTip(text);
+ content = text;
+ elideText();
}
-void ElidedLabel::resizeEvent(QResizeEvent *event)
+void ElidedLabel::elideText()
{
- QLabel::resizeEvent(event);
-
QFontMetrics font = this->fontMetrics();
QString elidedLine = font.elidedText(content, Qt::ElideRight, width());
- setText(elidedLine);
+ QLabel::setText(elidedLine);
+}
+
+void ElidedLabel::resizeEvent(QResizeEvent *event)
+{
+ QLabel::resizeEvent(event);
+ elideText();
}
diff --git a/lib/downloads/widgets/elidedlabel.h b/lib/downloads/widgets/elidedlabel.h
index 96d2609..3415720 100644
--- a/lib/downloads/widgets/elidedlabel.h
+++ b/lib/downloads/widgets/elidedlabel.h
@@ -1,62 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
/*
* This file is part of smolbote. It's copyrighted by the contributors recorded
* in the version control history of the file, available from its original
* location: https://neueland.iserlohn-fortress.net/smolbote.hg
*
- * SPDX-License-Identifier: BSD-3-Clause
+ * SPDX-License-Identifier: GPL-3.0
*/
-#ifndef ELIDEDLABEL_H
-#define ELIDEDLABEL_H
+#ifndef SMOLBOTE_ELIDEDLABEL_H
+#define SMOLBOTE_ELIDEDLABEL_H
#include <QLabel>
@@ -66,22 +17,18 @@ class ElidedLabel : public QLabel
public:
explicit ElidedLabel(QWidget *parent = nullptr);
- void setContent(const QString &text);
const QString &text() const
{
return content;
}
- bool isElided() const
- {
- return elided;
- }
+ void setText(const QString &text);
protected:
+ void elideText();
void resizeEvent(QResizeEvent *event) override;
private:
- bool elided;
QString content;
};
-#endif // ELIDEDLABEL_H
+#endif // SMOLBOTE_ELIDEDLABEL_H