mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
disable dialogue subview buttons while document is locked
This commit is contained in:
parent
6769479358
commit
d5e6d8a58b
@ -714,20 +714,26 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id,
|
||||
this, SLOT (requestFocus (const std::string&)));
|
||||
|
||||
// button bar
|
||||
RecordButtonBar *buttons = new RecordButtonBar (id, getTable(), mBottom,
|
||||
mButtons = new RecordButtonBar (id, getTable(), mBottom,
|
||||
&getCommandDispatcher(), this);
|
||||
|
||||
// layout
|
||||
getMainLayout().addWidget (buttons);
|
||||
getMainLayout().addWidget (mButtons);
|
||||
getMainLayout().addWidget (mBottom);
|
||||
|
||||
// connections
|
||||
connect (buttons, SIGNAL (nextId()), this, SLOT (nextId()));
|
||||
connect (buttons, SIGNAL (prevId()), this, SLOT (prevId()));
|
||||
connect (buttons, SIGNAL (showPreview()), this, SLOT (showPreview()));
|
||||
connect (buttons, SIGNAL (viewRecord()), this, SLOT (viewRecord()));
|
||||
connect (mButtons, SIGNAL (nextId()), this, SLOT (nextId()));
|
||||
connect (mButtons, SIGNAL (prevId()), this, SLOT (prevId()));
|
||||
connect (mButtons, SIGNAL (showPreview()), this, SLOT (showPreview()));
|
||||
connect (mButtons, SIGNAL (viewRecord()), this, SLOT (viewRecord()));
|
||||
connect (this, SIGNAL (universalIdChanged (const CSMWorld::UniversalId&)),
|
||||
buttons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
||||
mButtons, SLOT (universalIdChanged (const CSMWorld::UniversalId&)));
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSubView::setEditLock (bool locked)
|
||||
{
|
||||
SimpleDialogueSubView::setEditLock (locked);
|
||||
mButtons->setEditLock (locked);
|
||||
}
|
||||
|
||||
void CSVWorld::DialogueSubView::prevId()
|
||||
|
@ -218,17 +218,22 @@ namespace CSVWorld
|
||||
void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
|
||||
};
|
||||
|
||||
class RecordButtonBar;
|
||||
|
||||
class DialogueSubView : public SimpleDialogueSubView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
TableBottomBox* mBottom;
|
||||
RecordButtonBar *mButtons;
|
||||
|
||||
public:
|
||||
|
||||
DialogueSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document,
|
||||
const CreatorFactoryBase& creatorFactory, bool sorting = false);
|
||||
|
||||
virtual void setEditLock (bool locked);
|
||||
|
||||
private slots:
|
||||
|
||||
void nextId();
|
||||
|
@ -9,11 +9,25 @@
|
||||
|
||||
#include "../world/tablebottombox.hpp"
|
||||
|
||||
void CSVWorld::RecordButtonBar::updateModificationButtons()
|
||||
{
|
||||
bool createAndDeleteDisabled = !mBottom || !mBottom->canCreateAndDelete() || mLocked;
|
||||
|
||||
mCloneButton->setDisabled (createAndDeleteDisabled);
|
||||
mAddButton->setDisabled (createAndDeleteDisabled);
|
||||
mDeleteButton->setDisabled (createAndDeleteDisabled);
|
||||
|
||||
bool commandDisabled = !mCommandDispatcher || mLocked;
|
||||
|
||||
mRevertButton->setDisabled (commandDisabled);
|
||||
mDeleteButton->setDisabled (commandDisabled);
|
||||
}
|
||||
|
||||
CSVWorld::RecordButtonBar::RecordButtonBar (const CSMWorld::UniversalId& id,
|
||||
CSMWorld::IdTable& table, TableBottomBox *bottomBox,
|
||||
CSMWorld::CommandDispatcher *commandDispatcher, QWidget *parent)
|
||||
: QWidget (parent), mId (id), mTable (table), mBottom (bottomBox),
|
||||
mCommandDispatcher (commandDispatcher)
|
||||
mCommandDispatcher (commandDispatcher), mLocked (false)
|
||||
{
|
||||
QHBoxLayout *buttonsLayout = new QHBoxLayout;
|
||||
buttonsLayout->setContentsMargins (0, 0, 0, 0);
|
||||
@ -51,54 +65,51 @@ CSVWorld::RecordButtonBar::RecordButtonBar (const CSMWorld::UniversalId& id,
|
||||
}
|
||||
|
||||
// right section
|
||||
QToolButton* cloneButton = new QToolButton (this);
|
||||
cloneButton->setIcon(QIcon(":/edit-clone.png"));
|
||||
cloneButton->setToolTip ("Clone record");
|
||||
buttonsLayout->addWidget(cloneButton);
|
||||
mCloneButton = new QToolButton (this);
|
||||
mCloneButton->setIcon(QIcon(":/edit-clone.png"));
|
||||
mCloneButton->setToolTip ("Clone record");
|
||||
buttonsLayout->addWidget(mCloneButton);
|
||||
|
||||
QToolButton* addButton = new QToolButton (this);
|
||||
addButton->setIcon(QIcon(":/add.png"));
|
||||
addButton->setToolTip ("Add new record");
|
||||
buttonsLayout->addWidget(addButton);
|
||||
mAddButton = new QToolButton (this);
|
||||
mAddButton->setIcon(QIcon(":/add.png"));
|
||||
mAddButton->setToolTip ("Add new record");
|
||||
buttonsLayout->addWidget(mAddButton);
|
||||
|
||||
QToolButton* deleteButton = new QToolButton (this);
|
||||
deleteButton->setIcon(QIcon(":/edit-delete.png"));
|
||||
deleteButton->setToolTip ("Delete record");
|
||||
buttonsLayout->addWidget(deleteButton);
|
||||
mDeleteButton = new QToolButton (this);
|
||||
mDeleteButton->setIcon(QIcon(":/edit-delete.png"));
|
||||
mDeleteButton->setToolTip ("Delete record");
|
||||
buttonsLayout->addWidget(mDeleteButton);
|
||||
|
||||
QToolButton* revertButton = new QToolButton (this);
|
||||
revertButton->setIcon(QIcon(":/edit-undo.png"));
|
||||
revertButton->setToolTip ("Revert record");
|
||||
buttonsLayout->addWidget(revertButton);
|
||||
mRevertButton = new QToolButton (this);
|
||||
mRevertButton->setIcon(QIcon(":/edit-undo.png"));
|
||||
mRevertButton->setToolTip ("Revert record");
|
||||
buttonsLayout->addWidget(mRevertButton);
|
||||
|
||||
setLayout (buttonsLayout);
|
||||
|
||||
// disabling and connections
|
||||
if(!mBottom || !mBottom->canCreateAndDelete())
|
||||
// connections
|
||||
if(mBottom && mBottom->canCreateAndDelete())
|
||||
{
|
||||
cloneButton->setDisabled (true);
|
||||
addButton->setDisabled (true);
|
||||
deleteButton->setDisabled (true);
|
||||
}
|
||||
else
|
||||
{
|
||||
connect (addButton, SIGNAL (clicked()), mBottom, SLOT (createRequest()));
|
||||
connect (cloneButton, SIGNAL (clicked()), this, SLOT (cloneRequest()));
|
||||
connect (mAddButton, SIGNAL (clicked()), mBottom, SLOT (createRequest()));
|
||||
connect (mCloneButton, SIGNAL (clicked()), this, SLOT (cloneRequest()));
|
||||
}
|
||||
|
||||
connect (nextButton, SIGNAL (clicked()), this, SIGNAL (nextId()));
|
||||
connect (prevButton, SIGNAL (clicked()), this, SIGNAL (prevId()));
|
||||
|
||||
if (!mCommandDispatcher)
|
||||
if (mCommandDispatcher)
|
||||
{
|
||||
revertButton->setDisabled (true);
|
||||
deleteButton->setDisabled (true);
|
||||
}
|
||||
else
|
||||
{
|
||||
connect (revertButton, SIGNAL (clicked()), mCommandDispatcher, SLOT (executeRevert()));
|
||||
connect (deleteButton, SIGNAL (clicked()), mCommandDispatcher, SLOT (executeDelete()));
|
||||
connect (mRevertButton, SIGNAL (clicked()), mCommandDispatcher, SLOT (executeRevert()));
|
||||
connect (mDeleteButton, SIGNAL (clicked()), mCommandDispatcher, SLOT (executeDelete()));
|
||||
}
|
||||
|
||||
updateModificationButtons();
|
||||
}
|
||||
|
||||
void CSVWorld::RecordButtonBar::setEditLock (bool locked)
|
||||
{
|
||||
mLocked = locked;
|
||||
updateModificationButtons();
|
||||
}
|
||||
|
||||
void CSVWorld::RecordButtonBar::universalIdChanged (const CSMWorld::UniversalId& id)
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include "../../model/world/universalid.hpp"
|
||||
|
||||
class QToolButton;
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
class IdTable;
|
||||
@ -33,13 +35,24 @@ namespace CSVWorld
|
||||
CSMWorld::IdTable& mTable;
|
||||
TableBottomBox *mBottom;
|
||||
CSMWorld::CommandDispatcher *mCommandDispatcher;
|
||||
QToolButton *mCloneButton;
|
||||
QToolButton *mAddButton;
|
||||
QToolButton *mDeleteButton;
|
||||
QToolButton *mRevertButton;
|
||||
bool mLocked;
|
||||
|
||||
private:
|
||||
|
||||
void updateModificationButtons();
|
||||
|
||||
public:
|
||||
|
||||
RecordButtonBar (const CSMWorld::UniversalId& id,
|
||||
CSMWorld::IdTable& table, TableBottomBox *bottomBox = 0,
|
||||
CSMWorld::CommandDispatcher *commandDispatcher = 0, QWidget *parent = 0);
|
||||
|
||||
void setEditLock (bool locked);
|
||||
|
||||
public slots:
|
||||
|
||||
void universalIdChanged (const CSMWorld::UniversalId& id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user