fix_camera_capture

This commit is contained in:
shun_iwasawa 2017-07-03 15:46:30 +09:00
parent fb6a407b78
commit 1351732653
6 changed files with 68 additions and 15 deletions

View file

@ -69,7 +69,8 @@ public:
virtual ~BrowserPopupController() {} virtual ~BrowserPopupController() {}
virtual bool isExecute() { return true; }; virtual bool isExecute() { return true; };
virtual QString getPath() { return QString(); }; virtual QString getPath() { return QString(); };
virtual void openPopup(QStringList, bool, QString){}; virtual void openPopup(QStringList, bool, QString,
const QWidget * = NULL){};
}; };
static BrowserPopupController *m_browserPopupController; static BrowserPopupController *m_browserPopupController;

View file

@ -2072,7 +2072,8 @@ BrowserPopupController::BrowserPopupController() : m_browserPopup() {
void BrowserPopupController::openPopup(QStringList filters, void BrowserPopupController::openPopup(QStringList filters,
bool isDirectoryOnly, bool isDirectoryOnly,
QString lastSelectedPath) { QString lastSelectedPath,
const QWidget *parentWidget) {
if (!m_browserPopup) m_browserPopup = new BrowserPopup(); if (!m_browserPopup) m_browserPopup = new BrowserPopup();
m_browserPopup->setWindowTitle(QString("")); m_browserPopup->setWindowTitle(QString(""));
@ -2084,6 +2085,19 @@ void BrowserPopupController::openPopup(QStringList filters,
m_browserPopup->initFolder(TFilePath(lastSelectedPath.toStdWString())); m_browserPopup->initFolder(TFilePath(lastSelectedPath.toStdWString()));
m_browserPopup->setFileMode(isDirectoryOnly); m_browserPopup->setFileMode(isDirectoryOnly);
if (parentWidget) {
QWidget *pwidget = NULL;
foreach (pwidget, QApplication::topLevelWidgets()) {
if (pwidget->isWindow() && pwidget->isVisible() &&
pwidget->isAncestorOf(parentWidget)) {
Qt::WindowFlags flags = m_browserPopup->windowFlags();
m_browserPopup->setParent(pwidget);
m_browserPopup->setWindowFlags(flags);
break;
}
}
}
if (isDirectoryOnly) if (isDirectoryOnly)
m_browserPopup->setFilename(TFilePath(lastSelectedPath.toStdWString())); m_browserPopup->setFilename(TFilePath(lastSelectedPath.toStdWString()));

View file

@ -433,8 +433,11 @@ public:
BrowserPopupController(); BrowserPopupController();
bool isExecute() override { return m_isExecute; } bool isExecute() override { return m_isExecute; }
// if parentWidget is non-zero, then check if the any modal dialog is ancestor
// of it.
void openPopup(QStringList filters, bool isDirectoryOnly, void openPopup(QStringList filters, bool isDirectoryOnly,
QString lastSelectedPath) override; QString lastSelectedPath,
const QWidget *parentWidget = NULL) override;
QString getPath() override; QString getPath() override;
}; };

View file

@ -81,6 +81,7 @@ TEnv::StringVar CamCapCameraResolution("CamCapCameraResolution", "");
// Whether to open save-in popup on launch // Whether to open save-in popup on launch
TEnv::IntVar CamCapOpenSaveInPopupOnLaunch("CamCapOpenSaveInPopupOnLaunch", 0); TEnv::IntVar CamCapOpenSaveInPopupOnLaunch("CamCapOpenSaveInPopupOnLaunch", 0);
// SaveInFolderPopup settings // SaveInFolderPopup settings
TEnv::StringVar CamCapSaveInParentFolder("CamCapSaveInParentFolder", "");
TEnv::IntVar CamCapSaveInPopupSubFolder("CamCapSaveInPopupSubFolder", 0); TEnv::IntVar CamCapSaveInPopupSubFolder("CamCapSaveInPopupSubFolder", 0);
TEnv::StringVar CamCapSaveInPopupProject("CamCapSaveInPopupProject", ""); TEnv::StringVar CamCapSaveInPopupProject("CamCapSaveInPopupProject", "");
TEnv::StringVar CamCapSaveInPopupEpisode("CamCapSaveInPopupEpisode", "1"); TEnv::StringVar CamCapSaveInPopupEpisode("CamCapSaveInPopupEpisode", "1");
@ -584,8 +585,14 @@ PencilTestSaveInFolderPopup::PencilTestSaveInFolderPopup(QWidget* parent)
: Dialog(parent, true, false, "PencilTestSaveInFolder") { : Dialog(parent, true, false, "PencilTestSaveInFolder") {
setWindowTitle("Create the Destination Subfolder to Save"); setWindowTitle("Create the Destination Subfolder to Save");
m_parentFolderField = new FileField( QString parentFolder = QString::fromStdString(CamCapSaveInParentFolder);
this, QString("+%1").arg(QString::fromStdString(TProject::Extras))); if (parentFolder.isEmpty())
parentFolder = QString("+%1").arg(QString::fromStdString(TProject::Extras));
m_parentFolderField = new FileField(this, parentFolder);
QPushButton* setAsDefaultBtn = new QPushButton(tr("Set As Default"), this);
setAsDefaultBtn->setToolTip(
tr("Set the current \"Save In\" path as the default."));
m_subFolderCB = new QCheckBox(tr("Create Subfolder"), this); m_subFolderCB = new QCheckBox(tr("Create Subfolder"), this);
@ -638,6 +645,7 @@ PencilTestSaveInFolderPopup::PencilTestSaveInFolderPopup(QWidget* parent)
<< tr("Episode + Sequence + Scene") << tr("Episode + Sequence + Scene")
<< tr("Project + Episode + Sequence + Scene"); << tr("Project + Episode + Sequence + Scene");
m_subNameFormatCombo->addItems(items); m_subNameFormatCombo->addItems(items);
m_subNameFormatCombo->setCurrentIndex(CamCapSaveInPopupAutoSubName - 1);
showPopupOnLaunchCB->setChecked(CamCapOpenSaveInPopupOnLaunch != 0); showPopupOnLaunchCB->setChecked(CamCapOpenSaveInPopupOnLaunch != 0);
@ -647,13 +655,18 @@ PencilTestSaveInFolderPopup::PencilTestSaveInFolderPopup(QWidget* parent)
m_topLayout->setMargin(10); m_topLayout->setMargin(10);
m_topLayout->setSpacing(10); m_topLayout->setSpacing(10);
{ {
QHBoxLayout* saveInLay = new QHBoxLayout(); QGridLayout* saveInLay = new QGridLayout();
saveInLay->setMargin(0); saveInLay->setMargin(0);
saveInLay->setSpacing(3); saveInLay->setHorizontalSpacing(3);
saveInLay->setVerticalSpacing(0);
{ {
saveInLay->addWidget(new QLabel(tr("Save In:"), this), 0); saveInLay->addWidget(new QLabel(tr("Save In:"), this), 0, 0,
saveInLay->addWidget(m_parentFolderField, 1); Qt::AlignRight | Qt::AlignVCenter);
saveInLay->addWidget(m_parentFolderField, 0, 1);
saveInLay->addWidget(setAsDefaultBtn, 1, 1);
} }
saveInLay->setColumnStretch(0, 0);
saveInLay->setColumnStretch(1, 1);
m_topLayout->addLayout(saveInLay); m_topLayout->addLayout(saveInLay);
m_topLayout->addWidget(m_subFolderCB, 0, Qt::AlignLeft); m_topLayout->addWidget(m_subFolderCB, 0, Qt::AlignLeft);
@ -725,9 +738,13 @@ PencilTestSaveInFolderPopup::PencilTestSaveInFolderPopup(QWidget* parent)
SLOT(updateSubFolderName())); SLOT(updateSubFolderName()));
ret = ret && connect(m_autoSubNameCB, SIGNAL(clicked(bool)), this, ret = ret && connect(m_autoSubNameCB, SIGNAL(clicked(bool)), this,
SLOT(onAutoSubNameCBClicked(bool))); SLOT(onAutoSubNameCBClicked(bool)));
ret = ret && connect(m_subNameFormatCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(updateSubFolderName()));
ret = ret && connect(showPopupOnLaunchCB, SIGNAL(clicked(bool)), this, ret = ret && connect(showPopupOnLaunchCB, SIGNAL(clicked(bool)), this,
SLOT(onShowPopupOnLaunchCBClicked(bool))); SLOT(onShowPopupOnLaunchCBClicked(bool)));
ret = ret && connect(setAsDefaultBtn, SIGNAL(pressed()), this,
SLOT(onSetAsDefaultBtnPressed()));
ret = ret && connect(okBtn, SIGNAL(clicked(bool)), this, SLOT(onOkPressed())); ret = ret && connect(okBtn, SIGNAL(clicked(bool)), this, SLOT(onOkPressed()));
ret = ret && connect(cancelBtn, SIGNAL(clicked(bool)), this, SLOT(reject())); ret = ret && connect(cancelBtn, SIGNAL(clicked(bool)), this, SLOT(reject()));
@ -745,6 +762,12 @@ QString PencilTestSaveInFolderPopup::getPath() {
return m_parentFolderField->getPath() + "\\" + m_subFolderNameField->text(); return m_parentFolderField->getPath() + "\\" + m_subFolderNameField->text();
} }
//-----------------------------------------------------------------------------
QString PencilTestSaveInFolderPopup::getParentPath() {
return m_parentFolderField->getPath();
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
namespace { namespace {
QString formatString(QString inStr, int charNum) { QString formatString(QString inStr, int charNum) {
@ -813,6 +836,12 @@ void PencilTestSaveInFolderPopup::onShowPopupOnLaunchCBClicked(bool on) {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void PencilTestSaveInFolderPopup::onSetAsDefaultBtnPressed() {
CamCapSaveInParentFolder = m_parentFolderField->getPath().toStdString();
}
//-----------------------------------------------------------------------------
void PencilTestSaveInFolderPopup::onOkPressed() { void PencilTestSaveInFolderPopup::onOkPressed() {
if (!m_subFolderCB->isChecked()) { if (!m_subFolderCB->isChecked()) {
accept(); accept();
@ -850,7 +879,9 @@ void PencilTestSaveInFolderPopup::onOkPressed() {
CamCapSaveInPopupEpisode = m_episodeField->text().toStdString(); CamCapSaveInPopupEpisode = m_episodeField->text().toStdString();
CamCapSaveInPopupSequence = m_sequenceField->text().toStdString(); CamCapSaveInPopupSequence = m_sequenceField->text().toStdString();
CamCapSaveInPopupScene = m_sceneField->text().toStdString(); CamCapSaveInPopupScene = m_sceneField->text().toStdString();
CamCapSaveInPopupAutoSubName = (m_autoSubNameCB->isChecked()) ? 1 : 0; CamCapSaveInPopupAutoSubName = (!m_autoSubNameCB->isChecked())
? 0
: m_subNameFormatCombo->currentIndex() + 1;
// create folder // create folder
try { try {
@ -886,6 +917,8 @@ PencilTestPopup::PencilTestPopup()
TFilePath(L"penciltest" + dateTime + L".jpg"); TFilePath(L"penciltest" + dateTime + L".jpg");
m_cacheImagePath = cacheImageFp.getQString(); m_cacheImagePath = cacheImageFp.getQString();
m_saveInFolderPopup = new PencilTestSaveInFolderPopup(this);
m_cameraViewfinder = new MyViewFinder(this); m_cameraViewfinder = new MyViewFinder(this);
// CameraViewfinderContainer* cvfContainer = new // CameraViewfinderContainer* cvfContainer = new
// CameraViewfinderContainer(m_cameraViewfinder, this); // CameraViewfinderContainer(m_cameraViewfinder, this);
@ -904,8 +937,9 @@ PencilTestPopup::PencilTestPopup()
m_frameNumberEdit = new FrameNumberLineEdit(this, startFrame); m_frameNumberEdit = new FrameNumberLineEdit(this, startFrame);
m_fileTypeCombo = new QComboBox(this); m_fileTypeCombo = new QComboBox(this);
m_fileFormatOptionButton = new QPushButton(tr("Options"), this); m_fileFormatOptionButton = new QPushButton(tr("Options"), this);
m_saveInFileFld = new FileField(
0, QString("+%1").arg(QString::fromStdString(TProject::Extras))); m_saveInFileFld = new FileField(this, m_saveInFolderPopup->getParentPath());
QToolButton* nextLevelButton = new QToolButton(this); QToolButton* nextLevelButton = new QToolButton(this);
m_saveOnCaptureCB = m_saveOnCaptureCB =
new QCheckBox(tr("Save images as they are captured"), this); new QCheckBox(tr("Save images as they are captured"), this);
@ -943,8 +977,6 @@ PencilTestPopup::PencilTestPopup()
QPushButton* subfolderButton = new QPushButton(tr("Subfolder"), this); QPushButton* subfolderButton = new QPushButton(tr("Subfolder"), this);
m_saveInFolderPopup = new PencilTestSaveInFolderPopup(this);
//---- //----
m_resolutionCombo->setMaximumWidth(fontMetrics().width("0000 x 0000") + 25); m_resolutionCombo->setMaximumWidth(fontMetrics().width("0000 x 0000") + 25);

View file

@ -138,11 +138,13 @@ class PencilTestSaveInFolderPopup : public DVGui::Dialog {
public: public:
PencilTestSaveInFolderPopup(QWidget* parent = 0); PencilTestSaveInFolderPopup(QWidget* parent = 0);
QString getPath(); QString getPath();
QString getParentPath();
protected slots: protected slots:
void updateSubFolderName(); void updateSubFolderName();
void onAutoSubNameCBClicked(bool); void onAutoSubNameCBClicked(bool);
void onShowPopupOnLaunchCBClicked(bool); void onShowPopupOnLaunchCBClicked(bool);
void onSetAsDefaultBtnPressed();
void onOkPressed(); void onOkPressed();
}; };

View file

@ -94,7 +94,8 @@ void FileField::browseDirectory() {
if (!m_browserPopupController) return; if (!m_browserPopupController) return;
m_browserPopupController->openPopup( m_browserPopupController->openPopup(
m_filters, (m_fileMode == QFileDialog::DirectoryOnly), m_filters, (m_fileMode == QFileDialog::DirectoryOnly),
(m_lastSelectedPath == m_descriptionText) ? "" : m_lastSelectedPath); (m_lastSelectedPath == m_descriptionText) ? "" : m_lastSelectedPath,
this);
if (m_browserPopupController->isExecute()) if (m_browserPopupController->isExecute())
directory = m_browserPopupController->getPath(); directory = m_browserPopupController->getPath();