Commit cbf47d1b authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Fix KTabWidget porting issue

Restore drop on tabs

Reviewed by Albert
parent b6d3854e
......@@ -96,10 +96,12 @@ Shell::Shell( const QString &serializedOptions )
m_tabWidget->tabBar()->hide();
m_tabWidget->setDocumentMode( true );
m_tabWidget->setMovable( true );
m_tabWidget->setAcceptDrops(true);
m_tabWidget->installEventFilter(this);
connect( m_tabWidget, &QTabWidget::currentChanged, this, &Shell::setActiveTab );
connect( m_tabWidget, &QTabWidget::tabCloseRequested, this, &Shell::closeTab );
connect( m_tabWidget, SIGNAL(testCanDecode(const QDragMoveEvent*,bool&)), SLOT(testTabDrop(const QDragMoveEvent*,bool&)) ); // kf5 FIXME DnD
connect( m_tabWidget, SIGNAL(receivedDropEvent(QDropEvent*)), SLOT(handleTabDrop(QDropEvent*)) ); // kf5 FIXME DnD
connect( m_tabWidget->tabBar(), &QTabBar::tabMoved, this, &Shell::moveTabData );
setCentralWidget( m_tabWidget );
......@@ -138,6 +140,25 @@ Shell::Shell( const QString &serializedOptions )
}
}
bool Shell::eventFilter(QObject *obj, QEvent *event)
{
QDragMoveEvent* dmEvent = dynamic_cast<QDragMoveEvent*>(event);
if (dmEvent) {
bool accept = dmEvent->mimeData()->hasUrls();
event->setAccepted(accept);
return accept;
}
QDropEvent* dEvent = dynamic_cast<QDropEvent*>(event);
if (dEvent) {
const QList<QUrl> list = KUrlMimeData::urlsFromMimeData(dEvent->mimeData());
handleDroppedUrls(list);
dEvent->setAccepted(true);
return true;
}
return false;
}
bool Shell::isValid() const
{
return m_isValid;
......@@ -652,17 +673,6 @@ void Shell::handleDroppedUrls( const QList<QUrl>& urls )
}
}
void Shell::testTabDrop( const QDragMoveEvent* event, bool& accept )
{
accept = event->mimeData()->hasUrls();
}
void Shell::handleTabDrop( QDropEvent* event )
{
const QList<QUrl> list = KUrlMimeData::urlsFromMimeData( event->mimeData() );
handleDroppedUrls( list );
}
void Shell::moveTabData( int from, int to )
{
m_tabs.move( from, to );
......
......@@ -119,8 +119,6 @@ private slots:
void closeTab( int tab );
void activateNextTab();
void activatePrevTab();
void testTabDrop( const QDragMoveEvent* event, bool& accept );
void handleTabDrop( QDropEvent* event );
void moveTabData( int from, int to );
void slotFitWindowToPage( const QSize& pageViewSize, const QSize& pageSize );
......@@ -138,6 +136,8 @@ private:
int findTabIndex( QObject* sender );
private:
bool eventFilter(QObject *obj, QEvent *event) override;
KPluginFactory* m_partFactory;
KRecentFilesAction* m_recent;
QStringList m_fileformats;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment