Skip to content

Commit c553454

Browse files
committed
rti online view remembers location
1 parent bb774be commit c553454

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

relightlab/relightapp.cpp

+25-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "recentprojects.h"
55
#include "mainwindow.h"
66
#include "preferences.h"
7+
#include "../relight/httpserver.h"
78

89
#include <QMessageBox>
910
#include <QFileDialog>
@@ -104,7 +105,7 @@ RelightApp::RelightApp(int &argc, char **argv): QApplication(argc, argv) {
104105
addAction("show_list", "Show list", "list", "");
105106
addAction("show_grid", "Show grid", "grid", "");
106107

107-
addAction("view_rti", "View RTI", "cast", "");
108+
addAction("view_rti", "View RTI in browser", "cast", "", SLOT(rtiView()));
108109

109110
addAction("help", "Help", "help-circle", "");
110111
addAction("about", "About", "info", "");
@@ -352,6 +353,29 @@ void RelightApp::loadThumbnails() {
352353

353354
}
354355

356+
void RelightApp::rtiView() {
357+
QString last = lastViewDir();
358+
QString dirname = QFileDialog::getExistingDirectory(nullptr, "Select a folder containing an RTI in relight format: json and jpeg", last);
359+
if(dirname.isNull())
360+
return;
361+
QDir dir(dirname);
362+
QFileInfo info(dir.filePath("info.json"));
363+
if(!info.exists()) {
364+
QMessageBox::warning(nullptr, "Could not open relight folder", "It seems this folder do not contains an rti in relight format");
365+
return;
366+
}
367+
setLastViewDir(dirname);
368+
try {
369+
HttpServer &server = HttpServer::instance();
370+
server.stop();
371+
server.port = 8880;
372+
server.start(dirname);
373+
server.show();
374+
} catch(QString error) {
375+
QMessageBox::critical(nullptr, "Could not cast!", error);
376+
}
377+
}
378+
355379
void RelightApp::openPreferences() {
356380
if(!preferences)
357381
preferences = new Preferences(mainwindow);

relightlab/relightapp.h

+10
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public slots:
7272
void saveProject();
7373
void saveProjectAs();
7474
void close();
75+
void rtiView();
7576

7677
void openPreferences();
7778
void setDarkTheme(bool on);
@@ -88,6 +89,7 @@ public slots:
8889

8990
QAction *addAction(const QString &id, const QString &label, const QString &icon, const QString &shortcut, const char *method = nullptr);
9091
QAction *action(const QString &id) { return actions[id]; }
92+
9193
QString lastProjectDir() {
9294
return QSettings().value("LastProjectDir", QDir::homePath()).toString();
9395
}
@@ -107,6 +109,14 @@ public slots:
107109
void clearLastOutputDir() {
108110
last_output_dir = QString();
109111
}
112+
113+
QString lastViewDir() {
114+
return QSettings().value("LastViewDir", QDir::homePath()).toString();
115+
}
116+
void setLastViewDir(QString dir) {
117+
QSettings().setValue("LastViewDir", dir);
118+
}
119+
110120
bool needsSavingProceed();
111121

112122
QStringList domes();

relightlab/scaleframe.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ScaleFrame::ScaleFrame(QWidget *parent): QFrame(parent) {
2121
QHBoxLayout *controls = new QHBoxLayout;
2222
content->addLayout(controls);
2323

24-
QPushButton *take = new QPushButton("Take a new measurement...");
24+
QPushButton *take = new QPushButton("Set new scale measurement...");
2525
controls->addWidget(take);
2626

2727
scale = new QDoubleSpinBox;

0 commit comments

Comments
 (0)