diff options
Diffstat (limited to 'src/panels')
| -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/panel.cpp | 9 | ||||
| -rw-r--r-- | src/panels/panel.h | 6 | ||||
| -rw-r--r-- | src/panels/terminal/terminalpanel.cpp | 11 | ||||
| -rw-r--r-- | src/panels/terminal/terminalpanel.h | 5 |
7 files changed, 71 insertions, 79 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/panel.cpp b/src/panels/panel.cpp index e8250c62b..94f80f7e7 100644 --- a/src/panels/panel.cpp +++ b/src/panels/panel.cpp @@ -54,6 +54,15 @@ void Panel::setUrl(const QUrl &url) } } +void Panel::refreshUrl(const QUrl &url) +{ + const QUrl oldUrl = m_url; + m_url = url; + if (!urlChanged()) { + m_url = oldUrl; + } +} + void Panel::readSettings() { } diff --git a/src/panels/panel.h b/src/panels/panel.h index 5f1fabb4a..23136a4b9 100644 --- a/src/panels/panel.h +++ b/src/panels/panel.h @@ -46,6 +46,12 @@ public Q_SLOTS: void setUrl(const QUrl &url); /** + * This is invoked whenever the folder being displayed in the + * active Dolphin view is refreshed. + */ + void refreshUrl(const QUrl &url); + + /** * Refreshes the view to get synchronized with the settings. */ virtual void readSettings(); diff --git a/src/panels/terminal/terminalpanel.cpp b/src/panels/terminal/terminalpanel.cpp index a357b31ac..55773345c 100644 --- a/src/panels/terminal/terminalpanel.cpp +++ b/src/panels/terminal/terminalpanel.cpp @@ -50,9 +50,10 @@ TerminalPanel::TerminalPanel(QWidget *parent) TerminalPanel::~TerminalPanel() { if (m_konsolePart) { - // Avoid when QObject cleanup, which comes after our destructor, deletes the konsolePart - // and subsequently calls back into our slot when the destructor has already run. disconnect(m_konsolePart, &KParts::ReadOnlyPart::destroyed, this, &TerminalPanel::terminalExited); + // Delete before QObject child cleanup, while m_konsolePartClientBuilder is still alive. + delete m_konsolePart; + m_konsolePart = nullptr; } } @@ -145,9 +146,10 @@ bool TerminalPanel::urlChanged() return false; } - const bool sendInput = m_terminal && !hasProgramRunning() && isVisible() && m_syncUrl; + const bool sendInput = m_terminal && !hasProgramRunning() && isVisible() && m_syncUrl && url() != m_url; if (sendInput) { changeDir(url()); + m_url = url(); } return true; @@ -178,7 +180,8 @@ void TerminalPanel::showEvent(QShowEvent *event) // namely the one of the single inner terminal and not the outer KonsolePart if (!m_konsolePart->factory() && m_terminalWidget) { if (!m_konsolePart->clientBuilder()) { - m_konsolePart->setClientBuilder(new KXMLGUIBuilder(m_terminalWidget)); + m_konsolePartClientBuilder = std::make_unique<KXMLGUIBuilder>(m_terminalWidget); + m_konsolePart->setClientBuilder(m_konsolePartClientBuilder.get()); } auto factory = new KXMLGUIFactory(m_konsolePart->clientBuilder(), this); diff --git a/src/panels/terminal/terminalpanel.h b/src/panels/terminal/terminalpanel.h index 0aaf921c0..d6ed4b981 100644 --- a/src/panels/terminal/terminalpanel.h +++ b/src/panels/terminal/terminalpanel.h @@ -12,6 +12,9 @@ #include <QQueue> +#include <memory> + +class KXMLGUIBuilder; class TerminalInterface; class KActionCollection; class KMessageWidget; @@ -86,6 +89,7 @@ private: private: bool m_clearTerminal; bool m_syncUrl; + QUrl m_url; KIO::StatJob *m_mostLocalUrlJob; QVBoxLayout *m_layout; @@ -93,6 +97,7 @@ private: QWidget *m_terminalWidget; KMessageWidget *m_konsolePartMissingMessage; KParts::ReadOnlyPart *m_konsolePart; + std::unique_ptr<KXMLGUIBuilder> m_konsolePartClientBuilder; QString m_konsolePartCurrentDirectory; QQueue<QString> m_sendCdToTerminalHistory; org::kde::KIOFuse::VFS m_kiofuseInterface; |
