From 7bfeb36ae8fd8d20c56c43f7c7fe0255e656ef6e Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Dec 24 2021 03:41:39 +0000 Subject: project settings-aware frame number field size --- diff --git a/toonz/sources/toonz/penciltestpopup.cpp b/toonz/sources/toonz/penciltestpopup.cpp index 4266468..0688e3e 100644 --- a/toonz/sources/toonz/penciltestpopup.cpp +++ b/toonz/sources/toonz/penciltestpopup.cpp @@ -44,6 +44,7 @@ #include "toonz/levelproperties.h" #include "toonz/tcamera.h" #include "toonz/preferences.h" +#include "toonz/filepathproperties.h" // TnzCore includes #include "tsystem.h" @@ -688,7 +689,6 @@ void MyVideoWidget::mouseReleaseEvent(QMouseEvent* event) { FrameNumberLineEdit::FrameNumberLineEdit(QWidget* parent, TFrameId fId, bool acceptLetter) : LineEdit(parent) { - setFixedWidth(60); if (acceptLetter) { QString regExpStr = QString("^%1$").arg(TFilePath::fidRegExpStr()); m_regexpValidator = new QRegExpValidator(QRegExp(regExpStr), this); @@ -701,6 +701,7 @@ FrameNumberLineEdit::FrameNumberLineEdit(QWidget* parent, TFrameId fId, new QRegExpValidator(QRegExp("^\\d{1,3}[A-Ia-i]?$"), this); updateValidator(); + updateSize(); setValue(fId); } @@ -716,6 +717,22 @@ void FrameNumberLineEdit::updateValidator() { //----------------------------------------------------------------------------- +void FrameNumberLineEdit::updateSize() { + FilePathProperties* fpProp = + TProjectManager::instance()->getCurrentProject()->getFilePathProperties(); + bool useStandard = fpProp->useStandard(); + int letterCount = fpProp->letterCountForSuffix(); + if (useStandard) + setFixedWidth(60); + else { + // 4 digits + letters reserve 12 px each + int lc = (letterCount == 0) ? 9 : letterCount + 4; + setFixedWidth(12 * lc); + } + updateGeometry(); +} +//----------------------------------------------------------------------------- + void FrameNumberLineEdit::setValue(TFrameId fId) { QString str; if (Preferences::instance()->isShowFrameNumberWithLettersEnabled()) { @@ -764,6 +781,7 @@ void FrameNumberLineEdit::onProjectSwitched() { m_regexpValidator = new QRegExpValidator(QRegExp(regExpStr), this); updateValidator(); if (oldValidator) delete oldValidator; + updateSize(); } void FrameNumberLineEdit::onProjectChanged() { onProjectSwitched(); } diff --git a/toonz/sources/toonz/penciltestpopup.h b/toonz/sources/toonz/penciltestpopup.h index b6569fe..feb81ee 100644 --- a/toonz/sources/toonz/penciltestpopup.h +++ b/toonz/sources/toonz/penciltestpopup.h @@ -126,6 +126,7 @@ class FrameNumberLineEdit : public DVGui::LineEdit, QRegExpValidator *m_regexpValidator, *m_regexpValidator_alt; void updateValidator(); + void updateSize(); QString m_textOnFocusIn; public: diff --git a/toonz/sources/toonz/penciltestpopup_qt.cpp b/toonz/sources/toonz/penciltestpopup_qt.cpp index a0333c3..58aa19b 100644 --- a/toonz/sources/toonz/penciltestpopup_qt.cpp +++ b/toonz/sources/toonz/penciltestpopup_qt.cpp @@ -32,6 +32,7 @@ #include "toonz/levelproperties.h" #include "toonz/tcamera.h" #include "toonz/preferences.h" +#include "toonz/filepathproperties.h" // TnzCore includes #include "tsystem.h" @@ -886,7 +887,6 @@ void MyVideoWidget::mouseReleaseEvent(QMouseEvent* event) { FrameNumberLineEdit::FrameNumberLineEdit(QWidget* parent, TFrameId fId, bool acceptLetter) : LineEdit(parent) { - setFixedWidth(60); if (acceptLetter) { QString regExpStr = QString("^%1$").arg(TFilePath::fidRegExpStr()); m_regexpValidator = new QRegExpValidator(QRegExp(regExpStr), this); @@ -899,6 +899,7 @@ FrameNumberLineEdit::FrameNumberLineEdit(QWidget* parent, TFrameId fId, new QRegExpValidator(QRegExp("^\\d{1,3}[A-Ia-i]?$"), this); updateValidator(); + updateSize(); setValue(fId); } @@ -914,6 +915,23 @@ void FrameNumberLineEdit::updateValidator() { //----------------------------------------------------------------------------- +void FrameNumberLineEdit::updateSize() { + FilePathProperties* fpProp = + TProjectManager::instance()->getCurrentProject()->getFilePathProperties(); + bool useStandard = fpProp->useStandard(); + int letterCount = fpProp->letterCountForSuffix(); + if (useStandard) + setFixedWidth(60); + else { + // 4 digits + letters reserve 12 px each + int lc = (letterCount == 0) ? 9 : letterCount + 4; + setFixedWidth(12 * lc); + } + updateGeometry(); +} + +//----------------------------------------------------------------------------- + void FrameNumberLineEdit::setValue(TFrameId fId) { QString str; if (Preferences::instance()->isShowFrameNumberWithLettersEnabled()) { diff --git a/toonz/sources/toonz/penciltestpopup_qt.h b/toonz/sources/toonz/penciltestpopup_qt.h index a0a4bdd..30d0300 100644 --- a/toonz/sources/toonz/penciltestpopup_qt.h +++ b/toonz/sources/toonz/penciltestpopup_qt.h @@ -192,6 +192,7 @@ class FrameNumberLineEdit : public DVGui::LineEdit, QRegExpValidator *m_regexpValidator, *m_regexpValidator_alt; void updateValidator(); + void updateSize(); QString m_textOnFocusIn; public: