mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-03 05:45:32 +00:00
Fixed / implemented missing features for RecordStatusDelegate
Implemented updating editor application from preferences menu, loading settings when editor loads, adding Record Status Display prefernce. Fixed multiple bugs, made changes to CSM(V)Settings classes to make implementing new prefrences easier. Rewrote CSMSettings::UserSettings to retain last-loaded settings. Adjusted icon position in Record Status column Capitalized status text Added delegate to referenceables table
This commit is contained in:
parent
1d93cf09bc
commit
700d55f1fb
36 changed files with 597 additions and 365 deletions
|
@ -57,11 +57,11 @@ opencs_hdrs_noqt (view/doc
|
||||||
|
|
||||||
|
|
||||||
opencs_units (view/world
|
opencs_units (view/world
|
||||||
table tablesubview scriptsubview
|
table tablesubview scriptsubview util
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/world
|
opencs_units_noqt (view/world
|
||||||
dialoguesubview util subviews enumdelegate vartypedelegate scripthighlighter recordstatusdelegate
|
dialoguesubview subviews enumdelegate vartypedelegate scripthighlighter recordstatusdelegate
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,6 +78,7 @@ opencs_units (view/settings
|
||||||
proxyblock
|
proxyblock
|
||||||
abstractwidget
|
abstractwidget
|
||||||
usersettingsdialog
|
usersettingsdialog
|
||||||
|
samplepage
|
||||||
editorpage
|
editorpage
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,6 @@ namespace CSMSettings
|
||||||
explicit SettingContainer (QObject *parent = 0);
|
explicit SettingContainer (QObject *parent = 0);
|
||||||
explicit SettingContainer (const QString &value, QObject *parent = 0);
|
explicit SettingContainer (const QString &value, QObject *parent = 0);
|
||||||
|
|
||||||
virtual QString getName() const {return "";}
|
|
||||||
|
|
||||||
void insert (const QString &value);
|
void insert (const QString &value);
|
||||||
void update (const QString &value, int index = 0);
|
void update (const QString &value, int index = 0);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ namespace CSMSettings
|
||||||
QStringPair *mValuePair;
|
QStringPair *mValuePair;
|
||||||
QStringList *mValueList;
|
QStringList *mValueList;
|
||||||
bool mIsMultiValue;
|
bool mIsMultiValue;
|
||||||
QString mName;
|
|
||||||
QString mDefaultValue;
|
QString mDefaultValue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -20,8 +19,10 @@ namespace CSMSettings
|
||||||
const QString& defaultValue, QObject *parent = 0)
|
const QString& defaultValue, QObject *parent = 0)
|
||||||
: SettingContainer(defaultValue, parent),
|
: SettingContainer(defaultValue, parent),
|
||||||
mIsMultiValue (isMultiValue), mValueList (0),
|
mIsMultiValue (isMultiValue), mValueList (0),
|
||||||
mName (name), mValuePair (0), mDefaultValue (defaultValue)
|
mValuePair (0), mDefaultValue (defaultValue)
|
||||||
{}
|
{
|
||||||
|
QObject::setObjectName(name);
|
||||||
|
}
|
||||||
|
|
||||||
bool updateItem (const QStringList *values);
|
bool updateItem (const QStringList *values);
|
||||||
bool updateItem (const QString &value);
|
bool updateItem (const QString &value);
|
||||||
|
@ -33,7 +34,6 @@ namespace CSMSettings
|
||||||
inline QStringPair *getValuePair() { return mValuePair; }
|
inline QStringPair *getValuePair() { return mValuePair; }
|
||||||
inline void setValuePair (QStringPair valuePair) { mValuePair = new QStringPair(valuePair); }
|
inline void setValuePair (QStringPair valuePair) { mValuePair = new QStringPair(valuePair); }
|
||||||
|
|
||||||
inline QString getName () const { return mName; }
|
|
||||||
inline bool isMultivalue () { return mIsMultiValue; }
|
inline bool isMultivalue () { return mIsMultiValue; }
|
||||||
|
|
||||||
void setDefaultValue (const QString &value);
|
void setDefaultValue (const QString &value);
|
||||||
|
|
|
@ -7,12 +7,15 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
|
||||||
#include "settingcontainer.hpp"
|
#include "settingcontainer.hpp"
|
||||||
|
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
/**
|
/**
|
||||||
* Workaround for problems with whitespaces in paths in older versions of Boost library
|
* Workaround for problems with whitespaces in paths in older versions of Boost library
|
||||||
*/
|
*/
|
||||||
|
@ -29,47 +32,67 @@ namespace boost
|
||||||
} /* namespace boost */
|
} /* namespace boost */
|
||||||
#endif /* (BOOST_VERSION <= 104600) */
|
#endif /* (BOOST_VERSION <= 104600) */
|
||||||
|
|
||||||
|
|
||||||
CSMSettings::UserSettings::UserSettings()
|
CSMSettings::UserSettings::UserSettings()
|
||||||
{
|
{
|
||||||
mUserSettingsInstance = this;
|
mUserSettingsInstance = this;
|
||||||
|
|
||||||
|
mReadWriteMessage = QObject::tr("<br><b>Could not open or create file for writing</b><br><br> \
|
||||||
|
Please make sure you have the right permissions and try again.<br>");
|
||||||
|
|
||||||
|
mReadOnlyMessage = QObject::tr("<br><b>Could not open file for reading</b><br><br> \
|
||||||
|
Please make sure you have the right permissions and try again.<br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMSettings::UserSettings::~UserSettings()
|
CSMSettings::UserSettings::~UserSettings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile *CSMSettings::UserSettings::openFile (const QString &filename)
|
QTextStream *CSMSettings::UserSettings::openFileStream (const QString &filePath, bool isReadOnly)
|
||||||
{
|
{
|
||||||
QFile *file = new QFile(filename);
|
QFile *file = new QFile(filePath);
|
||||||
|
|
||||||
bool success = (file->open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) ;
|
QIODevice::OpenMode openFlags;
|
||||||
|
|
||||||
if (!success)
|
if (isReadOnly)
|
||||||
|
openFlags = QIODevice::ReadOnly | QIODevice::Text;
|
||||||
|
else
|
||||||
|
openFlags = QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate;
|
||||||
|
|
||||||
|
if (!(file->open(openFlags)))
|
||||||
{
|
{
|
||||||
// File cannot be opened or created
|
// File cannot be opened or created
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setWindowTitle(QObject::tr("Error writing OpenMW configuration file"));
|
msgBox.setWindowTitle(QObject::tr("OpenCS configuration file I/O error"));
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||||
msgBox.setText(QObject::tr("<br><b>Could not open or create %0 for writing</b><br><br> \
|
|
||||||
Please make sure you have the right permissions \
|
QString fileMessage = QObject::tr("<br> File: %0").arg(file->fileName());
|
||||||
and try again.<br>").arg(file->fileName()));
|
|
||||||
|
if (!isReadOnly)
|
||||||
|
msgBox.setText (mReadWriteMessage + fileMessage);
|
||||||
|
else
|
||||||
|
msgBox.setText (mReadOnlyMessage + fileMessage);
|
||||||
|
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
delete file;
|
delete file;
|
||||||
file = 0;
|
file = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return file;
|
QTextStream *stream = 0;
|
||||||
|
|
||||||
|
if (file)
|
||||||
|
{
|
||||||
|
stream = new QTextStream(file);
|
||||||
|
stream->setCodec(QTextCodec::codecForName("UTF-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return stream;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSMSettings::UserSettings::writeFile(QFile *file, QMap<QString, CSMSettings::SettingList *> &settings)
|
bool CSMSettings::UserSettings::writeFile(QMap<QString, CSMSettings::SettingList *> &settings)
|
||||||
{
|
{
|
||||||
if (!file)
|
QTextStream *stream = openFileStream(mPaths.back());
|
||||||
return false;
|
|
||||||
|
|
||||||
QTextStream stream(file);
|
|
||||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
|
||||||
|
|
||||||
QList<QString> keyList = settings.keys();
|
QList<QString> keyList = settings.keys();
|
||||||
|
|
||||||
|
@ -77,19 +100,33 @@ bool CSMSettings::UserSettings::writeFile(QFile *file, QMap<QString, CSMSettings
|
||||||
{
|
{
|
||||||
SettingList *sectionSettings = settings[key];
|
SettingList *sectionSettings = settings[key];
|
||||||
|
|
||||||
stream << "[" << key << "]" << '\n';
|
*stream << "[" << key << "]" << '\n';
|
||||||
|
|
||||||
foreach (SettingContainer *item, *sectionSettings)
|
foreach (SettingContainer *item, *sectionSettings)
|
||||||
stream << item->getName() << " = " << item->getValue() << '\n';
|
*stream << item->objectName() << " = " << item->getValue() << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
file->close();
|
stream->device()->close();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::UserSettings::getSettings(QTextStream &stream, SectionMap §ions)
|
const CSMSettings::SectionMap &CSMSettings::UserSettings::getSettings()
|
||||||
{
|
{
|
||||||
|
return mSectionSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::UserSettings::loadFromFile(const QString &filePath)
|
||||||
|
{
|
||||||
|
if (filePath.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
mSectionSettings.clear();
|
||||||
|
|
||||||
|
QTextStream *stream = openFileStream (filePath, true);
|
||||||
|
|
||||||
|
if (stream)
|
||||||
|
{
|
||||||
//looks for a square bracket, "'\\["
|
//looks for a square bracket, "'\\["
|
||||||
//that has one or more "not nothing" in it, "([^]]+)"
|
//that has one or more "not nothing" in it, "([^]]+)"
|
||||||
//and is closed with a square bracket, "\\]"
|
//and is closed with a square bracket, "\\]"
|
||||||
|
@ -97,7 +134,7 @@ void CSMSettings::UserSettings::getSettings(QTextStream &stream, SectionMap &sec
|
||||||
QRegExp sectionRe("^\\[([^]]+)\\]");
|
QRegExp sectionRe("^\\[([^]]+)\\]");
|
||||||
|
|
||||||
//Find any character(s) that is/are not equal sign(s), "[^=]+"
|
//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*"
|
//followed by an optional whitespace, an equal sign, and another optional whitespace, "\\s*=\\s*"
|
||||||
//and one or more periods, "(.+)"
|
//and one or more periods, "(.+)"
|
||||||
|
|
||||||
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
||||||
|
@ -105,9 +142,9 @@ void CSMSettings::UserSettings::getSettings(QTextStream &stream, SectionMap &sec
|
||||||
CSMSettings::SettingMap *settings = 0;
|
CSMSettings::SettingMap *settings = 0;
|
||||||
QString section = "none";
|
QString section = "none";
|
||||||
|
|
||||||
while (!stream.atEnd())
|
while (!stream->atEnd())
|
||||||
{
|
{
|
||||||
QString line = stream.readLine().simplified();
|
QString line = stream->readLine().simplified();
|
||||||
|
|
||||||
if (line.isEmpty() || line.startsWith("#"))
|
if (line.isEmpty() || line.startsWith("#"))
|
||||||
continue;
|
continue;
|
||||||
|
@ -118,7 +155,7 @@ void CSMSettings::UserSettings::getSettings(QTextStream &stream, SectionMap &sec
|
||||||
{
|
{
|
||||||
//add the previous section's settings to the member map
|
//add the previous section's settings to the member map
|
||||||
if (settings)
|
if (settings)
|
||||||
sections.insert(section, settings);
|
mSectionSettings.insert(section, settings);
|
||||||
|
|
||||||
//save new section and create a new list
|
//save new section and create a new list
|
||||||
section = sectionRe.cap(1);
|
section = sectionRe.cap(1);
|
||||||
|
@ -129,9 +166,55 @@ void CSMSettings::UserSettings::getSettings(QTextStream &stream, SectionMap &sec
|
||||||
if (keyRe.indexIn(line) != -1)
|
if (keyRe.indexIn(line) != -1)
|
||||||
{
|
{
|
||||||
SettingContainer *sc = new SettingContainer (keyRe.cap(2).simplified());
|
SettingContainer *sc = new SettingContainer (keyRe.cap(2).simplified());
|
||||||
|
sc->setObjectName(keyRe.cap(1).simplified());
|
||||||
(*settings)[keyRe.cap(1).simplified()] = sc;
|
(*settings)[keyRe.cap(1).simplified()] = sc;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
sections.insert(section, settings);
|
|
||||||
|
mSectionSettings.insert(section, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
stream->device()->close();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
||||||
|
{
|
||||||
|
if (mPaths.count() == 0)
|
||||||
|
{
|
||||||
|
mPaths.append(QString::fromStdString(mCfgMgr.getGlobalPath().string()) + fileName);
|
||||||
|
mPaths.append(QString::fromStdString(mCfgMgr.getLocalPath().string()) + fileName);
|
||||||
|
mPaths.append(QString::fromStdString(mCfgMgr.getUserPath().string()) + fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (const QString &path, mPaths)
|
||||||
|
{
|
||||||
|
qDebug() << "Loading config file:" << qPrintable(path);
|
||||||
|
loadFromFile(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::UserSettings::updateSettings (const QString §ionName, const QString &settingName)
|
||||||
|
{
|
||||||
|
SettingMap *settings = mSectionSettings[sectionName];
|
||||||
|
|
||||||
|
if (!settings)
|
||||||
|
return;
|
||||||
|
|
||||||
|
SettingContainer *setting = 0;
|
||||||
|
|
||||||
|
if (settingName.isEmpty())
|
||||||
|
{
|
||||||
|
foreach (setting, *settings)
|
||||||
|
emit signalUpdateEditorSetting (setting->objectName(), setting->getValue());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setting = (*settings)[settingName];
|
||||||
|
|
||||||
|
if (setting)
|
||||||
|
emit signalUpdateEditorSetting (setting->objectName(), setting->getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
|
|
||||||
#include "support.hpp"
|
#include "support.hpp"
|
||||||
|
|
||||||
|
#ifndef Q_MOC_RUN
|
||||||
|
#include <components/files/configurationmanager.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Files { typedef std::vector<boost::filesystem::path> PathContainer;
|
namespace Files { typedef std::vector<boost::filesystem::path> PathContainer;
|
||||||
struct ConfigurationManager;}
|
struct ConfigurationManager;}
|
||||||
|
|
||||||
|
@ -22,6 +26,14 @@ namespace CSMSettings {
|
||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
SectionMap mSectionSettings;
|
||||||
|
UserSettings *mUserSettingsInstance;
|
||||||
|
QStringList mPaths;
|
||||||
|
Files::ConfigurationManager mCfgMgr;
|
||||||
|
|
||||||
|
QString mReadOnlyMessage;
|
||||||
|
QString mReadWriteMessage;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static UserSettings &instance()
|
static UserSettings &instance()
|
||||||
|
@ -31,19 +43,22 @@ namespace CSMSettings {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile *openFile (const QString &);
|
bool writeFile(QMap<QString, SettingList *> §ions);
|
||||||
bool writeFile(QFile *file, QMap<QString, SettingList *> §ions);
|
const SectionMap &getSettings ();
|
||||||
void getSettings (QTextStream &stream, SectionMap &settings);
|
void updateSettings (const QString §ionName, const QString &settingName = "");
|
||||||
|
void loadSettings (const QString &fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
UserSettings *mUserSettingsInstance;
|
|
||||||
UserSettings();
|
UserSettings();
|
||||||
~UserSettings();
|
~UserSettings();
|
||||||
|
|
||||||
UserSettings (UserSettings const &); //not implemented
|
UserSettings (UserSettings const &); //not implemented
|
||||||
void operator= (UserSettings const &); //not implemented
|
void operator= (UserSettings const &); //not implemented
|
||||||
|
|
||||||
|
QTextStream *openFileStream (const QString &filePath, bool isReadOnly = false);
|
||||||
|
void loadFromFile (const QString &filePath = "");
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ CSMWorld::RefIdCollection::RefIdCollection()
|
||||||
mColumns.push_back (RefIdColumn ("ID", ColumnBase::Display_String,
|
mColumns.push_back (RefIdColumn ("ID", ColumnBase::Display_String,
|
||||||
ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false));
|
ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false));
|
||||||
baseColumns.mId = &mColumns.back();
|
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));
|
ColumnBase::Flag_Table | ColumnBase::Flag_Dialogue, false, false));
|
||||||
baseColumns.mModified = &mColumns.back();
|
baseColumns.mModified = &mColumns.back();
|
||||||
mColumns.push_back (RefIdColumn ("Type", ColumnBase::Display_Integer,
|
mColumns.push_back (RefIdColumn ("Type", ColumnBase::Display_Integer,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "subview.hpp"
|
#include "subview.hpp"
|
||||||
|
|
||||||
|
|
||||||
CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id) : mUniversalId (id)
|
CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id) : mUniversalId (id)
|
||||||
{
|
{
|
||||||
/// \todo add a button to the title bar that clones this sub view
|
/// \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;
|
return mUniversalId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::SubView::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace CSVDoc
|
||||||
CSMWorld::UniversalId getUniversalId() const;
|
CSMWorld::UniversalId getUniversalId() const;
|
||||||
|
|
||||||
virtual void setEditLock (bool locked) = 0;
|
virtual void setEditLock (bool locked) = 0;
|
||||||
|
virtual void updateEditorSetting (const QString &, const QString &);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
|
|
@ -258,11 +258,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)
|
/// \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);
|
SubView *view = mSubViewFactory.makeSubView (id, *mDocument);
|
||||||
|
view->setObjectName ("subview");
|
||||||
mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view);
|
mSubViewWindow.addDockWidget (Qt::TopDockWidgetArea, view);
|
||||||
|
|
||||||
connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&)), this,
|
connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&)), this,
|
||||||
SLOT (addSubView (const CSMWorld::UniversalId&)));
|
SLOT (addSubView (const CSMWorld::UniversalId&)));
|
||||||
|
|
||||||
|
CSMSettings::UserSettings::instance().updateSettings("Editor", "Record Status Display");
|
||||||
|
|
||||||
view->show();
|
view->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,20 +369,13 @@ void CSVDoc::View::showUserSettings()
|
||||||
{
|
{
|
||||||
CSVSettings::UserSettingsDialog *settingsDialog = new CSVSettings::UserSettingsDialog(this);
|
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();
|
settingsDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::View::slotUpdateEditorSetting(const QString &settingName, const QString &settingValue)
|
void CSVDoc::View::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||||
{
|
{
|
||||||
static QString lastValue = "";
|
if (settingName == "Record Status Display")
|
||||||
|
foreach (QObject *view, mSubViewWindow.children())
|
||||||
if (lastValue != settingValue)
|
if (view->objectName() == "subview")
|
||||||
{
|
dynamic_cast<CSVDoc::SubView *>(view)->updateEditorSetting (settingName, settingValue);
|
||||||
//evaluate settingName against tokens to determine which function to call to update Editor application.
|
|
||||||
|
|
||||||
lastValue = settingValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,8 @@ namespace CSVDoc
|
||||||
|
|
||||||
void exitApplication();
|
void exitApplication();
|
||||||
|
|
||||||
|
void loadUserSettings();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews);
|
View (ViewManager& viewManager, CSMDoc::Document *document, int totalViews);
|
||||||
|
@ -88,6 +90,8 @@ namespace CSVDoc
|
||||||
|
|
||||||
Operations *getOperations() const;
|
Operations *getOperations() const;
|
||||||
|
|
||||||
|
void updateEditorSetting (const QString &, const QString &);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void newDocumentRequest();
|
void newDocumentRequest();
|
||||||
|
@ -102,8 +106,6 @@ namespace CSVDoc
|
||||||
|
|
||||||
void abortOperation (int type);
|
void abortOperation (int type);
|
||||||
|
|
||||||
void slotUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void newView();
|
void newView();
|
||||||
|
|
|
@ -13,13 +13,13 @@
|
||||||
#include "../world/enumdelegate.hpp"
|
#include "../world/enumdelegate.hpp"
|
||||||
#include "../world/vartypedelegate.hpp"
|
#include "../world/vartypedelegate.hpp"
|
||||||
#include "../world/recordstatusdelegate.hpp"
|
#include "../world/recordstatusdelegate.hpp"
|
||||||
|
#include "../settings/usersettingsdialog.hpp"
|
||||||
|
|
||||||
#include "view.hpp"
|
#include "view.hpp"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QtGui/QApplication>
|
#include <QtGui/QApplication>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
void CSVDoc::ViewManager::updateIndices()
|
void CSVDoc::ViewManager::updateIndices()
|
||||||
{
|
{
|
||||||
|
@ -121,6 +121,11 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager)
|
||||||
|
|
||||||
mDelegateFactories->add (CSMWorld::ColumnBase::Display_RecordState,
|
mDelegateFactories->add (CSMWorld::ColumnBase::Display_RecordState,
|
||||||
new CSVWorld::RecordStatusDelegateFactory() );
|
new CSVWorld::RecordStatusDelegateFactory() );
|
||||||
|
|
||||||
|
connect (&CSMSettings::UserSettings::instance(), SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)),
|
||||||
|
this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)));
|
||||||
|
|
||||||
|
CSMSettings::UserSettings::instance().loadSettings("opencs.cfg");
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVDoc::ViewManager::~ViewManager()
|
CSVDoc::ViewManager::~ViewManager()
|
||||||
|
@ -347,3 +352,10 @@ void CSVDoc::ViewManager::exitApplication (CSVDoc::View *view)
|
||||||
if (notifySaveOnClose (view))
|
if (notifySaveOnClose (view))
|
||||||
QApplication::instance()->exit();
|
QApplication::instance()->exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::ViewManager::slotUpdateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||||
|
{
|
||||||
|
if (settingName == "Record Status Display")
|
||||||
|
foreach (CSVDoc::View *view, mViews)
|
||||||
|
view->updateEditorSetting (settingName, settingValue);
|
||||||
|
}
|
||||||
|
|
|
@ -72,6 +72,8 @@ namespace CSVDoc
|
||||||
void progress (int current, int max, int type, int threads, CSMDoc::Document *document);
|
void progress (int current, int max, int type, int threads, CSMDoc::Document *document);
|
||||||
|
|
||||||
void onExitWarningHandler(int state, CSMDoc::Document* document);
|
void onExitWarningHandler(int state, CSMDoc::Document* document);
|
||||||
|
|
||||||
|
void slotUpdateEditorSetting (const QString &, const QString &);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,18 +13,32 @@
|
||||||
CSVSettings::AbstractPage::AbstractPage(QWidget *parent):
|
CSVSettings::AbstractPage::AbstractPage(QWidget *parent):
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
{
|
{
|
||||||
|
QGridLayout *pageLayout = new QGridLayout(this);
|
||||||
|
setLayout (pageLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVSettings::AbstractPage::AbstractPage(const QString &pageName, QWidget *parent):
|
CSVSettings::AbstractPage::AbstractPage(const QString &pageName, QWidget *parent):
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
{
|
{
|
||||||
QWidget::setObjectName (pageName);
|
QWidget::setObjectName (pageName);
|
||||||
|
|
||||||
|
QGridLayout *pageLayout = new QGridLayout(this);
|
||||||
|
setLayout (pageLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVSettings::AbstractPage::~AbstractPage()
|
CSVSettings::AbstractPage::~AbstractPage()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
void CSVSettings::AbstractPage::setupUi()
|
||||||
|
{
|
||||||
|
// Hacks to get the stylesheet look properly
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
QPlastiqueStyle *style = new QPlastiqueStyle;
|
||||||
|
//profilesComboBox->setStyle(style);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
*/
|
||||||
CSMSettings::SettingList *CSVSettings::AbstractPage::getSettings()
|
CSMSettings::SettingList *CSVSettings::AbstractPage::getSettings()
|
||||||
{
|
{
|
||||||
CSMSettings::SettingList *settings = new CSMSettings::SettingList();
|
CSMSettings::SettingList *settings = new CSMSettings::SettingList();
|
||||||
|
|
|
@ -28,7 +28,7 @@ namespace CSVSettings {
|
||||||
|
|
||||||
~AbstractPage();
|
~AbstractPage();
|
||||||
|
|
||||||
virtual void setupUi()=0;
|
virtual void setupUi() = 0;
|
||||||
|
|
||||||
virtual void initializeWidgets (const CSMSettings::SettingMap &settings) = 0;
|
virtual void initializeWidgets (const CSMSettings::SettingMap &settings) = 0;
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace CSVSettings {
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
template <typename S, typename T>
|
template <typename S, typename T>
|
||||||
AbstractBlock *buildBlock (T &def)
|
AbstractBlock *buildBlock (T *def)
|
||||||
{
|
{
|
||||||
S *block = new S (this);
|
S *block = new S (this);
|
||||||
int ret = block->build (def);
|
int ret = block->build (def);
|
||||||
|
@ -47,12 +47,12 @@ namespace CSVSettings {
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
QWidget::layout()->addWidget (block->getGroupBox());
|
QGroupBox *box = block->getGroupBox();
|
||||||
|
QWidget::layout()->addWidget (box);
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,7 @@ void CSVSettings::BlankPage::initPage()
|
||||||
void CSVSettings::BlankPage::setupUi()
|
void CSVSettings::BlankPage::setupUi()
|
||||||
{
|
{
|
||||||
QGroupBox *pageBox = new QGroupBox(this);
|
QGroupBox *pageBox = new QGroupBox(this);
|
||||||
QLayout* pageLayout = new QVBoxLayout();
|
layout()->addWidget(pageBox);
|
||||||
|
|
||||||
setLayout(pageLayout);
|
|
||||||
pageLayout->addWidget(pageBox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVSettings::BlankPage::initializeWidgets (const CSMSettings::SettingMap &settings)
|
void CSVSettings::BlankPage::initializeWidgets (const CSMSettings::SettingMap &settings)
|
||||||
|
|
|
@ -23,7 +23,7 @@ int CSVSettings::CustomBlock::build(GroupBlockDefList &defList, GroupBlockDefLis
|
||||||
for (; listIt != defList.end(); ++listIt)
|
for (; listIt != defList.end(); ++listIt)
|
||||||
{
|
{
|
||||||
if (!(*listIt)->isProxy)
|
if (!(*listIt)->isProxy)
|
||||||
retVal = buildGroupBlock (*(*listIt));
|
retVal = buildGroupBlock (*listIt);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mGroupList << proxyBlock;
|
mGroupList << proxyBlock;
|
||||||
|
@ -32,7 +32,7 @@ int CSVSettings::CustomBlock::build(GroupBlockDefList &defList, GroupBlockDefLis
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxyIt != defaultIt)
|
if (proxyIt != defaultIt)
|
||||||
retVal = buildProxyBlock (*(*proxyIt), proxyBlock);
|
retVal = buildProxyBlock (*proxyIt, proxyBlock);
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ CSVSettings::GroupBox *CSVSettings::CustomBlock::buildGroupBox (Orientation orie
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CSVSettings::CustomBlock::buildGroupBlock(GroupBlockDef &def)
|
int CSVSettings::CustomBlock::buildGroupBlock(GroupBlockDef *def)
|
||||||
{
|
{
|
||||||
GroupBlock *block = new GroupBlock (getParent());
|
GroupBlock *block = new GroupBlock (getParent());
|
||||||
|
|
||||||
|
@ -57,9 +57,9 @@ int CSVSettings::CustomBlock::buildGroupBlock(GroupBlockDef &def)
|
||||||
return block->build(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->properties.size() != 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int retVal = block->build(def);
|
int retVal = block->build(def);
|
||||||
|
@ -67,7 +67,7 @@ int CSVSettings::CustomBlock::buildProxyBlock(GroupBlockDef& def, ProxyBlock *bl
|
||||||
if (retVal != 0)
|
if (retVal != 0)
|
||||||
return retVal;
|
return retVal;
|
||||||
|
|
||||||
foreach (QStringList *list, *(def.properties.at(0)->proxyList))
|
foreach (QStringList *list, *(def->properties.at(0)->proxyList))
|
||||||
{
|
{
|
||||||
QString proxiedBlockName = list->at(0);
|
QString proxiedBlockName = list->at(0);
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ namespace CSVSettings
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int buildGroupBlock(GroupBlockDef &def);
|
int buildGroupBlock(GroupBlockDef *def);
|
||||||
int buildProxyBlock(GroupBlockDef &def, ProxyBlock *block);
|
int buildProxyBlock(GroupBlockDef *def, ProxyBlock *block);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // CUSTOMBLOCK_HPP
|
#endif // CUSTOMBLOCK_HPP
|
||||||
|
|
|
@ -1,156 +1,52 @@
|
||||||
#include "editorpage.hpp"
|
#include "editorpage.hpp"
|
||||||
|
|
||||||
#include <QList>
|
|
||||||
#include <QListView>
|
|
||||||
#include <QGroupBox>
|
|
||||||
#include <QRadioButton>
|
|
||||||
#include <QDockWidget>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QGridLayout>
|
|
||||||
#include <QStyle>
|
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
#include <QPlastiqueStyle>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../../model/settings/usersettings.hpp"
|
|
||||||
#include "groupblock.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)
|
AbstractPage(parent)
|
||||||
{
|
{
|
||||||
// Hacks to get the stylesheet look properly
|
|
||||||
#ifdef Q_OS_MAC
|
|
||||||
QPlastiqueStyle *style = new QPlastiqueStyle;
|
|
||||||
//profilesComboBox->setStyle(style);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
setupUi();
|
setupUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSVSettings::EditorPage::EditorPage (const QString &pageName, QWidget* parent)
|
||||||
|
: AbstractPage (pageName, parent)
|
||||||
|
{
|
||||||
|
setupUi();
|
||||||
|
}
|
||||||
|
|
||||||
|
CSVSettings::GroupBlockDef *CSVSettings::EditorPage::setupRecordStatusDisplay()
|
||||||
|
{
|
||||||
|
GroupBlockDef *statusBlock = new GroupBlockDef(QString("Record Status Display"));
|
||||||
|
|
||||||
|
SettingsItemDef *statusItem = new SettingsItemDef (statusBlock->title, "Icon and Text");
|
||||||
|
*(statusItem->valueList) << QString("Icon and Text") << QString("Icon Only") << QString("Text Only");
|
||||||
|
|
||||||
|
WidgetDef statusWidget (Widget_RadioButton);
|
||||||
|
statusWidget.valueList = statusItem->valueList;
|
||||||
|
|
||||||
|
statusItem->widget = statusWidget;
|
||||||
|
|
||||||
|
statusBlock->properties << statusItem;
|
||||||
|
|
||||||
|
return statusBlock;
|
||||||
|
}
|
||||||
|
|
||||||
void CSVSettings::EditorPage::setupUi()
|
void CSVSettings::EditorPage::setupUi()
|
||||||
{
|
{
|
||||||
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"));
|
|
||||||
|
|
||||||
////////////////////////////
|
mAbstractBlocks << buildBlock<GroupBlock>(setupRecordStatusDisplay());
|
||||||
//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;
|
|
||||||
|
|
||||||
reuseSubwindow.properties << reuseSubItem;
|
|
||||||
reuseSubItem->widget = reuseSubWidget;
|
|
||||||
|
|
||||||
///////////////////////////////
|
|
||||||
//custom window size properties
|
|
||||||
///////////////////////////////
|
|
||||||
|
|
||||||
//custom width
|
|
||||||
SettingsItemDef *widthItem = new SettingsItemDef ("Window Width", "640");
|
|
||||||
widthItem->widget = WidgetDef (Widget_LineEdit);
|
|
||||||
widthItem->widget.widgetWidth = 45;
|
|
||||||
|
|
||||||
//custom height
|
|
||||||
SettingsItemDef *heightItem = new SettingsItemDef ("Window Height", "480");
|
|
||||||
heightItem->widget = WidgetDef (Widget_LineEdit);
|
|
||||||
heightItem->widget.widgetWidth = 45;
|
|
||||||
heightItem->widget.caption = "x";
|
|
||||||
|
|
||||||
customWindowSize.properties << widthItem << heightItem;
|
|
||||||
customWindowSize.widgetOrientation = Orient_Horizontal;
|
|
||||||
customWindowSize.isVisible = false;
|
|
||||||
|
|
||||||
|
|
||||||
//pre-defined
|
|
||||||
SettingsItemDef *widthByHeightItem = new SettingsItemDef ("Window Size", "640x480");
|
|
||||||
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);
|
|
||||||
|
|
||||||
setLayout (pageLayout);
|
|
||||||
|
|
||||||
mAbstractBlocks << buildBlock<GroupBlock> (topLevelWindowCount)
|
|
||||||
<< buildBlock<GroupBlock> (reuseSubwindow)
|
|
||||||
<< buildBlock<ToggleBlock> (windowSize)
|
|
||||||
<< buildBlock<GroupBlock> (undoStack);
|
|
||||||
|
|
||||||
foreach (AbstractBlock *block, mAbstractBlocks)
|
foreach (AbstractBlock *block, mAbstractBlocks)
|
||||||
{
|
{
|
||||||
connect (block, SIGNAL (signalUpdateSetting (const QString &, const QString &)),
|
connect (block, SIGNAL (signalUpdateSetting (const QString &, const QString &)),
|
||||||
this, SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)) );
|
this, SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect ( this,
|
||||||
|
SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)),
|
||||||
|
&(CSMSettings::UserSettings::instance()),
|
||||||
|
SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVSettings::EditorPage::initializeWidgets (const CSMSettings::SettingMap &settings)
|
void CSVSettings::EditorPage::initializeWidgets (const CSMSettings::SettingMap &settings)
|
||||||
|
|
|
@ -1,28 +1,30 @@
|
||||||
#ifndef EDITORPAGE_H
|
#ifndef EDITORPAGE_HPP
|
||||||
#define EDITORPAGE_H
|
#define EDITORPAGE_HPP
|
||||||
|
|
||||||
|
#include "support.hpp"
|
||||||
#include "abstractpage.hpp"
|
#include "abstractpage.hpp"
|
||||||
|
|
||||||
class QGroupBox;
|
namespace CSVSettings
|
||||||
|
{
|
||||||
namespace CSVSettings {
|
|
||||||
|
|
||||||
class UserSettings;
|
|
||||||
class AbstractBlock;
|
|
||||||
|
|
||||||
class EditorPage : public AbstractPage
|
class EditorPage : public AbstractPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
explicit EditorPage(QWidget *parent = 0);
|
||||||
|
explicit EditorPage (const QString &pageName, QWidget* parent = 0);
|
||||||
|
|
||||||
EditorPage(QWidget *parent = 0);
|
|
||||||
|
|
||||||
void setupUi();
|
|
||||||
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
||||||
|
void setupUi();
|
||||||
|
|
||||||
|
private:
|
||||||
|
GroupBlockDef *setupRecordStatusDisplay();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||||
|
|
||||||
|
public slots:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif //EDITORPAGE_H
|
|
||||||
|
#endif // EDITORPAGE_HPP
|
||||||
|
|
|
@ -9,22 +9,22 @@ CSVSettings::GroupBlock::GroupBlock (bool isVisible, QWidget *parent)
|
||||||
: AbstractBlock (isVisible, parent)
|
: AbstractBlock (isVisible, parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
int CSVSettings::GroupBlock::build (GroupBlockDef &def)
|
int CSVSettings::GroupBlock::build (GroupBlockDef *def)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (def.properties.size() == 0)
|
if (def->properties.size() == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
|
|
||||||
setVisible (def.isVisible);
|
setVisible (def->isVisible);
|
||||||
|
|
||||||
mBox->setLayout(createLayout (def.widgetOrientation, true));
|
mBox->setLayout(createLayout (def->widgetOrientation, true));
|
||||||
|
|
||||||
setObjectName (def.title);
|
setObjectName (def->title);
|
||||||
mBox->setTitle (def.title);
|
mBox->setTitle (def->title);
|
||||||
|
|
||||||
foreach (SettingsItemDef *itemDef, def.properties)
|
foreach (SettingsItemDef *itemDef, def->properties)
|
||||||
{
|
{
|
||||||
ItemBlock *block = new ItemBlock (mBox);
|
ItemBlock *block = new ItemBlock (mBox);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace CSVSettings
|
||||||
GroupBlock (QWidget* parent = 0);
|
GroupBlock (QWidget* parent = 0);
|
||||||
GroupBlock (bool isVisible, QWidget *parent = 0);
|
GroupBlock (bool isVisible, QWidget *parent = 0);
|
||||||
|
|
||||||
int build (GroupBlockDef &def);
|
int build (GroupBlockDef *def);
|
||||||
|
|
||||||
bool updateSettings (const CSMSettings::SettingMap &settings);
|
bool updateSettings (const CSMSettings::SettingMap &settings);
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@ CSVSettings::ProxyBlock::ProxyBlock (QWidget *parent)
|
||||||
: GroupBlock (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
|
//get the list of pre-defined values for the proxy
|
||||||
mValueList = proxyDef.properties.at(0)->valueList;
|
mValueList = proxyDef->properties.at(0)->valueList;
|
||||||
|
|
||||||
bool success = GroupBlock::build(proxyDef);
|
bool success = GroupBlock::build(proxyDef);
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace CSVSettings
|
||||||
explicit ProxyBlock (ItemBlock *proxyItemBlock, QWidget *parent = 0);
|
explicit ProxyBlock (ItemBlock *proxyItemBlock, QWidget *parent = 0);
|
||||||
|
|
||||||
void addSetting (ItemBlock* settingBlock, QStringList *proxyList);
|
void addSetting (ItemBlock* settingBlock, QStringList *proxyList);
|
||||||
int build (GroupBlockDef &def);
|
int build (GroupBlockDef *def);
|
||||||
|
|
||||||
CSMSettings::SettingList *getSettings() { return 0; }
|
CSMSettings::SettingList *getSettings() { return 0; }
|
||||||
bool updateSettings (const CSMSettings::SettingMap &settings);
|
bool updateSettings (const CSMSettings::SettingMap &settings);
|
||||||
|
|
159
apps/opencs/view/settings/samplepage.cpp
Normal file
159
apps/opencs/view/settings/samplepage.cpp
Normal file
|
@ -0,0 +1,159 @@
|
||||||
|
#include "samplepage.hpp"
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QListView>
|
||||||
|
#include <QGroupBox>
|
||||||
|
#include <QRadioButton>
|
||||||
|
#include <QDockWidget>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QStyle>
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
#include <QPlastiqueStyle>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
#include "groupblock.hpp"
|
||||||
|
#include "toggleblock.hpp"
|
||||||
|
|
||||||
|
CSVSettings::SamplePage::SamplePage(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::SamplePage::setupUi()
|
||||||
|
{
|
||||||
|
GroupBlockDef *undoStack = new GroupBlockDef(QString("Undo Stack Size"));
|
||||||
|
GroupBlockDef *topLevelWindowCount = new GroupBlockDef(QString("Maximum Top-Level Window Count"));
|
||||||
|
GroupBlockDef *reuseSubwindow = new GroupBlockDef(QString("Reuse Subwindows"));
|
||||||
|
GroupBlockDef *customWindowSize = new GroupBlockDef(QString ("Custom Window Size"));
|
||||||
|
GroupBlockDef *definedWindowSize = new GroupBlockDef(QString ("Pre-Defined Window Size"));
|
||||||
|
GroupBlockDef *windowSizeToggle = new GroupBlockDef(QString ("Window Size"));
|
||||||
|
CustomBlockDef *windowSize = new CustomBlockDef(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;
|
||||||
|
|
||||||
|
reuseSubwindow->properties << reuseSubItem;
|
||||||
|
reuseSubItem->widget = reuseSubWidget;
|
||||||
|
|
||||||
|
///////////////////////////////
|
||||||
|
//custom window size properties
|
||||||
|
///////////////////////////////
|
||||||
|
|
||||||
|
//custom width
|
||||||
|
SettingsItemDef *widthItem = new SettingsItemDef ("Window Width", "640");
|
||||||
|
widthItem->widget = WidgetDef (Widget_LineEdit);
|
||||||
|
widthItem->widget.widgetWidth = 45;
|
||||||
|
|
||||||
|
//custom height
|
||||||
|
SettingsItemDef *heightItem = new SettingsItemDef ("Window Height", "480");
|
||||||
|
heightItem->widget = WidgetDef (Widget_LineEdit);
|
||||||
|
heightItem->widget.widgetWidth = 45;
|
||||||
|
heightItem->widget.caption = "x";
|
||||||
|
|
||||||
|
customWindowSize->properties << widthItem << heightItem;
|
||||||
|
customWindowSize->widgetOrientation = Orient_Horizontal;
|
||||||
|
customWindowSize->isVisible = false;
|
||||||
|
|
||||||
|
|
||||||
|
//pre-defined
|
||||||
|
SettingsItemDef *widthByHeightItem = new SettingsItemDef ("Window Size", "640x480");
|
||||||
|
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";
|
||||||
|
|
||||||
|
mAbstractBlocks << buildBlock<GroupBlock> (topLevelWindowCount)
|
||||||
|
<< buildBlock<GroupBlock> (reuseSubwindow)
|
||||||
|
<< buildBlock<ToggleBlock> (windowSize)
|
||||||
|
<< buildBlock<GroupBlock> (undoStack);
|
||||||
|
|
||||||
|
foreach (AbstractBlock *block, mAbstractBlocks)
|
||||||
|
{
|
||||||
|
connect (block, SIGNAL (signalUpdateSetting (const QString &, const QString &)),
|
||||||
|
this, SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::SamplePage::initializeWidgets (const CSMSettings::SettingMap &settings)
|
||||||
|
{
|
||||||
|
//iterate each item in each blocks in this section
|
||||||
|
//validate the corresponding setting against the defined valuelist if any.
|
||||||
|
for (AbstractBlockList::Iterator it_block = mAbstractBlocks.begin();
|
||||||
|
it_block != mAbstractBlocks.end(); ++it_block)
|
||||||
|
(*it_block)->updateSettings (settings);
|
||||||
|
}
|
28
apps/opencs/view/settings/samplepage.hpp
Normal file
28
apps/opencs/view/settings/samplepage.hpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#ifndef SAMPLEPAGE_H
|
||||||
|
#define SAMPLEPAGE_H
|
||||||
|
|
||||||
|
#include "abstractpage.hpp"
|
||||||
|
|
||||||
|
class QGroupBox;
|
||||||
|
|
||||||
|
namespace CSVSettings {
|
||||||
|
|
||||||
|
class UserSettings;
|
||||||
|
class AbstractBlock;
|
||||||
|
|
||||||
|
class SamplePage : public AbstractPage
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
explicit SamplePage(QWidget *parent = 0);
|
||||||
|
|
||||||
|
void setupUi();
|
||||||
|
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif //SAMPLEPAGE_H
|
|
@ -7,24 +7,24 @@ CSVSettings::ToggleBlock::ToggleBlock(QWidget *parent) :
|
||||||
CustomBlock(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;
|
return -1;
|
||||||
|
|
||||||
QList<GroupBlockDef *>::Iterator it = def.blockDefList.begin();
|
QList<GroupBlockDef *>::Iterator it = def->blockDefList.begin();
|
||||||
|
|
||||||
//first def in the list is the def for the toggle block
|
//first def in the list is the def for the toggle block
|
||||||
GroupBlockDef *toggleDef = *it++;
|
GroupBlockDef *toggleDef = *it++;
|
||||||
|
|
||||||
if (toggleDef->captions.size() != def.blockDefList.size()-1 )
|
if (toggleDef->captions.size() != def->blockDefList.size()-1 )
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
if (toggleDef->widgets.size() == 0)
|
if (toggleDef->widgets.size() == 0)
|
||||||
return -3;
|
return -3;
|
||||||
|
|
||||||
//create the toogle block UI structure
|
//create the toogle block UI structure
|
||||||
QLayout *blockLayout = createLayout (def.blockOrientation, true);
|
QLayout *blockLayout = createLayout (def->blockOrientation, true);
|
||||||
GroupBox *propertyBox = buildGroupBox (toggleDef->widgetOrientation);
|
GroupBox *propertyBox = buildGroupBox (toggleDef->widgetOrientation);
|
||||||
|
|
||||||
mBox->setLayout(blockLayout);
|
mBox->setLayout(blockLayout);
|
||||||
|
@ -34,13 +34,13 @@ int CSVSettings::ToggleBlock::build(CustomBlockDef &def)
|
||||||
//this manages proxy block construction.
|
//this manages proxy block construction.
|
||||||
//Any settings managed by the proxy setting
|
//Any settings managed by the proxy setting
|
||||||
//must be included in the blocks defined in the list.
|
//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)
|
for (GroupBlockList::iterator it = mGroupList.begin(); it != mGroupList.end(); ++it)
|
||||||
propertyBox->layout()->addWidget ((*it)->getGroupBox());
|
propertyBox->layout()->addWidget ((*it)->getGroupBox());
|
||||||
|
|
||||||
//build togle widgets, linking them to the settings
|
//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(toggleBox);
|
||||||
blockLayout->addWidget(propertyBox);
|
blockLayout->addWidget(propertyBox);
|
||||||
|
@ -49,16 +49,16 @@ int CSVSettings::ToggleBlock::build(CustomBlockDef &def)
|
||||||
return 0;
|
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());
|
GroupBox *box = new GroupBox (false, getParent());
|
||||||
|
|
||||||
QLayout *layout = createLayout (def.widgetOrientation, true, static_cast<QWidget *>(box));
|
QLayout *layout = createLayout (def->widgetOrientation, true, static_cast<QWidget *>(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);
|
QString caption = def->captions.at(i);
|
||||||
WidgetDef *wDef = def.widgets.at(i);
|
WidgetDef *wDef = def->widgets.at(i);
|
||||||
|
|
||||||
wDef->caption = caption;
|
wDef->caption = caption;
|
||||||
wDef->widgetAlignment = Align_Left;
|
wDef->widgetAlignment = Align_Left;
|
||||||
|
|
|
@ -18,10 +18,10 @@ namespace CSVSettings
|
||||||
public:
|
public:
|
||||||
explicit ToggleBlock(QWidget *parent = 0);
|
explicit ToggleBlock(QWidget *parent = 0);
|
||||||
|
|
||||||
int build (CustomBlockDef &def);
|
int build (CustomBlockDef *def);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GroupBox *buildToggleWidgets (GroupBlockDef &def, QString &defaultToggle);
|
GroupBox *buildToggleWidgets (GroupBlockDef *def, QString &defaultToggle);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif // TOGGLEBLOCK_HPP
|
#endif // TOGGLEBLOCK_HPP
|
||||||
|
|
|
@ -9,20 +9,21 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
|
#include <QGridLayout>
|
||||||
|
|
||||||
#include "blankpage.hpp"
|
#include "blankpage.hpp"
|
||||||
#include "editorpage.hpp"
|
#include "samplepage.hpp"
|
||||||
#include "../../model/settings/support.hpp"
|
|
||||||
|
|
||||||
|
#include "../../model/settings/support.hpp"
|
||||||
|
#include <boost/filesystem/path.hpp>
|
||||||
#include "settingwidget.hpp"
|
#include "settingwidget.hpp"
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
CSVSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) :
|
CSVSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) :
|
||||||
QMainWindow (parent), mStackedWidget (0)
|
QMainWindow (parent), mStackedWidget (0)
|
||||||
{
|
{
|
||||||
setWindowTitle(QString::fromUtf8 ("User Settings"));
|
setWindowTitle(QString::fromUtf8 ("User Settings"));
|
||||||
buildPages();
|
buildPages();
|
||||||
setWidgetStates (loadSettings());
|
setWidgetStates ();
|
||||||
positionWindow ();
|
positionWindow ();
|
||||||
|
|
||||||
connect (mListWidget,
|
connect (mListWidget,
|
||||||
|
@ -40,13 +41,16 @@ void CSVSettings::UserSettingsDialog::closeEvent (QCloseEvent *event)
|
||||||
writeSettings();
|
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)
|
//iterate the tabWidget's pages (sections)
|
||||||
for (int i = 0; i < mStackedWidget->count(); i++)
|
for (int i = 0; i < mStackedWidget->count(); i++)
|
||||||
{
|
{
|
||||||
//get the settings defined for the entire section
|
//get the settings defined for the entire section
|
||||||
CSMSettings::SettingMap *settings = settingsMap [mStackedWidget->widget(i)->objectName()];
|
CSMSettings::SettingMap *settings = sectionSettings [mStackedWidget->widget(i)->objectName()];
|
||||||
|
|
||||||
//if found, initialize the page's widgets
|
//if found, initialize the page's widgets
|
||||||
if (settings)
|
if (settings)
|
||||||
|
@ -65,18 +69,25 @@ void CSVSettings::UserSettingsDialog::buildPages()
|
||||||
mListWidget = new QListWidget (centralWidget);
|
mListWidget = new QListWidget (centralWidget);
|
||||||
mStackedWidget = new QStackedWidget (centralWidget);
|
mStackedWidget = new QStackedWidget (centralWidget);
|
||||||
|
|
||||||
QLayout* dialogLayout = new QHBoxLayout();
|
QGridLayout* dialogLayout = new QGridLayout();
|
||||||
|
|
||||||
dialogLayout->addWidget (mListWidget);
|
mListWidget->setMinimumWidth(0);
|
||||||
dialogLayout->addWidget (mStackedWidget);
|
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);
|
centralWidget->setLayout (dialogLayout);
|
||||||
|
|
||||||
setCentralWidget (centralWidget);
|
setCentralWidget (centralWidget);
|
||||||
setDockOptions (QMainWindow::AllowNestedDocks);
|
setDockOptions (QMainWindow::AllowNestedDocks);
|
||||||
|
|
||||||
//uncomment to test with sample editor page.
|
//uncomment to test with sample editor page.
|
||||||
//createSamplePage();
|
// TODO: Reimplement sample page using createPage function
|
||||||
createPage<BlankPage>("Page1");
|
//createPage<SamplePage>("Sample");
|
||||||
|
createPage<EditorPage>("Editor");
|
||||||
createPage<BlankPage>("Page2");
|
createPage<BlankPage>("Page2");
|
||||||
createPage<BlankPage>("Page3");
|
createPage<BlankPage>("Page3");
|
||||||
}
|
}
|
||||||
|
@ -85,14 +96,16 @@ void CSVSettings::UserSettingsDialog::createSamplePage()
|
||||||
{
|
{
|
||||||
//add pages to stackedwidget and items to listwidget
|
//add pages to stackedwidget and items to listwidget
|
||||||
CSVSettings::AbstractPage *page
|
CSVSettings::AbstractPage *page
|
||||||
= new CSVSettings::EditorPage(this);
|
= new CSVSettings::SamplePage(this);
|
||||||
|
|
||||||
mStackedWidget->addWidget (page);
|
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 &)));
|
||||||
|
|
||||||
connect ( page, SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)),
|
new QListWidgetItem (page->objectName(), mListWidget);
|
||||||
&(CSMSettings::UserSettings::instance()), SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVSettings::UserSettingsDialog::positionWindow ()
|
void CSVSettings::UserSettingsDialog::positionWindow ()
|
||||||
|
@ -103,47 +116,6 @@ void CSVSettings::UserSettingsDialog::positionWindow ()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMSettings::SectionMap CSVSettings::UserSettingsDialog::loadSettings ()
|
|
||||||
{
|
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
|
||||||
|
|
||||||
mPaths.append(QString("opencs.cfg"));
|
|
||||||
mPaths.append(userPath + QString("opencs.cfg"));
|
|
||||||
|
|
||||||
CSMSettings::SectionMap settingsMap;
|
|
||||||
|
|
||||||
foreach (const QString &path, mPaths)
|
|
||||||
{
|
|
||||||
qDebug() << "Loading config file:" << qPrintable(path);
|
|
||||||
QFile file(path);
|
|
||||||
|
|
||||||
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("<br><b>Could not open %0 for reading</b><br><br> \
|
|
||||||
Please make sure you have the right permissions \
|
|
||||||
and try again.<br>").arg(file.fileName()));
|
|
||||||
msgBox.exec();
|
|
||||||
return settingsMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
QTextStream stream(&file);
|
|
||||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
|
||||||
|
|
||||||
CSMSettings::UserSettings::instance().getSettings(stream, settingsMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
file.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
return settingsMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVSettings::UserSettingsDialog::writeSettings()
|
void CSVSettings::UserSettingsDialog::writeSettings()
|
||||||
{
|
{
|
||||||
QMap<QString, CSMSettings::SettingList *> settings;
|
QMap<QString, CSMSettings::SettingList *> settings;
|
||||||
|
@ -154,7 +126,7 @@ void CSVSettings::UserSettingsDialog::writeSettings()
|
||||||
settings [page->objectName()] = page->getSettings();
|
settings [page->objectName()] = page->getSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMSettings::UserSettings::instance().writeFile(CSMSettings::UserSettings::instance().openFile(mPaths.back()), settings);
|
CSMSettings::UserSettings::instance().writeFile(settings);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,14 +4,13 @@
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
|
#include <QApplication>
|
||||||
#ifndef Q_MOC_RUN
|
|
||||||
#include <components/files/configurationmanager.hpp>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
#include "../../model/settings/support.hpp"
|
#include "../../model/settings/support.hpp"
|
||||||
|
|
||||||
|
#include "editorpage.hpp"
|
||||||
|
|
||||||
class QHBoxLayout;
|
class QHBoxLayout;
|
||||||
class AbstractWidget;
|
class AbstractWidget;
|
||||||
class QStackedWidget;
|
class QStackedWidget;
|
||||||
|
@ -28,7 +27,6 @@ namespace CSVSettings {
|
||||||
QStringList mPaths;
|
QStringList mPaths;
|
||||||
QListWidget *mListWidget;
|
QListWidget *mListWidget;
|
||||||
QStackedWidget *mStackedWidget;
|
QStackedWidget *mStackedWidget;
|
||||||
Files::ConfigurationManager mCfgMgr;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UserSettingsDialog(QMainWindow *parent = 0);
|
UserSettingsDialog(QMainWindow *parent = 0);
|
||||||
|
@ -38,10 +36,9 @@ namespace CSVSettings {
|
||||||
|
|
||||||
void closeEvent (QCloseEvent *event);
|
void closeEvent (QCloseEvent *event);
|
||||||
AbstractPage *getAbstractPage (int index);
|
AbstractPage *getAbstractPage (int index);
|
||||||
void setWidgetStates (CSMSettings::SectionMap settingsMap);
|
void setWidgetStates ();
|
||||||
void buildPages();
|
void buildPages();
|
||||||
void positionWindow ();
|
void positionWindow ();
|
||||||
CSMSettings::SectionMap loadSettings();
|
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
void createSamplePage();
|
void createSamplePage();
|
||||||
|
|
||||||
|
@ -61,6 +58,12 @@ namespace CSVSettings {
|
||||||
if (mStackedWidget->sizeHint().height() < 480)
|
if (mStackedWidget->sizeHint().height() < 480)
|
||||||
mStackedWidget->sizeHint().setHeight(480);
|
mStackedWidget->sizeHint().setHeight(480);
|
||||||
|
|
||||||
|
QFontMetrics fm (QApplication::font());
|
||||||
|
int textWidth = fm.width(page->objectName());
|
||||||
|
|
||||||
|
if ((textWidth + 50) > mListWidget->minimumWidth())
|
||||||
|
mListWidget->setMinimumWidth(textWidth + 50);
|
||||||
|
|
||||||
resize (mStackedWidget->sizeHint());
|
resize (mStackedWidget->sizeHint());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
CSVWorld::RecordStatusDelegate::RecordStatusDelegate(QUndoStack &undoStack, QObject *parent)
|
CSVWorld::RecordStatusDelegate::RecordStatusDelegate(QUndoStack &undoStack, QObject *parent)
|
||||||
: CommandDelegate (undoStack, parent)
|
: CommandDelegate (undoStack, parent)
|
||||||
|
@ -36,23 +37,23 @@ void CSVWorld::RecordStatusDelegate::paint (QPainter *painter, const QStyleOptio
|
||||||
switch (index.data().toInt())
|
switch (index.data().toInt())
|
||||||
{
|
{
|
||||||
case 0: // State_BaseOnly
|
case 0: // State_BaseOnly
|
||||||
text = "base";
|
text = "Base";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: // State_Modified
|
case 1: // State_Modified
|
||||||
text = "modified";
|
text = "Modified";
|
||||||
icon = mModifiedIcon;
|
icon = mModifiedIcon;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: // State_Modified_Only
|
case 2: // State_Modified_Only
|
||||||
text = "added";
|
text = "Added";
|
||||||
icon = mAddedIcon;
|
icon = mAddedIcon;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: // State_Deleted
|
case 3: // State_Deleted
|
||||||
|
|
||||||
case 4: // State_Erased
|
case 4: // State_Erased
|
||||||
text = "deleted";
|
text = "Deleted";
|
||||||
icon = mDeletedIcon;
|
icon = mDeletedIcon;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -70,14 +71,14 @@ void CSVWorld::RecordStatusDelegate::paint (QPainter *painter, const QStyleOptio
|
||||||
|
|
||||||
if (mStatusDisplay == 0 && (icon) )
|
if (mStatusDisplay == 0 && (icon) )
|
||||||
{
|
{
|
||||||
iconRect.setRight (iconRect.left() + mIconSize*2);
|
iconRect.setRight (iconRect.left()+ mIconSize*2);
|
||||||
textRect.setLeft (iconRect.right() + mTextLeftOffset *2);
|
textRect.setLeft (iconRect.right() + mTextLeftOffset *1.25);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
textRect.setLeft (textRect.left() + mTextLeftOffset );
|
textRect.setLeft (textRect.left() + mTextLeftOffset );
|
||||||
|
|
||||||
if ( (mStatusDisplay == 0 || mStatusDisplay == 1) && (icon) )
|
if ( (mStatusDisplay == 0 || mStatusDisplay == 1) && (icon) )
|
||||||
painter->drawPixmap(iconRect.center(),icon->pixmap(mIconSize, mIconSize));
|
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
|
// icon + text or text only, or force text if no icon exists for status
|
||||||
if (mStatusDisplay == 0 || mStatusDisplay == 2 || !(icon) )
|
if (mStatusDisplay == 0 || mStatusDisplay == 2 || !(icon) )
|
||||||
|
@ -99,3 +100,21 @@ CSVWorld::CommandDelegate *CSVWorld::RecordStatusDelegateFactory::makeDelegate (
|
||||||
{
|
{
|
||||||
return new RecordStatusDelegate (undoStack, parent);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -35,12 +35,12 @@ namespace CSVWorld
|
||||||
|
|
||||||
QSize sizeHint (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
|
class RecordStatusDelegateFactory : public CommandDelegateFactory
|
||||||
{
|
{
|
||||||
//std::vector<std::pair<int, QString> > mValues;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
virtual CommandDelegate *makeDelegate (QUndoStack& undoStack, QObject *parent) const;
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "../../model/world/idtableproxymodel.hpp"
|
#include "../../model/world/idtableproxymodel.hpp"
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
#include "../../model/world/record.hpp"
|
#include "../../model/world/record.hpp"
|
||||||
|
#include "recordstatusdelegate.hpp"
|
||||||
|
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ std::vector<std::string> CSVWorld::Table::listDeletableSelectedIds() const
|
||||||
|
|
||||||
CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack,
|
CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack,
|
||||||
bool createAndDelete)
|
bool createAndDelete)
|
||||||
: mUndoStack (undoStack), mCreateAction (0), mEditLock (false)
|
: mUndoStack (undoStack), mCreateAction (0), mEditLock (false), mRecordStatusDisplay (0)
|
||||||
{
|
{
|
||||||
mModel = &dynamic_cast<CSMWorld::IdTable&> (*data.getTableModel (id));
|
mModel = &dynamic_cast<CSMWorld::IdTable&> (*data.getTableModel (id));
|
||||||
|
|
||||||
|
@ -161,6 +162,7 @@ void CSVWorld::Table::createRecord()
|
||||||
|
|
||||||
mUndoStack.push (new CSMWorld::CreateCommand (*mProxyModel, stream.str()));
|
mUndoStack.push (new CSMWorld::CreateCommand (*mProxyModel, stream.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::Table::revertRecord()
|
void CSVWorld::Table::revertRecord()
|
||||||
|
@ -202,3 +204,12 @@ void CSVWorld::Table::deleteRecord()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::Table::updateEditorSetting (const QString &settingName, const QString &settingValue)
|
||||||
|
{
|
||||||
|
if (settingName == "Record Status Display")
|
||||||
|
{
|
||||||
|
dynamic_cast<CSVWorld::RecordStatusDelegate *>(this->itemDelegateForColumn(1))->updateEditorSetting (settingName, settingValue);
|
||||||
|
emit dataChanged(mModel->index(0,1), mModel->index(mModel->rowCount()-1, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace CSVWorld
|
||||||
CSMWorld::IdTableProxyModel *mProxyModel;
|
CSMWorld::IdTableProxyModel *mProxyModel;
|
||||||
CSMWorld::IdTable *mModel;
|
CSMWorld::IdTable *mModel;
|
||||||
bool mEditLock;
|
bool mEditLock;
|
||||||
|
int mRecordStatusDisplay;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -52,6 +53,8 @@ namespace CSVWorld
|
||||||
|
|
||||||
CSMWorld::UniversalId getUniversalId (int row) const;
|
CSMWorld::UniversalId getUniversalId (int row) const;
|
||||||
|
|
||||||
|
void updateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void createRecord();
|
void createRecord();
|
||||||
|
|
|
@ -23,3 +23,10 @@ void CSVWorld::TableSubView::rowActivated (const QModelIndex& index)
|
||||||
{
|
{
|
||||||
focusId (mTable->getUniversalId (index.row()));
|
focusId (mTable->getUniversalId (index.row()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::TableSubView::updateEditorSetting(const QString &settingName, const QString &settingValue)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (settingName == "Record Status Display")
|
||||||
|
mTable->updateEditorSetting(settingName, settingValue);
|
||||||
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@ namespace CSVWorld
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TableSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document, bool createAndDelete);
|
TableSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document, bool createAndDelete);
|
||||||
|
|
||||||
virtual void setEditLock (bool locked);
|
virtual void setEditLock (bool locked);
|
||||||
|
void updateEditorSetting (const QString &, const QString &);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,8 @@ namespace CSVWorld
|
||||||
///< \brief Use commands instead of manipulating the model directly
|
///< \brief Use commands instead of manipulating the model directly
|
||||||
class CommandDelegate : public QStyledItemDelegate
|
class CommandDelegate : public QStyledItemDelegate
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
QUndoStack& mUndoStack;
|
QUndoStack& mUndoStack;
|
||||||
bool mEditLock;
|
bool mEditLock;
|
||||||
|
|
||||||
|
@ -105,6 +107,10 @@ namespace CSVWorld
|
||||||
void setEditLock (bool locked);
|
void setEditLock (bool locked);
|
||||||
|
|
||||||
bool isEditLocked() const;
|
bool isEditLocked() const;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
virtual void slotUpdateEditorSetting (const QString &settingName, const QString &settingValue) {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue