New static data location for read-only data files

Access in CMake via ${WSJT_SHARE_DESTINATION}/${WSJT_DATA_DESTINATION}

Access in wsjtx.exe using Configuration::data_dir()

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@5487 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2015-06-01 21:47:55 +00:00
parent 6248063353
commit 78eb749b50
4 changed files with 29 additions and 4 deletions

View File

@ -152,6 +152,7 @@ set (WSJT_BIN_DESTINATION bin)
set (WSJT_LIB_DESTINATION lib)
set (WSJT_SHARE_DESTINATION share)
set (WSJT_DOC_DESTINATION doc/${CMAKE_PROJECT_NAME})
set (WSJT_DATA_DESTINATION ${CMAKE_PROJECT_NAME})
set (WSJT_MANPAGE_DESTINATION share)
set (WSJT_PLUGIN_DESTINATION lib/plugins)
set (WSJT_QT_CONF_DESTINATION bin)
@ -159,6 +160,7 @@ set (WSJT_QT_CONF_DESTINATION bin)
if (WIN32)
set (WSJT_SHARE_DESTINATION bin)
set (WSJT_DOC_DESTINATION doc)
set (WSJT_DATA_DESTINATION data)
set (WSJT_PLUGIN_DESTINATION plugins)
endif (WIN32)
@ -167,6 +169,7 @@ if (APPLE)
set (WSJT_SHARE_DESTINATION ${CMAKE_PROJECT_NAME}.app/Contents/Resources)
set (WSJT_MANPAGE_DESTINATION ${CMAKE_PROJECT_NAME}.app/Contents/Resources)
set (WSJT_DOC_DESTINATION doc)
set (WSJT_DATA_DESTINATION data)
set (WSJT_PLUGIN_DESTINATION ${CMAKE_PROJECT_NAME}.app/Contents/PlugIns)
set (WSJT_QT_CONF_DESTINATION ${CMAKE_PROJECT_NAME}.app/Contents/Resources)
endif (APPLE)

View File

@ -442,6 +442,7 @@ private:
QSettings * settings_;
QDir doc_dir_;
QDir data_dir_;
QDir temp_dir_;
QDir default_save_directory_;
QDir save_directory_;
@ -569,6 +570,7 @@ Configuration::~Configuration ()
}
QDir Configuration::doc_dir () const {return m_->doc_dir_;}
QDir Configuration::data_dir () const {return m_->data_dir_;}
QDir Configuration::temp_dir () const {return m_->temp_dir_;}
int Configuration::exec () {return m_->exec ();}
@ -700,6 +702,7 @@ Configuration::impl::impl (Configuration * self, QSettings * settings, QWidget *
, ui_ {new Ui::configuration_dialog}
, settings_ {settings}
, doc_dir_ {QApplication::applicationDirPath ()}
, data_dir_ {QApplication::applicationDirPath ()}
, frequencies_ {&bands_}
, next_frequencies_ {&bands_}
, stations_ {&bands_}
@ -719,15 +722,15 @@ Configuration::impl::impl (Configuration * self, QSettings * settings, QWidget *
{
ui_->setupUi (this);
#if !defined (CMAKE_BUILD)
#define WSJT_SHARE_DESTINATION "."
#define WSJT_DOC_DESTINATION "."
#define WSJT_DATA_DESTINATION "."
#endif
#if !defined (Q_OS_WIN) || QT_VERSION >= 0x050300
auto path = QStandardPaths::locate (QStandardPaths::DataLocation, WSJT_DOC_DESTINATION, QStandardPaths::LocateDirectory);
if (path.isEmpty ())
auto doc_path = QStandardPaths::locate (QStandardPaths::DataLocation, WSJT_DOC_DESTINATION, QStandardPaths::LocateDirectory);
if (doc_path.isEmpty ())
{
doc_dir_.cdUp ();
#if defined (Q_OS_MAC)
@ -739,10 +742,27 @@ Configuration::impl::impl (Configuration * self, QSettings * settings, QWidget *
}
else
{
doc_dir_.cd (path);
doc_dir_.cd (doc_path);
}
auto data_path = QStandardPaths::locate (QStandardPaths::DataLocation, WSJT_DATA_DESTINATION, QStandardPaths::LocateDirectory);
if (data_path.isEmpty ())
{
data_dir_.cdUp ();
#if defined (Q_OS_MAC)
data_dir_.cdUp ();
data_dir_.cdUp ();
#endif
data_dir_.cd (WSJT_SHARE_DESTINATION);
data_dir_.cd (WSJT_DATA_DESTINATION);
}
else
{
data_dir_.cd (data_path);
}
#else
doc_dir_.cd (WSJT_DOC_DESTINATION);
data_dir_.cd (WSJT_DATA_DESTINATION);
#endif
{

View File

@ -73,6 +73,7 @@ public:
QDir temp_dir () const;
QDir doc_dir () const;
QDir data_dir () const;
QAudioDeviceInfo const& audio_input_device () const;
AudioDevice::Channel audio_input_channel () const;

View File

@ -13,6 +13,7 @@
#cmakedefine WSJT_SHARE_DESTINATION "@WSJT_SHARE_DESTINATION@"
#cmakedefine WSJT_LIB_DESTINATION "@WSJT_LIB_DESTINATION@"
#cmakedefine WSJT_DOC_DESTINATION "@WSJT_DOC_DESTINATION@"
#cmakedefine WSJT_DATA_DESTINATION "@WSJT_DATA_DESTINATION@"
#cmakedefine PROJECT_MANUAL "@PROJECT_MANUAL@"
#cmakedefine PROJECT_MANUAL_DIRECTORY_URL "@PROJECT_MANUAL_DIRECTORY_URL@"