when loading file by drag and drop then create the objects in the active document

if no document exists then use i18n to translate the document name
This commit is contained in:
wmayer
2018-09-15 19:05:08 +02:00
parent d1f1230ef5
commit f809a50be8
2 changed files with 15 additions and 7 deletions

View File

@@ -554,14 +554,22 @@ void Application::importFrom(const char* FileName, const char* DocName, const ch
activeDocument()->setModified(false);
}
else {
Command::doCommand(Command::App, "%s.insert(u\"%s\",\"%s\")"
, Module, unicodepath.c_str(), DocName);
if (DocName) {
Command::doCommand(Command::App, "%s.insert(u\"%s\",\"%s\")"
, Module, unicodepath.c_str(), DocName);
}
else {
Command::doCommand(Command::App, "%s.insert(u\"%s\")"
, Module, unicodepath.c_str());
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/View");
if (hGrp->GetBool("AutoFitToView", true))
Command::doCommand(Command::Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
if (getDocument(DocName))
getDocument(DocName)->setModified(true);
Gui::Document* doc = activeDocument();
if (DocName) doc = getDocument(DocName);
if (doc)
doc->setModified(true);
}
// the original file name is required

View File

@@ -1287,8 +1287,8 @@ void MainWindow::dropEvent (QDropEvent* e)
{
const QMimeData* data = e->mimeData();
if (data->hasUrls()) {
// pass no document to let create a new one if needed
loadUrls(0, data->urls());
// load the files into the active document if there is one, otherwise let create one
loadUrls(App::GetApplication().getActiveDocument(), data->urls());
}
else {
QMainWindow::dropEvent(e);
@@ -1538,7 +1538,7 @@ void MainWindow::loadUrls(App::Document* doc, const QList<QUrl>& url)
}
}
const char *docName = doc ? doc->getName() : "Unnamed";
QByteArray docName = doc ? doc->getName() : qApp->translate("StdCmdNew","Unnamed").toUtf8();
SelectModule::Dict dict = SelectModule::importHandler(files);
// load the files with the associated modules
for (SelectModule::Dict::iterator it = dict.begin(); it != dict.end(); ++it) {