- feature: drop files to devcpp to open them

This commit is contained in:
royqh1979 2021-09-05 21:17:33 +08:00
parent ca9f144444
commit a1fe8c38b1
2 changed files with 25 additions and 0 deletions

View File

@ -13,6 +13,7 @@
#include <QCloseEvent>
#include <QComboBox>
#include <QDesktopServices>
#include <QDragEnterEvent>
#include <QFileDialog>
#include <QInputDialog>
#include <QLabel>
@ -59,6 +60,7 @@ MainWindow::MainWindow(QWidget *parent)
ui->EditorTabsRight,
ui->splitterEditorPanel,
ui->EditorPanel);
setAcceptDrops(true);
setupActions();
ui->EditorTabsRight->setVisible(false);
@ -1514,6 +1516,24 @@ void MainWindow::showEvent(QShowEvent *event)
}
}
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls()){
event->acceptProposedAction();
}
}
void MainWindow::dropEvent(QDropEvent *event)
{
if (event->mimeData()->hasUrls()) {
foreach(const QUrl& url, event->mimeData()->urls()){
if (!url.isLocalFile())
continue;
openFile(url.toLocalFile());
}
}
}
void MainWindow::on_actionSave_triggered()
{
Editor * editor = mEditorList->getEditor();

View File

@ -354,6 +354,11 @@ private:
protected:
void closeEvent(QCloseEvent *event) override;
void showEvent(QShowEvent* event) override;
// QWidget interface
protected:
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
};
extern MainWindow* pMainWindow;