Merge pull request #1216 from manongjohn/scene_edit_history_preference
Control file history information
This commit is contained in:
commit
205f942226
11 changed files with 103 additions and 23 deletions
|
@ -26,8 +26,12 @@ using namespace std;
|
|||
|
||||
//-------------------------------------------------------
|
||||
|
||||
TContentHistory::TContentHistory(bool isLevel)
|
||||
: m_isLevel(isLevel), m_frozenHistory() {}
|
||||
TContentHistory::TContentHistory(bool isLevel, QString altUsername,
|
||||
bool recordEdit)
|
||||
: m_isLevel(isLevel)
|
||||
, m_frozenHistory()
|
||||
, m_altUsername(altUsername)
|
||||
, m_recordEdit(recordEdit) {}
|
||||
|
||||
//-------------------------------------------------------
|
||||
|
||||
|
@ -36,7 +40,8 @@ TContentHistory::~TContentHistory() {}
|
|||
//-------------------------------------------------------
|
||||
|
||||
TContentHistory *TContentHistory::clone() const {
|
||||
TContentHistory *history = new TContentHistory(m_isLevel);
|
||||
TContentHistory *history =
|
||||
new TContentHistory(m_isLevel, m_altUsername, m_recordEdit);
|
||||
history->deserialize(serialize());
|
||||
return history;
|
||||
}
|
||||
|
@ -84,7 +89,7 @@ inline QString getStr(const TFrameId &id) {
|
|||
const QString Fmt = "dd MMM yy hh:mm";
|
||||
|
||||
static QString getLine(int counter, const QDateTime &date,
|
||||
const set<TFrameId> &frames) {
|
||||
const set<TFrameId> &frames, QString altUsername) {
|
||||
static QString user;
|
||||
static QString machine;
|
||||
if (user == "") {
|
||||
|
@ -97,6 +102,8 @@ static QString getLine(int counter, const QDateTime &date,
|
|||
else if (value.startsWith("COMPUTERNAME="))
|
||||
machine = blanks(value.right(value.size() - 13));
|
||||
}
|
||||
|
||||
if (!altUsername.isEmpty()) user = blanks(altUsername);
|
||||
}
|
||||
|
||||
if (frames.empty())
|
||||
|
@ -149,7 +156,9 @@ const QString TContentHistory::currentToString() const {
|
|||
|
||||
if (!m_isLevel) {
|
||||
assert(m_records.size() == 1);
|
||||
return getLine(++counter, m_records.begin()->second, set<TFrameId>());
|
||||
if (!m_recordEdit) return "";
|
||||
return getLine(++counter, m_records.begin()->second, set<TFrameId>(),
|
||||
m_altUsername);
|
||||
}
|
||||
|
||||
QString out;
|
||||
|
@ -168,7 +177,8 @@ const QString TContentHistory::currentToString() const {
|
|||
++it1;
|
||||
}
|
||||
assert(!frames.empty());
|
||||
out += getLine(++counter, currDate, frames);
|
||||
if (m_recordEdit)
|
||||
out += getLine(++counter, currDate, frames, m_altUsername);
|
||||
if (it1 != dateSorted.end()) currDate = it1->first;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
//#include <fstream.h>
|
||||
#include "../compatibility/tfile_io.h"
|
||||
#include "tenv.h"
|
||||
#include "toonz/preferences.h"
|
||||
|
||||
/*=====================================================================*/
|
||||
|
||||
|
@ -700,7 +701,11 @@ void ParsedPliImp::loadInfo(bool readPlt, TPalette *&palette,
|
|||
m_iChan.seekg(pos, ios::beg);
|
||||
TagElem *tagElem = readTag();
|
||||
TextTag *textTag = (TextTag *)tagElem->m_tag;
|
||||
history = new TContentHistory(true);
|
||||
QString altUsername =
|
||||
Preferences::instance()->getStringValue(recordAsUsername);
|
||||
bool recordEdit =
|
||||
Preferences::instance()->getBoolValue(recordFileHistory);
|
||||
history = new TContentHistory(true, altUsername, recordEdit);
|
||||
history->deserialize(QString::fromStdString(textTag->m_text));
|
||||
delete tagElem;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "tenv.h"
|
||||
#include "tconvert.h"
|
||||
#include "trasterimage.h"
|
||||
#include "toonz/preferences.h"
|
||||
|
||||
#include <QByteArray>
|
||||
|
||||
|
@ -1501,7 +1502,13 @@ TLevelReaderTzl::TLevelReaderTzl(const TFilePath &path)
|
|||
fread(&historyData[0], 1, lSize, historyChan);
|
||||
fclose(historyChan);
|
||||
|
||||
if (!m_contentHistory) m_contentHistory = new TContentHistory(true);
|
||||
if (!m_contentHistory) {
|
||||
QString altUsername =
|
||||
Preferences::instance()->getStringValue(recordAsUsername);
|
||||
bool recordEdit =
|
||||
Preferences::instance()->getBoolValue(recordFileHistory);
|
||||
m_contentHistory = new TContentHistory(true, altUsername, recordEdit);
|
||||
}
|
||||
m_contentHistory->deserialize(QString::fromStdString(historyData));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,12 +29,14 @@ class DVAPI TContentHistory {
|
|||
bool m_isLevel;
|
||||
std::map<TFrameId, QDateTime> m_records;
|
||||
QString m_frozenHistory;
|
||||
QString m_altUsername;
|
||||
bool m_recordEdit;
|
||||
|
||||
const QString currentToString() const;
|
||||
|
||||
public:
|
||||
//! set isLevel=true if you want to keep track of single-frames modifications
|
||||
TContentHistory(bool isLevel);
|
||||
TContentHistory(bool isLevel, QString altUsername, bool recordEdit);
|
||||
|
||||
~TContentHistory();
|
||||
|
||||
|
|
|
@ -73,6 +73,8 @@ enum PreferencesItemId {
|
|||
rasterBackgroundColor,
|
||||
resetUndoOnSavingLevel,
|
||||
defaultProjectPath,
|
||||
recordFileHistory,
|
||||
recordAsUsername,
|
||||
|
||||
//----------
|
||||
// Import / Export
|
||||
|
|
|
@ -651,6 +651,17 @@ void PreferencesPopup::onColorCalibrationChanged() {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PreferencesPopup::onRecordAsUserChanged() {
|
||||
QString username = m_pref->getStringValue(recordAsUsername);
|
||||
if (username.isEmpty()) {
|
||||
username = TSystem::getUserName();
|
||||
m_pref->setValue(recordAsUsername, QVariant::fromValue(username));
|
||||
getUI<LineEdit*>(recordAsUsername)->setText(username);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PreferencesPopup::onDefLevelTypeChanged() {
|
||||
bool isRaster = m_pref->getIntValue(DefLevelType) != PLI_XSHLEVEL &&
|
||||
!m_pref->getBoolValue(newLevelSizeToCameraSizeEnabled);
|
||||
|
@ -971,7 +982,8 @@ void PreferencesPopup::onImportPolicyExternallyChanged(int policy) {
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
QWidget* PreferencesPopup::createUI(PreferencesItemId id,
|
||||
const QList<ComboBoxItem>& comboItems) {
|
||||
const QList<ComboBoxItem>& comboItems,
|
||||
bool isLineEdit) {
|
||||
PreferencesItem item = m_pref->getItem(id);
|
||||
// create widget depends on the parameter types
|
||||
QWidget* widget = nullptr;
|
||||
|
@ -1039,6 +1051,12 @@ QWidget* PreferencesPopup::createUI(PreferencesItemId id,
|
|||
ret = connect(combo, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(onChange()));
|
||||
widget = combo;
|
||||
} else if (isLineEdit) { // create LineEdit
|
||||
DVGui::LineEdit* lineEdit =
|
||||
new DVGui::LineEdit(item.value.toString(), this);
|
||||
ret =
|
||||
connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(onChange()));
|
||||
widget = lineEdit;
|
||||
} else { // create FileField
|
||||
DVGui::FileField* field =
|
||||
new DVGui::FileField(this, item.value.toString());
|
||||
|
@ -1115,16 +1133,18 @@ QGridLayout* PreferencesPopup::insertGroupBoxUI(PreferencesItemId id,
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
void PreferencesPopup::insertUI(PreferencesItemId id, QGridLayout* layout,
|
||||
const QList<ComboBoxItem>& comboItems) {
|
||||
const QList<ComboBoxItem>& comboItems,
|
||||
bool isLineEdit) {
|
||||
PreferencesItem item = m_pref->getItem(id);
|
||||
|
||||
QWidget* widget = createUI(id, comboItems);
|
||||
QWidget* widget = createUI(id, comboItems, isLineEdit);
|
||||
if (!widget) return;
|
||||
|
||||
bool isFileField = false;
|
||||
bool isEditBox = false;
|
||||
if (item.type == QMetaType::QVariantMap ||
|
||||
(item.type == QMetaType::QString && dynamic_cast<FileField*>(widget)))
|
||||
isFileField = true;
|
||||
(item.type == QMetaType::QString &&
|
||||
(dynamic_cast<FileField*>(widget) || dynamic_cast<LineEdit*>(widget))))
|
||||
isEditBox = true;
|
||||
|
||||
// CheckBox contains label in itself
|
||||
if (item.type == QMetaType::Bool)
|
||||
|
@ -1133,8 +1153,8 @@ void PreferencesPopup::insertUI(PreferencesItemId id, QGridLayout* layout,
|
|||
int row = layout->rowCount();
|
||||
layout->addWidget(new QLabel(getUIString(id), this), row, 0,
|
||||
Qt::AlignRight | Qt::AlignVCenter);
|
||||
if (isFileField)
|
||||
layout->addWidget(widget, row, 1, 1, 2);
|
||||
if (isEditBox)
|
||||
layout->addWidget(widget, row, 1, 1, (isLineEdit ? 1 : 2));
|
||||
else {
|
||||
bool isWideComboBox = false;
|
||||
for (auto cbItem : comboItems) {
|
||||
|
@ -1267,6 +1287,8 @@ QString PreferencesPopup::getUIString(PreferencesItemId id) {
|
|||
{resetUndoOnSavingLevel, tr("Clear Undo History when Saving Levels")},
|
||||
{doNotShowPopupSaveScene, tr("Do not show Save Scene popup warning")},
|
||||
{defaultProjectPath, tr("Default Project Path:")},
|
||||
{recordFileHistory, tr("Record File History* (tnz, pli, hst)")},
|
||||
{recordAsUsername, tr("History Username*:")},
|
||||
|
||||
// Import / Export
|
||||
{ffmpegPath, tr("Executable Directory:")},
|
||||
|
@ -1914,8 +1936,16 @@ QWidget* PreferencesPopup::createSavingPage() {
|
|||
|
||||
insertUI(fastRenderPath, lay);
|
||||
|
||||
QGridLayout* recordHistoryLay = insertGroupBoxUI(recordFileHistory, lay);
|
||||
{ insertUI(recordAsUsername, recordHistoryLay, QList<ComboBoxItem>(), true); }
|
||||
|
||||
lay->setRowStretch(lay->rowCount(), 1);
|
||||
insertFootNote(lay);
|
||||
widget->setLayout(lay);
|
||||
|
||||
m_onEditedFuncMap.insert(recordAsUsername,
|
||||
&PreferencesPopup::onRecordAsUserChanged);
|
||||
|
||||
return widget;
|
||||
}
|
||||
|
||||
|
@ -2391,6 +2421,8 @@ void PreferencesPopup::onChange() {
|
|||
m_pref->setValue(id, field->getValue());
|
||||
else if (QGroupBox* groupBox = dynamic_cast<QGroupBox*>(senderWidget))
|
||||
m_pref->setValue(id, groupBox->isChecked());
|
||||
else if (LineEdit* lineEdit = dynamic_cast<LineEdit*>(senderWidget))
|
||||
m_pref->setValue(id, lineEdit->text());
|
||||
else
|
||||
return;
|
||||
|
||||
|
|
|
@ -102,10 +102,12 @@ private:
|
|||
|
||||
QWidget* createUI(
|
||||
PreferencesItemId id,
|
||||
const QList<ComboBoxItem>& comboItems = QList<ComboBoxItem>());
|
||||
const QList<ComboBoxItem>& comboItems = QList<ComboBoxItem>(),
|
||||
bool isLineEdit = false);
|
||||
QGridLayout* insertGroupBoxUI(PreferencesItemId id, QGridLayout* layout);
|
||||
void insertUI(PreferencesItemId id, QGridLayout* layout,
|
||||
const QList<ComboBoxItem>& comboItems = QList<ComboBoxItem>());
|
||||
const QList<ComboBoxItem>& comboItems = QList<ComboBoxItem>(),
|
||||
bool isLineEdit = false);
|
||||
void insertDualUIs(
|
||||
PreferencesItemId leftId, PreferencesItemId rightId, QGridLayout* layout,
|
||||
const QList<ComboBoxItem>& leftComboItems = QList<ComboBoxItem>(),
|
||||
|
@ -149,6 +151,8 @@ private:
|
|||
void onUnitChanged();
|
||||
void beforeRoomChoiceChanged();
|
||||
void onColorCalibrationChanged();
|
||||
// Saving
|
||||
void onRecordAsUserChanged();
|
||||
// Drawing
|
||||
void onDefLevelTypeChanged();
|
||||
void onUseNumpadForSwitchingStylesClicked();
|
||||
|
|
|
@ -497,6 +497,11 @@ void Preferences::definePreferenceItems() {
|
|||
define(defaultProjectPath, "defaultProjectPath", QMetaType::QString,
|
||||
documentsPath);
|
||||
|
||||
define(recordFileHistory, "recordFileHistory", QMetaType::Bool, true);
|
||||
|
||||
QString userName = TSystem::getUserName();
|
||||
define(recordAsUsername, "recordAsUsername", QMetaType::QString, userName);
|
||||
|
||||
// Import / Export
|
||||
define(ffmpegPath, "ffmpegPath", QMetaType::QString, "");
|
||||
define(ffmpegTimeout, "ffmpegTimeout", QMetaType::Int, 0, 0,
|
||||
|
|
|
@ -1499,8 +1499,12 @@ TCamera *ToonzScene::getCurrentPreviewCamera() {
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
TContentHistory *ToonzScene::getContentHistory(bool createIfNeeded) {
|
||||
if (!m_contentHistory && createIfNeeded)
|
||||
m_contentHistory = new TContentHistory(false);
|
||||
if (!m_contentHistory && createIfNeeded) {
|
||||
QString altUsername =
|
||||
Preferences::instance()->getStringValue(recordAsUsername);
|
||||
bool recordEdit = Preferences::instance()->getBoolValue(recordFileHistory);
|
||||
m_contentHistory = new TContentHistory(false, altUsername, recordEdit);
|
||||
}
|
||||
return m_contentHistory;
|
||||
}
|
||||
|
||||
|
|
|
@ -331,7 +331,10 @@ void TXshSimpleLevel::touchFrame(const TFrameId &fid) {
|
|||
m_properties->setDirtyFlag(true);
|
||||
TContentHistory *ch = getContentHistory();
|
||||
if (!ch) {
|
||||
ch = new TContentHistory(true);
|
||||
QString altUsername =
|
||||
Preferences::instance()->getStringValue(recordAsUsername);
|
||||
bool recordEdit = Preferences::instance()->getBoolValue(recordFileHistory);
|
||||
ch = new TContentHistory(true, altUsername, recordEdit);
|
||||
setContentHistory(ch);
|
||||
}
|
||||
ch->frameModifiedNow(fid);
|
||||
|
|
|
@ -225,7 +225,7 @@ InfoViewerImp::InfoViewerImp()
|
|||
create(eSampleSize, QObject::tr("Sample Size: "));
|
||||
create(eSampleType, QObject::tr("Sample Type: "));
|
||||
|
||||
m_historyLabel.setStyleSheet("color: rgb(0, 0, 200);");
|
||||
setLabelStyle(&m_historyLabel);
|
||||
m_history.setStyleSheet("font-size: 12px; font-family: \"courier\";");
|
||||
// m_history.setStyleSheet("font-family: \"courier\";");
|
||||
m_history.setReadOnly(true);
|
||||
|
@ -344,6 +344,12 @@ void InfoViewerImp::setImageInfo() {
|
|||
} catch (...) {
|
||||
return;
|
||||
}
|
||||
if (lr && m_path.getType() == "pli") {
|
||||
try {
|
||||
lr->loadInfo();
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
if (!m_fids.empty() && lr && ii) {
|
||||
setVal(eImageSize,
|
||||
QString::number(ii->m_lx) + " X " + QString::number(ii->m_ly));
|
||||
|
|
Loading…
Reference in a new issue