diff --git a/CMakeLists.txt b/CMakeLists.txt index ec8c7049b..6948a3420 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -305,9 +305,12 @@ configure_file(${OpenMW_SOURCE_DIR}/files/transparency-overrides.cfg configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg.local "${OpenMW_BINARY_DIR}/openmw.cfg") + configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg "${OpenMW_BINARY_DIR}/openmw.cfg.install") +configure_file(${OpenMW_SOURCE_DIR}/files/opencs.cfg + "${OpenMW_BINARY_DIR}/opencs.cfg") if (NOT WIN32 AND NOT APPLE) configure_file(${OpenMW_SOURCE_DIR}/files/openmw.desktop @@ -352,6 +355,7 @@ if(DPKG_PROGRAM) INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") INSTALL(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" DESTINATION "../etc/openmw/" RENAME "openmw.cfg" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") + INSTALL(FILES "${OpenMW_BINARY_DIR}/opencs.cfg" DESTINATION "../etc/openmw/" PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT "openmw") #Install resources INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "share/games/openmw/" FILE_PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT "Resources") @@ -591,6 +595,7 @@ if (APPLE) install(FILES "${OpenMW_BINARY_DIR}/openmw.cfg.install" RENAME "openmw.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) install(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) install(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) + install(FILES "${OpenMW_BINARY_DIR}/opencs.cfg" DESTINATION "${INSTALL_SUBDIR}" COMPONENT Runtime) set(CPACK_GENERATOR "DragNDrop") set(CPACK_PACKAGE_VERSION ${OPENMW_VERSION}) @@ -706,6 +711,7 @@ if (NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE) #INSTALL(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "${SYSCONFDIR}" ) INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${SYSCONFDIR}" ) INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${SYSCONFDIR}" ) + INSTALL(FILES "${OpenMW_BINARY_DIR}/opencs.cfg" DESTINATION "${SYSCONFDIR}" ) # Install resources INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${DATADIR}" ) diff --git a/apps/launcher/settings/gamesettings.cpp b/apps/launcher/settings/gamesettings.cpp index 1b0a2e9bf..205879bc3 100644 --- a/apps/launcher/settings/gamesettings.cpp +++ b/apps/launcher/settings/gamesettings.cpp @@ -6,8 +6,6 @@ #include #include -#include - #include #include diff --git a/apps/launcher/settings/settingsbase.hpp b/apps/launcher/settings/settingsbase.hpp index 6bf2eff66..ed8ada56c 100644 --- a/apps/launcher/settings/settingsbase.hpp +++ b/apps/launcher/settings/settingsbase.hpp @@ -7,8 +7,6 @@ #include #include -#include - template class SettingsBase { diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 158f7d7f1..866c0f1f2 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -57,11 +57,11 @@ opencs_hdrs_noqt (view/doc opencs_units (view/world - table tablesubview scriptsubview + table tablesubview scriptsubview util ) opencs_units_noqt (view/world - dialoguesubview util subviews enumdelegate vartypedelegate scripthighlighter + dialoguesubview subviews enumdelegate vartypedelegate scripthighlighter recordstatusdelegate ) diff --git a/apps/opencs/editor.cpp b/apps/opencs/editor.cpp index 991d59537..082fa376c 100644 --- a/apps/opencs/editor.cpp +++ b/apps/opencs/editor.cpp @@ -62,15 +62,9 @@ void CS::Editor::setupDataFiles() mFileDialog.addFiles(path); } - //Settings setup - QStringList settingFiles; - QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string()); - - settingFiles.append(QString("opencs.cfg")); - settingFiles.append(userPath + QString("opencs.cfg")); - - mUserSettings.setSettingsFiles(settingFiles); - mUserSettings.readSettings(); + //load the settings into the userSettings instance. + const QString settingFileName = "opencs.cfg"; + CSMSettings::UserSettings::instance().loadSettings(settingFileName); } diff --git a/apps/opencs/model/doc/document.cpp b/apps/opencs/model/doc/document.cpp index 07cc32465..30e9c21d1 100644 --- a/apps/opencs/model/doc/document.cpp +++ b/apps/opencs/model/doc/document.cpp @@ -1,6 +1,4 @@ - #include "document.hpp" - #include void CSMDoc::Document::load (const std::vector::const_iterator& begin, diff --git a/apps/opencs/model/settings/settingcontainer.hpp b/apps/opencs/model/settings/settingcontainer.hpp index eb264248d..5af298a57 100644 --- a/apps/opencs/model/settings/settingcontainer.hpp +++ b/apps/opencs/model/settings/settingcontainer.hpp @@ -15,21 +15,31 @@ namespace CSMSettings QStringList *mValues; public: + explicit SettingContainer (QObject *parent = 0); explicit SettingContainer (const QString &value, QObject *parent = 0); - virtual QString getName() const {return "";} - + /// add a value to the container + /// multiple values supported void insert (const QString &value); + + /// update an existing value + /// index specifies multiple values void update (const QString &value, int index = 0); + /// return value at specified index QString getValue (int index = -1) const; + + /// retrieve list of all values inline QStringList *getValues() const { return mValues; } + + /// return size of list int count() const; - //test for empty container - //useful for default-constructed containers returned by QMap when invalid key is passed + /// test for empty container + /// useful for default-constructed containers returned by QMap when invalid key is passed inline bool isEmpty() const { return (!mValue && !mValues); } + inline bool isMultiValue() const { return (mValues); } }; } diff --git a/apps/opencs/model/settings/settingsitem.cpp b/apps/opencs/model/settings/settingsitem.cpp index fef9d3e2f..5d897448a 100644 --- a/apps/opencs/model/settings/settingsitem.cpp +++ b/apps/opencs/model/settings/settingsitem.cpp @@ -1,5 +1,7 @@ #include "settingsitem.hpp" +#include + bool CSMSettings::SettingsItem::updateItem (const QStringList *values) { QStringList::ConstIterator it = values->begin(); @@ -66,21 +68,21 @@ bool CSMSettings::SettingsItem::updateItem(int valueListIndex) bool CSMSettings::SettingsItem::validate (const QString &value) { - bool isValid = true; + //if there is no value list or value pair, there is no validation to do + bool isValid = !(!mValueList->isEmpty() || mValuePair); - //validation required only if a value list or min/max value pair has been provided - if (mValueList->size()>0) + if (!isValid && !mValueList->isEmpty()) { - for (QStringList::ConstIterator it = mValueList->begin(); it !=mValueList->end(); ++it) + for (QStringList::Iterator it = mValueList->begin(); it != mValueList->end(); ++it) + // foreach (QString listItem, *mValueList) { - isValid = ( value == *it); + isValid = (value == *it); if (isValid) break; } } - - else if (mValuePair) + else if (!isValid && mValuePair) { int numVal = value.toInt(); diff --git a/apps/opencs/model/settings/settingsitem.hpp b/apps/opencs/model/settings/settingsitem.hpp index 8be05a4c7..c2587e892 100644 --- a/apps/opencs/model/settings/settingsitem.hpp +++ b/apps/opencs/model/settings/settingsitem.hpp @@ -7,12 +7,13 @@ namespace CSMSettings { + /// Represents a setting including metadata + /// (valid values, ranges, defaults, and multivalue status class SettingsItem : public SettingContainer { QStringPair *mValuePair; QStringList *mValueList; bool mIsMultiValue; - QString mName; QString mDefaultValue; public: @@ -20,26 +21,41 @@ namespace CSMSettings const QString& defaultValue, QObject *parent = 0) : SettingContainer(defaultValue, parent), mIsMultiValue (isMultiValue), mValueList (0), - mName (name), mValuePair (0), mDefaultValue (defaultValue) - {} - + mValuePair (0), mDefaultValue (defaultValue) + { + 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 QString &value); bool updateItem (int valueListIndex); + /// retroeve list of valid values for setting inline QStringList *getValueList() { return mValueList; } + + /// write list of valid values for setting inline void setValueList (QStringList *valueList) { mValueList = valueList; } + /// valuePair used for spin boxes (max / min) inline QStringPair *getValuePair() { return mValuePair; } + + /// set value range (spinbox / integer use) inline void setValuePair (QStringPair valuePair) { mValuePair = new QStringPair(valuePair); } - inline QString getName () const { return mName; } inline bool isMultivalue () { return mIsMultiValue; } void setDefaultValue (const QString &value); QString getDefaultValue () const; 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 bool validate (const QString &value); }; } diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 79de124c2..508942f58 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -7,13 +7,14 @@ #include #include #include + +#include #include #include - #include "settingcontainer.hpp" - #include + /** * Workaround for problems with whitespaces in paths in older versions of Boost library */ @@ -36,6 +37,12 @@ CSMSettings::UserSettings::UserSettings() { assert(!mUserSettingsInstance); mUserSettingsInstance = this; + + mReadWriteMessage = QObject::tr("
Could not open or create file for writing

\ + Please make sure you have the right permissions and try again.
"); + + mReadOnlyMessage = QObject::tr("
Could not open file for reading

\ + Please make sure you have the right permissions and try again.
"); } CSMSettings::UserSettings::~UserSettings() @@ -43,159 +50,193 @@ CSMSettings::UserSettings::~UserSettings() mUserSettingsInstance = 0; } -CSMSettings::SectionMap CSMSettings::UserSettings::getSettingsMap() const +QTextStream *CSMSettings::UserSettings::openFileStream (const QString &filePath, bool isReadOnly) const { - return mSectionMap; -} + QFile *file = new QFile(filePath); -QFile *CSMSettings::UserSettings::openFile (const QString &filename) const -{ - QFile *file = new QFile(filename); + QIODevice::OpenMode openFlags; + + if (isReadOnly) + openFlags = QIODevice::ReadOnly | QIODevice::Text; + else + openFlags = QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate; - bool success = (file->open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) ; + QTextStream *stream = 0; - if (!success) + if (file->open(openFlags)) + { + stream = new QTextStream(file); + stream->setCodec(QTextCodec::codecForName("UTF-8")); + } + + if (!stream) { - // File cannot be opened or created - QMessageBox msgBox; - msgBox.setWindowTitle(QObject::tr("Error writing OpenMW configuration file")); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText(QObject::tr("
Could not open or create %0 for writing

