added Drag & Drop support
This commit is contained in:
parent
740c0ee7d8
commit
fa4f40a1f8
|
@ -37,6 +37,7 @@
|
||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
|
#include <QMimeData>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
#include <QWebPage>
|
#include <QWebPage>
|
||||||
|
@ -129,7 +130,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
// other widgets
|
// other widgets
|
||||||
updateUiStatus();
|
updateUiStatus();
|
||||||
m_ui->abortButton->setVisible(false);
|
m_ui->abortButton->setVisible(false);
|
||||||
// connect signals and slots
|
// connect signals and slots, install event filter
|
||||||
// menu: application
|
// menu: application
|
||||||
connect(m_ui->actionSettings, &QAction::triggered, this, &MainWindow::showSettingsDlg);
|
connect(m_ui->actionSettings, &QAction::triggered, this, &MainWindow::showSettingsDlg);
|
||||||
connect(m_ui->actionQuit, &QAction::triggered, this, &MainWindow::close);
|
connect(m_ui->actionQuit, &QAction::triggered, this, &MainWindow::close);
|
||||||
|
@ -156,6 +157,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
connect(m_ui->selectNextCommandLinkButton, &QCommandLinkButton::clicked, this, &MainWindow::selectNextFile);
|
connect(m_ui->selectNextCommandLinkButton, &QCommandLinkButton::clicked, this, &MainWindow::selectNextFile);
|
||||||
connect(m_ui->abortButton, &QPushButton::clicked, [this] {m_abortClicked = true; m_ui->abortButton->setEnabled(false); });
|
connect(m_ui->abortButton, &QPushButton::clicked, [this] {m_abortClicked = true; m_ui->abortButton->setEnabled(false); });
|
||||||
connect(m_ui->tagSelectionComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), m_ui->stackedWidget, &QStackedWidget::setCurrentIndex);
|
connect(m_ui->tagSelectionComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), m_ui->stackedWidget, &QStackedWidget::setCurrentIndex);
|
||||||
|
// event filter
|
||||||
|
m_ui->fileNameLabel->installEventFilter(this);
|
||||||
|
m_ui->rightWidget->installEventFilter(this);
|
||||||
// apply settings
|
// apply settings
|
||||||
setCurrentDirectory(Settings::mainWindowCurrentFileBrowserDirectory());
|
setCurrentDirectory(Settings::mainWindowCurrentFileBrowserDirectory());
|
||||||
applySettingsFromDialog();
|
applySettingsFromDialog();
|
||||||
|
@ -195,6 +199,38 @@ void MainWindow::closeEvent(QCloseEvent *)
|
||||||
Settings::mainWindowCurrentFileBrowserDirectory() = currentDirectory();
|
Settings::mainWindowCurrentFileBrowserDirectory() = currentDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
|
||||||
|
{
|
||||||
|
if(obj == m_ui->rightWidget || obj == m_ui->fileNameLabel) {
|
||||||
|
switch(event->type()) {
|
||||||
|
case QEvent::DragEnter:
|
||||||
|
case QEvent::Drop:
|
||||||
|
if(QDropEvent *dropEvent = static_cast<QDropEvent *>(event)) {
|
||||||
|
QString data;
|
||||||
|
const QMimeData *mimeData = dropEvent->mimeData();
|
||||||
|
if(mimeData->hasUrls()) {
|
||||||
|
const QUrl url = mimeData->urls().front();
|
||||||
|
if(url.scheme() == QLatin1String("file")) {
|
||||||
|
data = url.path();
|
||||||
|
}
|
||||||
|
} else if(mimeData->hasText()) {
|
||||||
|
data = mimeData->text();
|
||||||
|
}
|
||||||
|
if(!data.isEmpty()) {
|
||||||
|
event->accept();
|
||||||
|
if(event->type() == QEvent::Drop) {
|
||||||
|
showFile(data, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QObject::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief This private slot is called when the entered text of m_ui->pathLineEdit which represents the current directory changes.
|
* \brief This private slot is called when the entered text of m_ui->pathLineEdit which represents the current directory changes.
|
||||||
* If the text is a valid path the current index of the m_ui->filesTreeView is updated to show the path. This invokes the file
|
* If the text is a valid path the current index of the m_ui->filesTreeView is updated to show the path. This invokes the file
|
||||||
|
|
|
@ -54,6 +54,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeEvent(QCloseEvent *);
|
virtual void closeEvent(QCloseEvent *);
|
||||||
|
virtual bool eventFilter(QObject *obj, QEvent *event);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
// file selection
|
// file selection
|
||||||
|
|
|
@ -79,6 +79,9 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="rightWidget" native="true">
|
<widget class="QWidget" name="rightWidget" native="true">
|
||||||
|
<property name="acceptDrops">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>3</number>
|
<number>3</number>
|
||||||
|
@ -91,6 +94,9 @@
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="fileNameLabel">
|
<widget class="QLabel" name="fileNameLabel">
|
||||||
|
<property name="acceptDrops">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>No file selected</string>
|
<string>No file selected</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -104,7 +110,11 @@
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWebView" name="infoWebView"/>
|
<widget class="QWebView" name="infoWebView">
|
||||||
|
<property name="acceptDrops">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<layout class="QVBoxLayout" name="tagEditVerticalLayout">
|
<layout class="QVBoxLayout" name="tagEditVerticalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -314,7 +324,7 @@ the file reverting all unsaved changings.</string>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1225</width>
|
<width>1225</width>
|
||||||
<height>23</height>
|
<height>29</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
|
Loading…
Reference in New Issue