Verified Commit 9a185997 authored by Tobias WEBER's avatar Tobias WEBER
Browse files

using home directories again in file dialogs

parent 242e0e5f
......@@ -403,7 +403,7 @@ ConfigSpaceDlg::ConfigSpaceDlg(QWidget* parent, QSettings *sett)
if(!this->m_pathsbuilder)
return;
QString dirLast = this->m_sett->value("configspace/cur_dir", "~/").toString();
QString dirLast = this->m_sett->value("configspace/cur_dir", g_homepath.c_str()).toString();
QString filename = QFileDialog::getSaveFileName(
this, "Save Line Segments", dirLast, "XML Files (*.xml)");
......@@ -419,7 +419,7 @@ ConfigSpaceDlg::ConfigSpaceDlg(QWidget* parent, QSettings *sett)
// export figure as pdf file
auto savePDF = [this]()
{
QString dirLast = this->m_sett->value("configspace/cur_dir", "~/").toString();
QString dirLast = this->m_sett->value("configspace/cur_dir", g_homepath.c_str()).toString();
QString filename = QFileDialog::getSaveFileName(
this, "Save PDF Figure", dirLast, "PDF Files (*.pdf)");
if(filename=="")
......@@ -436,7 +436,7 @@ ConfigSpaceDlg::ConfigSpaceDlg(QWidget* parent, QSettings *sett)
if(!this->m_pathsbuilder)
return;
QString dirLast = this->m_sett->value("configspace/cur_dir", "~/").toString();
QString dirLast = this->m_sett->value("configspace/cur_dir", g_homepath.c_str()).toString();
QString filename = QFileDialog::getSaveFileName(
this, "Save DOT Graph", dirLast, "DOT Files (*.dot)");
if(filename=="")
......@@ -456,7 +456,7 @@ ConfigSpaceDlg::ConfigSpaceDlg(QWidget* parent, QSettings *sett)
{
std::shared_ptr<PathsExporterBase> exporter;
QString dirLast = this->m_sett->value("configspace/cur_dir", "~/").toString();
QString dirLast = this->m_sett->value("configspace/cur_dir", g_homepath.c_str()).toString();
QString filename = QFileDialog::getSaveFileName(
this, "Export Path", dirLast, "Text Files (*.txt)");
if(filename=="")
......
......@@ -166,7 +166,7 @@ void PathsTool::NewFile()
*/
void PathsTool::OpenFile()
{
QString dirLast = m_sett.value("cur_dir", "").toString();
QString dirLast = m_sett.value("cur_dir", g_homepath.c_str()).toString();
QFileDialog filedlg(this, "Open Instrument File", dirLast,
"TAS-Paths Files (*.taspaths)");
......@@ -203,7 +203,7 @@ void PathsTool::SaveFile()
*/
void PathsTool::SaveFileAs()
{
QString dirLast = m_sett.value("cur_dir", "").toString();
QString dirLast = m_sett.value("cur_dir", g_homepath.c_str()).toString();
QFileDialog filedlg(this, "Save Instrument File", dirLast,
"TAS-Paths Files (*.taspaths)");
......@@ -228,7 +228,7 @@ void PathsTool::SaveFileAs()
*/
void PathsTool::SaveScreenshot()
{
QString dirLast = m_sett.value("cur_dir", "").toString();
QString dirLast = m_sett.value("cur_dir", g_homepath.c_str()).toString();
QFileDialog filedlg(this, "Save Screenshot", dirLast,
"PNG Images (*.png);;JPEG Images (*.jpg)");
......@@ -261,7 +261,7 @@ bool PathsTool::ExportPath(PathsExporterFormat fmt)
{
std::shared_ptr<PathsExporterBase> exporter;
QString dirLast = m_sett.value("cur_dir", "").toString();
QString dirLast = m_sett.value("cur_dir", g_homepath.c_str()).toString();
QFileDialog filedlg(this, "Export Path", dirLast,
"Text Files (*.txt)");
......
......@@ -207,7 +207,7 @@ XtalConfigSpaceDlg::XtalConfigSpaceDlg(QWidget* parent, QSettings *sett)
// export figure as pdf file
auto savePDF = [this]()
{
QString dirLast = this->m_sett->value("xtalconfigspace/cur_dir", "~/").toString();
QString dirLast = this->m_sett->value("xtalconfigspace/cur_dir", g_homepath.c_str()).toString();
QString filename = QFileDialog::getSaveFileName(
this, "Save PDF Figure", dirLast, "PDF Files (*.pdf)");
if(filename=="")
......
......@@ -55,8 +55,11 @@ public:
//setApplicationDisplayName(TASPATHS_TITLE);
setApplicationVersion(TASPATHS_VERSION);
// application path
// paths
g_apppath = applicationDirPath().toStdString();
g_homepath = QDir::homePath().toStdString();
// qt plugin libraries
addLibraryPath(applicationDirPath() + QDir::separator() + ".." +
QDir::separator() + "Libraries" + QDir::separator() + "Qt_Plugins");
#ifdef DEBUG
......
......@@ -35,8 +35,9 @@
// resource manager
Resources g_res{};
// application path
// application binary and home directory path
std::string g_apppath = ".";
std::string g_homepath = "~/";
// maximum number of threads
......
......@@ -46,8 +46,9 @@
// resource manager
extern Resources g_res;
// application binary path
// application binary and home directory path
extern std::string g_apppath;
extern std::string g_homepath;
// maximum number of threads for calculations
extern unsigned int g_maxnum_threads;
......
......@@ -33,6 +33,7 @@
#else
#include <QtWidgets/QActionGroup>
#endif
#include <QtCore/QDir>
#include <QtGui/QMouseEvent>
#include <QtWidgets/QApplication>
#include <QtWidgets/QMenuBar>
......@@ -673,7 +674,7 @@ HullWnd::HullWnd(QWidget* pParent) : QMainWindow{pParent},
QAction *actionExportSvg = new QAction{QIcon::fromTheme("image-x-generic"), "Export SVG...", this};
connect(actionExportSvg, &QAction::triggered, [this]()
{
QString dirLast = m_sett.value("recent_dir", "~/").toString();
QString dirLast = m_sett.value("recent_dir", QDir::homePath()).toString();
if(QString file = QFileDialog::getSaveFileName(
this, "Export SVG", dirLast,
......@@ -1116,7 +1117,7 @@ bool HullWnd::OpenFile(const QString& file)
*/
void HullWnd::OpenFile()
{
QString dirLast = m_sett.value("recent_dir", "~/").toString();
QString dirLast = m_sett.value("recent_dir", QDir::homePath()).toString();
if(QString file = QFileDialog::getOpenFileName(this,
"Open Data", dirLast,
......@@ -1186,7 +1187,7 @@ void HullWnd::SaveFile()
*/
void HullWnd::SaveFileAs()
{
QString dirLast = m_sett.value("recent_dir", "~/").toString();
QString dirLast = m_sett.value("recent_dir", QDir::homePath()).toString();
if(QString file = QFileDialog::getSaveFileName(this,
"Save Data", dirLast,
......
......@@ -33,6 +33,7 @@
#else
#include <QtWidgets/QActionGroup>
#endif
#include <QtCore/QDir>
#include <QtGui/QMouseEvent>
#include <QtWidgets/QApplication>
#include <QtWidgets/QMenuBar>
......@@ -932,7 +933,7 @@ LinesWnd::LinesWnd(QWidget* pParent) : QMainWindow{pParent},
QAction *actionExportSvg = new QAction{QIcon::fromTheme("image-x-generic"), "Export SVG...", this};
connect(actionExportSvg, &QAction::triggered, [this]()
{
QString dirLast = m_sett.value("recent_dir", "~/").toString();
QString dirLast = m_sett.value("recent_dir", QDir::homePath()).toString();
if(QString file = QFileDialog::getSaveFileName(this,
"Export SVG", dirLast,
......@@ -950,7 +951,7 @@ LinesWnd::LinesWnd(QWidget* pParent) : QMainWindow{pParent},
QAction *actionExportGraph = new QAction{"Export Voronoi Graph...", this};
connect(actionExportGraph, &QAction::triggered, [this]()
{
QString dirLast = m_sett.value("recent_dir", "~/").toString();
QString dirLast = m_sett.value("recent_dir", QDir::homePath()).toString();
if(QString file = QFileDialog::getSaveFileName(this,
"Export DOT", dirLast,
......@@ -1469,7 +1470,7 @@ bool LinesWnd::OpenFile(const QString& file)
*/
void LinesWnd::OpenFile()
{
QString dirLast = m_sett.value("recent_dir", "~/").toString();
QString dirLast = m_sett.value("recent_dir", QDir::homePath()).toString();
if(QString file = QFileDialog::getOpenFileName(this,
"Open Data", dirLast,
......@@ -1539,7 +1540,7 @@ void LinesWnd::SaveFile()
*/
void LinesWnd::SaveFileAs()
{
QString dirLast = m_sett.value("recent_dir", "~/").toString();
QString dirLast = m_sett.value("recent_dir", QDir::homePath()).toString();
if(QString file = QFileDialog::getSaveFileName(this,
"Save Data", dirLast,
......
......@@ -28,13 +28,14 @@
#include "poly.h"
#include <QtCore/QDir>
#include <QtGui/QMouseEvent>
#include <QtWidgets/QApplication>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QLabel>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QFileDialog>
#include <QtWidgets/QMessageBox>
#include <QtGui/QMouseEvent>
#include <QtSvg/QSvgGenerator>
#include <locale>
......@@ -442,7 +443,7 @@ PolyWnd::PolyWnd(QWidget* pParent) : QMainWindow{pParent},
QAction *actionExportSvg = new QAction{QIcon::fromTheme("image-x-generic"), "Export SVG...", this};
connect(actionExportSvg, &QAction::triggered, [this]()
{
QString dirLast = m_sett.value("recent_dir", "~/").toString();
QString dirLast = m_sett.value("recent_dir", QDir::homePath()).toString();
if(QString file = QFileDialog::getSaveFileName(this,
"Export SVG", dirLast,
......@@ -737,7 +738,7 @@ bool PolyWnd::OpenFile(const QString& file)
*/
void PolyWnd::OpenFile()
{
QString dirLast = m_sett.value("recent_dir", "~/").toString();
QString dirLast = m_sett.value("recent_dir", QDir::homePath()).toString();
if(QString file = QFileDialog::getOpenFileName(this,
"Load Data", dirLast,
......@@ -807,7 +808,7 @@ void PolyWnd::SaveFile()
*/
void PolyWnd::SaveFileAs()
{
QString dirLast = m_sett.value("recent_dir", "~/").toString();
QString dirLast = m_sett.value("recent_dir", QDir::homePath()).toString();
if(QString file = QFileDialog::getSaveFileName(this,
"Save Data", dirLast,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment