History

Merge pull request #84 from Atlante45/feat/atp

Replace old drag&drop with new UI

Stephen Birarda committed 10 years ago

Commit 57ea51d2 parents 2e9ee4f 6bd7afc6 files · +76 −118Browse files

Showing the changes to interface/src/Application.cpp (1 of 6 files). Show all

Unified · Split

interface/src/Application.cpp+9−85
@@ -158,7 +158,6 @@ · 157 unmodified lines
158158 #include "Stars.h"
159159 #include "ui/AddressBarDialog.h"
160160 #include "ui/AvatarInputs.h"
161−#include "ui/AssetUploadDialogFactory.h"
162161 #include "ui/DialogsManager.h"
163162 #include "ui/LoginDialog.h"
164163 #include "ui/overlays/Cube3DOverlay.h"
@@ -3978,9 +3977,6 @@ void Application::nodeAdded(SharedNodePointer node) { · 3813 unmodified lines
39783977 if (node->getType() == NodeType::AvatarMixer) {
39793978 // new avatar mixer, send off our identity packet right away
39803979 getMyAvatar()->sendIdentityPacket();
3981− } else if (node->getType() == NodeType::AssetServer) {
3982− // the addition of an asset-server always re-enables the upload to asset server menu option
3983− Menu::getInstance()->getActionForOption(MenuOption::UploadAsset)->setEnabled(true);
39843980 }
39853981 }
39863982
@@ -4030,10 +4026,6 @@ void Application::nodeKilled(SharedNodePointer node) { · 43 unmodified lines
40304026 } else if (node->getType() == NodeType::AvatarMixer) {
40314027 // our avatar mixer has gone away - clear the hash of avatars
40324028 DependencyManager::get<AvatarManager>()->clearOtherAvatars();
4033− } else if (node->getType() == NodeType::AssetServer
4034− && !DependencyManager::get<NodeList>()->soloNodeOfType(NodeType::AssetServer)) {
4035− // this was our last asset server - disable the menu option to upload an asset
4036− Menu::getInstance()->getActionForOption(MenuOption::UploadAsset)->setEnabled(false);
40374029 }
40384030 }
40394031 void Application::trackIncomingOctreePacket(ReceivedMessage& message, SharedNodePointer sendingNode, bool wasStatsPacket) {
@@ -4259,7 +4251,10 @@ bool Application::acceptURL(const QString& urlString, bool defaultUpload) { · 219 unmodified lines
42594251 }
42604252 }
42614253
4262− return defaultUpload && askToUploadAsset(urlString);
4254+ if (defaultUpload) {
4255+ toggleAssetServerWidget(urlString);
4256+ }
4257+ return defaultUpload;
42634258 }
42644259
42654260 void Application::setSessionUUID(const QUuid& sessionUUID) {
@@ -4321,80 +4316,6 @@ bool Application::askToLoadScript(const QString& scriptFilenameOrURL) { · 55 unmodified lines
43214316 return true;
43224317 }
43234318
4324−bool Application::askToUploadAsset(const QString& filename) {
4325− if (!DependencyManager::get<NodeList>()->getThisNodeCanRez()) {
4326− OffscreenUi::warning(_window, "Failed Upload",
4327− QString("You don't have upload rights on that domain.\n\n"));
4328− return false;
4329− }
4330−
4331− QUrl url { filename };
4332− if (auto upload = DependencyManager::get<AssetClient>()->createUpload(url.toLocalFile())) {
4333−
4334− QMessageBox messageBox;
4335− messageBox.setWindowTitle("Asset upload");
4336− messageBox.setText("You are about to upload the following file to the asset server:\n" +
4337− url.toDisplayString());
4338− messageBox.setInformativeText("Do you want to continue?");
4339− messageBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
4340− messageBox.setDefaultButton(QMessageBox::Ok);
4341−
4342− // Option to drop model in world for models
4343− if (filename.endsWith(FBX_EXTENSION, Qt::CaseInsensitive) || filename.endsWith(OBJ_EXTENSION, Qt::CaseInsensitive)) {
4344− auto checkBox = new QCheckBox(&messageBox);
4345− checkBox->setText("Add to scene");
4346− messageBox.setCheckBox(checkBox);
4347− }
4348−
4349− if (messageBox.exec() != QMessageBox::Ok) {
4350− upload->deleteLater();
4351− return false;
4352− }
4353−
4354− // connect to the finished signal so we know when the AssetUpload is done
4355− if (messageBox.checkBox() && (messageBox.checkBox()->checkState() == Qt::Checked)) {
4356− // Custom behavior for models
4357− QObject::connect(upload, &AssetUpload::finished, this, &Application::modelUploadFinished);
4358− } else {
4359− QObject::connect(upload, &AssetUpload::finished,
4360− &AssetUploadDialogFactory::getInstance(),
4361− &AssetUploadDialogFactory::handleUploadFinished);
4362− }
4363−
4364− // start the upload now
4365− upload->start();
4366− return true;
4367− }
4368−
4369− // display a message box with the error
4370− OffscreenUi::warning(_window, "Failed Upload", QString("Failed to upload %1.\n\n").arg(filename));
4371− return false;
4372−}
4373−
4374−void Application::modelUploadFinished(AssetUpload* upload, const QString& hash) {
4375− auto fileInfo = QFileInfo(upload->getFilename());
4376− auto filename = fileInfo.fileName();
4377−
4378− if ((upload->getError() == AssetUpload::NoError) &&
4379− (filename.endsWith(FBX_EXTENSION, Qt::CaseInsensitive) ||
4380− filename.endsWith(OBJ_EXTENSION, Qt::CaseInsensitive))) {
4381−
4382− auto entities = DependencyManager::get<EntityScriptingInterface>();
4383−
4384− EntityItemProperties properties;
4385− properties.setType(EntityTypes::Model);
4386− properties.setModelURL(QString("%1:%2.%3").arg(URL_SCHEME_ATP).arg(hash).arg(fileInfo.completeSuffix()));
4387− properties.setPosition(_myCamera.getPosition() + _myCamera.getOrientation() * Vectors::FRONT * 2.0f);
4388− properties.setName(QUrl(upload->getFilename()).fileName());
4389−
4390− entities->addEntity(properties);
4391−
4392− upload->deleteLater();
4393− } else {
4394− AssetUploadDialogFactory::getInstance().handleUploadFinished(upload, hash);
4395− }
4396−}
4397−
43984319 bool Application::askToWearAvatarAttachmentUrl(const QString& url) {
43994320
44004321 QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
@@ -4494,9 +4415,12 @@ void Application::toggleRunningScriptsWidget() { · 93 unmodified lines
44944415 //}
44954416 }
44964417
4497−void Application::toggleAssetServerWidget() {
4418+void Application::toggleAssetServerWidget(QString filePath) {
44984419 static const QUrl url("AssetServer.qml");
4499− DependencyManager::get<OffscreenUi>()->show(url, "AssetServer");
4420+ auto urlSetter = [=](QQmlContext* context, QObject* newObject){
4421+ newObject->setProperty("currentFileUrl", filePath);
4422+ };
4423+ DependencyManager::get<OffscreenUi>()->show(url, "AssetServer", urlSetter);
45004424 }
45014425
45024426 void Application::packageModel() {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t