Skip to content

Commit

Permalink
Use user home directory for runs home
Browse files Browse the repository at this point in the history
On Windows, if one launches koviz from a desktop
icon, the koviz run directory is set to the
koviz install location.  Instead, default the
runs home to the user's home directory.
  • Loading branch information
keithvetter committed Aug 21, 2024
1 parent c10eda1 commit 968707f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libkoviz/runswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ RunsWidget::RunsWidget(Runs *runs,

// Dir/File model
_fileModel = new QFileSystemModel;

// Set initial runs home
_runsHome = QDir::currentPath();
QString exePath = _runsHome + QDir::separator() + "koviz.exe";
QString iconPath = _runsHome + QDir::separator() + "koviz.ico";
if (QFile::exists(exePath) && QFile::exists(iconPath)) {
// If koviz.exe and koviz.ico are in the current path,
// assume this is being launched from a Windows install location.
// In this case, set runs home to user's home directory
_runsHome = QStandardPaths::
writableLocation(QStandardPaths::HomeLocation);
}
_fileModel->setRootPath(_runsHome);

// Filter
Expand All @@ -38,7 +49,7 @@ RunsWidget::RunsWidget(Runs *runs,
_gridLayout->addWidget(_fileTreeView,1,0);

// Set browser root path
QModelIndex sourceIndex = _fileModel->index(QDir::currentPath());
QModelIndex sourceIndex = _fileModel->index(_runsHome);
QModelIndex proxyIndex = _filterModel->mapFromSource(sourceIndex);
_fileTreeView->setRootIndex(proxyIndex);
}
Expand Down
1 change: 1 addition & 0 deletions libkoviz/runswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <QFileSystemModel>
#include <QSortFilterProxyModel>
#include <QRegExp>
#include <QStandardPaths>

#include "bookmodel.h"
#include "monteinputsview.h"
Expand Down

0 comments on commit 968707f

Please sign in to comment.