\ - Please make sure you have the right permissions \ - and try again.
").arg(file->fileName())); - msgBox.exec(); delete file; file = 0; } - return file; + return stream; + } -bool CSMSettings::UserSettings::writeFile(QFile *file, QMap &settings) const +bool CSMSettings::UserSettings::writeSettings(QMap &settings) { - if (!file) - return false; - - QTextStream stream(file); - stream.setCodec(QTextCodec::codecForName("UTF-8")); + QTextStream *stream = openFileStream(mUserFilePath); - QList keyList = settings.keys(); + if (!stream) + displayFileErrorMessage(mReadWriteMessage, false); - foreach (QString key, keyList) + if (stream) { - SettingList *sectionSettings = settings[key]; + QList keyList = settings.keys(); - stream << "[" << key << "]" << '\n'; + foreach (QString key, keyList) + { + SettingList *sectionSettings = settings[key]; - foreach (SettingContainer *item, *sectionSettings) - stream << item->getName() << " = " << item->getValue() << '\n'; + *stream << "[" << key << "]" << '\n'; + + foreach (SettingContainer *item, *sectionSettings) + *stream << item->objectName() << " = " << item->getValue() << '\n'; + } + + stream->device()->close(); } - file->close(); + return (stream); +} + - return true; +const CSMSettings::SectionMap &CSMSettings::UserSettings::getSettings() const +{ + return mSectionSettings; } -void CSMSettings::UserSettings::getSettings(QTextStream &stream, SectionMap §ions) const +bool CSMSettings::UserSettings::loadFromFile(const QString &filePath) { - //looks for a square bracket, "'\\[" - //that has one or more "not nothing" in it, "([^]]+)" - //and is closed with a square bracket, "\\]" + if (filePath.isEmpty()) + return false; - QRegExp sectionRe("^\\[([^]]+)\\]"); + mSectionSettings.clear(); - //Find any character(s) that is/are not equal sign(s), "[^=]+" - //followed by an optional whitespace, an equal sign, and another optional whirespace, "\\s*=\\s*" - //and one or more periods, "(.+)" + QTextStream *stream = openFileStream (filePath, true); - QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$"); + if (stream) + { + //looks for a square bracket, "'\\[" + //that has one or more "not nothing" in it, "([^]]+)" + //and is closed with a square bracket, "\\]" - CSMSettings::SettingMap *settings = 0; - QString section = "none"; + QRegExp sectionRe("^\\[([^]]+)\\]"); - while (!stream.atEnd()) - { - QString line = stream.readLine().simplified(); + //Find any character(s) that is/are not equal sign(s), "[^=]+" + //followed by an optional whitespace, an equal sign, and another optional whitespace, "\\s*=\\s*" + //and one or more periods, "(.+)" - if (line.isEmpty() || line.startsWith("#")) - continue; + QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$"); - //if a section is found, push it onto a new QStringList - //and push the QStringList onto - if (sectionRe.exactMatch(line)) - { - //add the previous section's settings to the member map - if (settings) - sections.insert(section, settings); - - //save new section and create a new list - section = sectionRe.cap(1); - settings = new SettingMap; - continue; - } + CSMSettings::SettingMap *settings = 0; + QString section = "none"; - if (keyRe.indexIn(line) != -1) + while (!stream->atEnd()) { - SettingContainer *sc = new SettingContainer (keyRe.cap(2).simplified()); - (*settings)[keyRe.cap(1).simplified()] = sc; + QString line = stream->readLine().simplified(); + + if (line.isEmpty() || line.startsWith("#")) + continue; + + //if a section is found, push it onto a new QStringList + //and push the QStringList onto + if (sectionRe.exactMatch(line)) + { + //add the previous section's settings to the member map + if (settings) + mSectionSettings.insert(section, settings); + + //save new section and create a new list + section = sectionRe.cap(1); + settings = new SettingMap; + continue; + } + + if (keyRe.indexIn(line) != -1) + { + SettingContainer *sc = new SettingContainer (keyRe.cap(2).simplified()); + sc->setObjectName(keyRe.cap(1).simplified()); + (*settings)[keyRe.cap(1).simplified()] = sc; + } + } + mSectionSettings.insert(section, settings); + + stream->device()->close(); } - sections.insert(section, settings); + + return (stream); } -void CSMSettings::UserSettings::readSettings() +void CSMSettings::UserSettings::loadSettings (const QString &fileName) { - CSMSettings::SectionMap sectionMap; + bool globalOk; + bool localOk; - foreach (const QString &path, mSettingsFiles) - { - qDebug() << "Loading config file:" << qPrintable(path); - QFile file(path); + //global + QString globalFilePath = QString::fromStdString(mCfgMgr.getGlobalPath().string()) + fileName; + globalOk = loadFromFile(globalFilePath); - if (file.exists()) - { - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error opening OpenCS configuration file")); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setText(QObject::tr("
Could not open %0 for reading

\ - Please make sure you have the right permissions \ - and try again.
").arg(file.fileName())); - msgBox.exec(); - return; - } - QTextStream stream(&file); - stream.setCodec(QTextCodec::codecForName("UTF-8")); - + //local + QString localFilePath = QString::fromStdString(mCfgMgr.getLocalPath().string()) + fileName; + localOk = loadFromFile(localFilePath); - getSettings(stream, mSectionMap); - } + //user + mUserFilePath = QString::fromStdString(mCfgMgr.getUserPath().string()) + fileName; + loadFromFile(mUserFilePath); + + if (!(localOk || globalOk)) + { + QString message = QObject::tr("
Could not open user settings files for reading

