forked from mirror/openmw-tes3mp
added user settings option to toggle toolbars in single-record subviews
This commit is contained in:
parent
749eff5259
commit
fc6c14614b
5 changed files with 131 additions and 51 deletions
|
@ -217,6 +217,12 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
jumpToAdded->setDeclaredValues (jumpValues);
|
||||
}
|
||||
|
||||
declareSection ("dialogues", "ID Dialogues");
|
||||
{
|
||||
Setting *toolbar = createSetting (Type_CheckBox, "toolbar", "Show toolbar");
|
||||
toolbar->setDefaultValue ("true");
|
||||
}
|
||||
|
||||
declareSection ("report-input", "Reports");
|
||||
{
|
||||
QString none ("None");
|
||||
|
@ -310,6 +316,9 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
"<li>Strict: Promote warning to an error</li>"
|
||||
"</ul>");
|
||||
|
||||
Setting *toolbar = createSetting (Type_CheckBox, "toolbar", "Show toolbar");
|
||||
toolbar->setDefaultValue ("true");
|
||||
|
||||
Setting *formatInt = createSetting (Type_LineEdit, "colour-int", "Highlight Colour: Int");
|
||||
formatInt->setDefaultValues (QStringList() << "Dark magenta");
|
||||
formatInt->setToolTip ("(Default: Green) Use one of the following formats:" + tooltip);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "../../model/world/idtree.hpp"
|
||||
#include "../../model/world/commands.hpp"
|
||||
#include "../../model/doc/document.hpp"
|
||||
#include "../../model/settings/usersettings.hpp"
|
||||
|
||||
#include "../widget/coloreditor.hpp"
|
||||
#include "../widget/droplineedit.hpp"
|
||||
|
@ -830,25 +831,15 @@ void CSVWorld::SimpleDialogueSubView::updateCurrentId()
|
|||
}
|
||||
|
||||
|
||||
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
||||
CSMDoc::Document& document, const CreatorFactoryBase& creatorFactory, bool sorting)
|
||||
: SimpleDialogueSubView (id, document)
|
||||
void CSVWorld::DialogueSubView::addButtonBar()
|
||||
{
|
||||
// bottom box
|
||||
mBottom = new TableBottomBox (creatorFactory, document, id, this);
|
||||
if (mButtons)
|
||||
return;
|
||||
|
||||
mBottom->setSizePolicy (QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||
|
||||
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
|
||||
this, SLOT (requestFocus (const std::string&)));
|
||||
|
||||
// button bar
|
||||
mButtons = new RecordButtonBar (id, getTable(), mBottom,
|
||||
mButtons = new RecordButtonBar (getUniversalId(), getTable(), mBottom,
|
||||
&getCommandDispatcher(), this);
|
||||
|
||||
// layout
|
||||
getMainLayout().addWidget (mButtons);
|
||||
getMainLayout().addWidget (mBottom);
|
||||
getMainLayout().insertWidget (1, mButtons);
|
||||
|
||||
// connections
|
||||
connect (mButtons, SIGNAL (showPreview()), this, SLOT (showPreview()));
|
||||
|
@ -859,15 +850,56 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
|||
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
||||
}
|
||||
|
||||
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
||||
CSMDoc::Document& document, const CreatorFactoryBase& creatorFactory, bool sorting)
|
||||
: SimpleDialogueSubView (id, document), mButtons (0)
|
||||
{
|
||||
// bottom box
|
||||
mBottom = new TableBottomBox (creatorFactory, document, id, this);
|
||||
|
||||
mBottom->setSizePolicy (QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||
|
||||
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
|
||||
this, SLOT (requestFocus (const std::string&)));
|
||||
|
||||
// button bar
|
||||
if (CSMSettings::UserSettings::instance().setting ("dialogues/toolbar", QString("true")) == "true")
|
||||
addButtonBar();
|
||||
|
||||
// layout
|
||||
getMainLayout().addWidget (mBottom);
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
||||
{
|
||||
SimpleDialogueSubView::setEditLock (locked);
|
||||
|
||||
if (mButtons)
|
||||
mButtons->setEditLock (locked);
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSubView::updateUserSetting (const QString& name, const QStringList& value)
|
||||
{
|
||||
SimpleDialogueSubView::updateUserSetting (name, value);
|
||||
|
||||
if (name=="dialogues/toolbar")
|
||||
{
|
||||
if (value.at(0)==QString ("true"))
|
||||
{
|
||||
addButtonBar();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mButtons)
|
||||
{
|
||||
getMainLayout().removeWidget (mButtons);
|
||||
delete mButtons;
|
||||
mButtons = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mButtons)
|
||||
mButtons->updateUserSetting (name, value);
|
||||
}
|
||||
|
||||
|
|
|
@ -260,6 +260,10 @@ namespace CSVWorld
|
|||
TableBottomBox* mBottom;
|
||||
RecordButtonBar *mButtons;
|
||||
|
||||
private:
|
||||
|
||||
void addButtonBar();
|
||||
|
||||
public:
|
||||
|
||||
DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
||||
|
|
|
@ -17,19 +17,32 @@
|
|||
#include "scriptedit.hpp"
|
||||
#include "recordbuttonbar.hpp"
|
||||
|
||||
void CSVWorld::ScriptSubView::addButtonBar()
|
||||
{
|
||||
if (mButtons)
|
||||
return;
|
||||
|
||||
mButtons = new RecordButtonBar (getUniversalId(), *mModel, 0, &mCommandDispatcher, this);
|
||||
|
||||
mLayout.insertWidget (1, mButtons);
|
||||
|
||||
connect (mButtons, SIGNAL (switchToRow (int)), this, SLOT (switchToRow (int)));
|
||||
|
||||
connect (this, SIGNAL (universalIdChanged (const CSMWorld::UniversalId&)),
|
||||
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
||||
}
|
||||
|
||||
CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||
: SubView (id), mDocument (document), mColumn (-1), mBottom(0), mStatus(0),
|
||||
: SubView (id), mDocument (document), mColumn (-1), mBottom(0), mStatus(0), mButtons (0),
|
||||
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType()))
|
||||
{
|
||||
std::vector<std::string> selection (1, id.getId());
|
||||
mCommandDispatcher.setSelection (selection);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
|
||||
layout->addWidget (mEditor = new ScriptEdit (mDocument, ScriptHighlighter::Mode_General, this), 2);
|
||||
mLayout.addWidget (mEditor = new ScriptEdit (mDocument, ScriptHighlighter::Mode_General, this), 2);
|
||||
|
||||
QWidget *widget = new QWidget (this);;
|
||||
widget->setLayout (layout);
|
||||
widget->setLayout (&mLayout);
|
||||
setWidget (widget);
|
||||
|
||||
mModel = &dynamic_cast<CSMWorld::IdTable&> (
|
||||
|
@ -49,9 +62,8 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
|||
mEditor->setPlainText (mModel->data (mModel->getModelIndex (id.getId(), mColumn)).toString());
|
||||
|
||||
// buttons
|
||||
mButtons = new RecordButtonBar (id, *mModel, 0, &mCommandDispatcher, this);
|
||||
|
||||
layout->addWidget (mButtons);
|
||||
if (CSMSettings::UserSettings::instance().setting ("script-editor/toolbar", QString("true")) == "true")
|
||||
addButtonBar();
|
||||
|
||||
// status bar
|
||||
QStatusBar *statusBar = new QStatusBar(mBottom);
|
||||
|
@ -64,7 +76,7 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
|||
bottmLayout->addWidget (statusBar);
|
||||
mBottom->setLayout (bottmLayout);
|
||||
|
||||
layout->addWidget (mBottom, 0);
|
||||
mLayout.addWidget (mBottom, 0);
|
||||
|
||||
// signals
|
||||
connect (mEditor, SIGNAL (textChanged()), this, SLOT (textChanged()));
|
||||
|
@ -75,11 +87,6 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
|||
connect (mModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
||||
this, SLOT (rowsAboutToBeRemoved (const QModelIndex&, int, int)));
|
||||
|
||||
connect (mButtons, SIGNAL (switchToRow (int)), this, SLOT (switchToRow (int)));
|
||||
|
||||
connect (this, SIGNAL (universalIdChanged (const CSMWorld::UniversalId&)),
|
||||
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
||||
|
||||
updateStatusBar();
|
||||
connect(mEditor, SIGNAL(cursorPositionChanged()), this, SLOT(updateStatusBar()));
|
||||
}
|
||||
|
@ -88,15 +95,32 @@ void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStr
|
|||
{
|
||||
if (name == "script-editor/show-linenum")
|
||||
{
|
||||
std::string showLinenum = value.at(0).toStdString();
|
||||
std::string showLinenum = value.at(0).toUtf8().constData();
|
||||
mEditor->showLineNum(showLinenum == "true");
|
||||
mBottom->setVisible(showLinenum == "true");
|
||||
}
|
||||
else if (name == "script-editor/mono-font")
|
||||
{
|
||||
mEditor->setMonoFont(value.at(0).toStdString() == "true");
|
||||
mEditor->setMonoFont (value.at(0)==QString ("true"));
|
||||
}
|
||||
else if (name=="script-editor/toolbar")
|
||||
{
|
||||
if (value.at(0)==QString ("true"))
|
||||
{
|
||||
addButtonBar();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (mButtons)
|
||||
{
|
||||
mLayout.removeWidget (mButtons);
|
||||
delete mButtons;
|
||||
mButtons = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mButtons)
|
||||
mButtons->updateUserSetting (name, value);
|
||||
}
|
||||
|
||||
|
@ -113,7 +137,10 @@ void CSVWorld::ScriptSubView::updateStatusBar ()
|
|||
void CSVWorld::ScriptSubView::setEditLock (bool locked)
|
||||
{
|
||||
mEditor->setReadOnly (locked);
|
||||
|
||||
if (mButtons)
|
||||
mButtons->setEditLock (locked);
|
||||
|
||||
mCommandDispatcher.setEditLock (locked);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
#ifndef CSV_WORLD_SCRIPTSUBVIEW_H
|
||||
#define CSV_WORLD_SCRIPTSUBVIEW_H
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "../../model/world/commanddispatcher.hpp"
|
||||
|
||||
#include "../doc/subview.hpp"
|
||||
|
||||
class QModelIndex;
|
||||
class QLabel;
|
||||
class QVBoxLayout;
|
||||
|
||||
namespace CSMDoc
|
||||
{
|
||||
|
@ -35,6 +38,11 @@ namespace CSVWorld
|
|||
QLabel *mStatus;
|
||||
RecordButtonBar *mButtons;
|
||||
CSMWorld::CommandDispatcher mCommandDispatcher;
|
||||
QVBoxLayout mLayout;
|
||||
|
||||
private:
|
||||
|
||||
void addButtonBar();
|
||||
|
||||
public:
|
||||
|
||||
|
|
Loading…
Reference in a new issue