mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-05 00:08:00 +03:00
added user settings option to toggle toolbars in single-record subviews
Conflicts: apps/opencs/view/world/dialoguesubview.cpp
This commit is contained in:
parent
05ed8ada11
commit
ab0b5932f7
5 changed files with 119 additions and 39 deletions
|
@ -244,6 +244,12 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
jumpToAdded->setDeclaredValues (jumpValues);
|
jumpToAdded->setDeclaredValues (jumpValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declareSection ("dialogues", "ID Dialogues");
|
||||||
|
{
|
||||||
|
Setting *toolbar = createSetting (Type_CheckBox, "toolbar", "Show toolbar");
|
||||||
|
toolbar->setDefaultValue ("true");
|
||||||
|
}
|
||||||
|
|
||||||
declareSection ("report-input", "Reports");
|
declareSection ("report-input", "Reports");
|
||||||
{
|
{
|
||||||
QString none ("None");
|
QString none ("None");
|
||||||
|
@ -337,6 +343,9 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
"<li>Strict: Promote warning to an error</li>"
|
"<li>Strict: Promote warning to an error</li>"
|
||||||
"</ul>");
|
"</ul>");
|
||||||
|
|
||||||
|
Setting *toolbar = createSetting (Type_CheckBox, "toolbar", "Show toolbar");
|
||||||
|
toolbar->setDefaultValue ("true");
|
||||||
|
|
||||||
Setting *formatInt = createSetting (Type_LineEdit, "colour-int", "Highlight Colour: Int");
|
Setting *formatInt = createSetting (Type_LineEdit, "colour-int", "Highlight Colour: Int");
|
||||||
formatInt->setDefaultValues (QStringList() << "Dark magenta");
|
formatInt->setDefaultValues (QStringList() << "Dark magenta");
|
||||||
formatInt->setToolTip ("(Default: Green) Use one of the following formats:" + tooltip);
|
formatInt->setToolTip ("(Default: Green) Use one of the following formats:" + tooltip);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "../../model/world/idtree.hpp"
|
#include "../../model/world/idtree.hpp"
|
||||||
#include "../../model/world/commands.hpp"
|
#include "../../model/world/commands.hpp"
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
#include "../widget/coloreditor.hpp"
|
#include "../widget/coloreditor.hpp"
|
||||||
#include "../widget/droplineedit.hpp"
|
#include "../widget/droplineedit.hpp"
|
||||||
|
@ -863,25 +864,15 @@ void CSVWorld::SimpleDialogueSubView::refreshNpcDialogue (int type, const std::s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
void CSVWorld::DialogueSubView::addButtonBar()
|
||||||
CSMDoc::Document& document, const CreatorFactoryBase& creatorFactory, bool sorting)
|
|
||||||
: SimpleDialogueSubView (id, document)
|
|
||||||
{
|
{
|
||||||
// bottom box
|
if (mButtons)
|
||||||
mBottom = new TableBottomBox (creatorFactory, document, id, this);
|
return;
|
||||||
|
|
||||||
mBottom->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
mButtons = new RecordButtonBar (getUniversalId(), getTable(), mBottom,
|
||||||
|
|
||||||
connect (mBottom, SIGNAL (requestFocus (const std::string&)),
|
|
||||||
this, SLOT (requestFocus (const std::string&)));
|
|
||||||
|
|
||||||
// button bar
|
|
||||||
mButtons = new RecordButtonBar (id, getTable(), mBottom,
|
|
||||||
&getCommandDispatcher(), this);
|
&getCommandDispatcher(), this);
|
||||||
|
|
||||||
// layout
|
getMainLayout().insertWidget (1, mButtons);
|
||||||
getMainLayout().addWidget (mButtons);
|
|
||||||
getMainLayout().addWidget (mBottom);
|
|
||||||
|
|
||||||
// connections
|
// connections
|
||||||
connect (mButtons, SIGNAL (showPreview()), this, SLOT (showPreview()));
|
connect (mButtons, SIGNAL (showPreview()), this, SLOT (showPreview()));
|
||||||
|
@ -892,15 +883,56 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
||||||
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
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)
|
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
||||||
{
|
{
|
||||||
SimpleDialogueSubView::setEditLock (locked);
|
SimpleDialogueSubView::setEditLock (locked);
|
||||||
|
|
||||||
|
if (mButtons)
|
||||||
mButtons->setEditLock (locked);
|
mButtons->setEditLock (locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::DialogueSubView::updateUserSetting (const QString& name, const QStringList& value)
|
void CSVWorld::DialogueSubView::updateUserSetting (const QString& name, const QStringList& value)
|
||||||
{
|
{
|
||||||
SimpleDialogueSubView::updateUserSetting (name, 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);
|
mButtons->updateUserSetting (name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,8 +195,8 @@ namespace CSVWorld
|
||||||
CSMDoc::Document& mDocument;
|
CSMDoc::Document& mDocument;
|
||||||
std::vector<CSMWorld::NestedTableProxyModel*> mNestedModels; //Plain, raw C pointers, deleted in the dtor
|
std::vector<CSMWorld::NestedTableProxyModel*> mNestedModels; //Plain, raw C pointers, deleted in the dtor
|
||||||
|
|
||||||
void createEditorContextMenu(QWidget *editor,
|
void createEditorContextMenu(QWidget *editor,
|
||||||
CSMWorld::ColumnBase::Display display,
|
CSMWorld::ColumnBase::Display display,
|
||||||
int currentRow) const;
|
int currentRow) const;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ namespace CSVWorld
|
||||||
void updateCurrentId();
|
void updateCurrentId();
|
||||||
|
|
||||||
bool isLocked() const;
|
bool isLocked() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SimpleDialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
SimpleDialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document);
|
||||||
|
@ -258,10 +258,14 @@ namespace CSVWorld
|
||||||
class DialogueSubView : public SimpleDialogueSubView
|
class DialogueSubView : public SimpleDialogueSubView
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
TableBottomBox* mBottom;
|
TableBottomBox* mBottom;
|
||||||
RecordButtonBar *mButtons;
|
RecordButtonBar *mButtons;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void addButtonBar();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
||||||
|
@ -270,14 +274,14 @@ namespace CSVWorld
|
||||||
virtual void setEditLock (bool locked);
|
virtual void setEditLock (bool locked);
|
||||||
|
|
||||||
virtual void updateUserSetting (const QString& name, const QStringList& value);
|
virtual void updateUserSetting (const QString& name, const QStringList& value);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void showPreview();
|
void showPreview();
|
||||||
|
|
||||||
void viewRecord();
|
void viewRecord();
|
||||||
|
|
||||||
void switchToRow (int row);
|
void switchToRow (int row);
|
||||||
|
|
||||||
void requestFocus (const std::string& id);
|
void requestFocus (const std::string& id);
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,19 +17,32 @@
|
||||||
#include "scriptedit.hpp"
|
#include "scriptedit.hpp"
|
||||||
#include "recordbuttonbar.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)
|
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()))
|
mCommandDispatcher (document, CSMWorld::UniversalId::getParentType (id.getType()))
|
||||||
{
|
{
|
||||||
std::vector<std::string> selection (1, id.getId());
|
std::vector<std::string> selection (1, id.getId());
|
||||||
mCommandDispatcher.setSelection (selection);
|
mCommandDispatcher.setSelection (selection);
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
mLayout.addWidget (mEditor = new ScriptEdit (mDocument, ScriptHighlighter::Mode_General, this), 2);
|
||||||
|
|
||||||
layout->addWidget (mEditor = new ScriptEdit (mDocument, ScriptHighlighter::Mode_General, this), 2);
|
|
||||||
|
|
||||||
QWidget *widget = new QWidget (this);;
|
QWidget *widget = new QWidget (this);;
|
||||||
widget->setLayout (layout);
|
widget->setLayout (&mLayout);
|
||||||
setWidget (widget);
|
setWidget (widget);
|
||||||
|
|
||||||
mModel = &dynamic_cast<CSMWorld::IdTable&> (
|
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());
|
mEditor->setPlainText (mModel->data (mModel->getModelIndex (id.getId(), mColumn)).toString());
|
||||||
|
|
||||||
// buttons
|
// buttons
|
||||||
mButtons = new RecordButtonBar (id, *mModel, 0, &mCommandDispatcher, this);
|
if (CSMSettings::UserSettings::instance().setting ("script-editor/toolbar", QString("true")) == "true")
|
||||||
|
addButtonBar();
|
||||||
layout->addWidget (mButtons);
|
|
||||||
|
|
||||||
// status bar
|
// status bar
|
||||||
QStatusBar *statusBar = new QStatusBar(mBottom);
|
QStatusBar *statusBar = new QStatusBar(mBottom);
|
||||||
|
@ -64,7 +76,7 @@ CSVWorld::ScriptSubView::ScriptSubView (const CSMWorld::UniversalId& id, CSMDoc:
|
||||||
bottmLayout->addWidget (statusBar);
|
bottmLayout->addWidget (statusBar);
|
||||||
mBottom->setLayout (bottmLayout);
|
mBottom->setLayout (bottmLayout);
|
||||||
|
|
||||||
layout->addWidget (mBottom, 0);
|
mLayout.addWidget (mBottom, 0);
|
||||||
|
|
||||||
// signals
|
// signals
|
||||||
connect (mEditor, SIGNAL (textChanged()), this, SLOT (textChanged()));
|
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)),
|
connect (mModel, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
||||||
this, SLOT (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();
|
updateStatusBar();
|
||||||
connect(mEditor, SIGNAL(cursorPositionChanged()), this, SLOT(updateStatusBar()));
|
connect(mEditor, SIGNAL(cursorPositionChanged()), this, SLOT(updateStatusBar()));
|
||||||
}
|
}
|
||||||
|
@ -88,16 +95,33 @@ void CSVWorld::ScriptSubView::updateUserSetting (const QString& name, const QStr
|
||||||
{
|
{
|
||||||
if (name == "script-editor/show-linenum")
|
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");
|
mEditor->showLineNum(showLinenum == "true");
|
||||||
mBottom->setVisible(showLinenum == "true");
|
mBottom->setVisible(showLinenum == "true");
|
||||||
}
|
}
|
||||||
else if (name == "script-editor/mono-font")
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mButtons->updateUserSetting (name, value);
|
if (mButtons)
|
||||||
|
mButtons->updateUserSetting (name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::ScriptSubView::updateStatusBar ()
|
void CSVWorld::ScriptSubView::updateStatusBar ()
|
||||||
|
@ -113,7 +137,10 @@ void CSVWorld::ScriptSubView::updateStatusBar ()
|
||||||
void CSVWorld::ScriptSubView::setEditLock (bool locked)
|
void CSVWorld::ScriptSubView::setEditLock (bool locked)
|
||||||
{
|
{
|
||||||
mEditor->setReadOnly (locked);
|
mEditor->setReadOnly (locked);
|
||||||
mButtons->setEditLock (locked);
|
|
||||||
|
if (mButtons)
|
||||||
|
mButtons->setEditLock (locked);
|
||||||
|
|
||||||
mCommandDispatcher.setEditLock (locked);
|
mCommandDispatcher.setEditLock (locked);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
#ifndef CSV_WORLD_SCRIPTSUBVIEW_H
|
#ifndef CSV_WORLD_SCRIPTSUBVIEW_H
|
||||||
#define CSV_WORLD_SCRIPTSUBVIEW_H
|
#define CSV_WORLD_SCRIPTSUBVIEW_H
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include "../../model/world/commanddispatcher.hpp"
|
#include "../../model/world/commanddispatcher.hpp"
|
||||||
|
|
||||||
#include "../doc/subview.hpp"
|
#include "../doc/subview.hpp"
|
||||||
|
|
||||||
class QModelIndex;
|
class QModelIndex;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class QVBoxLayout;
|
||||||
|
|
||||||
namespace CSMDoc
|
namespace CSMDoc
|
||||||
{
|
{
|
||||||
|
@ -35,6 +38,11 @@ namespace CSVWorld
|
||||||
QLabel *mStatus;
|
QLabel *mStatus;
|
||||||
RecordButtonBar *mButtons;
|
RecordButtonBar *mButtons;
|
||||||
CSMWorld::CommandDispatcher mCommandDispatcher;
|
CSMWorld::CommandDispatcher mCommandDispatcher;
|
||||||
|
QVBoxLayout mLayout;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void addButtonBar();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue