forked from mirror/openmw-tes3mp
Final changes for record status icon feature, incl. window size user
preference 1. Included updated status icons, added base.png 2. Added doxygen comments CSV / CSM Settings classes 3. Implemented Glorf's code for window size preference 4. Minor changes code that searches maps in CSV / CSM Settings classes 5. Removed CSVSettings::SamplePage class 6. Other minor code maintenance / improvements
This commit is contained in:
parent
965d93ea40
commit
101c147217
39 changed files with 427 additions and 358 deletions
|
@ -78,7 +78,6 @@ opencs_units (view/settings
|
||||||
proxyblock
|
proxyblock
|
||||||
abstractwidget
|
abstractwidget
|
||||||
usersettingsdialog
|
usersettingsdialog
|
||||||
samplepage
|
|
||||||
editorpage
|
editorpage
|
||||||
windowpage
|
windowpage
|
||||||
)
|
)
|
||||||
|
|
|
@ -62,15 +62,9 @@ void CS::Editor::setupDataFiles()
|
||||||
mFileDialog.addFiles(path);
|
mFileDialog.addFiles(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Settings setup
|
//load the settings into the userSettings instance.
|
||||||
QStringList settingFiles;
|
const QString settingFileName = "opencs.cfg";
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
CSMSettings::UserSettings::instance().loadSettings(settingFileName);
|
||||||
|
|
||||||
settingFiles.append(QString("opencs.cfg"));
|
|
||||||
settingFiles.append(userPath + QString("opencs.cfg"));
|
|
||||||
|
|
||||||
mUserSettings.setSettingsFiles(settingFiles);
|
|
||||||
mUserSettings.readSettings();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,19 +15,31 @@ namespace CSMSettings
|
||||||
QStringList *mValues;
|
QStringList *mValues;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit SettingContainer (QObject *parent = 0);
|
explicit SettingContainer (QObject *parent = 0);
|
||||||
explicit SettingContainer (const QString &value, QObject *parent = 0);
|
explicit SettingContainer (const QString &value, QObject *parent = 0);
|
||||||
|
|
||||||
|
/// add a value to the container
|
||||||
|
/// multiple values supported
|
||||||
void insert (const QString &value);
|
void insert (const QString &value);
|
||||||
|
|
||||||
|
/// update an existing value
|
||||||
|
/// index specifies multiple values
|
||||||
void update (const QString &value, int index = 0);
|
void update (const QString &value, int index = 0);
|
||||||
|
|
||||||
|
/// return value at specified index
|
||||||
QString getValue (int index = -1) const;
|
QString getValue (int index = -1) const;
|
||||||
|
|
||||||
|
/// retrieve list of all values
|
||||||
inline QStringList *getValues() const { return mValues; }
|
inline QStringList *getValues() const { return mValues; }
|
||||||
|
|
||||||
|
/// return size of list
|
||||||
int count() const;
|
int count() const;
|
||||||
|
|
||||||
//test for empty container
|
/// test for empty container
|
||||||
//useful for default-constructed containers returned by QMap when invalid key is passed
|
/// useful for default-constructed containers returned by QMap when invalid key is passed
|
||||||
inline bool isEmpty() const { return (!mValue && !mValues); }
|
inline bool isEmpty() const { return (!mValue && !mValues); }
|
||||||
|
|
||||||
inline bool isMultiValue() const { return (mValues); }
|
inline bool isMultiValue() const { return (mValues); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,21 +66,10 @@ bool CSMSettings::SettingsItem::updateItem(int valueListIndex)
|
||||||
|
|
||||||
bool CSMSettings::SettingsItem::validate (const QString &value)
|
bool CSMSettings::SettingsItem::validate (const QString &value)
|
||||||
{
|
{
|
||||||
bool isValid = true;
|
|
||||||
|
|
||||||
//validation required only if a value list or min/max value pair has been provided
|
//validation required only if a value list or min/max value pair has been provided
|
||||||
if (mValueList->size()>0)
|
bool isValid = (mValueList->find(value) != mValueList->end());
|
||||||
{
|
|
||||||
for (QStringList::ConstIterator it = mValueList->begin(); it !=mValueList->end(); ++it)
|
|
||||||
{
|
|
||||||
isValid = ( value == *it);
|
|
||||||
|
|
||||||
if (isValid)
|
if (!isValid && mValuePair)
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (mValuePair)
|
|
||||||
{
|
{
|
||||||
int numVal = value.toInt();
|
int numVal = value.toInt();
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
namespace CSMSettings
|
namespace CSMSettings
|
||||||
{
|
{
|
||||||
|
/// Represents a setting including metadata
|
||||||
|
/// (valid values, ranges, defaults, and multivalue status
|
||||||
class SettingsItem : public SettingContainer
|
class SettingsItem : public SettingContainer
|
||||||
{
|
{
|
||||||
QStringPair *mValuePair;
|
QStringPair *mValuePair;
|
||||||
|
@ -24,14 +26,24 @@ namespace CSMSettings
|
||||||
QObject::setObjectName(name);
|
QObject::setObjectName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// updateItem overloads for updating setting value
|
||||||
|
/// provided a list of values (multi-valued),
|
||||||
|
/// a specific value
|
||||||
|
/// or an index value corresponding to the mValueList
|
||||||
bool updateItem (const QStringList *values);
|
bool updateItem (const QStringList *values);
|
||||||
bool updateItem (const QString &value);
|
bool updateItem (const QString &value);
|
||||||
bool updateItem (int valueListIndex);
|
bool updateItem (int valueListIndex);
|
||||||
|
|
||||||
|
/// retroeve list of valid values for setting
|
||||||
inline QStringList *getValueList() { return mValueList; }
|
inline QStringList *getValueList() { return mValueList; }
|
||||||
|
|
||||||
|
/// write list of valid values for setting
|
||||||
inline void setValueList (QStringList *valueList) { mValueList = valueList; }
|
inline void setValueList (QStringList *valueList) { mValueList = valueList; }
|
||||||
|
|
||||||
|
/// valuePair used for spin boxes (max / min)
|
||||||
inline QStringPair *getValuePair() { return mValuePair; }
|
inline QStringPair *getValuePair() { return mValuePair; }
|
||||||
|
|
||||||
|
/// set value range (spinbox / integer use)
|
||||||
inline void setValuePair (QStringPair valuePair) { mValuePair = new QStringPair(valuePair); }
|
inline void setValuePair (QStringPair valuePair) { mValuePair = new QStringPair(valuePair); }
|
||||||
|
|
||||||
inline bool isMultivalue () { return mIsMultiValue; }
|
inline bool isMultivalue () { return mIsMultiValue; }
|
||||||
|
@ -40,6 +52,11 @@ namespace CSMSettings
|
||||||
QString getDefaultValue () const;
|
QString getDefaultValue () const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/// Verifies that the supplied value is one of the following:
|
||||||
|
/// 1. Within the limits of the value pair (min / max)
|
||||||
|
/// 2. One of the values indicated in the value list
|
||||||
|
/// TODO: value list logic iterates QList. Should use find() instead.
|
||||||
bool validate (const QString &value);
|
bool validate (const QString &value);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,15 +54,7 @@ CSMSettings::UserSettings::~UserSettings()
|
||||||
mUserSettingsInstance = 0;
|
mUserSettingsInstance = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QTextStream *CSMSettings::UserSettings::openFileStream (const QString &filePath, bool isReadOnly) const
|
||||||
//QTextStream *CSMSettings::UserSettings::openFileStream (const QString &filePath, bool isReadOnly)
|
|
||||||
|
|
||||||
CSMSettings::SectionMap CSMSettings::UserSettings::getSettingsMap() const
|
|
||||||
{
|
|
||||||
return mSectionMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFile *CSMSettings::UserSettings::openFile (const QString &filename) const
|
|
||||||
{
|
{
|
||||||
QFile *file = new QFile(filePath);
|
QFile *file = new QFile(filePath);
|
||||||
|
|
||||||
|
@ -105,10 +97,7 @@ QFile *CSMSettings::UserSettings::openFile (const QString &filename) const
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSMSettings::UserSettings::writeFile(QMap<QString, CSMSettings::SettingList *> &settings)
|
bool CSMSettings::UserSettings::writeSettings(QMap<QString, CSMSettings::SettingList *> &settings)
|
||||||
|
|
||||||
//bool CSMSettings::UserSettings::writeFile(QFile *file, QMap<QString, CSMSettings::SettingList *> &settings) const
|
|
||||||
|
|
||||||
{
|
{
|
||||||
QTextStream *stream = openFileStream(mPaths.back());
|
QTextStream *stream = openFileStream(mPaths.back());
|
||||||
|
|
||||||
|
@ -130,10 +119,7 @@ bool CSMSettings::UserSettings::writeFile(QMap<QString, CSMSettings::SettingList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const CSMSettings::SectionMap &CSMSettings::UserSettings::getSettings()
|
const CSMSettings::SectionMap &CSMSettings::UserSettings::getSettings() const
|
||||||
|
|
||||||
//void CSMSettings::UserSettings::getSettings(QTextStream &stream, SectionMap §ions) const
|
|
||||||
|
|
||||||
{
|
{
|
||||||
return mSectionSettings;
|
return mSectionSettings;
|
||||||
}
|
}
|
||||||
|
@ -234,64 +220,20 @@ void CSMSettings::UserSettings::updateSettings (const QString §ionName, cons
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setting = (*settings)[settingName];
|
if (settings->find(settingName)!=settings->end())
|
||||||
|
|
||||||
if (setting)
|
|
||||||
emit signalUpdateEditorSetting (setting->objectName(), setting->getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSMSettings::UserSettings::readSettings()
|
|
||||||
{
|
|
||||||
CSMSettings::SectionMap sectionMap;
|
|
||||||
|
|
||||||
foreach (const QString &path, mSettingsFiles)
|
|
||||||
{
|
|
||||||
qDebug() << "Loading config file:" << qPrintable(path);
|
|
||||||
QFile file(path);
|
|
||||||
|
|
||||||
if (file.exists())
|
|
||||||
{
|
{
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
setting = settings->value(settingName);
|
||||||
{
|
emit signalUpdateEditorSetting (setting->objectName(), setting->getValue());
|
||||||
QMessageBox msgBox;
|
|
||||||
msgBox.setWindowTitle(tr("Error opening OpenCS configuration file"));
|
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
||||||
msgBox.setText(QObject::tr("<br><b>Could not open %0 for reading</b><br><br> \
|
|
||||||
Please make sure you have the right permissions \
|
|
||||||
and try again.<br>").arg(file.fileName()));
|
|
||||||
msgBox.exec();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream stream(&file);
|
|
||||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
|
||||||
|
|
||||||
|
|
||||||
getSettings(stream, mSectionMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::UserSettings::setSettingsFiles(QStringList files)
|
QString CSMSettings::UserSettings::getSetting (const QString §ion, const QString &setting) const
|
||||||
{
|
{
|
||||||
mSettingsFiles = files;
|
if(mSectionSettings.find(section) == mSectionSettings.end())
|
||||||
}
|
|
||||||
|
|
||||||
QStringList CSMSettings::UserSettings::getSettingsFiles () const
|
|
||||||
{
|
|
||||||
return mSettingsFiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString CSMSettings::UserSettings::getSettingValue(QString section, QString setting) const
|
|
||||||
{
|
|
||||||
if(mSectionMap.find(section) == mSectionMap.end())
|
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
CSMSettings::SettingMap *settings = mSectionMap.value(section);
|
CSMSettings::SettingMap *settings = mSectionSettings.value(section);
|
||||||
|
|
||||||
if(settings->find(setting) == settings->end())
|
if(settings->find(setting) == settings->end())
|
||||||
return QString();
|
return QString();
|
||||||
|
@ -301,7 +243,7 @@ QString CSMSettings::UserSettings::getSettingValue(QString section, QString sett
|
||||||
return settingContainer->getValue();
|
return settingContainer->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
const CSMSettings::UserSettings& CSMSettings::UserSettings::instance()
|
CSMSettings::UserSettings& CSMSettings::UserSettings::instance()
|
||||||
{
|
{
|
||||||
assert(mUserSettingsInstance);
|
assert(mUserSettingsInstance);
|
||||||
return *mUserSettingsInstance;
|
return *mUserSettingsInstance;
|
||||||
|
|
|
@ -27,56 +27,53 @@ namespace CSMSettings {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
SectionMap mSectionSettings;
|
SectionMap mSectionSettings;
|
||||||
UserSettings *mUserSettingsInstance;
|
static UserSettings *mUserSettingsInstance;
|
||||||
QStringList mPaths;
|
QStringList mPaths;
|
||||||
Files::ConfigurationManager mCfgMgr;
|
Files::ConfigurationManager mCfgMgr;
|
||||||
|
|
||||||
QString mReadOnlyMessage;
|
QString mReadOnlyMessage;
|
||||||
QString mReadWriteMessage;
|
QString mReadWriteMessage;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
UserSettings();
|
/// Singleton implementation
|
||||||
~UserSettings();
|
static UserSettings& instance();
|
||||||
|
|
||||||
static const UserSettings& instance();
|
|
||||||
|
|
||||||
void readSettings();
|
|
||||||
void setSettingsFiles(QStringList files);
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
bool writeFile(QMap<QString, SettingList *> §ions);
|
|
||||||
const SectionMap &getSettings ();
|
|
||||||
void updateSettings (const QString §ionName, const QString &settingName = "");
|
|
||||||
void loadSettings (const QString &fileName);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
UserSettings();
|
UserSettings();
|
||||||
~UserSettings();
|
~UserSettings();
|
||||||
=======
|
|
||||||
QFile *openFile (const QString &) const;
|
|
||||||
bool writeFile(QFile *file, QMap<QString, SettingList *> §ions) const;
|
|
||||||
void getSettings (QTextStream &stream, SectionMap &settings) const;
|
|
||||||
QStringList getSettingsFiles () const;
|
|
||||||
CSMSettings::SectionMap getSettingsMap() const;
|
|
||||||
QString getSettingValue(QString section, QString setting) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
static UserSettings *mUserSettingsInstance;
|
|
||||||
|
|
||||||
CSMSettings::SectionMap mSectionMap;
|
|
||||||
QStringList mSettingsFiles;
|
|
||||||
>>>>>>> df1f1bd5c81d94a1ea2693000ec5dc589b069826
|
|
||||||
|
|
||||||
UserSettings (UserSettings const &); //not implemented
|
UserSettings (UserSettings const &); //not implemented
|
||||||
void operator= (UserSettings const &); //not implemented
|
void operator= (UserSettings const &); //not implemented
|
||||||
|
|
||||||
QTextStream *openFileStream (const QString &filePath, bool isReadOnly = false);
|
/// Writes settings to the last loaded settings file
|
||||||
|
bool writeSettings(QMap<QString, SettingList *> §ions);
|
||||||
|
|
||||||
|
/// Called from editor to trigger signal to update the specified setting.
|
||||||
|
/// If no setting name is specified, all settings found in the specified section are updated.
|
||||||
|
void updateSettings (const QString §ionName, const QString &settingName = "");
|
||||||
|
|
||||||
|
/// Retrieves the settings file at all three levels (global, local and user).
|
||||||
|
|
||||||
|
/// TODO: Multi-valued settings are not fully implemented. Setting values
|
||||||
|
/// loaded in later files will always overwrite previously loaded values.
|
||||||
|
void loadSettings (const QString &fileName);
|
||||||
|
|
||||||
|
/// Returns the entire map of settings across all sections
|
||||||
|
const SectionMap &getSettings () const;
|
||||||
|
|
||||||
|
/// Retrieves the value as a QString of the specified setting in the specified section
|
||||||
|
QString getSetting(const QString §ion, const QString &setting) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
/// Opens a QTextStream from the provided path as read-only or read-write.
|
||||||
|
QTextStream *openFileStream (const QString &filePath, bool isReadOnly = false) const;
|
||||||
|
|
||||||
|
/// Parses a setting file specified in filePath from the provided text stream.
|
||||||
void loadFromFile (const QString &filePath = "");
|
void loadFromFile (const QString &filePath = "");
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -180,8 +180,9 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
|
||||||
: mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1),
|
: mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1),
|
||||||
mViewTotal (totalViews)
|
mViewTotal (totalViews)
|
||||||
{
|
{
|
||||||
QString width = CSMSettings::UserSettings::instance().getSettingValue(QString("Window Size"), QString("Width"));
|
QString width = CSMSettings::UserSettings::instance().getSetting(QString("Window Size"), QString("Width"));
|
||||||
QString height = CSMSettings::UserSettings::instance().getSettingValue(QString("Window Size"), QString("Height"));
|
QString height = CSMSettings::UserSettings::instance().getSetting(QString("Window Size"), QString("Height"));
|
||||||
|
|
||||||
if(width==QString() || height==QString())
|
if(width==QString() || height==QString())
|
||||||
resize(800, 600);
|
resize(800, 600);
|
||||||
else
|
else
|
||||||
|
@ -378,10 +379,31 @@ void CSVDoc::View::showUserSettings()
|
||||||
settingsDialog->show();
|
settingsDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::View::resizeViewWidth (int width)
|
||||||
|
{
|
||||||
|
if (width >= 0)
|
||||||
|
resize (width, geometry().height());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVDoc::View::resizeViewHeight (int height)
|
||||||
|
{
|
||||||
|
if (height >= 0)
|
||||||
|
resize (geometry().width(), height);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVDoc::View::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
void CSVDoc::View::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||||
{
|
{
|
||||||
if (settingName == "Record Status Display")
|
if (settingName == "Record Status Display")
|
||||||
|
{
|
||||||
foreach (QObject *view, mSubViewWindow.children())
|
foreach (QObject *view, mSubViewWindow.children())
|
||||||
|
{
|
||||||
if (view->objectName() == "subview")
|
if (view->objectName() == "subview")
|
||||||
dynamic_cast<CSVDoc::SubView *>(view)->updateEditorSetting (settingName, settingValue);
|
dynamic_cast<CSVDoc::SubView *>(view)->updateEditorSetting (settingName, settingValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (settingName == "Width")
|
||||||
|
resizeViewWidth (settingValue.toInt());
|
||||||
|
|
||||||
|
else if (settingName == "Height")
|
||||||
|
resizeViewHeight (settingValue.toInt());
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,12 @@ namespace CSVDoc
|
||||||
|
|
||||||
void loadUserSettings();
|
void loadUserSettings();
|
||||||
|
|
||||||
|
/// User preference function
|
||||||
|
void resizeViewWidth (int width);
|
||||||
|
|
||||||
|
/// User preference function
|
||||||
|
void resizeViewHeight (int height);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews);
|
View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews);
|
||||||
|
@ -90,6 +96,7 @@ namespace CSVDoc
|
||||||
|
|
||||||
Operations *getOperations() const;
|
Operations *getOperations() const;
|
||||||
|
|
||||||
|
/// Function called by view manager when user preferences are updated
|
||||||
void updateEditorSetting (const QString &, const QString &);
|
void updateEditorSetting (const QString &, const QString &);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
void CSVDoc::ViewManager::updateIndices()
|
void CSVDoc::ViewManager::updateIndices()
|
||||||
{
|
{
|
||||||
std::map<CSMDoc::Document *, std::pair<int, int> > documents;
|
std::map<CSMDoc::Document *, std::pair<int, int> > documents;
|
||||||
|
@ -124,8 +125,6 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
||||||
|
|
||||||
connect (&CSMSettings::UserSettings::instance(), SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)),
|
connect (&CSMSettings::UserSettings::instance(), SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)),
|
||||||
this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)));
|
this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)));
|
||||||
|
|
||||||
CSMSettings::UserSettings::instance().loadSettings("opencs.cfg");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVDoc::ViewManager::~ViewManager()
|
CSVDoc::ViewManager::~ViewManager()
|
||||||
|
@ -355,7 +354,10 @@ void CSVDoc::ViewManager::exitApplication (CSVDoc::View *view)
|
||||||
|
|
||||||
void CSVDoc::ViewManager::slotUpdateEditorSetting (const QString &settingName, const QString &settingValue)
|
void CSVDoc::ViewManager::slotUpdateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||||
{
|
{
|
||||||
if (settingName == "Record Status Display")
|
if (settingName == "Record Status Display" ||
|
||||||
|
settingName == "Width" || settingName == "Height")
|
||||||
|
{
|
||||||
foreach (CSVDoc::View *view, mViews)
|
foreach (CSVDoc::View *view, mViews)
|
||||||
view->updateEditorSetting (settingName, settingValue);
|
view->updateEditorSetting (settingName, settingValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ namespace CSVDoc
|
||||||
|
|
||||||
void onExitWarningHandler(int state, CSMDoc::Document* document);
|
void onExitWarningHandler(int state, CSMDoc::Document* document);
|
||||||
|
|
||||||
|
/// connected to update signal in UserSettings
|
||||||
void slotUpdateEditorSetting (const QString &, const QString &);
|
void slotUpdateEditorSetting (const QString &, const QString &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,27 +38,27 @@ CSVSettings::AbstractWidget *CSVSettings::AbstractBlock::buildWidget (const QStr
|
||||||
{
|
{
|
||||||
|
|
||||||
case Widget_RadioButton:
|
case Widget_RadioButton:
|
||||||
widg = createSettingWidget<QRadioButton> (def, layout);
|
widg = new SettingWidget<QRadioButton> (def, layout, mBox);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Widget_SpinBox:
|
case Widget_SpinBox:
|
||||||
widg = createSettingWidget<QSpinBox> (def, layout);
|
widg = new SettingWidget<QSpinBox> (def, layout, mBox);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Widget_CheckBox:
|
case Widget_CheckBox:
|
||||||
widg = createSettingWidget<QCheckBox> (def, layout);
|
widg = new SettingWidget<QCheckBox> (def, layout, mBox);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Widget_LineEdit:
|
case Widget_LineEdit:
|
||||||
widg = createSettingWidget<QLineEdit> (def, layout);
|
widg = new SettingWidget<QLineEdit> (def, layout, mBox);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Widget_ListBox:
|
case Widget_ListBox:
|
||||||
widg = createSettingWidget<QListWidget> (def, layout);
|
widg = new SettingWidget<QListWidget> (def, layout, mBox);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Widget_ComboBox:
|
case Widget_ComboBox:
|
||||||
widg = createSettingWidget<QComboBox> (def, layout);
|
widg = new SettingWidget<QComboBox> (def, layout, mBox);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
namespace CSVSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/// Abstract base class for all blocks
|
||||||
class AbstractBlock : public QObject
|
class AbstractBlock : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -31,40 +32,50 @@ namespace CSVSettings
|
||||||
bool isVisible() const;
|
bool isVisible() const;
|
||||||
|
|
||||||
virtual CSMSettings::SettingList *getSettings() = 0;
|
virtual CSMSettings::SettingList *getSettings() = 0;
|
||||||
|
|
||||||
|
/// update settings found in the passed map and are encapsulated by the block
|
||||||
virtual bool updateSettings (const CSMSettings::SettingMap &settings) = 0;
|
virtual bool updateSettings (const CSMSettings::SettingMap &settings) = 0;
|
||||||
|
|
||||||
|
/// update callback function called from update slot
|
||||||
|
/// used for updating application-level settings in the editor
|
||||||
virtual bool updateBySignal (const QString &name, const QString &value, bool &doEmit)
|
virtual bool updateBySignal (const QString &name, const QString &value, bool &doEmit)
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/// Creates the layout which for the blocks QGroupBox
|
||||||
QLayout *createLayout (Orientation direction, bool isZeroMargin, QWidget* parent = 0);
|
QLayout *createLayout (Orientation direction, bool isZeroMargin, QWidget* parent = 0);
|
||||||
|
|
||||||
|
/// Creates widgets that exist as direct children of the block
|
||||||
AbstractWidget *buildWidget (const QString &widgetName, WidgetDef &wDef,
|
AbstractWidget *buildWidget (const QString &widgetName, WidgetDef &wDef,
|
||||||
QLayout *layout = 0, bool isConnected = true) const;
|
QLayout *layout = 0, bool isConnected = true) const;
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
AbstractWidget *createSettingWidget (WidgetDef &wDef, QLayout *layout) const
|
|
||||||
{
|
|
||||||
return new SettingWidget<T> (wDef, layout, mBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *getParent() const;
|
QWidget *getParent() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
/// enables / disables block-level widgets based on signals from other widgets
|
||||||
|
/// used in ToggleBlock
|
||||||
void slotSetEnabled (bool value);
|
void slotSetEnabled (bool value);
|
||||||
|
|
||||||
|
/// receives updates to applicaion-level settings in the Editor
|
||||||
void slotUpdateSetting (const QString &settingName, const QString &settingValue);
|
void slotUpdateSetting (const QString &settingName, const QString &settingValue);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
/// receives updates to a setting in the block pushed from the application level
|
||||||
void slotUpdate (const QString &value);
|
void slotUpdate (const QString &value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
//signal to functions outside the settings tab widget
|
/// signal to UserSettings instance
|
||||||
void signalUpdateSetting (const QString &propertyName, const QString &propertyValue);
|
void signalUpdateSetting (const QString &propertyName, const QString &propertyValue);
|
||||||
|
|
||||||
|
/// signal to widget for updating widget value
|
||||||
void signalUpdateWidget (const QString & value);
|
void signalUpdateWidget (const QString & value);
|
||||||
|
|
||||||
//propertyName and propertyValue are for properties for which the updated setting acts as a proxy
|
/// ProxyBlock use only.
|
||||||
|
/// Name and value correspond to settings for which the block is a proxy.
|
||||||
void signalUpdateProxySetting (const QString &propertyName, const QString &propertyValue);
|
void signalUpdateProxySetting (const QString &propertyName, const QString &propertyValue);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,16 +29,7 @@ CSVSettings::AbstractPage::AbstractPage(const QString &pageName, QWidget *parent
|
||||||
CSVSettings::AbstractPage::~AbstractPage()
|
CSVSettings::AbstractPage::~AbstractPage()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
void CSVSettings::AbstractPage::setupUi()
|
|
||||||
{
|
|
||||||
// Hacks to get the stylesheet look properly
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
QPlastiqueStyle *style = new QPlastiqueStyle;
|
|
||||||
//profilesComboBox->setStyle(style);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
CSMSettings::SettingList *CSVSettings::AbstractPage::getSettings()
|
CSMSettings::SettingList *CSVSettings::AbstractPage::getSettings()
|
||||||
{
|
{
|
||||||
CSMSettings::SettingList *settings = new CSMSettings::SettingList();
|
CSMSettings::SettingList *settings = new CSMSettings::SettingList();
|
||||||
|
|
|
@ -14,6 +14,11 @@ namespace CSVSettings {
|
||||||
|
|
||||||
typedef QList<AbstractBlock *> AbstractBlockList;
|
typedef QList<AbstractBlock *> AbstractBlockList;
|
||||||
|
|
||||||
|
/// Abstract base class for all setting pages in the dialog
|
||||||
|
|
||||||
|
/// \todo Scripted implementation of settings should eliminate the need
|
||||||
|
/// \todo derive page classes.
|
||||||
|
/// \todo AbstractPage should be replaced with a general page construction class.
|
||||||
class AbstractPage: public QWidget
|
class AbstractPage: public QWidget
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -30,14 +35,20 @@ namespace CSVSettings {
|
||||||
|
|
||||||
virtual void setupUi() = 0;
|
virtual void setupUi() = 0;
|
||||||
|
|
||||||
|
/// triggers widgiet initialization at the page level. All widgets updated to
|
||||||
|
/// current setting values
|
||||||
virtual void initializeWidgets (const CSMSettings::SettingMap &settings) = 0;
|
virtual void initializeWidgets (const CSMSettings::SettingMap &settings) = 0;
|
||||||
|
|
||||||
|
/// retrieve the list of settings local to the page.
|
||||||
CSMSettings::SettingList *getSettings();
|
CSMSettings::SettingList *getSettings();
|
||||||
|
|
||||||
void setObjectName();
|
void setObjectName();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/// Create a block for the page.
|
||||||
|
/// Block is constructed using passed definition struct
|
||||||
|
/// Page level-layout is created and assigned
|
||||||
template <typename S, typename T>
|
template <typename S, typename T>
|
||||||
AbstractBlock *buildBlock (T *def)
|
AbstractBlock *buildBlock (T *def)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,7 @@ class QLayout;
|
||||||
|
|
||||||
namespace CSVSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
|
/// Abstract base class for widgets which are used in user preferences dialog
|
||||||
class AbstractWidget : public QObject
|
class AbstractWidget : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -16,45 +17,49 @@ namespace CSVSettings
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/// Passed layout is assigned the constructed widget.
|
||||||
|
/// if no layout is passed, one is created.
|
||||||
explicit AbstractWidget (QLayout *layout = 0, QWidget* parent = 0)
|
explicit AbstractWidget (QLayout *layout = 0, QWidget* parent = 0)
|
||||||
: QObject (parent), mLayout (layout)
|
: QObject (parent), mLayout (layout)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//retrieve layout for insertion into itemblock
|
/// retrieve layout for insertion into itemblock
|
||||||
QLayout *getLayout();
|
QLayout *getLayout();
|
||||||
|
|
||||||
//create the derived widget instance
|
/// create the derived widget instance
|
||||||
void build (QWidget* widget, WidgetDef &def, bool noLabel = false);
|
void build (QWidget* widget, WidgetDef &def, bool noLabel = false);
|
||||||
|
|
||||||
//reference to the derived widget instance
|
/// reference to the derived widget instance
|
||||||
virtual QWidget *widget() = 0;
|
virtual QWidget *widget() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
//called by inbound signal for type-specific widget udpates
|
/// Callback called by receiving slot for widget udpates
|
||||||
virtual void updateWidget (const QString &value) = 0;
|
virtual void updateWidget (const QString &value) = 0;
|
||||||
|
|
||||||
//converts user-defined enum to Qt equivalents
|
/// Converts user-defined enum to Qt equivalents
|
||||||
QFlags<Qt::AlignmentFlag> getAlignment (Alignment flag);
|
QFlags<Qt::AlignmentFlag> getAlignment (Alignment flag);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//widget initialization utilities
|
/// Creates layout and assigns label and widget as appropriate
|
||||||
void createLayout (Orientation direction, bool isZeroMargin);
|
void createLayout (Orientation direction, bool isZeroMargin);
|
||||||
|
|
||||||
|
/// Creates label and widget according to passed definition
|
||||||
void buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel);
|
void buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel);
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
//outbound update
|
/// outbound update signal
|
||||||
void signalUpdateItem (const QString &value);
|
void signalUpdateItem (const QString &value);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
//inbound updates
|
/// receives inbound updates
|
||||||
void slotUpdateWidget (const QString &value);
|
void slotUpdateWidget (const QString &value);
|
||||||
|
|
||||||
//Outbound updates from derived widget signal
|
/// Overloads for outbound updates from derived widget signal
|
||||||
void slotUpdateItem (const QString &value);
|
void slotUpdateItem (const QString &value);
|
||||||
void slotUpdateItem (bool value);
|
void slotUpdateItem (bool value);
|
||||||
void slotUpdateItem (int value);
|
void slotUpdateItem (int value);
|
||||||
|
|
|
@ -20,16 +20,11 @@
|
||||||
CSVSettings::BlankPage::BlankPage(QWidget *parent):
|
CSVSettings::BlankPage::BlankPage(QWidget *parent):
|
||||||
AbstractPage("Blank", parent)
|
AbstractPage("Blank", parent)
|
||||||
{
|
{
|
||||||
initPage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVSettings::BlankPage::BlankPage(const QString &title, QWidget *parent):
|
CSVSettings::BlankPage::BlankPage(const QString &title, QWidget *parent):
|
||||||
AbstractPage(title, parent)
|
AbstractPage(title, parent)
|
||||||
{
|
|
||||||
initPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVSettings::BlankPage::initPage()
|
|
||||||
{
|
{
|
||||||
// Hacks to get the stylesheet look properly
|
// Hacks to get the stylesheet look properly
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
|
|
|
@ -10,6 +10,8 @@ namespace CSVSettings {
|
||||||
class UserSettings;
|
class UserSettings;
|
||||||
class AbstractBlock;
|
class AbstractBlock;
|
||||||
|
|
||||||
|
/// Derived page with no widgets
|
||||||
|
/// Reference use only.
|
||||||
class BlankPage : public AbstractPage
|
class BlankPage : public AbstractPage
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -20,9 +22,6 @@ namespace CSVSettings {
|
||||||
|
|
||||||
void setupUi();
|
void setupUi();
|
||||||
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
||||||
|
|
||||||
private:
|
|
||||||
void initPage();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ int CSVSettings::CustomBlock::buildGroupBlock(GroupBlockDef *def)
|
||||||
|
|
||||||
int CSVSettings::CustomBlock::buildProxyBlock(GroupBlockDef *def, ProxyBlock *block)
|
int CSVSettings::CustomBlock::buildProxyBlock(GroupBlockDef *def, ProxyBlock *block)
|
||||||
{
|
{
|
||||||
if (def->properties.size() != 1)
|
if (def->settingItems.size() != 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int retVal = block->build(def);
|
int retVal = block->build(def);
|
||||||
|
@ -67,7 +67,8 @@ int CSVSettings::CustomBlock::buildProxyBlock(GroupBlockDef *def, ProxyBlock *bl
|
||||||
if (retVal != 0)
|
if (retVal != 0)
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|
||||||
foreach (QStringList *list, *(def->properties.at(0)->proxyList))
|
// The first settingItem is the proxy setting, containing the list of settings bound to it.
|
||||||
|
foreach (QStringList *list, *(def->settingItems.at(0)->proxyList))
|
||||||
{
|
{
|
||||||
QString proxiedBlockName = list->at(0);
|
QString proxiedBlockName = list->at(0);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ namespace CSVSettings
|
||||||
|
|
||||||
class ProxyBlock;
|
class ProxyBlock;
|
||||||
|
|
||||||
|
/// Base class for customized user preference setting blocks
|
||||||
|
/// Special block classes should be derived from CustomBlock
|
||||||
class CustomBlock : public AbstractBlock
|
class CustomBlock : public AbstractBlock
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -19,17 +21,26 @@ namespace CSVSettings
|
||||||
|
|
||||||
explicit CustomBlock (QWidget *parent = 0);
|
explicit CustomBlock (QWidget *parent = 0);
|
||||||
|
|
||||||
|
/// Update settings local to the block
|
||||||
bool updateSettings (const CSMSettings::SettingMap &settings);
|
bool updateSettings (const CSMSettings::SettingMap &settings);
|
||||||
|
|
||||||
|
/// Retrieve settings local to the block
|
||||||
CSMSettings::SettingList *getSettings();
|
CSMSettings::SettingList *getSettings();
|
||||||
|
|
||||||
|
/// construct the block using the passed definition
|
||||||
int build (GroupBlockDefList &defList, GroupBlockDefList::Iterator *it = 0);
|
int build (GroupBlockDefList &defList, GroupBlockDefList::Iterator *it = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/// construct the block groupbox
|
||||||
GroupBox *buildGroupBox (Orientation orientation);
|
GroupBox *buildGroupBox (Orientation orientation);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/// Construction function for creating a standard GroupBlock child
|
||||||
int buildGroupBlock(GroupBlockDef *def);
|
int buildGroupBlock(GroupBlockDef *def);
|
||||||
|
|
||||||
|
/// Construction function for creating a standard ProxyBlock child
|
||||||
int buildProxyBlock(GroupBlockDef *def, ProxyBlock *block);
|
int buildProxyBlock(GroupBlockDef *def, ProxyBlock *block);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,13 +3,7 @@
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
CSVSettings::EditorPage::EditorPage(QWidget* parent) :
|
CSVSettings::EditorPage::EditorPage(QWidget* parent) :
|
||||||
AbstractPage(parent)
|
AbstractPage("Editor", parent)
|
||||||
{
|
|
||||||
setupUi();
|
|
||||||
}
|
|
||||||
|
|
||||||
CSVSettings::EditorPage::EditorPage (const QString &pageName, QWidget* parent)
|
|
||||||
: AbstractPage (pageName, parent)
|
|
||||||
{
|
{
|
||||||
setupUi();
|
setupUi();
|
||||||
}
|
}
|
||||||
|
@ -26,7 +20,7 @@ CSVSettings::GroupBlockDef *CSVSettings::EditorPage::setupRecordStatusDisplay()
|
||||||
|
|
||||||
statusItem->widget = statusWidget;
|
statusItem->widget = statusWidget;
|
||||||
|
|
||||||
statusBlock->properties << statusItem;
|
statusBlock->settingItems << statusItem;
|
||||||
|
|
||||||
return statusBlock;
|
return statusBlock;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,15 +12,18 @@ namespace CSVSettings
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit EditorPage(QWidget *parent = 0);
|
explicit EditorPage(QWidget *parent = 0);
|
||||||
explicit EditorPage (const QString &pageName, QWidget* parent = 0);
|
|
||||||
|
|
||||||
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
||||||
void setupUi();
|
void setupUi();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/// User preference view of the record status delegate's icon / text setting
|
||||||
GroupBlockDef *setupRecordStatusDisplay();
|
GroupBlockDef *setupRecordStatusDisplay();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
/// Signals up for changes to editor application-level settings
|
||||||
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
@ -12,7 +12,7 @@ CSVSettings::GroupBlock::GroupBlock (bool isVisible, QWidget *parent)
|
||||||
int CSVSettings::GroupBlock::build (GroupBlockDef *def)
|
int CSVSettings::GroupBlock::build (GroupBlockDef *def)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (def->properties.size() == 0)
|
if (def->settingItems.size() == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
|
@ -24,7 +24,7 @@ int CSVSettings::GroupBlock::build (GroupBlockDef *def)
|
||||||
setObjectName (def->title);
|
setObjectName (def->title);
|
||||||
mBox->setTitle (def->title);
|
mBox->setTitle (def->title);
|
||||||
|
|
||||||
foreach (SettingsItemDef *itemDef, def->properties)
|
foreach (SettingsItemDef *itemDef, def->settingItems)
|
||||||
{
|
{
|
||||||
ItemBlock *block = new ItemBlock (mBox);
|
ItemBlock *block = new ItemBlock (mBox);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ namespace CSVSettings
|
||||||
{
|
{
|
||||||
class ItemBlock;
|
class ItemBlock;
|
||||||
|
|
||||||
|
/// Base class for group blocks.
|
||||||
|
/// Derived block classes should use CustomBlock
|
||||||
class GroupBlock : public AbstractBlock
|
class GroupBlock : public AbstractBlock
|
||||||
{
|
{
|
||||||
ItemBlockList mItemBlockList;
|
ItemBlockList mItemBlockList;
|
||||||
|
@ -16,15 +18,24 @@ namespace CSVSettings
|
||||||
GroupBlock (QWidget* parent = 0);
|
GroupBlock (QWidget* parent = 0);
|
||||||
GroupBlock (bool isVisible, QWidget *parent = 0);
|
GroupBlock (bool isVisible, QWidget *parent = 0);
|
||||||
|
|
||||||
|
/// build the gorup block based on passed definition
|
||||||
int build (GroupBlockDef *def);
|
int build (GroupBlockDef *def);
|
||||||
|
|
||||||
|
/// update settings local to the group block
|
||||||
bool updateSettings (const CSMSettings::SettingMap &settings);
|
bool updateSettings (const CSMSettings::SettingMap &settings);
|
||||||
|
|
||||||
|
/// retrieve setting list local to the group block
|
||||||
CSMSettings::SettingList *getSettings();
|
CSMSettings::SettingList *getSettings();
|
||||||
|
|
||||||
|
/// retrieve item block by name from the passed list or local list
|
||||||
ItemBlock *getItemBlock (const QString &name, ItemBlockList *blockList = 0);
|
ItemBlock *getItemBlock (const QString &name, ItemBlockList *blockList = 0);
|
||||||
|
|
||||||
|
/// retrieve the item block by index from the local list
|
||||||
ItemBlock *getItemBlock (int index);
|
ItemBlock *getItemBlock (int index);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
/// create block layout based on passed definition
|
||||||
int buildLayout (GroupBlockDef &def);
|
int buildLayout (GroupBlockDef &def);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
namespace CSVSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
|
/// Custom implementation of QGroupBox to be used with block classes
|
||||||
class GroupBox : public QGroupBox
|
class GroupBox : public QGroupBox
|
||||||
{
|
{
|
||||||
static const QString INVISIBLE_BOX_STYLE;
|
static const QString INVISIBLE_BOX_STYLE;
|
||||||
|
|
|
@ -15,22 +15,32 @@ namespace CSVSettings
|
||||||
|
|
||||||
ItemBlock (QWidget* parent = 0);
|
ItemBlock (QWidget* parent = 0);
|
||||||
|
|
||||||
|
/// pure virtual function not implemneted
|
||||||
bool updateSettings (const CSMSettings::SettingMap &settings) { return false; }
|
bool updateSettings (const CSMSettings::SettingMap &settings) { return false; }
|
||||||
|
|
||||||
CSMSettings::SettingList *getSettings ();
|
CSMSettings::SettingList *getSettings ();
|
||||||
|
|
||||||
QString getValue () const;
|
QString getValue () const;
|
||||||
|
|
||||||
|
/// item blocks encapsulate only one setting
|
||||||
int getSettingCount();
|
int getSettingCount();
|
||||||
|
|
||||||
|
/// update setting value and corresponding widget
|
||||||
bool update (const QString &value);
|
bool update (const QString &value);
|
||||||
|
|
||||||
|
/// virtual construction function
|
||||||
int build(SettingsItemDef &iDef);
|
int build(SettingsItemDef &iDef);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/// custom construction function
|
||||||
void buildItemBlock (SettingsItemDef& iDef);
|
void buildItemBlock (SettingsItemDef& iDef);
|
||||||
void buildItemBlockWidgets (SettingsItemDef& iDef);
|
void buildItemBlockWidgets (SettingsItemDef& iDef);
|
||||||
|
|
||||||
|
/// update the setting value
|
||||||
bool updateItem (const QString &);
|
bool updateItem (const QString &);
|
||||||
|
|
||||||
|
/// callback function triggered when update to application level is signalled
|
||||||
bool updateBySignal (const QString &name, const QString &value, bool &doEmit);
|
bool updateBySignal (const QString &name, const QString &value, bool &doEmit);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ CSVSettings::ProxyBlock::ProxyBlock (QWidget *parent)
|
||||||
int CSVSettings::ProxyBlock::build (GroupBlockDef *proxyDef)
|
int CSVSettings::ProxyBlock::build (GroupBlockDef *proxyDef)
|
||||||
{
|
{
|
||||||
//get the list of pre-defined values for the proxy
|
//get the list of pre-defined values for the proxy
|
||||||
mValueList = proxyDef->properties.at(0)->valueList;
|
mValueList = proxyDef->settingItems.at(0)->valueList;
|
||||||
|
|
||||||
bool success = GroupBlock::build(proxyDef);
|
bool success = GroupBlock::build(proxyDef);
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,7 @@ namespace CSVSettings
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
//NOTE: mProxyItemBlockList and mProxyList
|
/// TODO: Combine mProxyItemBlockList and mProxyList.
|
||||||
//should be combined into a value pair and stored in one list.
|
|
||||||
ItemBlockList mProxiedItemBlockList;
|
ItemBlockList mProxiedItemBlockList;
|
||||||
ProxyList mProxyList;
|
ProxyList mProxyList;
|
||||||
QStringList *mValueList;
|
QStringList *mValueList;
|
||||||
|
@ -20,17 +19,28 @@ namespace CSVSettings
|
||||||
explicit ProxyBlock (QWidget *parent = 0);
|
explicit ProxyBlock (QWidget *parent = 0);
|
||||||
explicit ProxyBlock (ItemBlock *proxyItemBlock, QWidget *parent = 0);
|
explicit ProxyBlock (ItemBlock *proxyItemBlock, QWidget *parent = 0);
|
||||||
|
|
||||||
|
/// Add a block that contains a proxied setting to the proxy block.
|
||||||
void addSetting (ItemBlock* settingBlock, QStringList *proxyList);
|
void addSetting (ItemBlock* settingBlock, QStringList *proxyList);
|
||||||
|
|
||||||
int build (GroupBlockDef *def);
|
int build (GroupBlockDef *def);
|
||||||
|
|
||||||
CSMSettings::SettingList *getSettings() { return 0; }
|
CSMSettings::SettingList *getSettings() { return 0; }
|
||||||
|
|
||||||
|
/// Update settings local to the proxy block pushed from application level
|
||||||
bool updateSettings (const CSMSettings::SettingMap &settings);
|
bool updateSettings (const CSMSettings::SettingMap &settings);
|
||||||
|
|
||||||
|
/// callback function triggered when update to the application level is signaled.
|
||||||
bool updateBySignal (const QString &name, const QString &value, bool &doEmit);
|
bool updateBySignal (const QString &name, const QString &value, bool &doEmit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/// return the item block of a proxied setting
|
||||||
ItemBlock *getProxiedItemBlock (const QString &name);
|
ItemBlock *getProxiedItemBlock (const QString &name);
|
||||||
|
|
||||||
|
/// update the proxy setting with data from the proxied settings
|
||||||
bool updateByProxiedSettings(const CSMSettings::SettingMap *settings = 0);
|
bool updateByProxiedSettings(const CSMSettings::SettingMap *settings = 0);
|
||||||
|
|
||||||
|
/// update proxied settings with data from the proxy setting
|
||||||
bool updateProxiedSettings();
|
bool updateProxiedSettings();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -44,7 +44,7 @@ void CSVSettings::SamplePage::setupUi()
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
|
|
||||||
SettingsItemDef *undoStackItem = new SettingsItemDef (undoStack->title, "32");
|
SettingsItemDef *undoStackItem = new SettingsItemDef (undoStack->title, "32");
|
||||||
undoStack->properties << undoStackItem;
|
undoStack->settingItems << undoStackItem;
|
||||||
undoStackItem->minMax.left = "0";
|
undoStackItem->minMax.left = "0";
|
||||||
undoStackItem->minMax.right = "64";
|
undoStackItem->minMax.right = "64";
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ void CSVSettings::SamplePage::setupUi()
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
|
|
||||||
SettingsItemDef *topLevelItem = new SettingsItemDef (topLevelWindowCount->title, "100");
|
SettingsItemDef *topLevelItem = new SettingsItemDef (topLevelWindowCount->title, "100");
|
||||||
topLevelWindowCount->properties << topLevelItem;
|
topLevelWindowCount->settingItems << topLevelItem;
|
||||||
topLevelItem->minMax.left = "1";
|
topLevelItem->minMax.left = "1";
|
||||||
topLevelItem->minMax.right = "256";
|
topLevelItem->minMax.right = "256";
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ void CSVSettings::SamplePage::setupUi()
|
||||||
reuseSubWidget.valueList = (reuseSubItem->valueList);
|
reuseSubWidget.valueList = (reuseSubItem->valueList);
|
||||||
reuseSubWidget.widgetAlignment = Align_Left;
|
reuseSubWidget.widgetAlignment = Align_Left;
|
||||||
|
|
||||||
reuseSubwindow->properties << reuseSubItem;
|
reuseSubwindow->settingItems << reuseSubItem;
|
||||||
reuseSubItem->widget = reuseSubWidget;
|
reuseSubItem->widget = reuseSubWidget;
|
||||||
|
|
||||||
///////////////////////////////
|
///////////////////////////////
|
||||||
|
@ -98,7 +98,7 @@ void CSVSettings::SamplePage::setupUi()
|
||||||
heightItem->widget.widgetWidth = 45;
|
heightItem->widget.widgetWidth = 45;
|
||||||
heightItem->widget.caption = "x";
|
heightItem->widget.caption = "x";
|
||||||
|
|
||||||
customWindowSize->properties << widthItem << heightItem;
|
customWindowSize->settingItems << widthItem << heightItem;
|
||||||
customWindowSize->widgetOrientation = Orient_Horizontal;
|
customWindowSize->widgetOrientation = Orient_Horizontal;
|
||||||
customWindowSize->isVisible = false;
|
customWindowSize->isVisible = false;
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ void CSVSettings::SamplePage::setupUi()
|
||||||
|
|
||||||
widthByHeightItem->widget = widthByHeightWidget;
|
widthByHeightItem->widget = widthByHeightWidget;
|
||||||
|
|
||||||
definedWindowSize->properties << widthByHeightItem;
|
definedWindowSize->settingItems << widthByHeightItem;
|
||||||
definedWindowSize->isProxy = true;
|
definedWindowSize->isProxy = true;
|
||||||
definedWindowSize->isVisible = false;
|
definedWindowSize->isVisible = false;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,8 @@
|
||||||
|
|
||||||
namespace CSVSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
//VALID FOR RADIOBUTTON / CHECKBOX (or other toggle widget with it's own label)
|
|
||||||
|
/// Generic template for radiobuttons / checkboxes
|
||||||
template <typename T1>
|
template <typename T1>
|
||||||
class SettingWidget : public AbstractWidget
|
class SettingWidget : public AbstractWidget
|
||||||
{
|
{
|
||||||
|
@ -47,6 +48,7 @@ namespace CSVSettings
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// spin box template
|
||||||
template <>
|
template <>
|
||||||
class SettingWidget <QSpinBox>: public AbstractWidget
|
class SettingWidget <QSpinBox>: public AbstractWidget
|
||||||
{
|
{
|
||||||
|
@ -90,6 +92,7 @@ namespace CSVSettings
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// combo box template
|
||||||
template <>
|
template <>
|
||||||
class SettingWidget <QComboBox>: public CSVSettings::AbstractWidget
|
class SettingWidget <QComboBox>: public CSVSettings::AbstractWidget
|
||||||
{
|
{
|
||||||
|
@ -142,6 +145,7 @@ namespace CSVSettings
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// line edit template
|
||||||
template <>
|
template <>
|
||||||
class SettingWidget <QLineEdit>: public CSVSettings::AbstractWidget
|
class SettingWidget <QLineEdit>: public CSVSettings::AbstractWidget
|
||||||
{
|
{
|
||||||
|
@ -175,6 +179,8 @@ namespace CSVSettings
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// list widget template
|
||||||
|
/// TODO: Not fully implemented. Only widget supporting multi-valued settings
|
||||||
template <>
|
template <>
|
||||||
class SettingWidget <QListWidget>: public CSVSettings::AbstractWidget
|
class SettingWidget <QListWidget>: public CSVSettings::AbstractWidget
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,21 +44,44 @@ namespace CSVSettings
|
||||||
Align_Right = Qt::AlignRight
|
Align_Right = Qt::AlignRight
|
||||||
};
|
};
|
||||||
|
|
||||||
//template for defining the widget of a property.
|
/// definition struct for widgets
|
||||||
struct WidgetDef
|
struct WidgetDef
|
||||||
{
|
{
|
||||||
WidgetType type; //type of widget providing input
|
/// type of widget providing input
|
||||||
int labelWidth; //width of caption label
|
WidgetType type;
|
||||||
int widgetWidth; //width of input widget
|
|
||||||
Orientation orientation; //label / widget orientation (horizontal / vertical)
|
/// width of caption label
|
||||||
QString inputMask; //input mask (line edit)
|
int labelWidth;
|
||||||
QString caption; //label caption. Leave empty for multiple items. See BlockDef::captionList
|
|
||||||
QString value; //widget value. Leave empty for multiple items. See BlockDef::valueList
|
/// width of input widget
|
||||||
CSMSettings::QStringPair *minMax; //Min/Max QString value pair. If empty, assigned to property item value pair.
|
int widgetWidth;
|
||||||
QStringList *valueList; //value list for list widgets. If left empty, is assigned to property item value list during block build().
|
|
||||||
bool isDefault; //isDefault - determined at runtime.
|
/// label / widget orientation (horizontal / vertical)
|
||||||
Alignment valueAlignment; //left / center / right-justify text in widget
|
Orientation orientation;
|
||||||
Alignment widgetAlignment; //left / center / right-justify widget in group box
|
|
||||||
|
/// input mask (line edit only)
|
||||||
|
QString inputMask;
|
||||||
|
|
||||||
|
/// label caption. Leave empty for multiple items. See BlockDef::captionList
|
||||||
|
QString caption;
|
||||||
|
|
||||||
|
/// widget value. Leave empty for multiple items. See BlockDef::valueList
|
||||||
|
QString value;
|
||||||
|
|
||||||
|
/// Min/Max QString value pair. If empty, assigned to property item value pair.
|
||||||
|
CSMSettings::QStringPair *minMax;
|
||||||
|
|
||||||
|
/// value list for list widgets. If left empty, is assigned to property item value list during block build().
|
||||||
|
QStringList *valueList;
|
||||||
|
|
||||||
|
/// determined at runtime
|
||||||
|
bool isDefault;
|
||||||
|
|
||||||
|
/// left / center / right-justify text in widget
|
||||||
|
Alignment valueAlignment;
|
||||||
|
|
||||||
|
/// left / center / right-justify widget in group box
|
||||||
|
Alignment widgetAlignment;
|
||||||
|
|
||||||
|
|
||||||
WidgetDef() : labelWidth (-1), widgetWidth (-1),
|
WidgetDef() : labelWidth (-1), widgetWidth (-1),
|
||||||
|
@ -79,20 +102,34 @@ namespace CSVSettings
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//Defines the attributes of the property as it is represented in the config file
|
/// Defines the attributes of the setting as it is represented in the config file
|
||||||
//as well as the UI elements (group box and widget) that serve it.
|
/// as well as the UI elements (group box and widget) that serve it.
|
||||||
//Only one widget may serve as the input widget for the property.
|
/// Only one widget may serve as the input widget for the setting.
|
||||||
struct SettingsItemDef
|
struct SettingsItemDef
|
||||||
{
|
{
|
||||||
QString name; //property name
|
/// setting name
|
||||||
QStringList *valueList; //list of valid values for the property.
|
QString name;
|
||||||
//Used to populate option widget captions or list widget item lists (see WidgetDef::caption / value)
|
|
||||||
|
/// list of valid values for the setting
|
||||||
|
QStringList *valueList;
|
||||||
|
|
||||||
|
/// Used to populate option widget captions or list widget item lists (see WidgetDef::caption / value)
|
||||||
QString defaultValue;
|
QString defaultValue;
|
||||||
|
|
||||||
|
/// flag indicating multi-valued setting
|
||||||
bool hasMultipleValues;
|
bool hasMultipleValues;
|
||||||
CSMSettings::QStringPair minMax; //minimum / maximum value pair
|
|
||||||
WidgetDef widget; //definition of the input widget for this setting
|
/// minimum / maximum value pair
|
||||||
Orientation orientation; //general orientation of the widget / label for this property
|
CSMSettings::QStringPair minMax;
|
||||||
ProxyList *proxyList; //list of property and corresponding default values for proxy widget
|
|
||||||
|
/// definition of the input widget for this setting
|
||||||
|
WidgetDef widget;
|
||||||
|
|
||||||
|
/// general orientation of the widget / label for this setting
|
||||||
|
Orientation orientation;
|
||||||
|
|
||||||
|
/// list of settings and corresponding default values for proxy widget
|
||||||
|
ProxyList *proxyList;
|
||||||
|
|
||||||
SettingsItemDef() : name (""), defaultValue (""), orientation (Orient_Vertical), hasMultipleValues (false)
|
SettingsItemDef() : name (""), defaultValue (""), orientation (Orient_Vertical), hasMultipleValues (false)
|
||||||
{}
|
{}
|
||||||
|
@ -104,18 +141,32 @@ namespace CSVSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//Hierarchically, this is a "sub-section" of properties within a section, solely for UI organization.
|
/// Generic container block
|
||||||
//Does not correlate to config file structure.
|
|
||||||
struct GroupBlockDef
|
struct GroupBlockDef
|
||||||
{
|
{
|
||||||
QString title; //title of the block containing the property or properties of this sub-section
|
/// block title
|
||||||
QStringList captions; //list of captions for widgets at the block level (not associated with any particular property)
|
QString title;
|
||||||
WidgetList widgets; //list of widgets at the block level (not associated with any particular property)
|
|
||||||
QList<SettingsItemDef *> properties; //list of the property(ies) which are subordinate to the property block.
|
/// list of captions for widgets at the block level (not associated with any particular setting)
|
||||||
Orientation widgetOrientation; //general orientation of widgets in group block
|
QStringList captions;
|
||||||
bool isVisible; //determines whether or not box border/title are visible
|
|
||||||
bool isProxy; //indicates whether or not this block defines a proxy block
|
/// list of widgets at the block level (not associated with any particular setting)
|
||||||
QString defaultValue; //generic default value attribute
|
WidgetList widgets;
|
||||||
|
|
||||||
|
/// list of the settings which are subordinate to the setting block.
|
||||||
|
QList<SettingsItemDef *> settingItems;
|
||||||
|
|
||||||
|
/// general orientation of widgets in group block
|
||||||
|
Orientation widgetOrientation;
|
||||||
|
|
||||||
|
/// determines whether or not box border/title are visible
|
||||||
|
bool isVisible;
|
||||||
|
|
||||||
|
/// indicates whether or not this block defines a proxy block
|
||||||
|
bool isProxy;
|
||||||
|
|
||||||
|
/// generic default value attribute
|
||||||
|
QString defaultValue;
|
||||||
|
|
||||||
GroupBlockDef (): title(""), widgetOrientation (Orient_Vertical), isVisible (true), isProxy (false), defaultValue ("")
|
GroupBlockDef (): title(""), widgetOrientation (Orient_Vertical), isVisible (true), isProxy (false), defaultValue ("")
|
||||||
{}
|
{}
|
||||||
|
@ -125,11 +176,19 @@ namespace CSVSettings
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// used to create unique, complex blocks
|
||||||
struct CustomBlockDef
|
struct CustomBlockDef
|
||||||
{
|
{
|
||||||
|
/// block title
|
||||||
QString title;
|
QString title;
|
||||||
QString defaultValue; //default value for widgets unique to the custom block
|
|
||||||
GroupBlockDefList blockDefList; //list of settings groups that comprise the settings within the custom block
|
/// default value for widgets unique to the custom block
|
||||||
|
QString defaultValue;
|
||||||
|
|
||||||
|
/// list of settings groups that comprise the settings within the custom block
|
||||||
|
GroupBlockDefList blockDefList;
|
||||||
|
|
||||||
|
/// orientation of the widgets within the block
|
||||||
Orientation blockOrientation;
|
Orientation blockOrientation;
|
||||||
|
|
||||||
CustomBlockDef (): title (""), defaultValue (""), blockOrientation (Orient_Horizontal)
|
CustomBlockDef (): title (""), defaultValue (""), blockOrientation (Orient_Horizontal)
|
||||||
|
|
|
@ -21,6 +21,8 @@ namespace CSVSettings
|
||||||
int build (CustomBlockDef *def);
|
int build (CustomBlockDef *def);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/// Constructor for toggle widgets that are specific to toggle block
|
||||||
|
/// Widgets are not a part of the user preference settings
|
||||||
GroupBox *buildToggleWidgets (GroupBlockDef *def, QString &defaultToggle);
|
GroupBox *buildToggleWidgets (GroupBlockDef *def, QString &defaultToggle);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,19 +9,15 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
<<<<<<< HEAD
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
|
|
||||||
#include "blankpage.hpp"
|
|
||||||
#include "samplepage.hpp"
|
#include "samplepage.hpp"
|
||||||
=======
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include "blankpage.hpp"
|
|
||||||
#include "editorpage.hpp"
|
#include "editorpage.hpp"
|
||||||
#include "windowpage.hpp"
|
#include "windowpage.hpp"
|
||||||
#include "../../model/settings/support.hpp"
|
|
||||||
>>>>>>> df1f1bd5c81d94a1ea2693000ec5dc589b069826
|
|
||||||
|
|
||||||
#include "../../model/settings/support.hpp"
|
#include "../../model/settings/support.hpp"
|
||||||
#include <boost/filesystem/path.hpp>
|
#include <boost/filesystem/path.hpp>
|
||||||
|
@ -32,12 +28,7 @@ CSVSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) :
|
||||||
{
|
{
|
||||||
setWindowTitle(QString::fromUtf8 ("User Settings"));
|
setWindowTitle(QString::fromUtf8 ("User Settings"));
|
||||||
buildPages();
|
buildPages();
|
||||||
<<<<<<< HEAD
|
|
||||||
setWidgetStates ();
|
setWidgetStates ();
|
||||||
=======
|
|
||||||
setWidgetStates (CSMSettings::UserSettings::instance().getSettingsMap());
|
|
||||||
>>>>>>> df1f1bd5c81d94a1ea2693000ec5dc589b069826
|
|
||||||
positionWindow ();
|
|
||||||
|
|
||||||
connect (mListWidget,
|
connect (mListWidget,
|
||||||
SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
|
||||||
|
@ -63,11 +54,12 @@ void CSVSettings::UserSettingsDialog::setWidgetStates ()
|
||||||
for (int i = 0; i < mStackedWidget->count(); i++)
|
for (int i = 0; i < mStackedWidget->count(); i++)
|
||||||
{
|
{
|
||||||
//get the settings defined for the entire section
|
//get the settings defined for the entire section
|
||||||
CSMSettings::SettingMap *settings = sectionSettings [mStackedWidget->widget(i)->objectName()];
|
//and update widget
|
||||||
|
QString pageName = mStackedWidget->widget(i)->objectName();
|
||||||
|
|
||||||
//if found, initialize the page's widgets
|
if (sectionSettings.find(pageName) != sectionSettings.end())
|
||||||
if (settings)
|
|
||||||
{
|
{
|
||||||
|
CSMSettings::SettingMap *settings = sectionSettings.value(pageName);
|
||||||
AbstractPage *page = getAbstractPage (i);
|
AbstractPage *page = getAbstractPage (i);
|
||||||
page->initializeWidgets(*settings);
|
page->initializeWidgets(*settings);
|
||||||
}
|
}
|
||||||
|
@ -97,62 +89,11 @@ void CSVSettings::UserSettingsDialog::buildPages()
|
||||||
setCentralWidget (centralWidget);
|
setCentralWidget (centralWidget);
|
||||||
setDockOptions (QMainWindow::AllowNestedDocks);
|
setDockOptions (QMainWindow::AllowNestedDocks);
|
||||||
|
|
||||||
//uncomment to test with sample editor page.
|
createPage<WindowPage>();
|
||||||
<<<<<<< HEAD
|
createPage<EditorPage>();
|
||||||
// TODO: Reimplement sample page using createPage function
|
|
||||||
//createPage<SamplePage>("Sample");
|
|
||||||
createPage<EditorPage>("Editor");
|
|
||||||
=======
|
|
||||||
//createSamplePage();
|
|
||||||
/*createPage<BlankPage>("Page1");
|
|
||||||
>>>>>>> df1f1bd5c81d94a1ea2693000ec5dc589b069826
|
|
||||||
createPage<BlankPage>("Page2");
|
|
||||||
createPage<BlankPage>("Page3");*/
|
|
||||||
createWindowPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVSettings::UserSettingsDialog::createSamplePage()
|
|
||||||
{
|
|
||||||
//add pages to stackedwidget and items to listwidget
|
|
||||||
CSVSettings::AbstractPage *page
|
|
||||||
= new CSVSettings::SamplePage(this);
|
|
||||||
|
|
||||||
mStackedWidget->addWidget (page);
|
|
||||||
|
|
||||||
connect ( page,
|
|
||||||
SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)),
|
|
||||||
&(CSMSettings::UserSettings::instance()),
|
|
||||||
SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)));
|
|
||||||
|
|
||||||
new QListWidgetItem (page->objectName(), mListWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVSettings::UserSettingsDialog::createWindowPage()
|
|
||||||
{
|
|
||||||
//add pages to stackedwidget and items to listwidget
|
|
||||||
CSVSettings::AbstractPage *page
|
|
||||||
= new CSVSettings::WindowPage(this);
|
|
||||||
|
|
||||||
mStackedWidget->addWidget (page);
|
|
||||||
|
|
||||||
new QListWidgetItem (page->objectName(), mListWidget);
|
|
||||||
|
|
||||||
connect ( page, SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)),
|
|
||||||
&(CSMSettings::UserSettings::instance()), SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)));
|
|
||||||
}
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
void CSVSettings::UserSettingsDialog::positionWindow ()
|
|
||||||
{
|
|
||||||
QRect scr = QApplication::desktop()->screenGeometry();
|
|
||||||
|
|
||||||
move(scr.center().x() - (width() / 2), scr.center().y() - (height() / 2));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
>>>>>>> df1f1bd5c81d94a1ea2693000ec5dc589b069826
|
|
||||||
void CSVSettings::UserSettingsDialog::writeSettings()
|
void CSVSettings::UserSettingsDialog::writeSettings()
|
||||||
{
|
{
|
||||||
QMap<QString, CSMSettings::SettingList *> settings;
|
QMap<QString, CSMSettings::SettingList *> settings;
|
||||||
|
@ -162,15 +103,7 @@ void CSVSettings::UserSettingsDialog::writeSettings()
|
||||||
AbstractPage *page = getAbstractPage (i);
|
AbstractPage *page = getAbstractPage (i);
|
||||||
settings [page->objectName()] = page->getSettings();
|
settings [page->objectName()] = page->getSettings();
|
||||||
}
|
}
|
||||||
|
CSMSettings::UserSettings::instance().writeSettings(settings);
|
||||||
<<<<<<< HEAD
|
|
||||||
CSMSettings::UserSettings::instance().writeFile(settings);
|
|
||||||
=======
|
|
||||||
QStringList paths = CSMSettings::UserSettings::instance().getSettingsFiles();
|
|
||||||
|
|
||||||
CSMSettings::UserSettings::instance().writeFile(CSMSettings::UserSettings::instance().openFile(paths.back()), settings);
|
|
||||||
>>>>>>> df1f1bd5c81d94a1ea2693000ec5dc589b069826
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVSettings::AbstractPage *CSVSettings::UserSettingsDialog::getAbstractPage (int index)
|
CSVSettings::AbstractPage *CSVSettings::UserSettingsDialog::getAbstractPage (int index)
|
||||||
|
|
|
@ -33,33 +33,27 @@ namespace CSVSettings {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/// Settings are written on close
|
||||||
void closeEvent (QCloseEvent *event);
|
void closeEvent (QCloseEvent *event);
|
||||||
|
|
||||||
|
/// return the setting page by name
|
||||||
|
/// performs dynamic cast to AbstractPage *
|
||||||
AbstractPage *getAbstractPage (int index);
|
AbstractPage *getAbstractPage (int index);
|
||||||
void setWidgetStates ();
|
void setWidgetStates ();
|
||||||
void buildPages();
|
void buildPages();
|
||||||
void positionWindow ();
|
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
void createSamplePage();
|
|
||||||
|
|
||||||
//Pages
|
|
||||||
void createWindowPage();
|
|
||||||
|
|
||||||
|
/// Templated function to create a custom user preference page
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void createPage (const QString &title)
|
void createPage ()
|
||||||
{
|
{
|
||||||
T *page = new T(title, this);
|
T *page = new T(mStackedWidget);
|
||||||
|
|
||||||
mStackedWidget->addWidget (dynamic_cast<QWidget *>(page));
|
mStackedWidget->addWidget (dynamic_cast<QWidget *>(page));
|
||||||
|
|
||||||
new QListWidgetItem (page->objectName(), mListWidget);
|
new QListWidgetItem (page->objectName(), mListWidget);
|
||||||
|
|
||||||
//finishing touches
|
//finishing touches
|
||||||
if (mStackedWidget->sizeHint().width() < 640)
|
|
||||||
mStackedWidget->sizeHint().setWidth(640);
|
|
||||||
|
|
||||||
if (mStackedWidget->sizeHint().height() < 480)
|
|
||||||
mStackedWidget->sizeHint().setHeight(480);
|
|
||||||
|
|
||||||
QFontMetrics fm (QApplication::font());
|
QFontMetrics fm (QApplication::font());
|
||||||
int textWidth = fm.width(page->objectName());
|
int textWidth = fm.width(page->objectName());
|
||||||
|
|
||||||
|
@ -70,6 +64,8 @@ namespace CSVSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
|
/// Called when a different page is selected in the left-hand list widget
|
||||||
void slotChangePage (QListWidgetItem*, QListWidgetItem*);
|
void slotChangePage (QListWidgetItem*, QListWidgetItem*);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
#include "groupblock.hpp"
|
#include "groupblock.hpp"
|
||||||
#include "toggleblock.hpp"
|
#include "toggleblock.hpp"
|
||||||
|
#include "../../view/settings/abstractblock.hpp"
|
||||||
|
|
||||||
CSVSettings::WindowPage::WindowPage(QWidget *parent):
|
CSVSettings::WindowPage::WindowPage(QWidget *parent):
|
||||||
AbstractPage("Window Size", parent)
|
AbstractPage("Window Size", parent)
|
||||||
|
@ -29,35 +30,10 @@ CSVSettings::WindowPage::WindowPage(QWidget *parent):
|
||||||
setupUi();
|
setupUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVSettings::WindowPage::setupUi()
|
CSVSettings::GroupBlockDef * CSVSettings::WindowPage::buildDefinedWindowSize()
|
||||||
{
|
{
|
||||||
GroupBlockDef customWindowSize (QString ("Custom Window Size"));
|
GroupBlockDef *block = new GroupBlockDef ( "Defined Size");
|
||||||
GroupBlockDef definedWindowSize (QString ("Pre-Defined Window Size"));
|
|
||||||
GroupBlockDef windowSizeToggle (QString ("Window Size"));
|
|
||||||
CustomBlockDef windowSize (QString ("Window Size"));
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////
|
|
||||||
//custom window size properties
|
|
||||||
///////////////////////////////
|
|
||||||
|
|
||||||
//custom width
|
|
||||||
SettingsItemDef *widthItem = new SettingsItemDef ("Width", "640");
|
|
||||||
widthItem->widget = WidgetDef (Widget_LineEdit);
|
|
||||||
widthItem->widget.widgetWidth = 45;
|
|
||||||
|
|
||||||
//custom height
|
|
||||||
SettingsItemDef *heightItem = new SettingsItemDef ("Height", "480");
|
|
||||||
heightItem->widget = WidgetDef (Widget_LineEdit);
|
|
||||||
heightItem->widget.widgetWidth = 45;
|
|
||||||
heightItem->widget.caption = "x";
|
|
||||||
|
|
||||||
customWindowSize.properties << widthItem << heightItem;
|
|
||||||
customWindowSize.widgetOrientation = Orient_Horizontal;
|
|
||||||
customWindowSize.isVisible = false;
|
|
||||||
|
|
||||||
|
|
||||||
//pre-defined
|
|
||||||
SettingsItemDef *widthByHeightItem = new SettingsItemDef ("Window Size", "640x480");
|
SettingsItemDef *widthByHeightItem = new SettingsItemDef ("Window Size", "640x480");
|
||||||
WidgetDef widthByHeightWidget = WidgetDef (Widget_ComboBox);
|
WidgetDef widthByHeightWidget = WidgetDef (Widget_ComboBox);
|
||||||
widthByHeightWidget.widgetWidth = 90;
|
widthByHeightWidget.widgetWidth = 90;
|
||||||
|
@ -73,27 +49,72 @@ void CSVSettings::WindowPage::setupUi()
|
||||||
|
|
||||||
widthByHeightItem->widget = widthByHeightWidget;
|
widthByHeightItem->widget = widthByHeightWidget;
|
||||||
|
|
||||||
definedWindowSize.properties << widthByHeightItem;
|
block->settingItems << widthByHeightItem;
|
||||||
definedWindowSize.isProxy = true;
|
block->isProxy = true;
|
||||||
definedWindowSize.isVisible = false;
|
block->isVisible = false;
|
||||||
|
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVSettings::GroupBlockDef *CSVSettings::WindowPage::buildCustomWindowSize()
|
||||||
|
{
|
||||||
|
GroupBlockDef *block = new GroupBlockDef ("Custom Size");
|
||||||
|
|
||||||
|
//custom width
|
||||||
|
SettingsItemDef *widthItem = new SettingsItemDef ("Width", "640");
|
||||||
|
widthItem->widget = WidgetDef (Widget_LineEdit);
|
||||||
|
widthItem->widget.widgetWidth = 45;
|
||||||
|
|
||||||
|
//custom height
|
||||||
|
SettingsItemDef *heightItem = new SettingsItemDef ("Height", "480");
|
||||||
|
heightItem->widget = WidgetDef (Widget_LineEdit);
|
||||||
|
heightItem->widget.widgetWidth = 45;
|
||||||
|
heightItem->widget.caption = "x";
|
||||||
|
|
||||||
|
block->settingItems << widthItem << heightItem;
|
||||||
|
block->widgetOrientation = Orient_Horizontal;
|
||||||
|
block->isVisible = false;
|
||||||
|
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVSettings::GroupBlockDef *CSVSettings::WindowPage::buildWindowSizeToggle()
|
||||||
|
{
|
||||||
|
GroupBlockDef *block = new GroupBlockDef ("Window Size");
|
||||||
|
|
||||||
// window size toggle
|
// window size toggle
|
||||||
windowSizeToggle.captions << "Pre-Defined" << "Custom";
|
block->captions << "Pre-Defined" << "Custom";
|
||||||
windowSizeToggle.widgetOrientation = Orient_Vertical;
|
block->widgetOrientation = Orient_Vertical;
|
||||||
windowSizeToggle.isVisible = false;
|
block->isVisible = false;
|
||||||
|
|
||||||
//define a widget for each group in the toggle
|
//define a widget for each group in the toggle
|
||||||
for (int i = 0; i < 2; i++)
|
for (int i = 0; i < 2; i++)
|
||||||
windowSizeToggle.widgets << new WidgetDef (Widget_RadioButton);
|
block->widgets << new WidgetDef (Widget_RadioButton);
|
||||||
|
|
||||||
windowSizeToggle.widgets.at(0)->isDefault = false;
|
block->widgets.at(0)->isDefault = false;
|
||||||
|
|
||||||
windowSize.blockDefList << &windowSizeToggle << &definedWindowSize << &customWindowSize;
|
return block;
|
||||||
windowSize.defaultValue = "Custom";
|
}
|
||||||
|
|
||||||
QGridLayout *pageLayout = new QGridLayout(this);
|
CSVSettings::CustomBlockDef *CSVSettings::WindowPage::buildWindowSize(GroupBlockDef *toggle_def,
|
||||||
|
GroupBlockDef *defined_def,
|
||||||
|
GroupBlockDef *custom_def)
|
||||||
|
{
|
||||||
|
CustomBlockDef *block = new CustomBlockDef(QString ("Window Size"));
|
||||||
|
|
||||||
setLayout (pageLayout);
|
block->blockDefList << toggle_def << defined_def << custom_def;
|
||||||
|
block->defaultValue = "Custom";
|
||||||
|
|
||||||
|
return block;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::WindowPage::setupUi()
|
||||||
|
{
|
||||||
|
CustomBlockDef *windowSize = buildWindowSize(buildWindowSizeToggle(),
|
||||||
|
buildDefinedWindowSize(),
|
||||||
|
buildCustomWindowSize()
|
||||||
|
);
|
||||||
|
|
||||||
mAbstractBlocks << buildBlock<ToggleBlock> (windowSize);
|
mAbstractBlocks << buildBlock<ToggleBlock> (windowSize);
|
||||||
|
|
||||||
|
@ -102,8 +123,15 @@ void CSVSettings::WindowPage::setupUi()
|
||||||
connect (block, SIGNAL (signalUpdateSetting (const QString &, const QString &)),
|
connect (block, SIGNAL (signalUpdateSetting (const QString &, const QString &)),
|
||||||
this, SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)) );
|
this, SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect ( this,
|
||||||
|
SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)),
|
||||||
|
&(CSMSettings::UserSettings::instance()),
|
||||||
|
SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSVSettings::WindowPage::initializeWidgets (const CSMSettings::SettingMap &settings)
|
void CSVSettings::WindowPage::initializeWidgets (const CSMSettings::SettingMap &settings)
|
||||||
{
|
{
|
||||||
//iterate each item in each blocks in this section
|
//iterate each item in each blocks in this section
|
||||||
|
|
|
@ -21,6 +21,12 @@ namespace CSVSettings {
|
||||||
void setupUi();
|
void setupUi();
|
||||||
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
||||||
|
|
||||||
|
///
|
||||||
|
GroupBlockDef *buildCustomWindowSize();
|
||||||
|
GroupBlockDef *buildDefinedWindowSize();
|
||||||
|
GroupBlockDef *buildWindowSizeToggle();
|
||||||
|
CustomBlockDef *buildWindowSize (GroupBlockDef *, GroupBlockDef *, GroupBlockDef *);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,6 +10,7 @@ CSVWorld::RecordStatusDelegate::RecordStatusDelegate(QUndoStack &undoStack, QObj
|
||||||
mModifiedIcon = new QIcon (":./modified.png");
|
mModifiedIcon = new QIcon (":./modified.png");
|
||||||
mAddedIcon = new QIcon (":./added.png");
|
mAddedIcon = new QIcon (":./added.png");
|
||||||
mDeletedIcon = new QIcon (":./removed.png");
|
mDeletedIcon = new QIcon (":./removed.png");
|
||||||
|
mBaseIcon = new QIcon (":./base.png");
|
||||||
mIconSize = 16;
|
mIconSize = 16;
|
||||||
|
|
||||||
//Offset values are most likely device-dependent.
|
//Offset values are most likely device-dependent.
|
||||||
|
@ -38,6 +39,7 @@ void CSVWorld::RecordStatusDelegate::paint (QPainter *painter, const QStyleOptio
|
||||||
{
|
{
|
||||||
case 0: // State_BaseOnly
|
case 0: // State_BaseOnly
|
||||||
text = "Base";
|
text = "Base";
|
||||||
|
icon = mBaseIcon;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // State_Modified
|
case 1: // State_Modified
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace CSVWorld
|
||||||
QIcon *mModifiedIcon;
|
QIcon *mModifiedIcon;
|
||||||
QIcon *mAddedIcon;
|
QIcon *mAddedIcon;
|
||||||
QIcon *mDeletedIcon;
|
QIcon *mDeletedIcon;
|
||||||
|
QIcon *mBaseIcon;
|
||||||
|
|
||||||
int mStatusDisplay;
|
int mStatusDisplay;
|
||||||
|
|
||||||
|
|
|
@ -4,5 +4,6 @@
|
||||||
<file>added.png</file>
|
<file>added.png</file>
|
||||||
<file>modified.png</file>
|
<file>modified.png</file>
|
||||||
<file>removed.png</file>
|
<file>removed.png</file>
|
||||||
|
<file>base.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
Loading…
Reference in a new issue