Skip to content

Commit 843e10d

Browse files
authored
Merge pull request #2237 from nids2001/vs-screenshots
Part of #2022
2 parents 69c15e5 + 026eb06 commit 843e10d

File tree

15 files changed

+164
-22
lines changed

15 files changed

+164
-22
lines changed

src/Core/Application/Preferences/Preferences.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@ void Preferences::setDataDirectory(const boost::filesystem::path& path, bool run
102102
#endif
103103
}
104104

105+
boost::filesystem::path Preferences::screenshotDirectory() const
106+
{
107+
return screenshotDir_;
108+
}
109+
110+
void Preferences::setScreenshotDirectory(const boost::filesystem::path& path)
111+
{
112+
screenshotDir_ = path;
113+
114+
if (!boost::filesystem::exists(path))
115+
logWarning("Data directory {} does not exist.", path.string());
116+
if (!boost::filesystem::is_directory(path))
117+
logWarning("Data directory {} is not a directory.", path.string());
118+
119+
if (screenshotDir_.string().back() == boost::filesystem::path::preferred_separator)
120+
{
121+
screenshotDir_.remove_filename();
122+
}
123+
}
124+
105125
/// @todo: not sure where this should go.
106126
std::string Preferences::dataDirectoryPlaceholder() const
107127
{

src/Core/Application/Preferences/Preferences.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,16 @@ namespace SCIRun
102102
boost::filesystem::path dataDirectory() const;
103103
void setDataDirectory(const boost::filesystem::path& path, bool runPython = true);
104104

105+
boost::filesystem::path screenshotDirectory() const;
106+
void setScreenshotDirectory(const boost::filesystem::path& path);
107+
105108
std::vector<boost::filesystem::path> dataPath() const;
106109
void addToDataPath(const boost::filesystem::path& path);
107110
void setDataPath(const std::string& dirs); // ;-delimited
108111

109112
private:
110113
boost::filesystem::path dataDir_;
114+
boost::filesystem::path screenshotDir_;
111115
std::vector<boost::filesystem::path> dataPath_;
112116
};
113117

src/Interface/Application/Preferences.ui

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<x>0</x>
88
<y>0</y>
99
<width>738</width>
10-
<height>469</height>
10+
<height>484</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -36,8 +36,8 @@
3636
<rect>
3737
<x>0</x>
3838
<y>0</y>
39-
<width>714</width>
40-
<height>343</height>
39+
<width>720</width>
40+
<height>370</height>
4141
</rect>
4242
</property>
4343
<attribute name="label">
@@ -284,35 +284,35 @@
284284
<rect>
285285
<x>0</x>
286286
<y>0</y>
287-
<width>714</width>
288-
<height>343</height>
287+
<width>720</width>
288+
<height>370</height>
289289
</rect>
290290
</property>
291291
<attribute name="label">
292292
<string>Paths</string>
293293
</attribute>
294294
<layout class="QGridLayout" name="gridLayout_5">
295-
<item row="0" column="0">
296-
<widget class="QGroupBox" name="pathSettingsGroupBox_">
295+
<item row="1" column="0">
296+
<widget class="QGroupBox" name="screenshotSettingsGroupBox_">
297297
<property name="enabled">
298298
<bool>true</bool>
299299
</property>
300300
<property name="title">
301-
<string>SCIRun Path Settings</string>
301+
<string>ViewScene Screenshot Path Settings</string>
302302
</property>
303303
<property name="alignment">
304304
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
305305
</property>
306306
<layout class="QGridLayout" name="gridLayout_4">
307307
<item row="0" column="0">
308-
<widget class="QLabel" name="scirunDataLabel_">
308+
<widget class="QLabel" name="screenshotLabel_">
309309
<property name="text">
310-
<string>SCIRun Data</string>
310+
<string>Screenshot Path</string>
311311
</property>
312312
</widget>
313313
</item>
314314
<item row="0" column="1">
315-
<widget class="QLineEdit" name="scirunDataLineEdit_">
315+
<widget class="QLineEdit" name="screenshotLineEdit_">
316316
<property name="enabled">
317317
<bool>true</bool>
318318
</property>
@@ -322,7 +322,7 @@
322322
</widget>
323323
</item>
324324
<item row="0" column="2">
325-
<widget class="QPushButton" name="scirunDataPushButton_">
325+
<widget class="QPushButton" name="screenshotPathPushButton_">
326326
<property name="enabled">
327327
<bool>true</bool>
328328
</property>
@@ -334,7 +334,7 @@
334334
</layout>
335335
</widget>
336336
</item>
337-
<item row="1" column="0">
337+
<item row="3" column="0">
338338
<spacer name="verticalSpacer_2">
339339
<property name="orientation">
340340
<enum>Qt::Vertical</enum>
@@ -347,15 +347,57 @@
347347
</property>
348348
</spacer>
349349
</item>
350+
<item row="0" column="0">
351+
<widget class="QGroupBox" name="pathSettingsGroupBox_">
352+
<property name="enabled">
353+
<bool>true</bool>
354+
</property>
355+
<property name="title">
356+
<string>SCIRun Path Settings</string>
357+
</property>
358+
<property name="alignment">
359+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
360+
</property>
361+
<layout class="QGridLayout" name="gridLayout_4">
362+
<item row="0" column="0">
363+
<widget class="QLabel" name="scirunDataLabel_">
364+
<property name="text">
365+
<string>SCIRun Data</string>
366+
</property>
367+
</widget>
368+
</item>
369+
<item row="0" column="1">
370+
<widget class="QLineEdit" name="scirunDataLineEdit_">
371+
<property name="enabled">
372+
<bool>true</bool>
373+
</property>
374+
<property name="readOnly">
375+
<bool>true</bool>
376+
</property>
377+
</widget>
378+
</item>
379+
<item row="0" column="2">
380+
<widget class="QPushButton" name="scirunDataPushButton_">
381+
<property name="enabled">
382+
<bool>true</bool>
383+
</property>
384+
<property name="text">
385+
<string>Set...</string>
386+
</property>
387+
</widget>
388+
</item>
389+
</layout>
390+
</widget>
391+
</item>
350392
</layout>
351393
</widget>
352394
<widget class="QWidget" name="toolBoxPage2">
353395
<property name="geometry">
354396
<rect>
355397
<x>0</x>
356398
<y>0</y>
357-
<width>714</width>
358-
<height>343</height>
399+
<width>753</width>
400+
<height>143</height>
359401
</rect>
360402
</property>
361403
<attribute name="label">
3.38 KB
Loading
251 Bytes
Loading

