diff --git a/src/meshlabplugins/filter_sketchfab/filter_sketchfab.cpp b/src/meshlabplugins/filter_sketchfab/filter_sketchfab.cpp index a757569dd3..c74a2a6397 100644 --- a/src/meshlabplugins/filter_sketchfab/filter_sketchfab.cpp +++ b/src/meshlabplugins/filter_sketchfab/filter_sketchfab.cpp @@ -97,15 +97,25 @@ int FilterSketchFabPlugin::postCondition(QAction*) const void FilterSketchFabPlugin::initParameterSet(QAction* action, MeshModel&, RichParameterList& parlst) { + QSettings settings; + QVariant v = settings.value("SketchFab Code"); + QString sketchFabAPIValue; + if (v == QVariant()) { + sketchFabAPIValue = DEFAULT_API; + } + else { + sketchFabAPIValue = v.toString(); + } switch(ID(action)) { case FP_SKETCHFAB : - parlst.addParam(RichString("sketchFabKeyCode", "00000000", "Sketch Fab Code", "Mandatory.")); + parlst.addParam(RichString("sketchFabKeyCode", sketchFabAPIValue, "Sketch Fab Code", "Mandatory.")); parlst.addParam(RichString("title", "MeshLabModel", "Title", "Mandatory.")); parlst.addParam(RichString("description", "A model generated with meshlab", "Description", "Mandatory. A short description of the model that is uploaded.")); parlst.addParam(RichString("tags", "meshlab", "Tags", "Mandatory. Tags must be separated by a space. Typical tags usually used by MeshLab users: scan, photogrammetry.")); parlst.addParam(RichBool("isPrivate", false, "Private", "This parameter can be true only for PRO account.")); parlst.addParam(RichBool("isPublished", false, "Publish", "If true the model will be published immediately.")); parlst.addParam(RichBool("autoRotate", true, "Auto Rotate", "If true the model rotated by 90 degree on the X axis to maintain similar default orientation.")); + parlst.addParam(RichBool("saveApiSetting", sketchFabAPIValue != DEFAULT_API, "Save SketchFab Code", "Saves the API SketchFab code into the MeshLab settings, allowing to load it as default value every time you run this filter.")); break; default : assert(0); @@ -120,7 +130,7 @@ bool FilterSketchFabPlugin::applyFilter(QAction * action, MeshDocument& md, cons par.getString("sketchFabKeyCode"), par.getString("title"), par.getString("description"), par.getString("tags"), par.getBool("isPrivate"), par.getBool("isPublished"), - par.getBool("autoRotate")); + par.getBool("autoRotate"), par.getBool("saveApiSetting")); default: assert(0); return false; @@ -136,7 +146,8 @@ bool FilterSketchFabPlugin::sketchfab( const QString& tags, bool isPrivate, bool isPublished, - bool /*autoRotate*/) + bool /*autoRotate*/, + bool saveApiSetting) { qDebug("Export to SketchFab start "); this->fcb=cb; @@ -145,11 +156,19 @@ bool FilterSketchFabPlugin::sketchfab( Matrix44m rot; rot.SetRotateDeg(-90,Point3m(1,0,0)); Matrix44m rotI; rot.SetRotateDeg(90,Point3m(1,0,0)); - if(apiToken.isEmpty() || apiToken=="0000000") { + if(apiToken.isEmpty() || apiToken == DEFAULT_API) { this->errorMessage = QString("Please set in the MeshLab preferences your private API Token string that you can find on theSketchfab Password Settings."); return false; } + QSettings settings; + if (saveApiSetting) { + settings.setValue("SketchFab Code", apiToken); + } + else { + settings.remove("SketchFab Code"); + } + QString tmpObjFileName = QDir::tempPath() + "/xxxx.ply"; QString tmpZipFileName = QDir::tempPath() + "/xxxx.zip"; diff --git a/src/meshlabplugins/filter_sketchfab/filter_sketchfab.h b/src/meshlabplugins/filter_sketchfab/filter_sketchfab.h index bb32806754..93e01e1e52 100644 --- a/src/meshlabplugins/filter_sketchfab/filter_sketchfab.h +++ b/src/meshlabplugins/filter_sketchfab/filter_sketchfab.h @@ -53,8 +53,7 @@ public slots: void uploadProgress(qint64 bytesSent, qint64 bytesTotal); private: - bool sketchfab( - MeshDocument &md, + bool sketchfab(MeshDocument &md, vcg::CallBackPos* cb, const QString& apiToken, const QString&, @@ -62,6 +61,7 @@ public slots: const QString&, bool, bool, + bool, bool); bool upload( @@ -83,6 +83,7 @@ public slots: bool uploadCompleteFlag; vcg::CallBackPos * fcb; + const QString DEFAULT_API = "00000000"; }; diff --git a/vcglib b/vcglib index 3932ce448b..feea7d6b82 160000 --- a/vcglib +++ b/vcglib @@ -1 +1 @@ -Subproject commit 3932ce448b174b23b363e3308deb427228c847de +Subproject commit feea7d6b8205febbdd35e4a8e0ba811f4e829b40