\ + Global and local settings files could not be read.\ + You may have incorrect file permissions or the OpenCS installation may be corrupted.
"); + + message += QObject::tr("
Global filepath: ") + globalFilePath; + message += QObject::tr("
Local filepath: ") + localFilePath; - file.close(); + displayFileErrorMessage ( message, true); } } -void CSMSettings::UserSettings::setSettingsFiles(QStringList files) +void CSMSettings::UserSettings::updateSettings (const QString §ionName, const QString &settingName) { - mSettingsFiles = files; -} + SettingMap *settings = mSectionSettings[sectionName]; -QStringList CSMSettings::UserSettings::getSettingsFiles () const -{ - return mSettingsFiles; + if (!settings) + return; + + SettingContainer *setting = 0; + + if (settingName.isEmpty()) + { + foreach (setting, *settings) + emit signalUpdateEditorSetting (setting->objectName(), setting->getValue()); + } + else + { + if (settings->find(settingName)!=settings->end()) + { + setting = settings->value(settingName); + emit signalUpdateEditorSetting (setting->objectName(), setting->getValue()); + } + } } -QString CSMSettings::UserSettings::getSettingValue(QString section, QString setting) const +QString CSMSettings::UserSettings::getSetting (const QString §ion, const QString &setting) const { - if(mSectionMap.find(section) == mSectionMap.end()) + if(mSectionSettings.find(section) == mSectionSettings.end()) return QString(); - CSMSettings::SettingMap *settings = mSectionMap.value(section); + CSMSettings::SettingMap *settings = mSectionSettings.value(section); if(settings->find(setting) == settings->end()) return QString(); @@ -205,9 +246,24 @@ QString CSMSettings::UserSettings::getSettingValue(QString section, QString sett return settingContainer->getValue(); } -const CSMSettings::UserSettings& CSMSettings::UserSettings::instance() +CSMSettings::UserSettings& CSMSettings::UserSettings::instance() { assert(mUserSettingsInstance); return *mUserSettingsInstance; } +void CSMSettings::UserSettings::displayFileErrorMessage(const QString &message, bool isReadOnly) +{ + // File cannot be opened or created + QMessageBox msgBox; + msgBox.setWindowTitle(QObject::tr("OpenCS configuration file I/O error")); + msgBox.setIcon(QMessageBox::Critical); + msgBox.setStandardButtons(QMessageBox::Ok); + + if (!isReadOnly) + msgBox.setText (mReadWriteMessage + message); + else + msgBox.setText (message); + + msgBox.exec(); +} diff --git a/apps/opencs/model/settings/usersettings.hpp b/apps/opencs/model/settings/usersettings.hpp index 6a2628fd1..49b226df9 100644 --- a/apps/opencs/model/settings/usersettings.hpp +++ b/apps/opencs/model/settings/usersettings.hpp @@ -10,6 +10,10 @@ #include "support.hpp" +#ifndef Q_MOC_RUN +#include +#endif + namespace Files { typedef std::vector PathContainer; struct ConfigurationManager;} @@ -22,34 +26,56 @@ namespace CSMSettings { Q_OBJECT + SectionMap mSectionSettings; + static UserSettings *mUserSettingsInstance; + QString mUserFilePath; + Files::ConfigurationManager mCfgMgr; + QString mReadOnlyMessage; + QString mReadWriteMessage; + public: + /// Singleton implementation + static UserSettings& instance(); + UserSettings(); ~UserSettings(); - static const UserSettings& instance(); + UserSettings (UserSettings const &); //not implemented + void operator= (UserSettings const &); //not implemented + + /// Writes settings to the last loaded settings file + bool writeSettings(QMap §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 = ""); - void readSettings(); - void setSettingsFiles(QStringList files); + /// Retrieves the settings file at all three levels (global, local and user). - QFile *openFile (const QString &) const; - bool writeFile(QFile *file, QMap §ions) const; - void getSettings (QTextStream &stream, SectionMap &settings) const; - QStringList getSettingsFiles () const; - CSMSettings::SectionMap getSettingsMap() const; - QString getSettingValue(QString section, QString setting) const; + /// \todo Multi-valued settings are not fully implemented. Setting values + /// \todo 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: - static UserSettings *mUserSettingsInstance; - CSMSettings::SectionMap mSectionMap; - QStringList mSettingsFiles; + /// Opens a QTextStream from the provided path as read-only or read-write. + QTextStream *openFileStream (const QString &filePath, bool isReadOnly = false) const; - UserSettings (UserSettings const &); //not implemented - void operator= (UserSettings const &); //not implemented + /// Parses a setting file specified in filePath from the provided text stream. + bool loadFromFile (const QString &filePath = ""); + + void displayFileErrorMessage(const QString &message, bool isReadOnly); signals: + void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue); }; diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index 8cc435f3a..e71e633a4 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -41,7 +41,8 @@ namespace CSMWorld Display_ArmorType, Display_ClothingType, Display_CreatureType, - Display_WeaponType + Display_WeaponType, + Display_RecordState }; std::string mTitle; diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index f1d8d4ae6..649ae192f 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -53,7 +53,7 @@ namespace CSMWorld template struct RecordStateColumn : public Column { - RecordStateColumn() : Column ("*", ColumnBase::Display_Integer) {} + RecordStateColumn() : Column ("*", ColumnBase::Display_RecordState) {} virtual QVariant get (const Record& record) const { @@ -775,4 +775,4 @@ namespace CSMWorld }; } -#endif \ No newline at end of file +#endif diff --git a/apps/opencs/model/world/refidcollection.cpp b/apps/opencs/model/world/refidcollection.cpp index e11fe0fc8..2bb8d07b3 100644 --- a/apps/opencs/model/world/refidcollection.cpp +++ b/apps/opencs/model/world/refidcollection.cpp @@ -39,7 +39,7 @@ CSMWorld::RefIdCollection::RefIdCollection() mColumns.push_back (RefIdColumn ("ID", ColumnBase::Display_String, ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false)); baseColumns.mId = &mColumns.back(); - mColumns.push_back (RefIdColumn ("*", ColumnBase::Display_Integer, + mColumns.push_back (RefIdColumn ("*", ColumnBase::Display_RecordState, ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false)); baseColumns.mModified = &mColumns.back(); mColumns.push_back (RefIdColumn ("Type", ColumnBase::Display_Integer, @@ -537,4 +537,4 @@ void CSMWorld::RefIdCollection::load (ESM::ESMReader& reader, bool base, Univers int CSMWorld::RefIdCollection::getAppendIndex (UniversalId::Type type) const { return mData.getAppendIndex (type); -} \ No newline at end of file +} diff --git a/apps/opencs/view/doc/subview.cpp b/apps/opencs/view/doc/subview.cpp index affada012..731adabb3 100644 --- a/apps/opencs/view/doc/subview.cpp +++ b/apps/opencs/view/doc/subview.cpp @@ -1,5 +1,6 @@ #include "subview.hpp" + CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id) : mUniversalId (id) { /// \todo add a button to the title bar that clones this sub view @@ -15,3 +16,7 @@ CSMWorld::UniversalId CSVDoc::SubView::getUniversalId() const { return mUniversalId; } + +void CSVDoc::SubView::updateEditorSetting (const QString &settingName, const QString &settingValue) +{ +} diff --git a/apps/opencs/view/doc/subview.hpp b/apps/opencs/view/doc/subview.hpp index 985c5eb3c..280a2a487 100644 --- a/apps/opencs/view/doc/subview.hpp +++ b/apps/opencs/view/doc/subview.hpp @@ -35,6 +35,7 @@ namespace CSVDoc CSMWorld::UniversalId getUniversalId() const; virtual void setEditLock (bool locked) = 0; + virtual void updateEditorSetting (const QString &, const QString &); signals: @@ -42,4 +43,4 @@ namespace CSVDoc }; } -#endif \ No newline at end of file +#endif diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 1e19e6db4..e82629ff2 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include "../../model/doc/document.hpp" #include "../world/subviews.hpp" @@ -180,8 +179,9 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to : mViewManager (viewManager), mDocument (document), mViewIndex (totalViews-1), mViewTotal (totalViews) { - QString width = CSMSettings::UserSettings::instance().getSettingValue(QString("Window Size"), QString("Width")); - QString height = CSMSettings::UserSettings::instance().getSettingValue(QString("Window Size"), QString("Height")); + QString width = CSMSettings::UserSettings::instance().getSetting(QString("Window Size"), QString("Width")); + QString height = CSMSettings::UserSettings::instance().getSetting(QString("Window Size"), QString("Height")); + if(width==QString() || height==QString()) resize(800, 600); else @@ -264,11 +264,14 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id) /// \todo add an user setting to reuse sub views (on a per document basis or on a per top level view basis) SubView *view = mSubViewFactory.makeSubView (id, *mDocument); + view->setObjectName ("subview"); mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view); connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&)), this, SLOT (addSubView (const CSMWorld::UniversalId&))); + CSMSettings::UserSettings::instance().updateSettings("Editor", "Record Status Display"); + view->show(); } @@ -372,20 +375,34 @@ void CSVDoc::View::showUserSettings() { CSVSettings::UserSettingsDialog *settingsDialog = new CSVSettings::UserSettingsDialog(this); - connect (&(CSMSettings::UserSettings::instance()), SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)), - this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)) ); - settingsDialog->show(); } -void CSVDoc::View::slotUpdateEditorSetting(const QString &settingName, const QString &settingValue) +void CSVDoc::View::resizeViewWidth (int width) { - static QString lastValue = ""; + if (width >= 0) + resize (width, geometry().height()); +} - if (lastValue != settingValue) - { - //evaluate settingName against tokens to determine which function to call to update Editor application. +void CSVDoc::View::resizeViewHeight (int height) +{ + if (height >= 0) + resize (geometry().width(), height); +} - lastValue = settingValue; +void CSVDoc::View::updateEditorSetting (const QString &settingName, const QString &settingValue) +{ + if (settingName == "Record Status Display") + { + foreach (QObject *view, mSubViewWindow.children()) + { + if (view->objectName() == "subview") + dynamic_cast(view)->updateEditorSetting (settingName, settingValue); + } } + else if (settingName == "Width") + resizeViewWidth (settingValue.toInt()); + + else if (settingName == "Height") + resizeViewHeight (settingValue.toInt()); } diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp index 0552a86cb..74504e308 100644 --- a/apps/opencs/view/doc/view.hpp +++ b/apps/opencs/view/doc/view.hpp @@ -68,6 +68,14 @@ namespace CSVDoc void exitApplication(); + void loadUserSettings(); + + /// User preference function + void resizeViewWidth (int width); + + /// User preference function + void resizeViewHeight (int height); + public: View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews); @@ -88,6 +96,9 @@ namespace CSVDoc Operations *getOperations() const; + /// Function called by view manager when user preferences are updated + void updateEditorSetting (const QString &, const QString &); + signals: void newDocumentRequest(); @@ -102,8 +113,6 @@ namespace CSVDoc void abortOperation (int type); - void slotUpdateEditorSetting (const QString &settingName, const QString &settingValue); - private slots: void newView(); diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index d044098fe..bf9da68a0 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -12,13 +12,14 @@ #include "../world/util.hpp" #include "../world/enumdelegate.hpp" #include "../world/vartypedelegate.hpp" +#include "../world/recordstatusdelegate.hpp" +#include "../settings/usersettingsdialog.hpp" #include "view.hpp" #include #include #include -#include void CSVDoc::ViewManager::updateIndices() { @@ -117,6 +118,12 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) mDelegateFactories->add (CSMWorld::ColumnBase::Display_WeaponType, new CSVWorld::EnumDelegateFactory (sWeaponTypes)); + + mDelegateFactories->add (CSMWorld::ColumnBase::Display_RecordState, + new CSVWorld::RecordStatusDelegateFactory() ); + + connect (&CSMSettings::UserSettings::instance(), SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)), + this, SLOT (slotUpdateEditorSetting (const QString &, const QString &))); } CSVDoc::ViewManager::~ViewManager() @@ -343,3 +350,13 @@ void CSVDoc::ViewManager::exitApplication (CSVDoc::View *view) if (notifySaveOnClose (view)) QApplication::instance()->exit(); } + +void CSVDoc::ViewManager::slotUpdateEditorSetting (const QString &settingName, const QString &settingValue) +{ + if (settingName == "Record Status Display" || + settingName == "Width" || settingName == "Height") + { + foreach (CSVDoc::View *view, mViews) + view->updateEditorSetting (settingName, settingValue); + } +} diff --git a/apps/opencs/view/doc/viewmanager.hpp b/apps/opencs/view/doc/viewmanager.hpp index 90f23eaa1..1f4dcd51b 100644 --- a/apps/opencs/view/doc/viewmanager.hpp +++ b/apps/opencs/view/doc/viewmanager.hpp @@ -72,6 +72,9 @@ namespace CSVDoc void progress (int current, int max, int type, int threads, CSMDoc::Document *document); void onExitWarningHandler(int state, CSMDoc::Document* document); + + /// connected to update signal in UserSettings + void slotUpdateEditorSetting (const QString &, const QString &); }; } diff --git a/apps/opencs/view/settings/abstractblock.cpp b/apps/opencs/view/settings/abstractblock.cpp index 72d360348..65825ce8b 100644 --- a/apps/opencs/view/settings/abstractblock.cpp +++ b/apps/opencs/view/settings/abstractblock.cpp @@ -38,27 +38,27 @@ CSVSettings::AbstractWidget *CSVSettings::AbstractBlock::buildWidget (const QStr { case Widget_RadioButton: - widg = createSettingWidget (def, layout); + widg = new SettingWidget (def, layout, mBox); break; case Widget_SpinBox: - widg = createSettingWidget (def, layout); + widg = new SettingWidget (def, layout, mBox); break; case Widget_CheckBox: - widg = createSettingWidget (def, layout); + widg = new SettingWidget (def, layout, mBox); break; case Widget_LineEdit: - widg = createSettingWidget (def, layout); + widg = new SettingWidget (def, layout, mBox); break; case Widget_ListBox: - widg = createSettingWidget (def, layout); + widg = new SettingWidget (def, layout, mBox); break; case Widget_ComboBox: - widg = createSettingWidget (def, layout); + widg = new SettingWidget (def, layout, mBox); break; default: diff --git a/apps/opencs/view/settings/abstractblock.hpp b/apps/opencs/view/settings/abstractblock.hpp index 42e00b6d7..36108d752 100644 --- a/apps/opencs/view/settings/abstractblock.hpp +++ b/apps/opencs/view/settings/abstractblock.hpp @@ -11,6 +11,7 @@ namespace CSVSettings { + /// Abstract base class for all blocks class AbstractBlock : public QObject { Q_OBJECT @@ -31,40 +32,50 @@ namespace CSVSettings bool isVisible() const; 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; + + /// 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) { return false; } protected: + /// Creates the layout which for the blocks QGroupBox 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, QLayout *layout = 0, bool isConnected = true) const; - template - AbstractWidget *createSettingWidget (WidgetDef &wDef, QLayout *layout) const - { - return new SettingWidget (wDef, layout, mBox); - } - QWidget *getParent() const; public slots: + /// enables / disables block-level widgets based on signals from other widgets + /// used in ToggleBlock void slotSetEnabled (bool value); + + /// receives updates to applicaion-level settings in the Editor void slotUpdateSetting (const QString &settingName, const QString &settingValue); private slots: + /// receives updates to a setting in the block pushed from the application level void slotUpdate (const QString &value); signals: - //signal to functions outside the settings tab widget + /// signal to UserSettings instance void signalUpdateSetting (const QString &propertyName, const QString &propertyValue); + + /// signal to widget for updating widget 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); }; } diff --git a/apps/opencs/view/settings/abstractpage.cpp b/apps/opencs/view/settings/abstractpage.cpp index 512b5abbd..e6c605275 100644 --- a/apps/opencs/view/settings/abstractpage.cpp +++ b/apps/opencs/view/settings/abstractpage.cpp @@ -13,12 +13,17 @@ CSVSettings::AbstractPage::AbstractPage(QWidget *parent): QWidget(parent) { + QGridLayout *pageLayout = new QGridLayout(this); + setLayout (pageLayout); } CSVSettings::AbstractPage::AbstractPage(const QString &pageName, QWidget *parent): QWidget(parent) { QWidget::setObjectName (pageName); + + QGridLayout *pageLayout = new QGridLayout(this); + setLayout (pageLayout); } CSVSettings::AbstractPage::~AbstractPage() diff --git a/apps/opencs/view/settings/abstractpage.hpp b/apps/opencs/view/settings/abstractpage.hpp index 15ac82a62..77ef4524f 100644 --- a/apps/opencs/view/settings/abstractpage.hpp +++ b/apps/opencs/view/settings/abstractpage.hpp @@ -14,6 +14,11 @@ namespace CSVSettings { typedef QList 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 { @@ -28,18 +33,24 @@ namespace CSVSettings { ~AbstractPage(); - 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; + /// retrieve the list of settings local to the page. CSMSettings::SettingList *getSettings(); void setObjectName(); protected: + /// Create a block for the page. + /// Block is constructed using passed definition struct + /// Page level-layout is created and assigned template - AbstractBlock *buildBlock (T &def) + AbstractBlock *buildBlock (T *def) { S *block = new S (this); int ret = block->build (def); @@ -47,12 +58,12 @@ namespace CSVSettings { if (ret < 0) return 0; - QWidget::layout()->addWidget (block->getGroupBox()); + QGroupBox *box = block->getGroupBox(); + QWidget::layout()->addWidget (box); return block; } - }; } diff --git a/apps/opencs/view/settings/abstractwidget.hpp b/apps/opencs/view/settings/abstractwidget.hpp index ef00993fc..325de2bd2 100644 --- a/apps/opencs/view/settings/abstractwidget.hpp +++ b/apps/opencs/view/settings/abstractwidget.hpp @@ -8,6 +8,7 @@ class QLayout; namespace CSVSettings { + /// Abstract base class for widgets which are used in user preferences dialog class AbstractWidget : public QObject { Q_OBJECT @@ -16,45 +17,49 @@ namespace CSVSettings public: + /// Passed layout is assigned the constructed widget. + /// if no layout is passed, one is created. explicit AbstractWidget (QLayout *layout = 0, QWidget* parent = 0) : QObject (parent), mLayout (layout) {} - //retrieve layout for insertion into itemblock + /// retrieve layout for insertion into itemblock QLayout *getLayout(); - //create the derived widget instance + /// create the derived widget instance 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; 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; - //converts user-defined enum to Qt equivalents + /// Converts user-defined enum to Qt equivalents QFlags getAlignment (Alignment flag); private: - //widget initialization utilities + /// Creates layout and assigns label and widget as appropriate void createLayout (Orientation direction, bool isZeroMargin); + + /// Creates label and widget according to passed definition void buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel); signals: - //outbound update + /// outbound update signal void signalUpdateItem (const QString &value); public slots: - //inbound updates + /// receives inbound updates 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 (bool value); void slotUpdateItem (int value); diff --git a/apps/opencs/view/settings/blankpage.cpp b/apps/opencs/view/settings/blankpage.cpp index 57d5c7caa..837a31bee 100644 --- a/apps/opencs/view/settings/blankpage.cpp +++ b/apps/opencs/view/settings/blankpage.cpp @@ -20,16 +20,11 @@ CSVSettings::BlankPage::BlankPage(QWidget *parent): AbstractPage("Blank", parent) { - initPage(); + } CSVSettings::BlankPage::BlankPage(const QString &title, QWidget *parent): AbstractPage(title, parent) -{ - initPage(); -} - -void CSVSettings::BlankPage::initPage() { // Hacks to get the stylesheet look properly #ifdef Q_OS_MAC @@ -43,10 +38,7 @@ void CSVSettings::BlankPage::initPage() void CSVSettings::BlankPage::setupUi() { QGroupBox *pageBox = new QGroupBox(this); - QLayout* pageLayout = new QVBoxLayout(); - - setLayout(pageLayout); - pageLayout->addWidget(pageBox); + layout()->addWidget(pageBox); } void CSVSettings::BlankPage::initializeWidgets (const CSMSettings::SettingMap &settings) diff --git a/apps/opencs/view/settings/blankpage.hpp b/apps/opencs/view/settings/blankpage.hpp index 648d373f3..07049fb71 100644 --- a/apps/opencs/view/settings/blankpage.hpp +++ b/apps/opencs/view/settings/blankpage.hpp @@ -10,6 +10,8 @@ namespace CSVSettings { class UserSettings; class AbstractBlock; + /// Derived page with no widgets + /// Reference use only. class BlankPage : public AbstractPage { @@ -20,9 +22,6 @@ namespace CSVSettings { void setupUi(); void initializeWidgets (const CSMSettings::SettingMap &settings); - - private: - void initPage(); }; } diff --git a/apps/opencs/view/settings/customblock.cpp b/apps/opencs/view/settings/customblock.cpp index f44189569..a07ee5ac9 100644 --- a/apps/opencs/view/settings/customblock.cpp +++ b/apps/opencs/view/settings/customblock.cpp @@ -23,7 +23,7 @@ int CSVSettings::CustomBlock::build(GroupBlockDefList &defList, GroupBlockDefLis for (; listIt != defList.end(); ++listIt) { if (!(*listIt)->isProxy) - retVal = buildGroupBlock (*(*listIt)); + retVal = buildGroupBlock (*listIt); else { mGroupList << proxyBlock; @@ -32,7 +32,7 @@ int CSVSettings::CustomBlock::build(GroupBlockDefList &defList, GroupBlockDefLis } if (proxyIt != defaultIt) - retVal = buildProxyBlock (*(*proxyIt), proxyBlock); + retVal = buildProxyBlock (*proxyIt, proxyBlock); return retVal; } @@ -45,7 +45,7 @@ CSVSettings::GroupBox *CSVSettings::CustomBlock::buildGroupBox (Orientation orie return box; } -int CSVSettings::CustomBlock::buildGroupBlock(GroupBlockDef &def) +int CSVSettings::CustomBlock::buildGroupBlock(GroupBlockDef *def) { GroupBlock *block = new GroupBlock (getParent()); @@ -57,9 +57,9 @@ int CSVSettings::CustomBlock::buildGroupBlock(GroupBlockDef &def) return block->build(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; int retVal = block->build(def); @@ -67,7 +67,8 @@ int CSVSettings::CustomBlock::buildProxyBlock(GroupBlockDef& def, ProxyBlock *bl if (retVal != 0) 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); diff --git a/apps/opencs/view/settings/customblock.hpp b/apps/opencs/view/settings/customblock.hpp index b2f2a0261..54c50f395 100644 --- a/apps/opencs/view/settings/customblock.hpp +++ b/apps/opencs/view/settings/customblock.hpp @@ -8,6 +8,8 @@ namespace CSVSettings class ProxyBlock; + /// Base class for customized user preference setting blocks + /// Special block classes should be derived from CustomBlock class CustomBlock : public AbstractBlock { @@ -19,18 +21,27 @@ namespace CSVSettings explicit CustomBlock (QWidget *parent = 0); + /// Update settings local to the block bool updateSettings (const CSMSettings::SettingMap &settings); + + /// Retrieve settings local to the block CSMSettings::SettingList *getSettings(); + + /// construct the block using the passed definition int build (GroupBlockDefList &defList, GroupBlockDefList::Iterator *it = 0); protected: + /// construct the block groupbox GroupBox *buildGroupBox (Orientation orientation); private: - int buildGroupBlock(GroupBlockDef &def); - int buildProxyBlock(GroupBlockDef &def, ProxyBlock *block); + /// Construction function for creating a standard GroupBlock child + int buildGroupBlock(GroupBlockDef *def); + + /// Construction function for creating a standard ProxyBlock child + int buildProxyBlock(GroupBlockDef *def, ProxyBlock *block); }; } #endif // CUSTOMBLOCK_HPP diff --git a/apps/opencs/view/settings/editorpage.cpp b/apps/opencs/view/settings/editorpage.cpp index ad5a15f6f..50b5a6536 100644 --- a/apps/opencs/view/settings/editorpage.cpp +++ b/apps/opencs/view/settings/editorpage.cpp @@ -1,156 +1,46 @@ #include "editorpage.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef Q_OS_MAC -#include -#endif - -#include "../../model/settings/usersettings.hpp" #include "groupblock.hpp" -#include "toggleblock.hpp" +#include "../../model/settings/usersettings.hpp" -CSVSettings::EditorPage::EditorPage(QWidget *parent): +CSVSettings::EditorPage::EditorPage(QWidget* parent) : AbstractPage("Editor", parent) { - // Hacks to get the stylesheet look properly -#ifdef Q_OS_MAC - QPlastiqueStyle *style = new QPlastiqueStyle; - //profilesComboBox->setStyle(style); -#endif - setupUi(); } -void CSVSettings::EditorPage::setupUi() +CSVSettings::GroupBlockDef *CSVSettings::EditorPage::setupRecordStatusDisplay() { - GroupBlockDef undoStack (QString("Undo Stack Size")); - GroupBlockDef topLevelWindowCount (QString("Maximum Top-Level Window Count")); - GroupBlockDef reuseSubwindow (QString("Reuse Subwindows")); - GroupBlockDef customWindowSize (QString ("Custom Window Size")); - GroupBlockDef definedWindowSize (QString ("Pre-Defined Window Size")); - GroupBlockDef windowSizeToggle (QString ("Window Size")); - CustomBlockDef windowSize (QString ("Window Size")); - - //////////////////////////// - //undo stack size property - /////////////////////////// - - SettingsItemDef *undoStackItem = new SettingsItemDef (undoStack.title, "32"); - undoStack.properties << undoStackItem; - undoStackItem->minMax.left = "0"; - undoStackItem->minMax.right = "64"; - - WidgetDef stackWidget (Widget_SpinBox); - stackWidget.minMax = &(undoStackItem->minMax); - stackWidget.widgetWidth = 50; - - undoStackItem->widget = stackWidget; - - ////////////////////////////////////// - //number of top level windows property - ///////////////////////////////////// - - SettingsItemDef *topLevelItem = new SettingsItemDef (topLevelWindowCount.title, "100"); - topLevelWindowCount.properties << topLevelItem; - topLevelItem->minMax.left = "1"; - topLevelItem->minMax.right = "256"; - - WidgetDef topLvlWinWidget (Widget_SpinBox); - topLvlWinWidget.minMax = &(topLevelItem->minMax); - topLvlWinWidget.widgetWidth = 50; - - topLevelItem->widget = topLvlWinWidget; - - /////////////////////////// - //reuse subwindows property - //////////////////////////// - - SettingsItemDef *reuseSubItem = new SettingsItemDef (reuseSubwindow.title, "Reuse Subwindows"); - *(reuseSubItem->valueList) << "None" << "Top-Level" << "Document-Level"; - - WidgetDef reuseSubWidget (Widget_RadioButton); - reuseSubWidget.valueList = (reuseSubItem->valueList); - reuseSubWidget.widgetAlignment = Align_Left; + GroupBlockDef *statusBlock = new GroupBlockDef(QString("Record Status Display")); - reuseSubwindow.properties << reuseSubItem; - reuseSubItem->widget = reuseSubWidget; + SettingsItemDef *statusItem = new SettingsItemDef (statusBlock->title, "Icon and Text"); + *(statusItem->valueList) << QString("Icon and Text") << QString("Icon Only") << QString("Text Only"); - /////////////////////////////// - //custom window size properties - /////////////////////////////// + WidgetDef statusWidget (Widget_RadioButton); + statusWidget.valueList = statusItem->valueList; - //custom width - SettingsItemDef *widthItem = new SettingsItemDef ("Window Width", "640"); - widthItem->widget = WidgetDef (Widget_LineEdit); - widthItem->widget.widgetWidth = 45; + statusItem->widget = statusWidget; - //custom height - SettingsItemDef *heightItem = new SettingsItemDef ("Window Height", "480"); - heightItem->widget = WidgetDef (Widget_LineEdit); - heightItem->widget.widgetWidth = 45; - heightItem->widget.caption = "x"; + statusBlock->settingItems << statusItem; - customWindowSize.properties << widthItem << heightItem; - customWindowSize.widgetOrientation = Orient_Horizontal; - customWindowSize.isVisible = false; - - - //pre-defined - SettingsItemDef *widthByHeightItem = new SettingsItemDef ("Window Size", "640x480"); - WidgetDef widthByHeightWidget = WidgetDef (Widget_ComboBox); - widthByHeightWidget.widgetWidth = 90; - *(widthByHeightItem->valueList) << "640x480" << "800x600" << "1024x768"; - - QStringList *widthProxy = new QStringList; - QStringList *heightProxy = new QStringList; - - (*widthProxy) << "Window Width" << "640" << "800" << "1024"; - (*heightProxy) << "Window Height" << "480" << "600" << "768"; - - *(widthByHeightItem->proxyList) << widthProxy << heightProxy; - - widthByHeightItem->widget = widthByHeightWidget; - - definedWindowSize.properties << widthByHeightItem; - definedWindowSize.isProxy = true; - definedWindowSize.isVisible = false; - - // window size toggle - windowSizeToggle.captions << "Pre-Defined" << "Custom"; - windowSizeToggle.widgetOrientation = Orient_Vertical; - windowSizeToggle.isVisible = false; - - //define a widget for each group in the toggle - for (int i = 0; i < 2; i++) - windowSizeToggle.widgets << new WidgetDef (Widget_RadioButton); - - windowSizeToggle.widgets.at(0)->isDefault = false; - - windowSize.blockDefList << &windowSizeToggle << &definedWindowSize << &customWindowSize; - windowSize.defaultValue = "Custom"; - - QGridLayout *pageLayout = new QGridLayout(this); + return statusBlock; +} - setLayout (pageLayout); +void CSVSettings::EditorPage::setupUi() +{ - mAbstractBlocks << buildBlock (topLevelWindowCount) - << buildBlock (reuseSubwindow) - << buildBlock (windowSize) - << buildBlock (undoStack); + mAbstractBlocks << buildBlock(setupRecordStatusDisplay()); foreach (AbstractBlock *block, mAbstractBlocks) { connect (block, SIGNAL (signalUpdateSetting (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::EditorPage::initializeWidgets (const CSMSettings::SettingMap &settings) diff --git a/apps/opencs/view/settings/editorpage.hpp b/apps/opencs/view/settings/editorpage.hpp index 0c1e80e89..85215edab 100644 --- a/apps/opencs/view/settings/editorpage.hpp +++ b/apps/opencs/view/settings/editorpage.hpp @@ -1,28 +1,33 @@ -#ifndef EDITORPAGE_H -#define EDITORPAGE_H +#ifndef EDITORPAGE_HPP +#define EDITORPAGE_HPP +#include "support.hpp" #include "abstractpage.hpp" -class QGroupBox; - -namespace CSVSettings { - - class UserSettings; - class AbstractBlock; - +namespace CSVSettings +{ class EditorPage : public AbstractPage { Q_OBJECT public: + explicit EditorPage(QWidget *parent = 0); - EditorPage(QWidget *parent = 0); - - void setupUi(); void initializeWidgets (const CSMSettings::SettingMap &settings); + void setupUi(); + + private: + + /// User preference view of the record status delegate's icon / text setting + GroupBlockDef *setupRecordStatusDisplay(); signals: + + /// Signals up for changes to editor application-level settings void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue); + + public slots: }; } -#endif //EDITORPAGE_H + +#endif // EDITORPAGE_HPP diff --git a/apps/opencs/view/settings/groupblock.cpp b/apps/opencs/view/settings/groupblock.cpp index b18f629ba..85720ad41 100644 --- a/apps/opencs/view/settings/groupblock.cpp +++ b/apps/opencs/view/settings/groupblock.cpp @@ -9,22 +9,22 @@ CSVSettings::GroupBlock::GroupBlock (bool isVisible, QWidget *parent) : AbstractBlock (isVisible, 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; int retVal = 0; - setVisible (def.isVisible); + setVisible (def->isVisible); - mBox->setLayout(createLayout (def.widgetOrientation, true)); + mBox->setLayout(createLayout (def->widgetOrientation, true)); - setObjectName (def.title); - mBox->setTitle (def.title); + setObjectName (def->title); + mBox->setTitle (def->title); - foreach (SettingsItemDef *itemDef, def.properties) + foreach (SettingsItemDef *itemDef, def->settingItems) { ItemBlock *block = new ItemBlock (mBox); diff --git a/apps/opencs/view/settings/groupblock.hpp b/apps/opencs/view/settings/groupblock.hpp index a8fd4e3b4..5c0754193 100644 --- a/apps/opencs/view/settings/groupblock.hpp +++ b/apps/opencs/view/settings/groupblock.hpp @@ -8,6 +8,8 @@ namespace CSVSettings { class ItemBlock; + /// Base class for group blocks. + /// Derived block classes should use CustomBlock class GroupBlock : public AbstractBlock { ItemBlockList mItemBlockList; @@ -16,15 +18,24 @@ namespace CSVSettings GroupBlock (QWidget* parent = 0); GroupBlock (bool isVisible, QWidget *parent = 0); - int build (GroupBlockDef &def); + /// build the gorup block based on passed definition + int build (GroupBlockDef *def); + /// update settings local to the group block bool updateSettings (const CSMSettings::SettingMap &settings); + /// retrieve setting list local to the group block CSMSettings::SettingList *getSettings(); + + /// retrieve item block by name from the passed list or local list ItemBlock *getItemBlock (const QString &name, ItemBlockList *blockList = 0); + + /// retrieve the item block by index from the local list ItemBlock *getItemBlock (int index); protected: + + /// create block layout based on passed definition int buildLayout (GroupBlockDef &def); }; diff --git a/apps/opencs/view/settings/groupbox.hpp b/apps/opencs/view/settings/groupbox.hpp index 43cb2e0c3..9d3a01936 100644 --- a/apps/opencs/view/settings/groupbox.hpp +++ b/apps/opencs/view/settings/groupbox.hpp @@ -5,6 +5,7 @@ namespace CSVSettings { + /// Custom implementation of QGroupBox to be used with block classes class GroupBox : public QGroupBox { static const QString INVISIBLE_BOX_STYLE; diff --git a/apps/opencs/view/settings/itemblock.hpp b/apps/opencs/view/settings/itemblock.hpp index c7714ac64..1a5447e31 100644 --- a/apps/opencs/view/settings/itemblock.hpp +++ b/apps/opencs/view/settings/itemblock.hpp @@ -15,22 +15,32 @@ namespace CSVSettings ItemBlock (QWidget* parent = 0); + /// pure virtual function not implemneted bool updateSettings (const CSMSettings::SettingMap &settings) { return false; } CSMSettings::SettingList *getSettings (); + QString getValue () const; + /// item blocks encapsulate only one setting int getSettingCount(); + + /// update setting value and corresponding widget bool update (const QString &value); + /// virtual construction function int build(SettingsItemDef &iDef); private: + /// custom construction function void buildItemBlock (SettingsItemDef& iDef); void buildItemBlockWidgets (SettingsItemDef& iDef); + + /// update the setting value bool updateItem (const QString &); + /// callback function triggered when update to application level is signalled bool updateBySignal (const QString &name, const QString &value, bool &doEmit); }; } diff --git a/apps/opencs/view/settings/proxyblock.cpp b/apps/opencs/view/settings/proxyblock.cpp index 71a307084..81cc54fca 100644 --- a/apps/opencs/view/settings/proxyblock.cpp +++ b/apps/opencs/view/settings/proxyblock.cpp @@ -5,10 +5,10 @@ CSVSettings::ProxyBlock::ProxyBlock (QWidget *parent) : GroupBlock (parent) { } -int CSVSettings::ProxyBlock::build (GroupBlockDef &proxyDef) +int CSVSettings::ProxyBlock::build (GroupBlockDef *proxyDef) { //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); @@ -53,6 +53,8 @@ bool CSVSettings::ProxyBlock::updateProxiedSettings() bool success = false; int i = 0; + + //find the value index of the selected value in the proxy setting for (; i < mValueList->size(); ++i) { success = (value == mValueList->at(i)); @@ -64,6 +66,7 @@ bool CSVSettings::ProxyBlock::updateProxiedSettings() if (!success) return false; + // update the containing the proxied item's name foreach (QStringList *list, mProxyList) { if ( list->at(0) == block->objectName()) diff --git a/apps/opencs/view/settings/proxyblock.hpp b/apps/opencs/view/settings/proxyblock.hpp index f757842ea..90fb9bc97 100644 --- a/apps/opencs/view/settings/proxyblock.hpp +++ b/apps/opencs/view/settings/proxyblock.hpp @@ -9,8 +9,7 @@ namespace CSVSettings { Q_OBJECT - //NOTE: mProxyItemBlockList and mProxyList - //should be combined into a value pair and stored in one list. + /// TODO: Combine mProxyItemBlockList and mProxyList. ItemBlockList mProxiedItemBlockList; ProxyList mProxyList; QStringList *mValueList; @@ -20,17 +19,28 @@ namespace CSVSettings explicit ProxyBlock (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); - int build (GroupBlockDef &def); + + int build (GroupBlockDef *def); CSMSettings::SettingList *getSettings() { return 0; } + + /// Update settings local to the proxy block pushed from application level 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); private: + /// return the item block of a proxied setting ItemBlock *getProxiedItemBlock (const QString &name); + + /// update the proxy setting with data from the proxied settings bool updateByProxiedSettings(const CSMSettings::SettingMap *settings = 0); + + /// update proxied settings with data from the proxy setting bool updateProxiedSettings(); private slots: diff --git a/apps/opencs/view/settings/settingwidget.hpp b/apps/opencs/view/settings/settingwidget.hpp index b29523a3a..9f4513671 100644 --- a/apps/opencs/view/settings/settingwidget.hpp +++ b/apps/opencs/view/settings/settingwidget.hpp @@ -16,7 +16,8 @@ namespace CSVSettings { - //VALID FOR RADIOBUTTON / CHECKBOX (or other toggle widget with it's own label) + + /// Generic template for radiobuttons / checkboxes template class SettingWidget : public AbstractWidget { @@ -47,6 +48,7 @@ namespace CSVSettings } }; + /// spin box template template <> class SettingWidget : public AbstractWidget { @@ -90,6 +92,7 @@ namespace CSVSettings }; + /// combo box template template <> class SettingWidget : public CSVSettings::AbstractWidget { @@ -142,6 +145,7 @@ namespace CSVSettings }; + /// line edit template template <> class SettingWidget : public CSVSettings::AbstractWidget { @@ -175,6 +179,8 @@ namespace CSVSettings } }; + /// list widget template + /// \todo Not fully implemented. Only widget supporting multi-valued settings template <> class SettingWidget : public CSVSettings::AbstractWidget { diff --git a/apps/opencs/view/settings/support.hpp b/apps/opencs/view/settings/support.hpp index 7185d2706..1df0dac1e 100644 --- a/apps/opencs/view/settings/support.hpp +++ b/apps/opencs/view/settings/support.hpp @@ -44,21 +44,44 @@ namespace CSVSettings Align_Right = Qt::AlignRight }; - //template for defining the widget of a property. + /// definition struct for widgets struct WidgetDef { - WidgetType type; //type of widget providing input - int labelWidth; //width of caption label - int widgetWidth; //width of input widget - Orientation orientation; //label / widget orientation (horizontal / vertical) - QString inputMask; //input mask (line edit) - QString caption; //label caption. Leave empty for multiple items. See BlockDef::captionList - QString value; //widget value. Leave empty for multiple items. See BlockDef::valueList - CSMSettings::QStringPair *minMax; //Min/Max QString value pair. If empty, assigned to property item value pair. - 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. - Alignment valueAlignment; //left / center / right-justify text in widget - Alignment widgetAlignment; //left / center / right-justify widget in group box + /// type of widget providing input + WidgetType type; + + /// width of caption label + int labelWidth; + + /// width of input widget + int widgetWidth; + + /// label / widget orientation (horizontal / vertical) + Orientation orientation; + + /// 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), @@ -79,20 +102,34 @@ namespace CSVSettings }; - //Defines the attributes of the property as it is represented in the config file - //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. + /// 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. + /// Only one widget may serve as the input widget for the setting. struct SettingsItemDef { - QString name; //property name - QStringList *valueList; //list of valid values for the property. - //Used to populate option widget captions or list widget item lists (see WidgetDef::caption / value) + /// setting name + QString name; + + /// 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; + + /// flag indicating multi-valued setting bool hasMultipleValues; - CSMSettings::QStringPair minMax; //minimum / maximum value pair - WidgetDef widget; //definition of the input widget for this setting - Orientation orientation; //general orientation of the widget / label for this property - ProxyList *proxyList; //list of property and corresponding default values for proxy widget + + /// minimum / maximum value pair + CSMSettings::QStringPair minMax; + + /// 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) {} @@ -104,18 +141,32 @@ namespace CSVSettings }; - //Hierarchically, this is a "sub-section" of properties within a section, solely for UI organization. - //Does not correlate to config file structure. + /// Generic container block struct GroupBlockDef { - QString title; //title of the block containing the property or properties of this sub-section - QStringList captions; //list of captions for widgets at the block level (not associated with any particular property) - WidgetList widgets; //list of widgets at the block level (not associated with any particular property) - QList properties; //list of the property(ies) which are subordinate to the property block. - Orientation widgetOrientation; //general orientation of widgets in group block - bool isVisible; //determines whether or not box border/title are visible - bool isProxy; //indicates whether or not this block defines a proxy block - QString defaultValue; //generic default value attribute + /// block title + QString title; + + /// list of captions for widgets at the block level (not associated with any particular setting) + QStringList captions; + + /// list of widgets at the block level (not associated with any particular setting) + WidgetList widgets; + + /// list of the settings which are subordinate to the setting block. + QList 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 ("") {} @@ -125,11 +176,19 @@ namespace CSVSettings {} }; + /// used to create unique, complex blocks struct CustomBlockDef { + /// block 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; CustomBlockDef (): title (""), defaultValue (""), blockOrientation (Orient_Horizontal) diff --git a/apps/opencs/view/settings/toggleblock.cpp b/apps/opencs/view/settings/toggleblock.cpp index 12a42ca9c..3406a62c4 100644 --- a/apps/opencs/view/settings/toggleblock.cpp +++ b/apps/opencs/view/settings/toggleblock.cpp @@ -7,24 +7,24 @@ CSVSettings::ToggleBlock::ToggleBlock(QWidget *parent) : CustomBlock(parent) {} -int CSVSettings::ToggleBlock::build(CustomBlockDef &def) +int CSVSettings::ToggleBlock::build(CustomBlockDef *def) { - if (def.blockDefList.size()==0) + if (def->blockDefList.size()==0) return -1; - QList::Iterator it = def.blockDefList.begin(); + QList::Iterator it = def->blockDefList.begin(); //first def in the list is the def for the toggle block GroupBlockDef *toggleDef = *it++; - if (toggleDef->captions.size() != def.blockDefList.size()-1 ) + if (toggleDef->captions.size() != def->blockDefList.size()-1 ) return -2; if (toggleDef->widgets.size() == 0) return -3; //create the toogle block UI structure - QLayout *blockLayout = createLayout (def.blockOrientation, true); + QLayout *blockLayout = createLayout (def->blockOrientation, true); GroupBox *propertyBox = buildGroupBox (toggleDef->widgetOrientation); mBox->setLayout(blockLayout); @@ -34,13 +34,13 @@ int CSVSettings::ToggleBlock::build(CustomBlockDef &def) //this manages proxy block construction. //Any settings managed by the proxy setting //must be included in the blocks defined in the list. - CustomBlock::build (def.blockDefList, &it); + CustomBlock::build (def->blockDefList, &it); for (GroupBlockList::iterator it = mGroupList.begin(); it != mGroupList.end(); ++it) propertyBox->layout()->addWidget ((*it)->getGroupBox()); //build togle widgets, linking them to the settings - GroupBox *toggleBox = buildToggleWidgets (*toggleDef, def.defaultValue); + GroupBox *toggleBox = buildToggleWidgets (toggleDef, def->defaultValue); blockLayout->addWidget(toggleBox); blockLayout->addWidget(propertyBox); @@ -49,16 +49,16 @@ int CSVSettings::ToggleBlock::build(CustomBlockDef &def) return 0; } -CSVSettings::GroupBox *CSVSettings::ToggleBlock::buildToggleWidgets (GroupBlockDef &def, QString &defaultToggle) +CSVSettings::GroupBox *CSVSettings::ToggleBlock::buildToggleWidgets (GroupBlockDef *def, QString &defaultToggle) { GroupBox *box = new GroupBox (false, getParent()); - QLayout *layout = createLayout (def.widgetOrientation, true, static_cast(box)); + QLayout *layout = createLayout (def->widgetOrientation, true, static_cast(box)); - for (int i = 0; i < def.widgets.size(); ++i) + for (int i = 0; i < def->widgets.size(); ++i) { - QString caption = def.captions.at(i); - WidgetDef *wDef = def.widgets.at(i); + QString caption = def->captions.at(i); + WidgetDef *wDef = def->widgets.at(i); wDef->caption = caption; wDef->widgetAlignment = Align_Left; diff --git a/apps/opencs/view/settings/toggleblock.hpp b/apps/opencs/view/settings/toggleblock.hpp index 8afe701b8..4b6e8e344 100644 --- a/apps/opencs/view/settings/toggleblock.hpp +++ b/apps/opencs/view/settings/toggleblock.hpp @@ -18,10 +18,12 @@ namespace CSVSettings public: explicit ToggleBlock(QWidget *parent = 0); - int build (CustomBlockDef &def); + int build (CustomBlockDef *def); private: - GroupBox *buildToggleWidgets (GroupBlockDef &def, QString &defaultToggle); + /// 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); }; } #endif // TOGGLEBLOCK_HPP diff --git a/apps/opencs/view/settings/usersettingsdialog.cpp b/apps/opencs/view/settings/usersettingsdialog.cpp index d657ba06b..64b9aacff 100644 --- a/apps/opencs/view/settings/usersettingsdialog.cpp +++ b/apps/opencs/view/settings/usersettingsdialog.cpp @@ -9,13 +9,14 @@ #include #include #include -#include -#include "blankpage.hpp" +#include + #include "editorpage.hpp" #include "windowpage.hpp" -#include "../../model/settings/support.hpp" +#include "../../model/settings/support.hpp" +#include #include "settingwidget.hpp" CSVSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) : @@ -23,13 +24,12 @@ CSVSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) : { setWindowTitle(QString::fromUtf8 ("User Settings")); buildPages(); - setWidgetStates (CSMSettings::UserSettings::instance().getSettingsMap()); - positionWindow (); + setWidgetStates (); connect (mListWidget, SIGNAL (currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, - SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); + SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); } CSVSettings::UserSettingsDialog::~UserSettingsDialog() @@ -41,17 +41,21 @@ void CSVSettings::UserSettingsDialog::closeEvent (QCloseEvent *event) writeSettings(); } -void CSVSettings::UserSettingsDialog::setWidgetStates (CSMSettings::SectionMap settingsMap) +void CSVSettings::UserSettingsDialog::setWidgetStates () { + CSMSettings::UserSettings::instance().loadSettings("opencs.cfg"); + const CSMSettings::SectionMap §ionSettings = CSMSettings::UserSettings::instance().getSettings(); + //iterate the tabWidget's pages (sections) for (int i = 0; i < mStackedWidget->count(); i++) { //get the settings defined for the entire section - CSMSettings::SettingMap *settings = settingsMap [mStackedWidget->widget(i)->objectName()]; + //and update widget + QString pageName = mStackedWidget->widget(i)->objectName(); - //if found, initialize the page's widgets - if (settings) + if (sectionSettings.find(pageName) != sectionSettings.end()) { + CSMSettings::SettingMap *settings = sectionSettings.value(pageName); AbstractPage *page = getAbstractPage (i); page->initializeWidgets(*settings); } @@ -66,60 +70,26 @@ void CSVSettings::UserSettingsDialog::buildPages() mListWidget = new QListWidget (centralWidget); mStackedWidget = new QStackedWidget (centralWidget); - QLayout* dialogLayout = new QHBoxLayout(); + QGridLayout* dialogLayout = new QGridLayout(); - dialogLayout->addWidget (mListWidget); - dialogLayout->addWidget (mStackedWidget); + mListWidget->setMinimumWidth(0); + mListWidget->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Expanding); + + mStackedWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed); + + dialogLayout->addWidget (mListWidget,0,0); + dialogLayout->addWidget (mStackedWidget,0,1, Qt::AlignTop); centralWidget->setLayout (dialogLayout); setCentralWidget (centralWidget); setDockOptions (QMainWindow::AllowNestedDocks); - //uncomment to test with sample editor page. - //createSamplePage(); - /*createPage("Page1"); - createPage("Page2"); - createPage("Page3");*/ - createWindowPage(); -} -void CSVSettings::UserSettingsDialog::createSamplePage() -{ - //add pages to stackedwidget and items to listwidget - CSVSettings::AbstractPage *page - = new CSVSettings::EditorPage(this); - - mStackedWidget->addWidget (page); - - new QListWidgetItem (page->objectName(), mListWidget); + createPage(); + createPage(); - connect ( page, SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)), - &(CSMSettings::UserSettings::instance()), SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &))); } -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 &))); -} - -void CSVSettings::UserSettingsDialog::positionWindow () -{ - QRect scr = QApplication::desktop()->screenGeometry(); - - move(scr.center().x() - (width() / 2), scr.center().y() - (height() / 2)); - -} - - void CSVSettings::UserSettingsDialog::writeSettings() { QMap settings; @@ -129,11 +99,7 @@ void CSVSettings::UserSettingsDialog::writeSettings() AbstractPage *page = getAbstractPage (i); settings [page->objectName()] = page->getSettings(); } - - QStringList paths = CSMSettings::UserSettings::instance().getSettingsFiles(); - - CSMSettings::UserSettings::instance().writeFile(CSMSettings::UserSettings::instance().openFile(paths.back()), settings); - + CSMSettings::UserSettings::instance().writeSettings(settings); } CSVSettings::AbstractPage *CSVSettings::UserSettingsDialog::getAbstractPage (int index) diff --git a/apps/opencs/view/settings/usersettingsdialog.hpp b/apps/opencs/view/settings/usersettingsdialog.hpp index 71a4cb2f8..a992dbdf8 100644 --- a/apps/opencs/view/settings/usersettingsdialog.hpp +++ b/apps/opencs/view/settings/usersettingsdialog.hpp @@ -4,14 +4,13 @@ #include #include #include - -#ifndef Q_MOC_RUN -#include -#endif +#include #include "../../model/settings/usersettings.hpp" #include "../../model/settings/support.hpp" +#include "editorpage.hpp" + class QHBoxLayout; class AbstractWidget; class QStackedWidget; @@ -27,7 +26,6 @@ namespace CSVSettings { QListWidget *mListWidget; QStackedWidget *mStackedWidget; - Files::ConfigurationManager mCfgMgr; public: UserSettingsDialog(QMainWindow *parent = 0); @@ -35,37 +33,39 @@ namespace CSVSettings { private: + /// Settings are written on close void closeEvent (QCloseEvent *event); + + /// return the setting page by name + /// performs dynamic cast to AbstractPage * AbstractPage *getAbstractPage (int index); - void setWidgetStates (CSMSettings::SectionMap settingsMap); + void setWidgetStates (); void buildPages(); - void positionWindow (); void writeSettings(); - void createSamplePage(); - - //Pages - void createWindowPage(); + /// Templated function to create a custom user preference page template - void createPage (const QString &title) + void createPage () { - T *page = new T(title, this); + T *page = new T(mStackedWidget); mStackedWidget->addWidget (dynamic_cast(page)); new QListWidgetItem (page->objectName(), mListWidget); //finishing touches - if (mStackedWidget->sizeHint().width() < 640) - mStackedWidget->sizeHint().setWidth(640); + QFontMetrics fm (QApplication::font()); + int textWidth = fm.width(page->objectName()); - if (mStackedWidget->sizeHint().height() < 480) - mStackedWidget->sizeHint().setHeight(480); + if ((textWidth + 50) > mListWidget->minimumWidth()) + mListWidget->setMinimumWidth(textWidth + 50); resize (mStackedWidget->sizeHint()); } public slots: + + /// Called when a different page is selected in the left-hand list widget void slotChangePage (QListWidgetItem*, QListWidgetItem*); }; diff --git a/apps/opencs/view/settings/windowpage.cpp b/apps/opencs/view/settings/windowpage.cpp index e8677fa42..5bf5f2161 100644 --- a/apps/opencs/view/settings/windowpage.cpp +++ b/apps/opencs/view/settings/windowpage.cpp @@ -16,6 +16,7 @@ #include "../../model/settings/usersettings.hpp" #include "groupblock.hpp" #include "toggleblock.hpp" +#include "../../view/settings/abstractblock.hpp" CSVSettings::WindowPage::WindowPage(QWidget *parent): AbstractPage("Window Size", parent) @@ -29,35 +30,10 @@ CSVSettings::WindowPage::WindowPage(QWidget *parent): setupUi(); } -void CSVSettings::WindowPage::setupUi() +CSVSettings::GroupBlockDef * CSVSettings::WindowPage::buildDefinedWindowSize() { - GroupBlockDef customWindowSize (QString ("Custom Window 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; + GroupBlockDef *block = new GroupBlockDef ( "Defined Size"); - - //pre-defined SettingsItemDef *widthByHeightItem = new SettingsItemDef ("Window Size", "640x480"); WidgetDef widthByHeightWidget = WidgetDef (Widget_ComboBox); widthByHeightWidget.widgetWidth = 90; @@ -73,27 +49,74 @@ void CSVSettings::WindowPage::setupUi() widthByHeightItem->widget = widthByHeightWidget; - definedWindowSize.properties << widthByHeightItem; - definedWindowSize.isProxy = true; - definedWindowSize.isVisible = false; + block->settingItems << widthByHeightItem; + block->isProxy = true; + 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; + widthItem->widget.inputMask = "9999"; + + //custom height + SettingsItemDef *heightItem = new SettingsItemDef ("Height", "480"); + heightItem->widget = WidgetDef (Widget_LineEdit); + heightItem->widget.widgetWidth = 45; + heightItem->widget.caption = "x"; + heightItem->widget.inputMask = "9999"; + + 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 - windowSizeToggle.captions << "Pre-Defined" << "Custom"; - windowSizeToggle.widgetOrientation = Orient_Vertical; - windowSizeToggle.isVisible = false; + block->captions << "Pre-Defined" << "Custom"; + block->widgetOrientation = Orient_Vertical; + block->isVisible = false; //define a widget for each group in the toggle 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; - windowSize.defaultValue = "Custom"; + return block; +} + +CSVSettings::CustomBlockDef *CSVSettings::WindowPage::buildWindowSize(GroupBlockDef *toggle_def, + GroupBlockDef *defined_def, + GroupBlockDef *custom_def) +{ + CustomBlockDef *block = new CustomBlockDef(QString ("Window Size")); - QGridLayout *pageLayout = new QGridLayout(this); + block->blockDefList << toggle_def << defined_def << custom_def; + block->defaultValue = "Custom"; - setLayout (pageLayout); + return block; + +} + +void CSVSettings::WindowPage::setupUi() +{ + CustomBlockDef *windowSize = buildWindowSize(buildWindowSizeToggle(), + buildDefinedWindowSize(), + buildCustomWindowSize() + ); mAbstractBlocks << buildBlock (windowSize); @@ -102,8 +125,15 @@ void CSVSettings::WindowPage::setupUi() connect (block, SIGNAL (signalUpdateSetting (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) { //iterate each item in each blocks in this section diff --git a/apps/opencs/view/settings/windowpage.hpp b/apps/opencs/view/settings/windowpage.hpp index 7978263fc..2f2830625 100644 --- a/apps/opencs/view/settings/windowpage.hpp +++ b/apps/opencs/view/settings/windowpage.hpp @@ -21,6 +21,12 @@ namespace CSVSettings { void setupUi(); void initializeWidgets (const CSMSettings::SettingMap &settings); + /// + GroupBlockDef *buildCustomWindowSize(); + GroupBlockDef *buildDefinedWindowSize(); + GroupBlockDef *buildWindowSizeToggle(); + CustomBlockDef *buildWindowSize (GroupBlockDef *, GroupBlockDef *, GroupBlockDef *); + signals: void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue); }; diff --git a/apps/opencs/view/world/recordstatusdelegate.cpp b/apps/opencs/view/world/recordstatusdelegate.cpp new file mode 100644 index 000000000..243f509ef --- /dev/null +++ b/apps/opencs/view/world/recordstatusdelegate.cpp @@ -0,0 +1,122 @@ +#include "recordstatusdelegate.hpp" +#include +#include +#include +#include "../../model/settings/usersettings.hpp" + +CSVWorld::RecordStatusDelegate::RecordStatusDelegate(QUndoStack &undoStack, QObject *parent) + : CommandDelegate (undoStack, parent) +{ + mModifiedIcon = new QIcon (":./modified.png"); + mAddedIcon = new QIcon (":./added.png"); + mDeletedIcon = new QIcon (":./removed.png"); + mBaseIcon = new QIcon (":./base.png"); + mIconSize = 16; + + //Offset values are most likely device-dependent. + //Need to replace with device-independent references. + mTextLeftOffset = 3; + mIconTopOffset = -3; + + mStatusDisplay = 0; //icons and text by default. Remove when implemented as a user preference + + mFont = QApplication::font(); + mFont.setPointSize(10); + + mFontMetrics = new QFontMetrics(mFont); + + mTextAlignment.setAlignment (Qt::AlignLeft | Qt::AlignVCenter ); +} + +void CSVWorld::RecordStatusDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + painter->save(); + + QString text = ""; + QIcon *icon = 0; + + switch (index.data().toInt()) + { + case 0: // State_BaseOnly + text = "Base"; + icon = mBaseIcon; + break; + + case 1: // State_Modified + text = "Modified"; + icon = mModifiedIcon; + break; + + case 2: // State_Modified_Only + text = "Added"; + icon = mAddedIcon; + break; + + case 3: // State_Deleted + + case 4: // State_Erased + text = "Deleted"; + icon = mDeletedIcon; + break; + + default: + break; + } + + QRect textRect = option.rect; + QRect iconRect = option.rect; + + //for icon-only (1), default option.rect centers icon left-to-right + //otherwise, size option.rect to fit the icon, forcing left-alignment with text + iconRect.setTop (iconRect.top() + mIconTopOffset); + iconRect.setBottom (iconRect.top() + mIconSize); + + if (mStatusDisplay == 0 && (icon) ) + { + iconRect.setRight (iconRect.left()+ mIconSize*2); + textRect.setLeft (iconRect.right() + mTextLeftOffset *1.25); + } + else + textRect.setLeft (textRect.left() + mTextLeftOffset ); + + if ( (mStatusDisplay == 0 || mStatusDisplay == 1) && (icon) ) + painter->drawPixmap(iconRect.center().x()-10,iconRect.center().y()+2, icon->pixmap(mIconSize, mIconSize)); + + // icon + text or text only, or force text if no icon exists for status + if (mStatusDisplay == 0 || mStatusDisplay == 2 || !(icon) ) + { + painter->setFont(mFont); + painter->drawText(textRect, text, mTextAlignment); + } + + painter->restore(); +} + +QSize CSVWorld::RecordStatusDelegate::sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + return QSize(); +} + +CSVWorld::CommandDelegate *CSVWorld::RecordStatusDelegateFactory::makeDelegate (QUndoStack& undoStack, + QObject *parent) const +{ + return new RecordStatusDelegate (undoStack, parent); +} + +void CSVWorld::RecordStatusDelegate::updateEditorSetting (const QString &settingName, const QString &settingValue) +{ + if (settingName == "Record Status Display") + { + if (settingValue == "Icon and Text") + mStatusDisplay = 0; + + else if (settingValue == "Icon Only") + mStatusDisplay = 1; + + else if (settingValue == "Text Only") + mStatusDisplay = 2; + + else + mStatusDisplay = 0; + } +} diff --git a/apps/opencs/view/world/recordstatusdelegate.hpp b/apps/opencs/view/world/recordstatusdelegate.hpp new file mode 100644 index 000000000..b67226ad5 --- /dev/null +++ b/apps/opencs/view/world/recordstatusdelegate.hpp @@ -0,0 +1,53 @@ +#ifndef RECORDSTATUSDELEGATE_H +#define RECORDSTATUSDELEGATE_H + +#include "util.hpp" +#include +#include + +class QIcon; +class QFont; +class QFontMetrics; + +namespace CSVWorld +{ + class RecordStatusDelegate : public CommandDelegate + { + QFont mFont; + QFontMetrics *mFontMetrics; + + QTextOption mTextAlignment; + + QIcon *mModifiedIcon; + QIcon *mAddedIcon; + QIcon *mDeletedIcon; + QIcon *mBaseIcon; + + int mStatusDisplay; + + int mIconSize; + int mIconTopOffset; + int mTextLeftOffset; + + public: + explicit RecordStatusDelegate(QUndoStack& undoStack, QObject *parent = 0); + + void paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + + QSize sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const; + + void updateEditorSetting (const QString &settingName, const QString &settingValue); + + }; + + class RecordStatusDelegateFactory : public CommandDelegateFactory + { + public: + + virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const; + ///< The ownership of the returned CommandDelegate is transferred to the caller. + + }; +} +#endif // RECORDSTATUSDELEGATE_H + diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index f9167d259..1ec0dde09 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -12,6 +12,7 @@ #include "../../model/world/idtableproxymodel.hpp" #include "../../model/world/idtable.hpp" #include "../../model/world/record.hpp" +#include "recordstatusdelegate.hpp" #include "util.hpp" @@ -80,7 +81,7 @@ std::vector CSVWorld::Table::listDeletableSelectedIds() const CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete) -: mUndoStack (undoStack), mCreateAction (0), mEditLock (false) + : mUndoStack (undoStack), mCreateAction (0), mEditLock (false), mRecordStatusDisplay (0) { mModel = &dynamic_cast (*data.getTableModel (id)); @@ -161,6 +162,7 @@ void CSVWorld::Table::createRecord() mUndoStack.push (new CSMWorld::CreateCommand (*mProxyModel, stream.str())); } + } void CSVWorld::Table::revertRecord() @@ -201,4 +203,13 @@ void CSVWorld::Table::deleteRecord() mUndoStack.endMacro(); } } -} \ No newline at end of file +} + +void CSVWorld::Table::updateEditorSetting (const QString &settingName, const QString &settingValue) +{ + if (settingName == "Record Status Display") + { + dynamic_cast(this->itemDelegateForColumn(1))->updateEditorSetting (settingName, settingValue); + emit dataChanged(mModel->index(0,1), mModel->index(mModel->rowCount()-1, 1)); + } +} diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index df0224583..348e800cf 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -34,6 +34,7 @@ namespace CSVWorld CSMWorld::IdTableProxyModel *mProxyModel; CSMWorld::IdTable *mModel; bool mEditLock; + int mRecordStatusDisplay; private: @@ -52,6 +53,8 @@ namespace CSVWorld CSMWorld::UniversalId getUniversalId (int row) const; + void updateEditorSetting (const QString &settingName, const QString &settingValue); + private slots: void createRecord(); diff --git a/apps/opencs/view/world/tablesubview.cpp b/apps/opencs/view/world/tablesubview.cpp index bb4bb76c6..d139ef74b 100644 --- a/apps/opencs/view/world/tablesubview.cpp +++ b/apps/opencs/view/world/tablesubview.cpp @@ -22,4 +22,11 @@ void CSVWorld::TableSubView::setEditLock (bool locked) void CSVWorld::TableSubView::rowActivated (const QModelIndex& index) { focusId (mTable->getUniversalId (index.row())); -} \ No newline at end of file +} + +void CSVWorld::TableSubView::updateEditorSetting(const QString &settingName, const QString &settingValue) +{ + + if (settingName == "Record Status Display") + mTable->updateEditorSetting(settingName, settingValue); +} diff --git a/apps/opencs/view/world/tablesubview.hpp b/apps/opencs/view/world/tablesubview.hpp index 0e7b8aa30..13db8255a 100644 --- a/apps/opencs/view/world/tablesubview.hpp +++ b/apps/opencs/view/world/tablesubview.hpp @@ -23,8 +23,8 @@ namespace CSVWorld public: TableSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document, bool createAndDelete); - virtual void setEditLock (bool locked); + void updateEditorSetting (const QString &, const QString &); private slots: @@ -32,4 +32,4 @@ namespace CSVWorld }; } -#endif \ No newline at end of file +#endif diff --git a/apps/opencs/view/world/util.hpp b/apps/opencs/view/world/util.hpp index 95dfec6c5..251564e96 100644 --- a/apps/opencs/view/world/util.hpp +++ b/apps/opencs/view/world/util.hpp @@ -82,6 +82,8 @@ namespace CSVWorld ///< \brief Use commands instead of manipulating the model directly class CommandDelegate : public QStyledItemDelegate { + Q_OBJECT + QUndoStack& mUndoStack; bool mEditLock; @@ -105,6 +107,10 @@ namespace CSVWorld void setEditLock (bool locked); bool isEditLocked() const; + + private slots: + + virtual void slotUpdateEditorSetting (const QString &settingName, const QString &settingValue) {} }; } diff --git a/components/fileorderlist/model/datafilesmodel.cpp b/components/fileorderlist/model/datafilesmodel.cpp index 9f2e470b2..02a6766b0 100644 --- a/components/fileorderlist/model/datafilesmodel.cpp +++ b/components/fileorderlist/model/datafilesmodel.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include @@ -12,6 +11,8 @@ #include "datafilesmodel.hpp" +#include + DataFilesModel::DataFilesModel(QObject *parent) : QAbstractTableModel(parent) { diff --git a/files/opencs.cfg b/files/opencs.cfg new file mode 100644 index 000000000..3faac7c8e --- /dev/null +++ b/files/opencs.cfg @@ -0,0 +1,5 @@ +[Editor] +Record Status Display = Icon and Text +[Window Size] +Width = 640 +Height = 480 diff --git a/files/opencs/added.png b/files/opencs/added.png new file mode 100644 index 000000000..aff7e25d4 Binary files /dev/null and b/files/opencs/added.png differ diff --git a/files/opencs/base.png b/files/opencs/base.png new file mode 100644 index 000000000..4398e2d68 Binary files /dev/null and b/files/opencs/base.png differ diff --git a/files/opencs/modified.png b/files/opencs/modified.png new file mode 100644 index 000000000..d15ad827c Binary files /dev/null and b/files/opencs/modified.png differ diff --git a/files/opencs/raster/activator.png b/files/opencs/raster/activator.png new file mode 100644 index 000000000..0446af22c Binary files /dev/null and b/files/opencs/raster/activator.png differ diff --git a/files/opencs/raster/added.png b/files/opencs/raster/added.png new file mode 100644 index 000000000..ddd9c2108 Binary files /dev/null and b/files/opencs/raster/added.png differ diff --git a/files/opencs/raster/apparatus.png b/files/opencs/raster/apparatus.png new file mode 100644 index 000000000..3cef537e1 Binary files /dev/null and b/files/opencs/raster/apparatus.png differ diff --git a/files/opencs/raster/armor.png b/files/opencs/raster/armor.png new file mode 100644 index 000000000..fc534c7d1 Binary files /dev/null and b/files/opencs/raster/armor.png differ diff --git a/files/opencs/raster/base.png b/files/opencs/raster/base.png new file mode 100644 index 000000000..4398e2d68 Binary files /dev/null and b/files/opencs/raster/base.png differ diff --git a/files/opencs/raster/body-part.png b/files/opencs/raster/body-part.png new file mode 100644 index 000000000..333c5d523 Binary files /dev/null and b/files/opencs/raster/body-part.png differ diff --git a/files/opencs/raster/book.png b/files/opencs/raster/book.png new file mode 100644 index 000000000..3afa9e8aa Binary files /dev/null and b/files/opencs/raster/book.png differ diff --git a/files/opencs/raster/clothing.png b/files/opencs/raster/clothing.png new file mode 100644 index 000000000..88c9b6ab8 Binary files /dev/null and b/files/opencs/raster/clothing.png differ diff --git a/files/opencs/raster/container.png b/files/opencs/raster/container.png new file mode 100644 index 000000000..2a6ed01eb Binary files /dev/null and b/files/opencs/raster/container.png differ diff --git a/files/opencs/raster/creature.png b/files/opencs/raster/creature.png new file mode 100644 index 000000000..99cf9c87c Binary files /dev/null and b/files/opencs/raster/creature.png differ diff --git a/files/opencs/raster/dialogoue-info.png b/files/opencs/raster/dialogoue-info.png new file mode 100644 index 000000000..f6743d43c Binary files /dev/null and b/files/opencs/raster/dialogoue-info.png differ diff --git a/files/opencs/raster/dialogoue-journal.png b/files/opencs/raster/dialogoue-journal.png new file mode 100644 index 000000000..b6a95c538 Binary files /dev/null and b/files/opencs/raster/dialogoue-journal.png differ diff --git a/files/opencs/raster/dialogoue-regular.png b/files/opencs/raster/dialogoue-regular.png new file mode 100644 index 000000000..f9b8d252d Binary files /dev/null and b/files/opencs/raster/dialogoue-regular.png differ diff --git a/files/opencs/raster/dialogue-greeting.png b/files/opencs/raster/dialogue-greeting.png new file mode 100644 index 000000000..a35e1fe6d Binary files /dev/null and b/files/opencs/raster/dialogue-greeting.png differ diff --git a/files/opencs/raster/dialogue-persuasion.png b/files/opencs/raster/dialogue-persuasion.png new file mode 100644 index 000000000..5bc5d6113 Binary files /dev/null and b/files/opencs/raster/dialogue-persuasion.png differ diff --git a/files/opencs/raster/dialogue-speech.png b/files/opencs/raster/dialogue-speech.png new file mode 100644 index 000000000..11eb9f1ca Binary files /dev/null and b/files/opencs/raster/dialogue-speech.png differ diff --git a/files/opencs/raster/door.png b/files/opencs/raster/door.png new file mode 100644 index 000000000..aa48858ef Binary files /dev/null and b/files/opencs/raster/door.png differ diff --git a/files/opencs/raster/ingredient.png b/files/opencs/raster/ingredient.png new file mode 100644 index 000000000..6b36d008d Binary files /dev/null and b/files/opencs/raster/ingredient.png differ diff --git a/files/opencs/raster/leveled-creature.png b/files/opencs/raster/leveled-creature.png new file mode 100644 index 000000000..ad4a7c6f8 Binary files /dev/null and b/files/opencs/raster/leveled-creature.png differ diff --git a/files/opencs/raster/light.png b/files/opencs/raster/light.png new file mode 100644 index 000000000..c606fcd98 Binary files /dev/null and b/files/opencs/raster/light.png differ diff --git a/files/opencs/raster/lockpick.png b/files/opencs/raster/lockpick.png new file mode 100644 index 000000000..d9bd27f5e Binary files /dev/null and b/files/opencs/raster/lockpick.png differ diff --git a/files/opencs/raster/miscellaneous.png b/files/opencs/raster/miscellaneous.png new file mode 100644 index 000000000..744bcd9db Binary files /dev/null and b/files/opencs/raster/miscellaneous.png differ diff --git a/files/opencs/raster/modified.png b/files/opencs/raster/modified.png new file mode 100644 index 000000000..39bd182ac Binary files /dev/null and b/files/opencs/raster/modified.png differ diff --git a/files/opencs/raster/npc.png b/files/opencs/raster/npc.png new file mode 100644 index 000000000..7a07f26df Binary files /dev/null and b/files/opencs/raster/npc.png differ diff --git a/files/opencs/raster/potion.png b/files/opencs/raster/potion.png new file mode 100644 index 000000000..678f61fbf Binary files /dev/null and b/files/opencs/raster/potion.png differ diff --git a/files/opencs/raster/probe.png b/files/opencs/raster/probe.png new file mode 100644 index 000000000..01536186d Binary files /dev/null and b/files/opencs/raster/probe.png differ diff --git a/files/opencs/raster/random-item.png b/files/opencs/raster/random-item.png new file mode 100644 index 000000000..7b8e68e60 Binary files /dev/null and b/files/opencs/raster/random-item.png differ diff --git a/files/opencs/raster/removed.png b/files/opencs/raster/removed.png new file mode 100644 index 000000000..2354bc743 Binary files /dev/null and b/files/opencs/raster/removed.png differ diff --git a/files/opencs/raster/repair.png b/files/opencs/raster/repair.png new file mode 100644 index 000000000..6cf1c0aac Binary files /dev/null and b/files/opencs/raster/repair.png differ diff --git a/files/opencs/raster/sound.png b/files/opencs/raster/sound.png new file mode 100644 index 000000000..b072acf76 Binary files /dev/null and b/files/opencs/raster/sound.png differ diff --git a/files/opencs/raster/soundgen.png b/files/opencs/raster/soundgen.png new file mode 100644 index 000000000..70ae43a1d Binary files /dev/null and b/files/opencs/raster/soundgen.png differ diff --git a/files/opencs/raster/static.png b/files/opencs/raster/static.png new file mode 100644 index 000000000..b53be12d9 Binary files /dev/null and b/files/opencs/raster/static.png differ diff --git a/files/opencs/raster/weapon.png b/files/opencs/raster/weapon.png new file mode 100644 index 000000000..3d4b53466 Binary files /dev/null and b/files/opencs/raster/weapon.png differ diff --git a/files/opencs/removed.png b/files/opencs/removed.png new file mode 100644 index 000000000..2ca9e094b Binary files /dev/null and b/files/opencs/removed.png differ diff --git a/files/opencs/resources.qrc b/files/opencs/resources.qrc index ecfab44a2..926bda064 100644 --- a/files/opencs/resources.qrc +++ b/files/opencs/resources.qrc @@ -1,5 +1,9 @@ opencs.png + added.png + modified.png + removed.png + base.png diff --git a/files/opencs/scalable/Palette.svg b/files/opencs/scalable/Palette.svg new file mode 100644 index 000000000..f42475330 --- /dev/null +++ b/files/opencs/scalable/Palette.svg @@ -0,0 +1,569 @@ + + + + + + + image/svg+xml + + + + + + Tango Palette + + + Tuomas Kuosmanen + + + + + Garrett Le Sage +Kenneth Wimer +Jakub Steiner + + +http://www.tango-project.org/files/Tango-Palette.svg + + + unify + global + theme + color + palette + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/files/opencs/scalable/referenceable-record/.directory b/files/opencs/scalable/referenceable-record/.directory new file mode 100644 index 000000000..e2d80ed58 --- /dev/null +++ b/files/opencs/scalable/referenceable-record/.directory @@ -0,0 +1,5 @@ +[Dolphin] +PreviewsShown=true +Timestamp=2013,3,21,10,19,49 +Version=3 +ViewMode=1 diff --git a/files/opencs/scalable/referenceable-record/activator.svg b/files/opencs/scalable/referenceable-record/activator.svg new file mode 100644 index 000000000..0c6db59a7 --- /dev/null +++ b/files/opencs/scalable/referenceable-record/activator.svg @@ -0,0 +1,1088 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/referenceable-record/apparatus.svg b/files/opencs/scalable/referenceable-record/apparatus.svg new file mode 100644 index 000000000..37cef0e89 --- /dev/null +++ b/files/opencs/scalable/referenceable-record/apparatus.svg @@ -0,0 +1,1058 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/referenceable-record/book.svg b/files/opencs/scalable/referenceable-record/book.svg new file mode 100644 index 000000000..56c8e6c6f --- /dev/null +++ b/files/opencs/scalable/referenceable-record/book.svg @@ -0,0 +1,687 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/referenceable-record/container.svg b/files/opencs/scalable/referenceable-record/container.svg new file mode 100644 index 000000000..8c9465b66 --- /dev/null +++ b/files/opencs/scalable/referenceable-record/container.svg @@ -0,0 +1,1899 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/referenceable-record/ingredient.svg b/files/opencs/scalable/referenceable-record/ingredient.svg new file mode 100644 index 000000000..962a14ed1 --- /dev/null +++ b/files/opencs/scalable/referenceable-record/ingredient.svg @@ -0,0 +1,1107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/files/opencs/scalable/referenceable-record/light.svg b/files/opencs/scalable/referenceable-record/light.svg new file mode 100644 index 000000000..3bd5307f7 --- /dev/null +++ b/files/opencs/scalable/referenceable-record/light.svg @@ -0,0 +1,1508 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/referenceable-record/miscellaneous.svg b/files/opencs/scalable/referenceable-record/miscellaneous.svg new file mode 100644 index 000000000..96522048c --- /dev/null +++ b/files/opencs/scalable/referenceable-record/miscellaneous.svg @@ -0,0 +1,965 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/referenceable-record/potion.svg b/files/opencs/scalable/referenceable-record/potion.svg new file mode 100644 index 000000000..552c14f19 --- /dev/null +++ b/files/opencs/scalable/referenceable-record/potion.svg @@ -0,0 +1,1161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/referenceable-record/random-item.svg b/files/opencs/scalable/referenceable-record/random-item.svg new file mode 100644 index 000000000..d051ce049 --- /dev/null +++ b/files/opencs/scalable/referenceable-record/random-item.svg @@ -0,0 +1,156 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/referenceable-record/repair.svg b/files/opencs/scalable/referenceable-record/repair.svg new file mode 100644 index 000000000..b1a23956e --- /dev/null +++ b/files/opencs/scalable/referenceable-record/repair.svg @@ -0,0 +1,1280 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/referenceable-record/static.svg b/files/opencs/scalable/referenceable-record/static.svg new file mode 100644 index 000000000..a6f29370f --- /dev/null +++ b/files/opencs/scalable/referenceable-record/static.svg @@ -0,0 +1,1141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/referenceable-record/weapon.svg b/files/opencs/scalable/referenceable-record/weapon.svg new file mode 100644 index 000000000..2e832fff7 --- /dev/null +++ b/files/opencs/scalable/referenceable-record/weapon.svg @@ -0,0 +1,1206 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/status/.directory b/files/opencs/scalable/status/.directory new file mode 100644 index 000000000..e2d80ed58 --- /dev/null +++ b/files/opencs/scalable/status/.directory @@ -0,0 +1,5 @@ +[Dolphin] +PreviewsShown=true +Timestamp=2013,3,21,10,19,49 +Version=3 +ViewMode=1 diff --git a/files/opencs/scalable/status/added.svg b/files/opencs/scalable/status/added.svg new file mode 100644 index 000000000..d83649f50 --- /dev/null +++ b/files/opencs/scalable/status/added.svg @@ -0,0 +1,932 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/files/opencs/scalable/status/base.svg b/files/opencs/scalable/status/base.svg new file mode 100644 index 000000000..90c9bc319 --- /dev/null +++ b/files/opencs/scalable/status/base.svg @@ -0,0 +1,942 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/files/opencs/scalable/status/modified.svg b/files/opencs/scalable/status/modified.svg new file mode 100644 index 000000000..8d2ec4710 --- /dev/null +++ b/files/opencs/scalable/status/modified.svg @@ -0,0 +1,1155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/files/opencs/scalable/status/removed.svg b/files/opencs/scalable/status/removed.svg new file mode 100644 index 000000000..c879af91f --- /dev/null +++ b/files/opencs/scalable/status/removed.svg @@ -0,0 +1,935 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/files/opencs/scalable/top-level/gmst.svg b/files/opencs/scalable/top-level/gmst.svg new file mode 100644 index 000000000..3b59a44fe --- /dev/null +++ b/files/opencs/scalable/top-level/gmst.svg @@ -0,0 +1,1047 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + diff --git a/files/opencs/scalable/top-level/topic-regular.svg b/files/opencs/scalable/top-level/topic-regular.svg new file mode 100644 index 000000000..c972dfa18 --- /dev/null +++ b/files/opencs/scalable/top-level/topic-regular.svg @@ -0,0 +1,1045 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + +