diff options
Diffstat (limited to 'src/panels/information')
| -rw-r--r-- | src/panels/information/informationpanel.cpp | 60 | ||||
| -rw-r--r-- | src/panels/information/informationpanelcontent.cpp | 43 | ||||
| -rw-r--r-- | src/panels/information/mediawidget.cpp | 16 | ||||
| -rw-r--r-- | src/panels/information/pixmapviewer.cpp | 7 |
4 files changed, 49 insertions, 77 deletions
diff --git a/src/panels/information/informationpanel.cpp b/src/panels/information/informationpanel.cpp index 03e048ae7..5f613c520 100644 --- a/src/panels/information/informationpanel.cpp +++ b/src/panels/information/informationpanel.cpp @@ -49,6 +49,7 @@ InformationPanel::~InformationPanel() void InformationPanel::setSelection(const KFileItemList &selection) { m_selection = selection; + m_hoveredItem = KFileItem(); // Selection supersedes any stale hover if (!isVisible()) { return; @@ -83,14 +84,12 @@ void InformationPanel::requestDelayedItemInfo(const KFileItem &item) return; } - if (item.isNull()) { - m_hoveredItem = KFileItem(); - return; - } - cancelRequest(); - - m_isSelectionActive = false; + if (!item.isNull()) { + m_isSelectionActive = false; + } else { + m_isSelectionActive = !m_selection.isEmpty(); + } m_hoveredItem = item; m_infoTimer->start(); @@ -229,35 +228,36 @@ void InformationPanel::showItemInfo() cancelRequest(); //qDebug() << "showItemInfo" << m_fileItem; - if (m_hoveredItem.isNull() && (m_selection.count() > 1)) { + bool canShowHoverItem = !m_isSelectionActive && !m_hoveredItem.isNull() && InformationPanelSettings::showHovered(); + if (m_selection.count() > 1 && !canShowHoverItem) { // The information for a selection of items should be shown m_content->showItems(m_selection); - } else { - // The information for exactly one item should be shown - KFileItem item; + return; + } - if (!m_isSelectionActive && !m_hoveredItem.isNull() && InformationPanelSettings::showHovered()) { - item = m_hoveredItem; - } else if (m_isSelectionActive && !m_selection.isEmpty()) { - Q_ASSERT(m_selection.count() == 1); - item = m_selection.first(); - } + // The information for exactly one item should be shown + KFileItem item; + if (canShowHoverItem) { + item = m_hoveredItem; + } else if (!m_selection.isEmpty()) { + Q_ASSERT(m_selection.count() == 1); + item = m_selection.first(); + } - if (!item.isNull()) { - m_shownUrl = item.url(); - m_content->showItem(item); - return; - } + if (!item.isNull()) { + m_shownUrl = item.url(); + m_content->showItem(item); + return; + } - // No item is hovered and no selection has been done: provide - // an item for the currently shown directory. - m_shownUrl = url(); - m_folderStatJob = KIO::stat(m_shownUrl, KIO::StatJob::SourceSide, KIO::StatDefaultDetails | KIO::StatRecursiveSize, KIO::HideProgressInfo); - if (m_folderStatJob->uiDelegate()) { - KJobWidgets::setWindow(m_folderStatJob, this); - } - connect(m_folderStatJob, &KIO::Job::result, this, &InformationPanel::slotFolderStatFinished); + // No item is hovered and no selection has been done: provide + // an item for the currently shown directory. + m_shownUrl = url(); + m_folderStatJob = KIO::stat(m_shownUrl, KIO::StatJob::SourceSide, KIO::StatDefaultDetails | KIO::StatRecursiveSize, KIO::HideProgressInfo); + if (m_folderStatJob->uiDelegate()) { + KJobWidgets::setWindow(m_folderStatJob, this); } + connect(m_folderStatJob, &KIO::Job::result, this, &InformationPanel::slotFolderStatFinished); } void InformationPanel::slotFolderStatFinished(KJob *job) diff --git a/src/panels/information/informationpanelcontent.cpp b/src/panels/information/informationpanelcontent.cpp index 285ce3ae9..cdd98f54c 100644 --- a/src/panels/information/informationpanelcontent.cpp +++ b/src/panels/information/informationpanelcontent.cpp @@ -16,7 +16,6 @@ #include <KSeparator> #include <KSharedConfig> #include <KStringHandler> -#include <QPainterPath> #include <QIcon> #include <QStyle> @@ -27,9 +26,7 @@ #include <QDialogButtonBox> #include <QGesture> #include <QLabel> -#include <QLinearGradient> #include <QPainter> -#include <QPolygon> #include <QScrollArea> #include <QScroller> #include <QTextLayout> @@ -40,9 +37,6 @@ #include "mediawidget.h" #include "pixmapviewer.h" -const int PLAY_ARROW_SIZE = 24; -const int PLAY_ARROW_BORDER_SIZE = 2; - InformationPanelContent::InformationPanelContent(QWidget *parent) : QWidget(parent) , m_item() @@ -390,43 +384,6 @@ void InformationPanelContent::showPreview(const KFileItem &item, const QPixmap & p.setDevicePixelRatio(devicePixelRatioF()); } - if (m_isVideo) { - // adds a play arrow overlay - - auto maxDim = qMax(p.width(), p.height()); - auto arrowSize = qMax(PLAY_ARROW_SIZE, maxDim / 8); - - // compute relative pixel positions - const int zeroX = static_cast<int>((p.width() / 2 - arrowSize / 2) / p.devicePixelRatio()); - const int zeroY = static_cast<int>((p.height() / 2 - arrowSize / 2) / p.devicePixelRatio()); - - QPolygon arrow; - arrow << QPoint(zeroX, zeroY); - arrow << QPoint(zeroX, zeroY + arrowSize); - arrow << QPoint(zeroX + arrowSize, zeroY + arrowSize / 2); - - QPainterPath path; - path.addPolygon(arrow); - - QLinearGradient gradient(QPointF(zeroX, zeroY + arrowSize / 2), QPointF(zeroX + arrowSize, zeroY + arrowSize / 2)); - - QColor whiteColor = Qt::white; - QColor blackColor = Qt::black; - gradient.setColorAt(0, whiteColor); - gradient.setColorAt(1, blackColor); - - QBrush brush(gradient); - - QPainter painter(&p); - - QPen pen(blackColor, PLAY_ARROW_BORDER_SIZE, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); - painter.setPen(pen); - - painter.setRenderHint(QPainter::Antialiasing); - painter.drawPolygon(arrow); - painter.fillPath(path, brush); - } - m_preview->setPixmap(p); } diff --git a/src/panels/information/mediawidget.cpp b/src/panels/information/mediawidget.cpp index 20366445a..b514ab0d3 100644 --- a/src/panels/information/mediawidget.cpp +++ b/src/panels/information/mediawidget.cpp @@ -50,6 +50,7 @@ public: SeekSlider(Qt::Orientation orientation, QWidget *parent = nullptr) : QSlider(orientation, parent) { + grabGesture(Qt::TapAndHoldGesture); } protected: @@ -132,6 +133,15 @@ protected: QSlider::keyPressEvent(event); } } + + bool event(QEvent *event) override + { + if (event->type() == QEvent::Gesture) { + event->ignore(); + return true; + } + return QSlider::event(event); + } }; MediaWidget::MediaWidget(QWidget *parent) @@ -143,6 +153,8 @@ MediaWidget::MediaWidget(QWidget *parent) , m_player(nullptr) , m_seekSlider(nullptr) , m_videoWidget(nullptr) + , m_autoPlay(false) + , m_isVideo(false) { } @@ -292,8 +304,8 @@ void MediaWidget::initPlayer() { if (!m_player) { initLayout(); - m_player = new QMediaPlayer; - m_player->setAudioOutput(new QAudioOutput); + m_player = new QMediaPlayer(this); + m_player->setAudioOutput(new QAudioOutput(m_player)); m_videoWidget = new EmbeddedVideoPlayer(this); m_videoWidget->setCursor(Qt::PointingHandCursor); diff --git a/src/panels/information/pixmapviewer.cpp b/src/panels/information/pixmapviewer.cpp index 9ac9bd253..4f3f9e82f 100644 --- a/src/panels/information/pixmapviewer.cpp +++ b/src/panels/information/pixmapviewer.cpp @@ -54,6 +54,7 @@ void PixmapViewer::setPixmap(const QPixmap &pixmap) void PixmapViewer::setSizeHint(const QSize &size) { if (m_animatedImage && size != m_sizeHint) { + m_animatedImage->setScaledSize(QSize()); m_animatedImage->stop(); } @@ -104,10 +105,12 @@ void PixmapViewer::updateAnimatedImageFrame() Q_ASSERT(m_animatedImage); m_pixmap = m_animatedImage->currentPixmap(); - if (m_pixmap.width() > m_sizeHint.width() || m_pixmap.height() > m_sizeHint.height()) { - m_pixmap = m_pixmap.scaled(m_sizeHint, Qt::KeepAspectRatio); + const auto physicalSize = m_sizeHint * devicePixelRatio(); + if (m_pixmap.width() > physicalSize.width() || m_pixmap.height() > physicalSize.height()) { + m_pixmap = m_pixmap.scaled(physicalSize, Qt::KeepAspectRatio); m_animatedImage->setScaledSize(m_pixmap.size()); } + m_pixmap.setDevicePixelRatio(devicePixelRatio()); update(); } |
