History

move asset upload to AssetUploadDialogFactory

Stephen Birarda committed 11 years ago

Commit 5b5941f1 parent 0450e848 files · +112 −42Browse files

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

Unified · Split

interface/src/Menu.cpp+17−36
@@ -22,8 +22,6 @@ · 21 unmodified lines
2222 #include <UserActivityLogger.h>
2323 #include <VrMenu.h>
2424
25−#include <AssetClient.h>
26−
2725 #include "Application.h"
2826 #include "AccountManager.h"
2927 #include "audio/AudioScope.h"
@@ -34,13 +32,15 @@ · 4 unmodified lines
3432 #include "devices/3DConnexionClient.h"
3533 #include "MainWindow.h"
3634 #include "scripting/MenuScriptingInterface.h"
37−#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
38−#include "SpeechRecognizer.h"
39−#endif
35+#include "ui/AssetUploadDialogFactory.h"
4036 #include "ui/DialogsManager.h"
4137 #include "ui/StandAloneJSConsole.h"
4238 #include "InterfaceLogging.h"
4339
40+#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
41+#include "SpeechRecognizer.h"
42+#endif
43+
4444 #include "Menu.h"
4545
4646 Menu* Menu::_instance = NULL;
@@ -90,36 +90,6 @@ Menu::Menu() { · 43 unmodified lines
9090 addActionToQMenuAndActionHash(fileMenu, MenuOption::RunningScripts, Qt::CTRL | Qt::Key_J,
9191 qApp, SLOT(toggleRunningScriptsWidget()));
9292
93− // Asset uploading
94− {
95− auto action = new QAction("Upload File", fileMenu);
96− fileMenu->addAction(action);
97− action->setMenuRole(QAction::NoRole);
98− _actionHash.insert("Upload File", action);
99−
100− connect(action, &QAction::triggered, [this](bool checked) {
101− qDebug() << "Clicked upload file";
102− auto filename = QFileDialog::getOpenFileUrl(nullptr, "Select a file to upload");
103− if (!filename.isEmpty()) {
104− qDebug() << "Selected: " << filename;
105− QFile file { filename.path() };
106− if (file.open(QIODevice::ReadOnly)) {
107− QFileInfo fileInfo { filename.path() };
108− auto extension = fileInfo.suffix();
109− auto data = file.readAll();
110− auto assetClient = DependencyManager::get<AssetClient>();
111− assetClient->uploadAsset(data, extension, [this, extension](bool result, QString hash) mutable {
112− if (result) {
113− QMessageBox::information(this, "Upload Successful", "URL: apt:/" + hash + "." + extension);
114− } else {
115− QMessageBox::warning(this, "Upload Failed", "There was an error uploading the file.");
116− }
117− });
118− }
119− }
120− });
121− }
122−
12393 auto addressManager = DependencyManager::get<AddressManager>();
12494
12595 addDisabledActionAndSeparator(fileMenu, "History");
@@ -400,7 +370,18 @@ Menu::Menu() { · 274 unmodified lines
400370 addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools,
401371 0, // QML Qt::SHIFT | Qt::Key_L,
402372 dialogsManager.data(), SLOT(lodTools()));
403−
373+
374+ MenuWrapper* assetDeveloperMenu = developerMenu->addMenu("Assets");
375+
376+ auto& assetDialogFactory = AssetUploadDialogFactory::getInstance();
377+ assetDialogFactory.setParent(this);
378+
379+ addActionToQMenuAndActionHash(assetDeveloperMenu,
380+ MenuOption::UploadAsset,
381+ 0,
382+ &AssetUploadDialogFactory::getInstance(),
383+ SLOT(showDialog()));
384+
404385 MenuWrapper* avatarDebugMenu = developerMenu->addMenu("Avatar");
405386
406387 MenuWrapper* faceTrackingMenu = avatarDebugMenu->addMenu("Face Tracking");