|
|
|
@ -44,6 +44,14 @@ CSMSettings::UserSettings::UserSettings()
|
|
|
|
|
|
|
|
|
|
mSettings = 0;
|
|
|
|
|
|
|
|
|
|
mReadWriteMessage = QObject::tr("<br><b>Could not open or create file for \
|
|
|
|
|
writing</b><br><br> Please make sure you have the right\
|
|
|
|
|
permissions and try again.<br>");
|
|
|
|
|
|
|
|
|
|
mReadOnlyMessage = QObject::tr("<br><b>Could not open file for \
|
|
|
|
|
reading</b><br><br> Please make sure you have the \
|
|
|
|
|
right permissions and try again.<br>");
|
|
|
|
|
|
|
|
|
|
buildSettingModelDefaults();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -131,10 +139,10 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|
|
|
|
* proxy slave settings, but must match any declared values the proxy
|
|
|
|
|
* slave has, if any.
|
|
|
|
|
*******************************************************************/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
//create setting objects, specifying the basic widget type,
|
|
|
|
|
//the page name, and the view name
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
Setting *masterBoolean = createSetting (Type_RadioButton, section,
|
|
|
|
|
"Master Proxy");
|
|
|
|
|
|
|
|
|
@ -234,6 +242,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|
|
|
|
slaveIntegerSpinbox->setSerializable (false);
|
|
|
|
|
slaveDoubleSpinbox->setSerializable (false);
|
|
|
|
|
slaveSlider->setSerializable (false);
|
|
|
|
|
slaveDial->setSerializable (false);
|
|
|
|
|
|
|
|
|
|
slaveBoolean->setDefaultValues (QStringList()
|
|
|
|
|
<< "One" << "Three" << "Five");
|
|
|
|
@ -285,9 +294,34 @@ CSMSettings::UserSettings::~UserSettings()
|
|
|
|
|
mUserSettingsInstance = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMSettings::UserSettings::displayFileErrorMessage
|
|
|
|
|
(const QString &userpath,
|
|
|
|
|
const QString &globalpath,
|
|
|
|
|
const QString &localpath) const
|
|
|
|
|
{
|
|
|
|
|
QString message = QObject::tr("<br><b>An error was encountered loading \
|
|
|
|
|
user settings files.</b><br><br> One or several files could not \
|
|
|
|
|
be read. This may be caused by a missing configuration file, \
|
|
|
|
|
incorrect file permissions or a corrupted installation of \
|
|
|
|
|
OpenCS.<br>");
|
|
|
|
|
|
|
|
|
|
message += QObject::tr("<br>Global filepath: ") + globalpath;
|
|
|
|
|
message += QObject::tr("<br>Local filepath: ") + localpath;
|
|
|
|
|
message += QObject::tr("<br>User filepath: ") + userpath;
|
|
|
|
|
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
|
|
|
|
|
msgBox.setWindowTitle(QObject::tr("OpenCS configuration file I/O error"));
|
|
|
|
|
msgBox.setIcon(QMessageBox::Critical);
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
|
|
|
|
|
|
msgBox.setText (mReadWriteMessage + message);
|
|
|
|
|
msgBox.exec();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
|
|
|
|
{
|
|
|
|
|
mUserFilePath = QString::fromUtf8
|
|
|
|
|
QString userFilePath = QString::fromUtf8
|
|
|
|
|
(mCfgMgr.getUserConfigPath().string().c_str());
|
|
|
|
|
|
|
|
|
|
QString globalFilePath = QString::fromUtf8
|
|
|
|
@ -296,7 +330,7 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
|
|
|
|
QString localFilePath = QString::fromUtf8
|
|
|
|
|
(mCfgMgr.getLocalPath().string().c_str());
|
|
|
|
|
|
|
|
|
|
bool isUser = QFile (mUserFilePath + fileName).exists();
|
|
|
|
|
bool isUser = QFile (userFilePath + fileName).exists();
|
|
|
|
|
bool isSystem = QFile (globalFilePath + fileName).exists();
|
|
|
|
|
|
|
|
|
|
QString otherFilePath = globalFilePath;
|
|
|
|
@ -311,22 +345,12 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
|
|
|
|
//error condition - notify and return
|
|
|
|
|
if (!isUser || !isSystem)
|
|
|
|
|
{
|
|
|
|
|
QString message = QObject::tr("<br><b>An error was encountered loading \
|
|
|
|
|
user settings files.</b><br><br> One or several files could not \
|
|
|
|
|
be read. This may be caused by a missing configuration file, \
|
|
|
|
|
incorrect file permissions or a corrupted installation of \
|
|
|
|
|
OpenCS.<br>");
|
|
|
|
|
|
|
|
|
|
message += QObject::tr("<br>Global filepath: ") + globalFilePath;
|
|
|
|
|
message += QObject::tr("<br>Local filepath: ") + localFilePath;
|
|
|
|
|
message += QObject::tr("<br>User filepath: ") + mUserFilePath;
|
|
|
|
|
|
|
|
|
|
displayFileErrorMessage ( message, true);
|
|
|
|
|
displayFileErrorMessage (userFilePath, globalFilePath, localFilePath);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QSettings::setPath
|
|
|
|
|
(QSettings::IniFormat, QSettings::UserScope, mUserFilePath);
|
|
|
|
|
(QSettings::IniFormat, QSettings::UserScope, userFilePath);
|
|
|
|
|
|
|
|
|
|
QSettings::setPath
|
|
|
|
|
(QSettings::IniFormat, QSettings::SystemScope, otherFilePath);
|
|
|
|
|