Showing the changes to interface/src/ImportDialog.cpp (1 of 4 files). Show all
Unified · Split
| @@ -6,45 +6,48 @@ · 5 unmodified lines | ||
| 6 | 6 | // Copyright (c) 2013 High Fidelity, Inc. All rights reserved. |
| 7 | 7 | // |
| 8 | 8 | #include "ImportDialog.h" |
| 9 | −#include "Application.h" | |
| 10 | 9 | |
| 11 | 10 | #include <QStandardPaths> |
| 12 | 11 | #include <QGridLayout> |
| 13 | −#include <QMouseEvent> | |
| 12 | +#include <QSplitter> | |
| 14 | 13 | |
| 15 | −const QString WINDOW_NAME = QObject::tr("Import Voxels"); | |
| 16 | −const QString IMPORT_BUTTON_NAME = QObject::tr("Import"); | |
| 17 | −const QString IMPORT_FILE_TYPES = QObject::tr("Sparse Voxel Octree Files, " | |
| 18 | − "Square PNG, " | |
| 19 | − "Schematic Files " | |
| 20 | − "(*.svo *.png *.schematic)"); | |
| 14 | +const QString WINDOW_NAME = QObject::tr("Import Voxels"); | |
| 15 | +const QString IMPORT_BUTTON_NAME = QObject::tr("Import"); | |
| 16 | +const QString CANCEL_BUTTON_NAME = QObject::tr("Cancel"); | |
| 17 | +const QString IMPORT_FILE_TYPES = QObject::tr("Sparse Voxel Octree Files, " | |
| 18 | + "Square PNG, " | |
| 19 | + "Schematic Files " | |
| 20 | + "(*.svo *.png *.schematic)"); | |
| 21 | +const QString INFO_LABEL_TEXT = QObject::tr("This will load selected file into Hifi and\n" | |
| 22 | + "allow you to place it with Command V"); | |
| 21 | 23 | |
| 22 | 24 | const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); |
| 23 | 25 | |
| 24 | −ImportDialog::ImportDialog(QWidget *parent) | |
| 25 | − : QFileDialog(parent, WINDOW_NAME, DESKTOP_LOCATION, IMPORT_FILE_TYPES), | |
| 26 | − _importButton (IMPORT_BUTTON_NAME, this) { | |
| 26 | +ImportDialog::ImportDialog(QWidget *parent) : QFileDialog(parent, WINDOW_NAME, DESKTOP_LOCATION, IMPORT_FILE_TYPES), | |
| 27 | +_importButton(IMPORT_BUTTON_NAME, this), | |
| 28 | +_cancelButton(CANCEL_BUTTON_NAME, this), | |
| 29 | +_importLabel(IMPORT_BUTTON_NAME), | |
| 30 | +_infoLabel(INFO_LABEL_TEXT) { | |
| 31 | + | |
| 27 | 32 | setOption(QFileDialog::DontUseNativeDialog, true); |
| 28 | 33 | setFileMode(QFileDialog::ExistingFile); |
| 29 | 34 | setViewMode(QFileDialog::Detail); |
| 30 | 35 | |
| 36 | + setLayout(); | |
| 31 | 37 | QGridLayout* gridLayout = (QGridLayout*) layout(); |
| 32 | − gridLayout->addWidget(&_importButton , 2, 2); | |
| 38 | + gridLayout->addWidget(&_importLabel, 0, 0); | |
| 39 | + gridLayout->addWidget(&_infoLabel, 2, 0); | |
| 40 | + gridLayout->addWidget(&_cancelButton, 2, 1); | |
| 41 | + gridLayout->addWidget(&_importButton, 2, 2); | |
| 33 | 42 | gridLayout->setColumnStretch(3, 1); |
| 34 | 43 | |
| 35 | 44 | connect(&_importButton, SIGNAL(pressed()), SLOT(import())); |
| 36 | − | |
| 37 | 45 | connect(this, SIGNAL(currentChanged(QString)), SLOT(saveCurrentFile(QString))); |
| 38 | 46 | } |
| 39 | 47 | |
| 40 | 48 | ImportDialog::~ImportDialog() { |
| 41 | 49 | } |
| 42 | 50 | |
| 43 | −void ImportDialog::init() { | |
| 44 | − VoxelSystem* voxelSystem = Application::getInstance()->getSharedVoxelSystem(); | |
| 45 | − connect(voxelSystem, SIGNAL(importSize(float,float,float)), SLOT(setGLCamera(float,float,float))); | |
| 46 | −} | |
| 47 | − | |
| 48 | 51 | void ImportDialog::import() { |
| 49 | 52 | _importButton.setDisabled(true); |
| 50 | 53 | emit accepted(); |
| @@ -69,3 +72,72 @@ void ImportDialog::reset() { · 18 unmodified lines | ||
| 69 | 72 | void ImportDialog::saveCurrentFile(QString filename) { |
| 70 | 73 | _currentFile = filename; |
| 71 | 74 | } |
| 75 | + | |
| 76 | +void ImportDialog::setLayout() { | |
| 77 | + | |
| 78 | + // set ObjectName used in qss | |
| 79 | + _importButton.setObjectName("importButton"); | |
| 80 | + _cancelButton.setObjectName("cancelButton"); | |
| 81 | + | |
| 82 | + // set size policy used in | |
| 83 | + _importButton.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | |
| 84 | + _cancelButton.setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); | |
| 85 | + | |
| 86 | + // hide unused embeded widgets in QFileDialog | |
| 87 | + QWidget* widget = findChild<QWidget*>("lookInLabel"); | |
| 88 | + widget->hide(); | |
| 89 | + | |
| 90 | + widget = findChild<QWidget*>("lookInCombo"); | |
| 91 | + widget->hide(); | |
| 92 | + | |
| 93 | + widget = findChild<QWidget*>("backButton"); | |
| 94 | + widget->hide(); | |
| 95 | + | |
| 96 | + widget = findChild<QWidget*>("forwardButton"); | |
| 97 | + widget->hide(); | |
| 98 | + | |
| 99 | + widget = findChild<QWidget*>("toParentButton"); | |
| 100 | + widget->hide(); | |
| 101 | + | |
| 102 | + widget = findChild<QWidget*>("newFolderButton"); | |
| 103 | + widget->hide(); | |
| 104 | + | |
| 105 | + widget = findChild<QWidget*>("listModeButton"); | |
| 106 | + widget->hide(); | |
| 107 | + | |
| 108 | + widget = findChild<QWidget*>("detailModeButton"); | |
| 109 | + widget->hide(); | |
| 110 | + | |
| 111 | + widget = findChild<QWidget*>("fileNameEdit"); | |
| 112 | + widget->hide(); | |
| 113 | + | |
| 114 | + widget = findChild<QWidget*>("fileNameLabel"); | |
| 115 | + widget->hide(); | |
| 116 | + | |
| 117 | + widget = findChild<QWidget*>("fileTypeCombo"); | |
| 118 | + widget->hide(); | |
| 119 | + | |
| 120 | + widget = findChild<QWidget*>("fileTypeLabel"); | |
| 121 | + widget->hide(); | |
| 122 | + | |
| 123 | + widget = findChild<QWidget*>("buttonBox"); | |
| 124 | + widget->hide(); | |
| 125 | + | |
| 126 | + QSplitter *splitter = findChild<QSplitter*>("splitter"); | |
| 127 | + splitter->setHandleWidth(0); | |
| 128 | + | |
| 129 | + // remove blue outline on Mac | |
| 130 | + widget = findChild<QWidget*>("sidebar"); | |
| 131 | + widget->setAttribute(Qt::WA_MacShowFocusRect, false); | |
| 132 | + widget = findChild<QWidget*>("treeView"); | |
| 133 | + widget->setAttribute(Qt::WA_MacShowFocusRect, false); | |
| 134 | + | |
| 135 | + // set custom file icons | |
| 136 | + // setIconProvider(new HiFiIconProvider()); | |
| 137 | + | |
| 138 | + switchToResourcesParentIfRequired(); | |
| 139 | + QFile styleSheet("resources/styles/import_dialog.qss"); | |
| 140 | + if (styleSheet.open(QIODevice::ReadOnly)) { | |
| 141 | + setStyleSheet(styleSheet.readAll()); | |
| 142 | + } | |
| 143 | +} | |