src/Interface/Application/SCIRunMainWindow.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ SCIRunMainWindow::SCIRunMainWindow()
227227
makeFilterButtonMenu();
228228

229229
connect(prefsWindow_->scirunDataPushButton_, SIGNAL(clicked()), this, SLOT(setDataDirectoryFromGUI()));
230+
connect(prefsWindow_->screenshotPathPushButton_, SIGNAL(clicked()), this, SLOT(setScreenshotDirectoryFromGUI()));
230231
//connect(prefsWindow_->addToPathButton_, SIGNAL(clicked()), this, SLOT(addToPathFromGUI()));
231232
connect(actionFilter_modules_, SIGNAL(triggered()), this, SLOT(setFocusOnFilterLine()));
232233
connect(actionAddModule_, SIGNAL(triggered()), this, SLOT(addModuleKeyboardAction()));

src/Interface/Application/SCIRunMainWindow.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class SCIRunMainWindow : public QMainWindow, public Ui::SCIRunMainWindow
9090
void setCurrentFile(const QString& fileName);
9191
void setDataDirectory(const QString& dir);
9292
void setDataPath(const QString& dirs);
93+
void setScreenshotDirectory(const QString& dir);
9394
void setupQuitAfterExecute();
9495

9596
//TODO: extract another interface for command objects
@@ -110,6 +111,7 @@ public Q_SLOTS:
110111
void executeAll();
111112
void showZoomStatusMessage(int zoomLevel);
112113
void setDataDirectoryFromGUI();
114+
void setScreenshotDirectoryFromGUI();
113115
void setConnectionPipelineType(int type);
114116
void setSaveBeforeExecute(int state);
115117
void reportIssue();

src/Interface/Application/SCIRunMainWindowCommandInterface.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,18 @@ void SCIRunMainWindow::setDataDirectory(const QString& dir)
232232
}
233233
}
234234

235+
void SCIRunMainWindow::setScreenshotDirectory(const QString& dir)
236+
{
237+
if (!dir.isEmpty())
238+
{
239+
prefsWindow_->screenshotLineEdit_->setText(dir);
240+
prefsWindow_->screenshotLineEdit_->setToolTip(dir);
241+
242+
RemembersFileDialogDirectory::setStartingDir(dir);
243+
Preferences::Instance().setScreenshotDirectory(dir.toStdString());
244+
}
245+
}
246+
235247
void SCIRunMainWindow::setDataPath(const QString& dirs)
236248
{
237249
if (!dirs.isEmpty())

src/Interface/Application/SCIRunMainWindowSlotsPublic.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,15 @@ void SCIRunMainWindow::setDataDirectoryFromGUI()
102102
settings.setValue("dataDirectory", QString::fromStdString(Preferences::Instance().dataDirectory().string()));
103103
}
104104
}
105+
106+
void SCIRunMainWindow::setScreenshotDirectoryFromGUI()
107+
{
108+
auto dir = QFileDialog::getExistingDirectory(this, tr("Choose Screenshot Directory"), QString::fromStdString(Core::Preferences::Instance().screenshotDirectory().parent_path().string()));
109+
setScreenshotDirectory(dir);
110+
111+
{
112+
QSettings settings;
113+
settings.setValue("screenshotDirectory", QString::fromStdString(Preferences::Instance().screenshotDirectory().string()));
114+
}
115+
116+
}

src/Interface/Application/Settings.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ void SCIRunMainWindow::readSettings()
322322
makeSetting("dataDirectory", toString,
323323
[this](const QString& s) { setDataDirectory(s); },
324324
[]() { return QString::fromStdString(prefs.dataDirectory().string()); }),
325+
makeSetting("screenshotDirectory", toString,
326+
[this](const QString& s) { setScreenshotDirectory(s); },
327+
[]() { return QString::fromStdString(prefs.screenshotDirectory().string()); }),
325328
makeSetting("networkDirectory", toString,
326329
[this](const QString& s) { latestNetworkDirectory_.setPath(s); },
327330
[this]() { return latestNetworkDirectory_.path(); }),

0 commit comments

Comments
 (0)