mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Dropping a file onto a main window now opens that file.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@1861 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -29,6 +29,8 @@ QETMainWindow::QETMainWindow(QWidget *widget, Qt::WindowFlags flags) :
|
||||
{
|
||||
initCommonActions();
|
||||
initCommonMenus();
|
||||
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,3 +164,31 @@ bool QETMainWindow::event(QEvent *e) {
|
||||
*/
|
||||
void QETMainWindow::firstActivation(QEvent *) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Accept or refuse drag'n drop events depending on the dropped mime type;
|
||||
especially, accepts only URLs to local files that we could open.
|
||||
@param e le QDragEnterEvent correspondant au drag'n drop tente
|
||||
*/
|
||||
void QETMainWindow::dragEnterEvent(QDragEnterEvent *e) {
|
||||
if (e -> mimeData() -> hasUrls()) {
|
||||
if (QETApp::handledFiles(e -> mimeData() -> urls()).count()) {
|
||||
e -> acceptProposedAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Handle drops accepted on main windows; more specifically, open dropped files
|
||||
as long as they are handled by QElectrotech.
|
||||
@param e the QDropEvent describing the current drag'n drop
|
||||
*/
|
||||
void QETMainWindow::dropEvent(QDropEvent *e) {
|
||||
if (e -> mimeData() -> hasUrls()) {
|
||||
QStringList filepaths = QETApp::handledFiles(e -> mimeData() -> urls());
|
||||
if (filepaths.count()) {
|
||||
QETApp::instance() -> openFiles(QETArguments(filepaths));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user