mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09:52 +08:00
support drag and drop into edit area to open external files
This commit is contained in:
parent
d0bcd7a2c6
commit
8a6ce16db5
@ -125,9 +125,8 @@ int main(int argc, char *argv[])
|
|||||||
// Need to use absolute path here since VNote may be launched
|
// Need to use absolute path here since VNote may be launched
|
||||||
// in different working directory.
|
// in different working directory.
|
||||||
filePath = QDir::cleanPath(fi.absoluteFilePath());
|
filePath = QDir::cleanPath(fi.absoluteFilePath());
|
||||||
|
filePaths.append(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
filePaths.append(filePath);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,9 +597,6 @@ int VEditArea::focusNextWindow(int p_biaIdx)
|
|||||||
|
|
||||||
void VEditArea::moveCurrentTabOneSplit(bool p_right)
|
void VEditArea::moveCurrentTabOneSplit(bool p_right)
|
||||||
{
|
{
|
||||||
if (splitter->count() < 2) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
getWindow(curWindowIndex)->moveCurrentTabOneSplit(p_right);
|
getWindow(curWindowIndex)->moveCurrentTabOneSplit(p_right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ VEditWindow::VEditWindow(VNote *vnote, VEditArea *editArea, QWidget *parent)
|
|||||||
: QTabWidget(parent), vnote(vnote), m_editArea(editArea),
|
: QTabWidget(parent), vnote(vnote), m_editArea(editArea),
|
||||||
m_curTabWidget(NULL), m_lastTabWidget(NULL)
|
m_curTabWidget(NULL), m_lastTabWidget(NULL)
|
||||||
{
|
{
|
||||||
|
setAcceptDrops(true);
|
||||||
initTabActions();
|
initTabActions();
|
||||||
setupCornerWidget();
|
setupCornerWidget();
|
||||||
|
|
||||||
@ -808,6 +809,7 @@ void VEditWindow::moveCurrentTabOneSplit(bool p_right)
|
|||||||
if (idx == -1) {
|
if (idx == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
moveTabOneSplit(idx, p_right);
|
moveTabOneSplit(idx, p_right);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -918,3 +920,37 @@ VEditTab* VEditWindow::getTab(int tabIndex) const
|
|||||||
return dynamic_cast<VEditTab *>(widget(tabIndex));
|
return dynamic_cast<VEditTab *>(widget(tabIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VEditWindow::dragEnterEvent(QDragEnterEvent *p_event)
|
||||||
|
{
|
||||||
|
if (p_event->mimeData()->hasFormat("text/uri-list")) {
|
||||||
|
p_event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void VEditWindow::dropEvent(QDropEvent *p_event)
|
||||||
|
{
|
||||||
|
const QMimeData *mime = p_event->mimeData();
|
||||||
|
if (mime->hasFormat("text/uri-list") && mime->hasUrls()) {
|
||||||
|
// Open external files in this edit window.
|
||||||
|
QStringList files;
|
||||||
|
QList<QUrl> urls = mime->urls();
|
||||||
|
for (int i = 0; i < urls.size(); ++i) {
|
||||||
|
QString file;
|
||||||
|
if (urls[i].isLocalFile()) {
|
||||||
|
file = urls[i].toLocalFile();
|
||||||
|
QFileInfo fi(file);
|
||||||
|
if (fi.exists() && fi.isFile()) {
|
||||||
|
file = QDir::cleanPath(fi.absoluteFilePath());
|
||||||
|
files.append(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!files.isEmpty()) {
|
||||||
|
focusWindow();
|
||||||
|
g_vnote->getMainWindow()->openExternalFiles(files);
|
||||||
|
}
|
||||||
|
|
||||||
|
p_event->acceptProposedAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -63,6 +63,12 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
// To accept specific drop.
|
||||||
|
void dragEnterEvent(QDragEnterEvent *p_event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
// Drop the data.
|
||||||
|
void dropEvent(QDropEvent *p_event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
// Status of current VEditTab has update.
|
// Status of current VEditTab has update.
|
||||||
void tabStatusUpdated(const VEditTabInfo &p_info);
|
void tabStatusUpdated(const VEditTabInfo &p_info);
|
||||||
|
@ -19,6 +19,7 @@ static const QString c_ClipboardPropertyMark = "CopiedImageURLAltered";
|
|||||||
VWebView::VWebView(VFile *p_file, QWidget *p_parent)
|
VWebView::VWebView(VFile *p_file, QWidget *p_parent)
|
||||||
: QWebEngineView(p_parent), m_file(p_file), m_actionHooked(false)
|
: QWebEngineView(p_parent), m_file(p_file), m_actionHooked(false)
|
||||||
{
|
{
|
||||||
|
setAcceptDrops(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VWebView::contextMenuEvent(QContextMenuEvent *p_event)
|
void VWebView::contextMenuEvent(QContextMenuEvent *p_event)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user