#include "rm_popup_capture.h" #include #include "rm_button.h" #include "title_widget.h" #include "rm_popup_content_background.h" #include #include #include #include #include "../rm_settings.h" #include "fm_button.h" #include "../core/fm_strings.h" #if (RM_MODEL_EMT_KR) #include "../core/rm_player.h" #endif #include "rm_dialog_overwrite_sys.h" // キャプチャー #if (FORCE_FM_STRING) RMPopupCapture::RMPopupCapture(QWidget *parent,QList* files) : RMPopup(parent,FMS::txt("capture"),"") #else RMPopupCapture::RMPopupCapture(QWidget *parent,QList* files) : RMPopup(parent,MKU8("\xe3\x82\xad\xe3\x83\xa3\xe3\x83\x97\xe3\x83\x81\xe3\x83\xa3\xe3\x83\xbc"),"") #endif { _files = files; this->setFixedSize(482,277); QVBoxLayout* layout = new QVBoxLayout(_contentWidget); layout->setContentsMargins(10,13,10,12); RMPopupContentBackground* bg = new RMPopupContentBackground(_contentWidget); layout->addWidget(bg); QVBoxLayout* contentLayout = new QVBoxLayout(bg); contentLayout->setAlignment(Qt::AlignTop); RMLayout::addSpacer(contentLayout,0,10); #if (FORCE_FM_STRING) QString title = FMS::txt("capture_desc"); #else QString title = MKU8("\xe3\x82\xad\xe3\x83\xa3\xe3\x83\x97\xe3\x83\x81\xe3\x83\xa3\xe3\x83\xbc\xe3\x82\x92\x4a\x50\x45\x47\xe3\x81\xa7\xe4\xbf\x9d\xe5\xad\x98\xe3\x81\x97\xe3\x81\xbe\xe3\x81\x99"); #if (LIVE_LANGUAGE_CHANGE) bool isJP = RMLanguage::isJP(); if(isJP == false) { _title->titleLabel->setText("Save Capture"); title = "Save capture file in JPEG"; } #endif #endif //FORCE_FM_STRING // キャプチャーをJPEGで保存します RMLayout::addLabel(bg, contentLayout, title, "text_header_label"); RMLayout::addSpacer(contentLayout,0,30); QWidget* fileWidget = new QWidget(bg); contentLayout->addWidget(fileWidget); QHBoxLayout* fileLayout = new QHBoxLayout(fileWidget); fileLayout->setMargin(0); fileLayout->setSpacing(10); // ファイル名 #if (FORCE_FM_STRING) title = QString(FMS::txt("file_name")+ " : "); #else title = QString(MKU8("\xe3\x83\x95\xe3\x82\xa1\xe3\x82\xa4\xe3\x83\xab\xe5\x90\x8d") + " : "); #if (LIVE_LANGUAGE_CHANGE) if(isJP == false) { title = "File Name: "; } #endif #endif RMLayout::addLabel(fileWidget, fileLayout, title, "text_header_label"); QFileInfo info = QFileInfo(files->at(0)); fileEdit = new QLineEdit(fileWidget); fileEdit->setObjectName("file"); fileEdit->setReadOnly(false); QString baseName = info.baseName(); QStringList bls = baseName.split("_"); fileEdit->setText(bls[0] + "_" + bls[1]); fileLayout->addWidget(fileEdit); RMLayout::addSpacer(fileLayout,70,0); QWidget* folderWidget = new QWidget(bg); contentLayout->addWidget(folderWidget); QHBoxLayout* folderLayout = new QHBoxLayout(folderWidget); folderLayout->setMargin(0); folderLayout->setSpacing(10); folderEdit = new QLineEdit(folderWidget); folderEdit->setObjectName("file"); folderEdit->setReadOnly(true); folderEdit->setText(RMSettings::instance()->lastBackupPath()); folderLayout->addWidget(folderEdit); // 変更 #if (LIVE_LANGUAGE2) RMButton* changeFolderButton = RMButton::create2(folderWidget,folderLayout,"button","change",QSize(60,30)); title = QString(FMS::txt("change")); #else // LIVE_LANGUAGE2 #if (FORCE_FM_STRING) title = FMS::txt("change"); #else // FORCE_FM_STRING title = MKU8("\xe5\xa4\x89\xe6\x9b\xb4"); #if (LIVE_LANGUAGE_CHANGE) if(isJP == false) { title = "Other..";} #endif // LIVE_LANGUAGE_CHANGE #endif // FORCE_FM_STRING RMButton* changeFolderButton = RMButton::create(folderWidget,folderLayout,"button",title,QSize(60,30)); #endif // LIVE_LANGUAGE2 changeFolderButton->setText(title); connect(changeFolderButton,SIGNAL(clicked()),this,SLOT(onChangeFolder())); _buttonLayout->setAlignment(Qt::AlignRight | Qt::AlignVCenter); #if (FORCE_FM_STRING) title = FMS::txt("save"); #else // 保存 title = MKU8("\xe4\xbf\x9d\xe5\xad\x98"); #if (LIVE_LANGUAGE_CHANGE) if(isJP == false) { title = "Save"; }; #endif #endif #if (LIVE_LANGUAGE2) RMButton* okButton = RMButton::create2(_buttonWidget,_buttonLayout,"button","save",QSize(120,30)); #else // LIVE_LANGUAGE2 RMButton* okButton = RMButton::create(_buttonWidget,_buttonLayout,"button",FMS::txt("save"),QSize(120,30)); #endif // LIVE_LANGUAGE2 okButton->setText(FMS::txt("save")); connect(okButton,SIGNAL(clicked()),this,SLOT(onOK())); RMLayout::addSpacer(_buttonLayout,10,0); // キャンセル #if (FORCE_FM_STRING) #if (LIVE_LANGUAGE2) RMButton* calcelButton = RMButton::create2(_buttonWidget,_buttonLayout,"button","cancel",QSize(120,30)); #else // LIVE_LANGUAGE2 RMButton* calcelButton = RMButton::create(_buttonWidget,_buttonLayout,"button",FMS::txt("cancel"),QSize(120,30)); #endif // LIVE_LANGUAGE2 calcelButton->setText(FMS::txt("cancel")); #else title = MKU8("\xe3\x82\xad\xe3\x83\xa3\xe3\x83\xb3\xe3\x82\xbb\xe3\x83\xab"); #if (LIVE_LANGUAGE_CHANGE) if(isJP == false) { title = "Cancel"; }; #endif RMButton* calcelButton = RMButton::create(_buttonWidget,_buttonLayout,"button",title,QSize(120,30)); calcelButton->setText(title); #endif // FORCE_FM_STRING connect(calcelButton,SIGNAL(clicked()),this,SLOT(reject())); RMLayout::addSpacer(_buttonLayout,20,0); _title->closeButton->setHidden(true); } void RMPopupCapture::onOK() { if(fileEdit->text().isEmpty()) { #if (FORCE_FM_STRING) QMessageBox msgBox(QMessageBox::Warning, "", FMS::txt("enter_file_name"), QMessageBox::Ok, this); #else QMessageBox msgBox(QMessageBox::Warning, "", // ファイル名を入れてください。 MKU8("\xe3\x83\x95\xe3\x82\xa1\xe3\x82\xa4\xe3\x83\xab\xe5\x90\x8d\xe3\x82\x92\xe5\x85\xa5\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x8f\xe3\x81\xa0\xe3\x81\x95\xe3\x81\x84\xe3\x80\x82"), QMessageBox::Ok, this); #endif msgBox.exec(); return; } if(_isFileExist() ) { #if (SINGLE_CH_VIEWER) QString fileNameMessage = fileEdit->text() + ".jpg"; #else QString fileNameMessage = fileEdit->text() + "_*.jpg"; #endif RMDialogOverwriteSys* dialog = new RMDialogOverwriteSys(RMApp::instance()->pMainWindow,fileNameMessage); // REJECT if( dialog->exec() == 0) { return; } } accept(); } bool RMPopupCapture::_isFileExist() { #if !(SINGLE_CH_VIEWER || TOGGLE_PLAYER) const QString front = QString::fromUtf8("\xe5\x89\x8d\xe6\x96\xb9"); const QString rear = QString::fromUtf8("\xe5\xbe\x8c\xe6\x96\xb9"); #endif foreach (QString src, *_files) { QString destPath; #if (SINGLE_CH_VIEWER || TOGGLE_PLAYER) destPath = destPath = QDir::cleanPath(folderEdit->text() + QDir::separator() + fileEdit->text() + ".jpg"); #else if(src.contains("CH1") == true) { destPath = QDir::cleanPath(folderEdit->text() + QDir::separator() + fileEdit->text() + "_" + front + ".jpg"); } else // CH2 { destPath = QDir::cleanPath(folderEdit->text() + QDir::separator() + fileEdit->text() + "_" + rear + ".jpg"); } #endif if(QFile::exists(destPath)) { return true; } } return false; } void RMPopupCapture::saveFiles() { bool bSuccess = true; #if (SINGLE_CH_VIEWER) QString destPath = QDir::cleanPath(folderEdit->text() + QDir::separator() + fileEdit->text() + ".jpg"); if(QFile::exists(destPath)) { QFile::remove(destPath); } bSuccess &= QFile::rename(_files->at(0),destPath); #else #if (FORCE_FM_STRING) #if (PENTA_CHANNEL) QString front = FMS::txt("select_front"); QString rear = FMS::txt("select_rear"); switch(RMApp::instance()->chMode) { case RMApp::ChannelModeFR: case RMApp::ChannelModeFront: front = FMS::txt("select_front"); rear = FMS::txt("select_rear"); break; case RMApp::ChannelModeLR: case RMApp::ChannelModeLeft: front = FMS::txt("select_left"); rear = FMS::txt("select_right"); break; case RMApp::ChannelModeRear: front = FMS::txt("select_rear"); break; case RMApp::ChannelModeRight: front = FMS::txt("select_right"); break; case RMApp::ChannelModeSub: front = FMS::txt("select_asst"); break; } #else // PENTA_CHANNEL const QString front = FMS::txt("front_suffix"); #if (RM_MODEL_EMT_KR) QString rear = FMS::txt("rear_suffix"); // 일단 후방 if(RMPlayer::instance()->isIndoor()) { if(RMPlayer::instance()->itemIsWideMode()) { rear = FMS::txt("indoor_suffix"); // 실내 } else { rear = FMS::txt("pedal_suffix"); // 페달 } } #else // RM_MODEL_EMT_KR const QString rear = FMS::txt("rear_suffix"); #endif // RM_MODEL_EMT_KR #endif // PENTA_CHANNEL #else const QString front = QString::fromUtf8("\xe5\x89\x8d\xe6\x96\xb9"); const QString rear = QString::fromUtf8("\xe5\xbe\x8c\xe6\x96\xb9"); #endif foreach (QString src, *_files) { QString destPath; if(src.contains("CH1") == true) { destPath = QDir::cleanPath(folderEdit->text() + QDir::separator() + fileEdit->text() + "_" + front + ".jpg"); } else // CH2 { destPath = QDir::cleanPath(folderEdit->text() + QDir::separator() + fileEdit->text() + "_" + rear + ".jpg"); } if(QFile::exists(destPath)) { QFile::remove(destPath); } bSuccess &= QFile::rename(src,destPath); } #endif if(bSuccess == false) { #if (FORCE_FM_STRING) QString fail = FMS::txt("save_jpg_fail"); #else QString fail = MKU8("\x4a\x50\x45\x47\xe3\x83\x95\xe3\x82\xa1\xe3\x82\xa4\xe3\x83\xab\xe7\x94\x9f\xe6\x88\x90\xe3\x81\xab\xe5\xa4\xb1\xe6\x95\x97\xe3\x81\x97\xe3\x81\xbe\xe3\x81\x97\xe3\x81\x9f\xe3\x80\x82"); #endif #if (LIVE_LANGUAGE_CHANGE && !REMOVE_OLD_C) if(RMLanguage::isJP() == false) { fail = "Unable to save file."; } #endif QMessageBox msgBox(QMessageBox::Warning, "", // JPEGファイル生成に失敗しました。 fail, QMessageBox::Ok, this); msgBox.exec(); } } void RMPopupCapture::onChangeFolder() { // フォルダー変更 #if (FORCE_FM_STRING) QString title = FMS::txt("change_folder"); #else QString title = MKU8("\xe3\x83\x95\xe3\x82\xa9\xe3\x83\xab\xe3\x83\x80\xe3\x83\xbc\xe5\xa4\x89\xe6\x9b\xb4"); #endif #if (LIVE_LANGUAGE_CHANGE && !REMOVE_OLD_C) if(RMLanguage::isJP() == false) { title = "AVI files";} #endif QString dir = RMApp::openFolder(folderEdit->text(),true,title); if(dir.isEmpty() == false) { RMSettings::instance()->setLastBackupPath(dir); folderEdit->setText(dir); } }