151 lines
4.9 KiB
C++
151 lines
4.9 KiB
C++
#include "rm_dialog_progress.h"
|
|
#include "../rm_include.h"
|
|
#include "fm_layer.h"
|
|
#include "../data/rm_video_list.h"
|
|
#include "title_widget.h"
|
|
#include "../rm_app.h"
|
|
#include "rm_widget_style_base.h"
|
|
#include "../data/rm_overwrite.h"
|
|
#include "fm_button.h"
|
|
#include "fm_colors.h"
|
|
#include "../core/fm_strings.h"
|
|
|
|
|
|
RMDialogProgress* RMDialogProgress::_progress = NULL;
|
|
|
|
void RMDialogProgress::start(QString title,bool bCancel,bool bFileList)
|
|
{
|
|
stop();
|
|
|
|
RMDialogProgress::_progress = new RMDialogProgress(RMApp::instance()->pMainWindow,title,bCancel,bFileList);
|
|
RMDialogProgress::_progress->show();
|
|
|
|
connect(RMVideoFileList::instance(),SIGNAL(updateProgress(int)),RMDialogProgress::_progress,SLOT(onUpdateValue(int)));
|
|
|
|
}
|
|
void RMDialogProgress::stop()
|
|
{
|
|
if(RMDialogProgress::_progress != NULL)
|
|
{
|
|
RMDialogProgress::_progress->setHidden(true);
|
|
delete RMDialogProgress::_progress;
|
|
RMDialogProgress::_progress = NULL;
|
|
}
|
|
}
|
|
|
|
RMDialogProgress::RMDialogProgress(QWidget *parent, QString title, bool bCancel, bool bFileList) : QDialog(parent)
|
|
{
|
|
this->setWindowFlags(this->windowFlags() | Qt::FramelessWindowHint);
|
|
|
|
this->setWindowModality(Qt::ApplicationModal);
|
|
|
|
this->setFixedSize(414,bCancel ? 140 : 100);
|
|
|
|
_layout = new QVBoxLayout(this);
|
|
_layout->setSpacing(0);
|
|
_layout->setMargin(0);
|
|
|
|
_title = new TitleWidget(this,title,"",true);
|
|
_layout->addWidget(_title);
|
|
_title->closeButton->setHidden(true);
|
|
|
|
QWidget* contentWidget = new QWidget(this);
|
|
FMWidgetBackground(contentWidget,"dialog_bg",0x3a3a3a);
|
|
//contentWidget->setObjectName("bg_widget");
|
|
_layout->addWidget(contentWidget);
|
|
|
|
QBoxLayout* contentLayout = new QHBoxLayout(contentWidget);
|
|
contentLayout->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
|
|
|
QWidget* borderWidget = new QWidget(contentWidget);
|
|
FMWidgetBorder(borderWidget,"dialog_border",0x595959);
|
|
borderWidget->setFixedSize(398,46);
|
|
contentLayout->addWidget(borderWidget);
|
|
|
|
QBoxLayout* borderLayout = new QHBoxLayout(borderWidget);
|
|
borderLayout->setAlignment(Qt::AlignCenter);
|
|
|
|
_progressBar = new QProgressBar(borderWidget);
|
|
_progressBar->setTextVisible(false);
|
|
_progressBar->setFixedSize(364,16);
|
|
_progressBar->setMaximum(PROGRESS_BAR_MAX);
|
|
_progressBar->setMinimum(0);
|
|
_progressBar->setValue(0);
|
|
|
|
|
|
QString progressStyle = "QProgressBar\
|
|
{\
|
|
background-color: white;\
|
|
border-style: none;\
|
|
}\
|
|
QProgressBar::chunk\
|
|
{\
|
|
background-color: #%color%;\
|
|
}";
|
|
#if (RM_MODEL_EMT_KR)
|
|
progressStyle = progressStyle.replace("%color%",QString().sprintf("%06X",FM_TEHEM_COLOR_P1));
|
|
#else
|
|
progressStyle = progressStyle.replace("%color%",QString().sprintf("%06X",FM_SILDER_COLOR));
|
|
#endif
|
|
|
|
_progressBar->setStyleSheet(progressStyle);
|
|
|
|
borderLayout->addWidget(_progressBar);
|
|
|
|
_bFileList = bFileList;
|
|
|
|
if(bCancel) {
|
|
|
|
QWidget* buttonWidget = new QWidget(this);
|
|
buttonWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
|
|
//buttonWidget->setObjectName("bg_widget");
|
|
FMWidgetBackground(buttonWidget,"dialog_bg",0x595959);
|
|
buttonWidget->setFixedHeight(43); // 65??
|
|
_layout->addWidget(buttonWidget);
|
|
|
|
QHBoxLayout* buttonLayout = new QHBoxLayout(buttonWidget);
|
|
buttonLayout->setSpacing(0);
|
|
buttonLayout->setMargin(0);
|
|
#if (FORCE_FM_STRING)
|
|
QString cancelString = FMS::txt("cancel");
|
|
#if (LIVE_LANGUAGE2)
|
|
RMButton* calcelButton = RMButton::create2(buttonWidget,buttonLayout,"popup_button","cancel",QSize(120,30));
|
|
#else // LIVE_LANGUAGE2
|
|
//FMButton* calcelButton = FMButton::btnTypeText(buttonWidget,buttonLayout,cancelString,cancelString,QSize(120,30),g_default_text_button_color_set);
|
|
RMButton* calcelButton = RMButton::create(buttonWidget,buttonLayout,"popup_button",cancelString,QSize(120,30));
|
|
#endif // LIVE_LANGUAGE2
|
|
#else // FORCE_FM_STRING
|
|
QString cancelString = MKU8("\xe3\x82\xad\xe3\x83\xa3\xe3\x83\xb3\xe3\x82\xbb\xe3\x83\xab");
|
|
#if (LIVE_LANGUAGE_CHANGE)
|
|
if(RMLanguage::isJP() == false)
|
|
{
|
|
cancelString = "Cancel";
|
|
}
|
|
#endif
|
|
RMButton* calcelButton = RMButton::create(buttonWidget,buttonLayout,"popup_button",cancelString,QSize(120,30));
|
|
#endif // FORCE_FM_STRING
|
|
calcelButton->setText(cancelString);
|
|
connect(calcelButton,SIGNAL(clicked()),this,SLOT(onCancel()));
|
|
}
|
|
|
|
}
|
|
void RMDialogProgress::onCancel()
|
|
{
|
|
if(!_bFileList) {
|
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
//setHidden(true);
|
|
RMOverwrite::gCurrent = OVERWRITE_OPTION_CANCEL;
|
|
//emit cancelProcess();
|
|
}
|
|
#if (SUPPORT_LOADING_CANCEL)
|
|
// 로딩 취소
|
|
RMVideoFileList::instance()->bCancelLoading = true;
|
|
#endif // SUPPORT_LOADING_CANCEL
|
|
}
|
|
|
|
void RMDialogProgress::onUpdateValue(int value)
|
|
{
|
|
_progressBar->setValue(value);
|
|
//qInfo() << "RMProgressDialog:" << value;
|
|
}
|