forked from qt-creator/qt-creator
Fix that files could not be dropped onto welcome screen
Needs to be implemented in Qt Quick itself nowadays. Task-number: QTCREATORBUG-14194 Change-Id: I0456dc5d86c03672d8b6b8f9c45799851db1b059 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@theqtcompany.com>
This commit is contained in:
@@ -33,6 +33,16 @@ Item {
|
|||||||
|
|
||||||
property int screenDependHeightDistance: Math.min(50, Math.max(16, height / 30))
|
property int screenDependHeightDistance: Math.min(50, Math.max(16, height / 30))
|
||||||
|
|
||||||
|
DropArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
keys: ["text/uri-list"]
|
||||||
|
onDropped: {
|
||||||
|
if ((drop.supportedActions & Qt.CopyAction != 0)
|
||||||
|
&& welcomeMode.openDroppedFiles(drop.urls))
|
||||||
|
drop.accept(Qt.CopyAction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SideBar {
|
SideBar {
|
||||||
id: sideBar
|
id: sideBar
|
||||||
model: pagesModel
|
model: pagesModel
|
||||||
|
@@ -52,6 +52,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QQmlPropertyMap>
|
#include <QQmlPropertyMap>
|
||||||
#include <QQuickImageProvider>
|
#include <QQuickImageProvider>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include <QtQuickWidgets/QQuickWidget>
|
#include <QtQuickWidgets/QQuickWidget>
|
||||||
#include <QtQml/QQmlContext>
|
#include <QtQml/QQmlContext>
|
||||||
@@ -135,6 +136,8 @@ public:
|
|||||||
QStringList recentProjectsShortcuts() const { return m_recentProjectsShortcuts; }
|
QStringList recentProjectsShortcuts() const { return m_recentProjectsShortcuts; }
|
||||||
QStringList sessionsShortcuts() const { return m_sessionsShortcuts; }
|
QStringList sessionsShortcuts() const { return m_sessionsShortcuts; }
|
||||||
|
|
||||||
|
Q_INVOKABLE bool openDroppedFiles(const QList<QUrl> &urls);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setActivePlugin(int pos)
|
void setActivePlugin(int pos)
|
||||||
{
|
{
|
||||||
@@ -307,6 +310,18 @@ void WelcomeMode::initPlugins()
|
|||||||
m_welcomePage->setSource(QUrl::fromLocalFile(path));
|
m_welcomePage->setSource(QUrl::fromLocalFile(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WelcomeMode::openDroppedFiles(const QList<QUrl> &urls)
|
||||||
|
{
|
||||||
|
const QList<QUrl> localUrls = Utils::filtered(urls, &QUrl::isLocalFile);
|
||||||
|
if (!localUrls.isEmpty()) {
|
||||||
|
QTimer::singleShot(0, [localUrls]() {
|
||||||
|
ICore::openFiles(Utils::transform(localUrls, &QUrl::toLocalFile), ICore::SwitchMode);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void WelcomeMode::welcomePluginAdded(QObject *obj)
|
void WelcomeMode::welcomePluginAdded(QObject *obj)
|
||||||
{
|
{
|
||||||
IWelcomePage *page = qobject_cast<IWelcomePage*>(obj);
|
IWelcomePage *page = qobject_cast<IWelcomePage*>(obj);
|
||||||
|
Reference in New Issue
Block a user