19
interface/resources/config/config.json
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"importFormats" : [
|
||||
{
|
||||
"extension": "png",
|
||||
"description": "Square PNG",
|
||||
"icon": "raster.svg"
|
||||
},
|
||||
{
|
||||
"extension": "svo",
|
||||
"description": "Sparse Voxel Octree Files",
|
||||
"icon": "voxel.svg"
|
||||
},
|
||||
{
|
||||
"extension": "schematic",
|
||||
"description": "Schematic Files",
|
||||
"icon": "voxel.svg"
|
||||
}
|
||||
]
|
||||
}
|
12
interface/resources/icons/computer.svg
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g>
|
||||
<path fill="#666666" d="M18.223,11.845c0,0.835-0.683,1.519-1.519,1.519h-5.163c0,0.807,0.607,1.49,0.607,1.822
|
||||
s-0.275,0.607-0.607,0.607H6.682c-0.332,0-0.607-0.275-0.607-0.607c0-0.351,0.607-0.997,0.607-1.822H1.519
|
||||
C0.683,13.363,0,12.68,0,11.845V1.519C0,0.684,0.683,0,1.519,0h15.186c0.835,0,1.519,0.684,1.519,1.519V11.845z M17.008,1.519
|
||||
c0-0.161-0.143-0.304-0.304-0.304H1.519c-0.161,0-0.304,0.143-0.304,0.304v7.896c0,0.161,0.143,0.304,0.304,0.304h15.186
|
||||
c0.161,0,0.304-0.143,0.304-0.304V1.519z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 884 B |
17
interface/resources/icons/desktop.svg
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<rect fill="#666666" width="17" height="1"/>
|
||||
</g>
|
||||
<g>
|
||||
<rect y="2" fill="#666666" width="17" height="11"/>
|
||||
</g>
|
||||
<rect x="1" y="4" fill="#989898" width="1" height="1"/>
|
||||
<rect x="1" y="6" fill="#989898" width="1" height="1"/>
|
||||
<rect x="4" y="4" fill="#989898" width="1" height="1"/>
|
||||
<rect x="4" y="6" fill="#989898" width="1" height="1"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 732 B |
15
interface/resources/icons/documents.svg
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#666666" d="M17.615,4.556v11.541c0,0.503-0.408,0.911-0.911,0.911H7.593c-0.503,0-0.911-0.408-0.911-0.911v-2.733
|
||||
H1.519c-0.503,0-0.911-0.408-0.911-0.911V6.074c0-0.503,0.295-1.206,0.646-1.557l3.872-3.872C5.477,0.294,6.179,0,6.682,0h3.948
|
||||
c0.503,0,0.911,0.408,0.911,0.911v3.113c0.37-0.219,0.845-0.38,1.215-0.38h3.948C17.207,3.645,17.615,4.053,17.615,4.556z
|
||||
M10.326,5.163V1.215H6.682v3.948c0,0.503-0.408,0.911-0.911,0.911H1.822v6.074h4.859v-2.43c0-0.503,0.295-1.206,0.646-1.557
|
||||
L10.326,5.163z M2.629,4.859h2.838V2.021L2.629,4.859z M16.4,4.859h-3.645v3.948c0,0.503-0.408,0.911-0.911,0.911H7.896v6.074
|
||||
H16.4V4.859z M8.703,8.504h2.838V5.666L8.703,8.504z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1 KiB |
14
interface/resources/icons/file.svg
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g>
|
||||
<path fill="#666666" d="M12.148,13.667c0,0.503-0.408,0.911-0.911,0.911H0.911C0.408,14.578,0,14.17,0,13.667V0.911
|
||||
C0,0.408,0.408,0,0.911,0h6.074c0.503,0,1.206,0.294,1.557,0.646l2.961,2.961c0.351,0.351,0.646,1.054,0.646,1.557V13.667z
|
||||
M10.934,13.363V6.074H6.985c-0.503,0-0.911-0.408-0.911-0.911V1.215H1.215v12.148H10.934z M9.719,8.2
|
||||
c0,0.171-0.133,0.304-0.304,0.304H2.733C2.562,8.504,2.43,8.371,2.43,8.2V7.593c0-0.171,0.133-0.304,0.304-0.304h6.682
|
||||
c0.171,0,0.304,0.133,0.304,0.304V8.2z M9.719,10.63c0,0.171-0.133,0.304-0.304,0.304H2.733c-0.171,0-0.304-0.133-0.304-0.304
|
||||
v-0.607c0-0.171,0.133-0.304,0.304-0.304h6.682c0.171,0,0.304,0.133,0.304,0.304V10.63z M10.857,4.859
|
||||
c-0.057-0.161-0.142-0.323-0.208-0.389L7.678,1.5C7.612,1.433,7.45,1.348,7.289,1.291v3.568H10.857z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
11
interface/resources/icons/folder.svg
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g>
|
||||
<path fill="#666666" d="M14.854,10.569c0,1.098-0.901,2-2,2H2c-1.098,0-2-0.901-2-2V2c0-1.098,0.901-2,2-2h2.856
|
||||
c1.098,0,2,0.901,2,2v0.286h5.999c1.098,0,2,0.901,2,2V10.569z M13.711,4.285c0-0.473-0.384-0.857-0.857-0.857H6.57
|
||||
c-0.473,0-0.857-0.384-0.857-0.857V2c0-0.473-0.384-0.857-0.857-0.857H2C1.526,1.143,1.143,1.526,1.143,2v8.569
|
||||
c0,0.473,0.384,0.857,0.857,0.857h10.854c0.473,0,0.857-0.384,0.857-0.857V4.285z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 800 B |
16
interface/resources/icons/home.svg
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#666666" d="M16.191,7.893c-0.054,0.063-0.139,0.106-0.223,0.116c-0.011,0-0.021,0-0.032,0
|
||||
c-0.085,0-0.159-0.021-0.223-0.074L8.375,1.816L1.037,7.935C0.963,7.988,0.878,8.02,0.782,8.009
|
||||
c-0.085-0.01-0.17-0.053-0.223-0.116l-0.657-0.785c-0.117-0.138-0.096-0.36,0.042-0.477l7.625-6.352
|
||||
c0.445-0.372,1.166-0.372,1.612,0l2.587,2.163V0.374c0-0.191,0.148-0.339,0.34-0.339h2.036c0.19,0,0.339,0.148,0.339,0.339v4.327
|
||||
l2.322,1.93c0.139,0.117,0.159,0.339,0.043,0.477L16.191,7.893z M14.483,12.93c0,0.371-0.308,0.679-0.679,0.679H9.732V9.536H7.018
|
||||
v4.072H2.945c-0.371,0-0.679-0.308-0.679-0.679V7.84c0-0.021,0.011-0.042,0.011-0.063l6.098-5.027l6.098,5.027
|
||||
c0.011,0.021,0.011,0.042,0.011,0.063V12.93z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.1 KiB |
12
interface/resources/icons/raster.svg
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g>
|
||||
<path fill="#666666" d="M15.049,10.75c0,0.688-0.562,1.25-1.25,1.25h-12.5c-0.688,0-1.25-0.562-1.25-1.25v-9.5
|
||||
C0.049,0.562,0.611,0,1.299,0h12.5c0.688,0,1.25,0.562,1.25,1.25V10.75z M1.299,1c-0.133,0-0.25,0.117-0.25,0.25v9.5
|
||||
c0,0.133,0.117,0.25,0.25,0.25h12.5c0.133,0,0.25-0.117,0.25-0.25v-9.5c0-0.133-0.117-0.25-0.25-0.25H1.299z M3.549,5
|
||||
c-0.828,0-1.5-0.672-1.5-1.5S2.72,2,3.549,2s1.5,0.672,1.5,1.5S4.377,5,3.549,5z M13.049,10h-11V8.5l2.5-2.5l1.25,1.25l4-4
|
||||
l3.25,3.25V10z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 862 B |
18
interface/resources/icons/voxel.svg
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
<g>
|
||||
<g>
|
||||
<path fill="#666666" d="M13.402,4.612c0-0.098-0.052-0.188-0.137-0.237c-0.085-0.049-0.189-0.049-0.274,0L7.704,7.428
|
||||
C7.423,7.59,7.25,7.89,7.25,8.215v6.105c0,0.098,0.052,0.188,0.137,0.237c0.085,0.049,0.189,0.049,0.274,0l5.085-2.936
|
||||
c0.407-0.235,0.657-0.668,0.657-1.138V4.612z"/>
|
||||
<path fill="#666666" d="M0.41,4.375c-0.085-0.049-0.189-0.049-0.274,0C0.052,4.424,0,4.514,0,4.612c0,0,0,0,0,0v5.872
|
||||
c0,0.469,0.25,0.903,0.657,1.138l5.085,2.936c0,0,0,0,0,0c0.085,0.049,0.189,0.049,0.274,0c0.085-0.049,0.136-0.139,0.136-0.237
|
||||
V8.215c0-0.325-0.173-0.625-0.455-0.787L0.41,4.375z"/>
|
||||
</g>
|
||||
<path fill="#666666" d="M12.443,3.586c0.085-0.049,0.137-0.139,0.137-0.237c0-0.098-0.052-0.188-0.137-0.237c0,0,0,0,0,0
|
||||
L7.358,0.176c-0.407-0.235-0.907-0.235-1.313,0L0.959,3.112c0,0,0,0,0,0C0.874,3.161,0.822,3.251,0.822,3.349
|
||||
c0,0.098,0.052,0.188,0.137,0.237l5.287,3.053c0.281,0.162,0.628,0.162,0.909,0L12.443,3.586z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
88
interface/resources/styles/import_dialog.qss
Normal file
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* import_dialog.qss
|
||||
* hifi
|
||||
*
|
||||
* Created by Stojce on 1/5/2014.
|
||||
* Copyright (c) 2014 High Fidelity, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
* {
|
||||
font-family: Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
QLabel {
|
||||
font-size: 16px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
QLabel#infoLabel {
|
||||
padding: 7px 0 0 7px;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
QPushButton {
|
||||
border-width: 0;
|
||||
border-radius: 9px;
|
||||
font-size: 18px;
|
||||
padding: 17px 0px 15px;
|
||||
width: 107px;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
QPushButton#importButton {
|
||||
color: #FFFFFF;
|
||||
font-weight: bold;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
QPushButton#importButton:enabled {
|
||||
background: #333333;
|
||||
}
|
||||
|
||||
QPushButton#importButton:!enabled {
|
||||
background: rgba(50, 50, 50, 0.5);
|
||||
}
|
||||
|
||||
QPushButton#cancelButton {
|
||||
color: #333333;
|
||||
background-color: #FFFFFF;
|
||||
width: 74px;
|
||||
margin-right: 11px;
|
||||
}
|
||||
|
||||
QSidebar, QTreeView {
|
||||
border: 1px solid #C5C5C5;
|
||||
font-size: 14px;
|
||||
margin: 0px;
|
||||
selection-background-color: #BDE4E3;
|
||||
selection-color: #333333;
|
||||
|
||||
}
|
||||
|
||||
QTreeView {
|
||||
border-left: none;
|
||||
}
|
||||
|
||||
QSplitter::handle, QDialog {
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
QTreeView QHeaderView {
|
||||
background: white;
|
||||
}
|
||||
|
||||
QTreeView QHeaderView:section {
|
||||
border-left: none;
|
||||
border-top: none;
|
||||
border-bottom: 1px solid #C5C5C5;
|
||||
border-right: 1px solid #C5C5C5;
|
||||
background: white;
|
||||
color: #666666;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
QSidebar::item,
|
||||
QTreeView::item {
|
||||
padding: 5px 0 4px;
|
||||
}
|
|
@ -1722,7 +1722,7 @@ void Application::init() {
|
|||
_sharedVoxelSystem.changeTree(&_clipboard);
|
||||
delete tmpTree;
|
||||
|
||||
_voxelImporter.init();
|
||||
_voxelImporter.init(_settings);
|
||||
|
||||
_environment.init();
|
||||
|
||||
|
|
|
@ -6,208 +6,132 @@
|
|||
// Copyright (c) 2013 High Fidelity, Inc. All rights reserved.
|
||||
//
|
||||
#include "ImportDialog.h"
|
||||
#include "Application.h"
|
||||
|
||||
#include <QStandardPaths>
|
||||
#include <QGridLayout>
|
||||
#include <QMouseEvent>
|
||||
#include <QSplitter>
|
||||
#include <QApplication>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
|
||||
const QString WINDOW_NAME = QObject::tr("Import Voxels");
|
||||
const QString IMPORT_BUTTON_NAME = QObject::tr("Import");
|
||||
const QString IMPORT_TO_CLIPBOARD_CHECKBOX_STRING = QObject::tr("Import into clipboard");
|
||||
const QString PREVIEW_CHECKBOX_STRING = QObject::tr("Load preview");
|
||||
const QString IMPORT_FILE_TYPES = QObject::tr("Sparse Voxel Octree Files, "
|
||||
"Square PNG, "
|
||||
"Schematic Files "
|
||||
"(*.svo *.png *.schematic)");
|
||||
const QString WINDOW_NAME = QObject::tr("Import Voxels");
|
||||
const QString IMPORT_BUTTON_NAME = QObject::tr("Import");
|
||||
const QString IMPORT_INFO = QObject::tr("<b>Import</b> %1 as voxels");
|
||||
const QString CANCEL_BUTTON_NAME = QObject::tr("Cancel");
|
||||
const QString INFO_LABEL_TEXT = QObject::tr("<div style='line-height:20px;'>"
|
||||
"This will load the selected file into Hifi and allow you<br/>"
|
||||
"to place it with %1-V; you must be in select or<br/>"
|
||||
"add mode (S or V keys will toggle mode) to place.</div>");
|
||||
|
||||
const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
||||
const int SHORT_FILE_EXTENSION = 4;
|
||||
const int SECOND_INDEX_LETTER = 1;
|
||||
|
||||
|
||||
const glm::vec3 UP_VECT = glm::vec3(0, 1, 0);
|
||||
const float ANGULAR_RATE = 0.02f;
|
||||
const float VERTICAL_ANGLE = (float)M_PI_4 / 2.0f;
|
||||
const float RETURN_RATE = 0.02f;
|
||||
const float NEAR_CLIP = 0.5f;
|
||||
const float FAR_CLIP = 10.0f;
|
||||
const float FIELD_OF_VIEW = 60.0f;
|
||||
|
||||
class GLWidget : public QGLWidget {
|
||||
public:
|
||||
GLWidget(QWidget* parent = NULL);
|
||||
void setDraw(bool draw) {_draw = draw;}
|
||||
void setTargetCenter(glm::vec3 targetCenter) { _targetCenter = targetCenter; }
|
||||
|
||||
protected:
|
||||
virtual void initializeGL();
|
||||
virtual void resizeGL(int width, int height);
|
||||
virtual void paintGL();
|
||||
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseMoveEvent(QMouseEvent* event);
|
||||
void mouseReleaseEvent(QMouseEvent* event);
|
||||
|
||||
private:
|
||||
VoxelSystem* _voxelSystem;
|
||||
|
||||
bool _draw;
|
||||
|
||||
double _a; // horizontal angle of the camera to the center of the object
|
||||
double _h; // vertical angle of the camera to the center of the object
|
||||
glm::vec3 _targetCenter;
|
||||
|
||||
bool _pressed;
|
||||
int _mouseX;
|
||||
int _mouseY;
|
||||
};
|
||||
|
||||
GLWidget::GLWidget(QWidget *parent)
|
||||
: QGLWidget(parent, Application::getInstance()->getGLWidget()),
|
||||
_draw(false),
|
||||
_a(0.0f),
|
||||
_h(VERTICAL_ANGLE),
|
||||
_targetCenter(0.5f, 0.5f, 0.5f),
|
||||
_pressed(false),
|
||||
_mouseX(0),
|
||||
_mouseY(0) {
|
||||
_voxelSystem = Application::getInstance()->getSharedVoxelSystem();
|
||||
}
|
||||
|
||||
void GLWidget::initializeGL() {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glShadeModel (GL_SMOOTH);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
|
||||
void GLWidget::resizeGL(int width, int height) {
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
gluPerspective(FIELD_OF_VIEW,
|
||||
(float) width / height,
|
||||
NEAR_CLIP,
|
||||
FAR_CLIP);
|
||||
}
|
||||
|
||||
void GLWidget::paintGL() {
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
if (!_pressed) {
|
||||
_a += ANGULAR_RATE;
|
||||
_h = (1.0f - RETURN_RATE) * _h + RETURN_RATE * VERTICAL_ANGLE;
|
||||
QIcon HiFiIconProvider::icon(QFileIconProvider::IconType type) const {
|
||||
|
||||
switchToResourcesParentIfRequired();
|
||||
|
||||
// types
|
||||
// Computer, Desktop, Trashcan, Network, Drive, Folder, File
|
||||
QString typeString;
|
||||
|
||||
switch (type) {
|
||||
case QFileIconProvider::Computer:
|
||||
typeString = "computer";
|
||||
break;
|
||||
|
||||
case QFileIconProvider::Desktop:
|
||||
typeString = "desktop";
|
||||
break;
|
||||
|
||||
case QFileIconProvider::Trashcan:
|
||||
case QFileIconProvider::Network:
|
||||
case QFileIconProvider::Drive:
|
||||
case QFileIconProvider::Folder:
|
||||
typeString = "folder";
|
||||
break;
|
||||
|
||||
default:
|
||||
typeString = "file";
|
||||
break;
|
||||
}
|
||||
|
||||
gluLookAt(_targetCenter.x + (glm::length(_targetCenter) + NEAR_CLIP) * cos(_a),
|
||||
_targetCenter.y + (glm::length(_targetCenter) + NEAR_CLIP) * sin(_h),
|
||||
_targetCenter.z + (glm::length(_targetCenter) + NEAR_CLIP) * sin(_a),
|
||||
_targetCenter.x, _targetCenter.y, _targetCenter.z,
|
||||
UP_VECT.x, UP_VECT.y, UP_VECT.z);
|
||||
return QIcon("resources/icons/" + typeString + ".svg");
|
||||
}
|
||||
|
||||
|
||||
if (_draw) {
|
||||
glBegin(GL_LINES);
|
||||
glColor3d(1, 1 ,1);
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(1, 0, 0);
|
||||
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(0, 1, 0);
|
||||
|
||||
glVertex3d(0, 0, 0);
|
||||
glVertex3d(0, 0, 1);
|
||||
|
||||
|
||||
glColor3d(0.4f, 0.4f ,0.4f);
|
||||
glVertex3d(2 * _targetCenter.x, 2 * _targetCenter.y, 2 * _targetCenter.z);
|
||||
glVertex3d(0 , 2 * _targetCenter.y, 2 * _targetCenter.z);
|
||||
|
||||
glVertex3d(2 * _targetCenter.x, 2 * _targetCenter.y, 2 * _targetCenter.z);
|
||||
glVertex3d(2 * _targetCenter.x, 0 , 2 * _targetCenter.z);
|
||||
|
||||
glVertex3d(2 * _targetCenter.x, 2 * _targetCenter.y, 2 * _targetCenter.z);
|
||||
glVertex3d(2 * _targetCenter.x, 2 * _targetCenter.y, 0 );
|
||||
glEnd();
|
||||
|
||||
glScalef(1.0f / TREE_SCALE, 1.0f / TREE_SCALE, 1.0f / TREE_SCALE);
|
||||
_voxelSystem->render(false);
|
||||
QIcon HiFiIconProvider::icon(const QFileInfo &info) const {
|
||||
switchToResourcesParentIfRequired();
|
||||
const QString ext = info.suffix().toLower();
|
||||
|
||||
if (info.isDir()) {
|
||||
if (info.absoluteFilePath() == QDir::homePath()) {
|
||||
return QIcon("resources/icons/home.svg");
|
||||
} else if (info.absoluteFilePath() == DESKTOP_LOCATION) {
|
||||
return QIcon("resources/icons/desktop.svg");
|
||||
} else if (info.absoluteFilePath() == QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)) {
|
||||
return QIcon("resources/icons/documents.svg");
|
||||
}
|
||||
return QIcon("resources/icons/folder.svg");
|
||||
}
|
||||
|
||||
QFileInfo iconFile("resources/icons/" + iconsMap[ext]);
|
||||
if (iconFile.exists() && iconFile.isFile()) {
|
||||
return QIcon(iconFile.filePath());
|
||||
}
|
||||
|
||||
return QIcon("resources/icons/file.svg");
|
||||
}
|
||||
|
||||
void GLWidget::mousePressEvent(QMouseEvent* event) {
|
||||
_pressed = true;
|
||||
_mouseX = event->globalX();
|
||||
_mouseY = event->globalY();
|
||||
QString HiFiIconProvider::type(const QFileInfo &info) const {
|
||||
if (info.isFile()) {
|
||||
if (info.suffix().size() > SHORT_FILE_EXTENSION) {
|
||||
// Capitalize extension
|
||||
return info.suffix().left(SECOND_INDEX_LETTER).toUpper() + info.suffix().mid(SECOND_INDEX_LETTER);
|
||||
}
|
||||
return info.suffix().toUpper();
|
||||
}
|
||||
|
||||
return QFileIconProvider::type(info);
|
||||
}
|
||||
|
||||
void GLWidget::mouseMoveEvent(QMouseEvent* event) {
|
||||
_a += (M_PI * (event->globalX() - _mouseX)) / height();
|
||||
_h += (M_PI * (event->globalY() - _mouseY)) / height();
|
||||
_h = glm::clamp(_h, -M_PI_4, M_PI_4);
|
||||
|
||||
_mouseX = event->globalX();
|
||||
_mouseY = event->globalY();
|
||||
}
|
||||
|
||||
void GLWidget::mouseReleaseEvent(QMouseEvent* event) {
|
||||
_pressed = false;
|
||||
}
|
||||
|
||||
ImportDialog::ImportDialog(QWidget *parent)
|
||||
: QFileDialog(parent, WINDOW_NAME, DESKTOP_LOCATION, IMPORT_FILE_TYPES),
|
||||
_importButton (IMPORT_BUTTON_NAME, this),
|
||||
_clipboardImportBox(IMPORT_TO_CLIPBOARD_CHECKBOX_STRING, this),
|
||||
_previewBox (PREVIEW_CHECKBOX_STRING, this),
|
||||
_previewBar (this),
|
||||
_glPreview (new GLWidget(this)) {
|
||||
ImportDialog::ImportDialog(QWidget* parent) :
|
||||
QFileDialog(parent, WINDOW_NAME, DESKTOP_LOCATION, NULL),
|
||||
_importButton(IMPORT_BUTTON_NAME, this),
|
||||
_cancelButton(CANCEL_BUTTON_NAME, this) {
|
||||
|
||||
setOption(QFileDialog::DontUseNativeDialog, true);
|
||||
setFileMode(QFileDialog::ExistingFile);
|
||||
setViewMode(QFileDialog::Detail);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
QString cmdString = ("Command");
|
||||
#else
|
||||
QString cmdString = ("Control");
|
||||
#endif
|
||||
QLabel* infoLabel = new QLabel(QString(INFO_LABEL_TEXT).arg(cmdString));
|
||||
infoLabel->setObjectName("infoLabel");
|
||||
|
||||
QGridLayout* gridLayout = (QGridLayout*) layout();
|
||||
gridLayout->addWidget(&_importButton , 2, 2);
|
||||
gridLayout->addWidget(&_clipboardImportBox, 2, 3);
|
||||
gridLayout->addWidget(&_previewBox , 3, 3);
|
||||
gridLayout->addWidget(&_previewBar , 0, 3);
|
||||
gridLayout->addWidget(_glPreview , 1, 3);
|
||||
gridLayout->setColumnStretch(3, 1);
|
||||
|
||||
_previewBar.setVisible(false);
|
||||
_previewBar.setRange(0, 100);
|
||||
_previewBar.setValue(0);
|
||||
gridLayout->addWidget(infoLabel, 2, 0, 2, 1);
|
||||
gridLayout->addWidget(&_cancelButton, 2, 1, 2, 1);
|
||||
gridLayout->addWidget(&_importButton, 2, 2, 2, 1);
|
||||
|
||||
setImportTypes();
|
||||
setLayout();
|
||||
|
||||
connect(&_importButton, SIGNAL(pressed()), SLOT(import()));
|
||||
connect(&_previewBox, SIGNAL(toggled(bool)), SIGNAL(previewToggled(bool)));
|
||||
connect(&_previewBox, SIGNAL(toggled(bool)), SLOT(preview(bool)));
|
||||
|
||||
connect(&_cancelButton, SIGNAL(pressed()), SLOT(close()));
|
||||
connect(this, SIGNAL(currentChanged(QString)), SLOT(saveCurrentFile(QString)));
|
||||
connect(&_glTimer, SIGNAL(timeout()), SLOT(timer()));
|
||||
}
|
||||
|
||||
ImportDialog::~ImportDialog() {
|
||||
delete _glPreview;
|
||||
}
|
||||
|
||||
void ImportDialog::init() {
|
||||
VoxelSystem* voxelSystem = Application::getInstance()->getSharedVoxelSystem();
|
||||
connect(voxelSystem, SIGNAL(importSize(float,float,float)), SLOT(setGLCamera(float,float,float)));
|
||||
connect(voxelSystem, SIGNAL(importProgress(int)), &_previewBar, SLOT(setValue(int)));
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void ImportDialog::import() {
|
||||
_importButton.setDisabled(true);
|
||||
_clipboardImportBox.setDisabled(true);
|
||||
_previewBox.setDisabled(true);
|
||||
|
||||
_previewBar.setValue(0);
|
||||
_previewBar.setVisible(true);
|
||||
|
||||
emit accepted();
|
||||
close();
|
||||
}
|
||||
|
||||
void ImportDialog::accept() {
|
||||
|
@ -219,44 +143,142 @@ void ImportDialog::reject() {
|
|||
}
|
||||
|
||||
int ImportDialog::exec() {
|
||||
// deselect selected file
|
||||
selectFile(" ");
|
||||
return QFileDialog::exec();
|
||||
}
|
||||
|
||||
void ImportDialog::setGLCamera(float x, float y, float z) {
|
||||
_glPreview->setTargetCenter(glm::vec3(x, y, z) / 2.0f);
|
||||
}
|
||||
|
||||
void ImportDialog::reset() {
|
||||
_previewBox.setChecked(false);
|
||||
_previewBar.setVisible(false);
|
||||
_previewBar.setValue(0);
|
||||
_importButton.setEnabled(true);
|
||||
_clipboardImportBox.setEnabled(true);
|
||||
_previewBox.setEnabled(true);
|
||||
|
||||
_glTimer.stop();
|
||||
_glPreview->setDraw(false);
|
||||
_glPreview->updateGL();
|
||||
}
|
||||
|
||||
void ImportDialog::preview(bool wantPreview) {
|
||||
_previewBar.setValue(0);
|
||||
_previewBar.setVisible(wantPreview);
|
||||
_glPreview->setDraw(wantPreview);
|
||||
|
||||
if (wantPreview) {
|
||||
_glTimer.start();
|
||||
} else {
|
||||
_glTimer.stop();
|
||||
_glPreview->updateGL();
|
||||
}
|
||||
_importButton.setEnabled(false);
|
||||
}
|
||||
|
||||
void ImportDialog::saveCurrentFile(QString filename) {
|
||||
_currentFile = filename;
|
||||
if (!filename.isEmpty() && QFileInfo(filename).isFile()) {
|
||||
_currentFile = filename;
|
||||
_importButton.setEnabled(true);
|
||||
} else {
|
||||
_currentFile.clear();
|
||||
_importButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ImportDialog::timer() {
|
||||
_glPreview->updateGL();
|
||||
_glTimer.start(16);
|
||||
void ImportDialog::setLayout() {
|
||||
|
||||
// set ObjectName used in qss for styling
|
||||
_importButton.setObjectName("importButton");
|
||||
_cancelButton.setObjectName("cancelButton");
|
||||
|
||||
// set fixed size
|
||||
_importButton.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
_cancelButton.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
|
||||
// hide unused embedded widgets in QFileDialog
|
||||
QWidget* widget = findChild<QWidget*>("lookInCombo");
|
||||
widget->hide();
|
||||
|
||||
widget = findChild<QWidget*>("backButton");
|
||||
widget->hide();
|
||||
|
||||
widget = findChild<QWidget*>("forwardButton");
|
||||
widget->hide();
|
||||
|
||||
widget = findChild<QWidget*>("toParentButton");
|
||||
widget->hide();
|
||||
|
||||
widget = findChild<QWidget*>("newFolderButton");
|
||||
widget->hide();
|
||||
|
||||
widget = findChild<QWidget*>("listModeButton");
|
||||
widget->hide();
|
||||
|
||||
widget = findChild<QWidget*>("detailModeButton");
|
||||
widget->hide();
|
||||
|
||||
widget = findChild<QWidget*>("fileNameEdit");
|
||||
widget->hide();
|
||||
|
||||
widget = findChild<QWidget*>("fileTypeCombo");
|
||||
widget->hide();
|
||||
|
||||
widget = findChild<QWidget*>("fileTypeLabel");
|
||||
widget->hide();
|
||||
|
||||
widget = findChild<QWidget*>("fileNameLabel");
|
||||
widget->hide();
|
||||
|
||||
widget = findChild<QWidget*>("buttonBox");
|
||||
widget->hide();
|
||||
|
||||
QSplitter* splitter = findChild<QSplitter*>("splitter");
|
||||
splitter->setHandleWidth(0);
|
||||
|
||||
// remove blue outline on Mac
|
||||
widget = findChild<QWidget*>("sidebar");
|
||||
widget->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
|
||||
widget = findChild<QWidget*>("treeView");
|
||||
widget->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
|
||||
// remove reference to treeView
|
||||
widget = NULL;
|
||||
widget->deleteLater();
|
||||
|
||||
switchToResourcesParentIfRequired();
|
||||
QFile styleSheet("resources/styles/import_dialog.qss");
|
||||
if (styleSheet.open(QIODevice::ReadOnly)) {
|
||||
setStyleSheet(styleSheet.readAll());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ImportDialog::setImportTypes() {
|
||||
|
||||
switchToResourcesParentIfRequired();
|
||||
QFile config("resources/config/config.json");
|
||||
config.open(QFile::ReadOnly | QFile::Text);
|
||||
QJsonDocument document = QJsonDocument::fromJson(config.readAll());
|
||||
if (!document.isNull() && !document.isEmpty()) {
|
||||
|
||||
QString importFormatsInfo;
|
||||
QString importFormatsFilterList;
|
||||
QHash<QString, QString> iconsMap;
|
||||
|
||||
QJsonObject configObject = document.object();
|
||||
if (!configObject.isEmpty()) {
|
||||
QJsonArray fileFormats = configObject["importFormats"].toArray();
|
||||
int formatsCounter = 0;
|
||||
foreach (const QJsonValue& fileFormat, fileFormats) {
|
||||
QJsonObject fileFormatObject = fileFormat.toObject();
|
||||
|
||||
QString ext(fileFormatObject["extension"].toString());
|
||||
QString description(fileFormatObject.value("description").toString());
|
||||
QString icon(fileFormatObject.value("icon").toString());
|
||||
|
||||
if (formatsCounter > 0) {
|
||||
importFormatsInfo.append(",");
|
||||
}
|
||||
|
||||
// set ' or' on last import type text
|
||||
if (formatsCounter == fileFormats.count() - 1) {
|
||||
importFormatsInfo.append(" or");
|
||||
}
|
||||
|
||||
importFormatsFilterList.append(QString("*.%1 ").arg(ext));
|
||||
importFormatsInfo.append(" .").append(ext);
|
||||
iconsMap[ext] = icon;
|
||||
formatsCounter++;
|
||||
}
|
||||
}
|
||||
|
||||
// set custom file icons
|
||||
setIconProvider(new HiFiIconProvider(iconsMap));
|
||||
setNameFilter(importFormatsFilterList);
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
QString cmdString = ("Command");
|
||||
#else
|
||||
QString cmdString = ("Control");
|
||||
#endif
|
||||
setLabelText(QFileDialog::LookIn, QString(IMPORT_INFO).arg(importFormatsInfo));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,54 +9,53 @@
|
|||
#ifndef __hifi__ImportDialog__
|
||||
#define __hifi__ImportDialog__
|
||||
|
||||
#include <VoxelSystem.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QPushButton>
|
||||
#include <QCheckBox>
|
||||
#include <QProgressBar>
|
||||
#include <QGLWidget>
|
||||
#include <QTimer>
|
||||
#include <QLabel>
|
||||
#include <QFileIconProvider>
|
||||
#include <QHash>
|
||||
|
||||
class GLWidget;
|
||||
#include <SharedUtil.h>
|
||||
|
||||
class HiFiIconProvider : public QFileIconProvider {
|
||||
public:
|
||||
HiFiIconProvider(const QHash<QString, QString> map) { iconsMap = map; };
|
||||
virtual QIcon icon(IconType type) const;
|
||||
virtual QIcon icon(const QFileInfo &info) const;
|
||||
virtual QString type(const QFileInfo &info) const;
|
||||
QHash<QString, QString> iconsMap;
|
||||
};
|
||||
|
||||
class ImportDialog : public QFileDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ImportDialog(QWidget* parent = NULL);
|
||||
~ImportDialog();
|
||||
|
||||
void init();
|
||||
void reset();
|
||||
|
||||
bool getWantPreview() const { return _previewBox.isChecked(); }
|
||||
QString getCurrentFile() const { return _currentFile; }
|
||||
bool getImportIntoClipboard() const { return _clipboardImportBox.isChecked(); }
|
||||
|
||||
signals:
|
||||
void previewToggled(bool);
|
||||
void accepted();
|
||||
|
||||
public slots:
|
||||
int exec();
|
||||
void setGLCamera(float x, float y, float z);
|
||||
void import();
|
||||
void accept();
|
||||
void reject();
|
||||
|
||||
private slots:
|
||||
void preview(bool preview);
|
||||
void saveCurrentFile(QString);
|
||||
void timer();
|
||||
|
||||
private:
|
||||
QString _currentFile;
|
||||
QPushButton _importButton;
|
||||
QCheckBox _clipboardImportBox;
|
||||
QCheckBox _previewBox;
|
||||
QProgressBar _previewBar;
|
||||
GLWidget* _glPreview;
|
||||
QTimer _glTimer;
|
||||
QString _currentFile;
|
||||
QPushButton _importButton;
|
||||
QPushButton _cancelButton;
|
||||
|
||||
void setLayout();
|
||||
void setImportTypes();
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__ImportDialog__) */
|
||||
|
|
|
@ -21,6 +21,9 @@ private:
|
|||
QString _filename;
|
||||
};
|
||||
|
||||
const QString SETTINGS_GROUP_NAME = "VoxelImport";
|
||||
const QString IMPORT_DIALOG_SETTINGS_KEY = "ImportDialogSettings";
|
||||
|
||||
VoxelImporter::VoxelImporter(QWidget* parent)
|
||||
: QObject(parent),
|
||||
_voxelTree(true),
|
||||
|
@ -28,13 +31,20 @@ VoxelImporter::VoxelImporter(QWidget* parent)
|
|||
_currentTask(NULL),
|
||||
_nextTask(NULL) {
|
||||
|
||||
connect(&_importDialog, SIGNAL(previewToggled(bool)), SLOT(preImport()));
|
||||
connect(&_importDialog, SIGNAL(currentChanged(QString)), SLOT(preImport()));
|
||||
connect(&_importDialog, SIGNAL(accepted()), SLOT(import()));
|
||||
}
|
||||
|
||||
void VoxelImporter::init() {
|
||||
_importDialog.init();
|
||||
void VoxelImporter::saveSettings(QSettings* settings) {
|
||||
settings->beginGroup(SETTINGS_GROUP_NAME);
|
||||
settings->setValue(IMPORT_DIALOG_SETTINGS_KEY, _importDialog.saveState());
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void VoxelImporter::init(QSettings* settings) {
|
||||
settings->beginGroup(SETTINGS_GROUP_NAME);
|
||||
_importDialog.restoreState(settings->value(IMPORT_DIALOG_SETTINGS_KEY).toByteArray());
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
VoxelImporter::~VoxelImporter() {
|
||||
|
@ -74,15 +84,13 @@ int VoxelImporter::exec() {
|
|||
reset();
|
||||
} else {
|
||||
_importDialog.reset();
|
||||
|
||||
if (_importDialog.getImportIntoClipboard()) {
|
||||
VoxelSystem* voxelSystem = Application::getInstance()->getSharedVoxelSystem();
|
||||
|
||||
voxelSystem->copySubTreeIntoNewTree(voxelSystem->getTree()->getRoot(),
|
||||
Application::getInstance()->getClipboard(),
|
||||
true);
|
||||
voxelSystem->changeTree(Application::getInstance()->getClipboard());
|
||||
}
|
||||
|
||||
VoxelSystem* voxelSystem = Application::getInstance()->getSharedVoxelSystem();
|
||||
|
||||
voxelSystem->copySubTreeIntoNewTree(voxelSystem->getTree()->getRoot(),
|
||||
Application::getInstance()->getClipboard(),
|
||||
true);
|
||||
voxelSystem->changeTree(Application::getInstance()->getClipboard());
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -95,23 +103,6 @@ int VoxelImporter::preImport() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (_importDialog.getWantPreview()) {
|
||||
_filename = filename;
|
||||
|
||||
if (_nextTask) {
|
||||
delete _nextTask;
|
||||
}
|
||||
|
||||
_nextTask = new ImportTask(_filename);
|
||||
connect(_nextTask, SIGNAL(destroyed()), SLOT(launchTask()));
|
||||
|
||||
if (_currentTask != NULL) {
|
||||
_voxelTree.cancelImport();
|
||||
} else {
|
||||
launchTask();
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,9 @@ public:
|
|||
VoxelImporter(QWidget* parent = NULL);
|
||||
~VoxelImporter();
|
||||
|
||||
void init();
|
||||
void init(QSettings* settings);
|
||||
void reset();
|
||||
void saveSettings(QSettings* settings);
|
||||
|
||||
VoxelTree* getVoxelTree() { return &_voxelTree; }
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <QNetworkReply>
|
||||
#include <QOpenGLBuffer>
|
||||
#include <QTimer>
|
||||
|
||||
#include "Application.h"
|
||||
#include "GeometryCache.h"
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <QGLWidget>
|
||||
#include <QNetworkReply>
|
||||
#include <QOpenGLFramebufferObject>
|
||||
#include <QTimer>
|
||||
|
||||
#include <glm/gtc/random.hpp>
|
||||
|
||||
|
|