Пример #1
0
QWidget* AutoImportWindow::setupInputFolderContainer() {
    GroupContainer* container = new GroupContainer();
    container->setTitle("Import Folder");

    QFormLayout* layout = new QFormLayout;
    layout->setHorizontalSpacing(10);
    layout->setVerticalSpacing(0);
    layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
    layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
    layout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
    layout->setLabelAlignment(Qt::AlignLeft);

    BrowserWidget* filesDirBrowser_ = new BrowserWidget(BrowserWidget::BrowseType::DIRECTORY);
    ParametersConfiguration* conf  = projectData.projectParameterData();
    QString importImagesPath = conf->getValue("import_dir");
    filesDirBrowser_->setPath(importImagesPath);
    setupWatcherPaths();
    connect(filesDirBrowser_, &BrowserWidget::pathChanged, [ = ] (const QString & value){
        conf->set("import_dir", value);
        setupWatcherPaths();
        analyzeImport();
    });
    layout->addRow(filesDirBrowser_);

    QLabel* introLabel = new QLabel(introText());
    introLabel->setWordWrap(true);
    QPalette pal = introLabel->palette();
    pal.setColor(QPalette::WindowText, Qt::darkGray);
    introLabel->setPalette(pal);
    layout->addRow(introLabel);

    QCheckBox* restartCheck = new QCheckBox("Import new images in the import folder on start");
    restartCheck->setChecked(ProjectPreferences().importRestartCheck());
    connect(restartCheck, &QCheckBox::toggled, [ = ] (bool check){
        ProjectPreferences().setImportRestartCheck(check);
    });
    layout->addRow(restartCheck);

    
    layout->addRow(continuous);
    
    deleteCheck = new QCheckBox("DELETE the original images in import folder after importing them");
    deleteCheck->setChecked(ProjectPreferences().importDeleteCheck());
    deleteLabel_->setVisible(deleteCheck->isChecked());
    connect(deleteCheck, &QCheckBox::toggled, [ = ] (bool check){
        ProjectPreferences().setImportDeleteCheck(check);
        deleteLabel_->setVisible(check);
    });
    layout->addRow(deleteCheck);
    
    container->setContainerLayout(layout);

    return container;
}
Пример #2
0
DictEditorWidget::DictEditorWidget(QWidget *parent)
    : QWidget(parent)
{

    mView = new QTableView;
    mModel = new DictEditorModel;
    mKeyEdit = new QComboBox;
    mValueEdit = new QLineEdit;
    mAddButton = new QToolButton;
    mRemButton = new QToolButton;
    mTypeLabel = new QLabel("type");
    mValueLabel = new QLabel("value");

    mAddButton->setIcon(QtAwesome::instance()->icon("plus"));
    mRemButton->setIcon(QtAwesome::instance()->icon("minus"));



    mView->setModel(mModel);
    mView->verticalHeader()->hide();
    mView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    mView->setSelectionBehavior(QAbstractItemView::SelectRows);




    QFormLayout * formLayout = new QFormLayout;
    formLayout->addRow(mTypeLabel,mKeyEdit);
    formLayout->addRow(mValueLabel,mValueEdit);
    formLayout->setVerticalSpacing(5);
    formLayout->setFormAlignment(Qt::AlignCenter);

    QVBoxLayout * vLayout = new QVBoxLayout;

    vLayout->addItem(formLayout);
    vLayout->addWidget(mView);


    QHBoxLayout * buttonLayout = new QHBoxLayout;
    buttonLayout->addWidget(mAddButton);
    buttonLayout->addWidget(mRemButton);
    buttonLayout->addStretch();

    vLayout->addLayout(buttonLayout);

    setLayout(vLayout);

    mKeyEdit->setEditable(true);


    connect(mAddButton,SIGNAL(clicked()),this,SLOT(addClicked()));
    connect(mRemButton,SIGNAL(clicked()),this,SLOT(removeClicked()));

}
Пример #3
0
QWidget* PreferencesDialog::getGeneralPage() {
    GroupContainer* widget = new GroupContainer();
    widget->setTitle("General");
    
    QFormLayout* mainLayout = new QFormLayout;
    mainLayout->setRowWrapPolicy(QFormLayout::WrapLongRows);
    mainLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
    mainLayout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
    mainLayout->setLabelAlignment(Qt::AlignRight);
    
    QCheckBox* autoSaveBox = new QCheckBox("Automatically save configurations when they are changed");
    autoSaveBox->setChecked(UserPreferences().autoSaveConfigs());
    connect(autoSaveBox, &QCheckBox::toggled, [=](bool check){
        UserPreferences().setAutoSaveConfigs(check);
        projectData.setAutoSave(check);
    });
    mainLayout->addRow(autoSaveBox);
    
    QCheckBox* advancedBox = new QCheckBox("Show advanced by default (valid on restart)");
    advancedBox->setChecked(UserPreferences().showAdvanced());
    connect(advancedBox, &QCheckBox::toggled, [=](bool check){
        UserPreferences().setShowAdvanced(check);
    });
    mainLayout->addRow(advancedBox);
     
    QSlider* outputVerbosityControl = new QSlider;
    outputVerbosityControl->setOrientation(Qt::Horizontal);
    outputVerbosityControl->setFixedSize(100, 20);
    outputVerbosityControl->setMinimum(0);
    outputVerbosityControl->setMaximum(3);
    outputVerbosityControl->setTickPosition(QSlider::TicksBothSides);
    outputVerbosityControl->setTickInterval(1);
    outputVerbosityControl->setSingleStep(1);
    outputVerbosityControl->setValue(UserPreferences().userLevel());
    connect(outputVerbosityControl, &QSlider::valueChanged, [=] (int level) {
        UserPreferences().setUserLevel(level);
    });
    mainLayout->addRow("Default verbosity level (valid on restart)", outputVerbosityControl);
    
    widget->setContainerLayout(mainLayout);
    
    QWidget* pageWid = new QWidget;
    QVBoxLayout *layout = new QVBoxLayout;
    layout->setMargin(0);
    layout->setSpacing(0);
    layout->addWidget(widget);
    layout->addStretch(1);
    pageWid->setLayout(layout);
    
    return pageWid;
}
Пример #4
0
void msg_dialog_frame::CreateOsk(const std::string& msg, char16_t* osk_text)
{
	if (osk_dialog)
	{
		osk_dialog->close();
		delete osk_dialog;
	}

	osk_dialog = new custom_dialog(type.disable_cancel);
	osk_dialog->setModal(true);
	osk_text_return = osk_text;

	//Title
	osk_dialog->setWindowTitle(qstr(msg));
	osk_dialog->setWindowFlags(osk_dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint);

	//Text Input
	QLineEdit* input = new QLineEdit(osk_dialog);
	input->setFixedWidth(200);
	input->setFocus();

	//Ok Button
	QPushButton* button_ok = new QPushButton("Ok", osk_dialog);
	button_ok->setFixedWidth(50);

	//Layout
	QHBoxLayout* buttonsLayout = new QHBoxLayout;
	buttonsLayout->setAlignment(Qt::AlignCenter);
	buttonsLayout->addWidget(button_ok);

	QFormLayout* layout = new QFormLayout(osk_dialog);
	layout->setFormAlignment(Qt::AlignHCenter);
	layout->addRow(input);
	layout->addRow(buttonsLayout);
	osk_dialog->setLayout(layout);

	//Events
	connect(input, &QLineEdit::textChanged, [=] {
		std::memcpy(osk_text_return, reinterpret_cast<const char16_t*>(input->text().constData()), input->text().size() * 2);
		on_osk_input_entered();
	});
	connect(input, &QLineEdit::returnPressed, [=] { on_close(CELL_MSGDIALOG_BUTTON_OK); osk_dialog->accept(); });
	connect(button_ok, &QAbstractButton::clicked, [=] { on_close(CELL_MSGDIALOG_BUTTON_OK); osk_dialog->accept(); });
	connect(osk_dialog, &QDialog::rejected, [=] {if (!type.disable_cancel) { on_close(CELL_MSGDIALOG_BUTTON_ESCAPE); }});

	//Fix size
	osk_dialog->setFixedSize(osk_dialog->sizeHint());
	osk_dialog->show();
}
Пример #5
0
QWidget* PreferencesDialog::getFontsPage() {
    QWidget* widget = new QWidget();

    //---------------------
    // Font
    //---------------------
    GroupContainer *fontGroup = new GroupContainer;
    fontGroup->setTitle("Font");

    //Font Size
    QSpinBox* fontSizeCombo = new QSpinBox;
    fontSizeCombo->setMinimum(8);
    fontSizeCombo->setMaximum(14);
    fontSizeCombo->setValue(QApplication::font().pointSize());

    connect(fontSizeCombo, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), 
            [=] (int i){UserPreferences().setFontSize(i);});

    //Font Weight
    QComboBox *fontWeightCombo = new QComboBox;
    fontWeightCombo->addItems(QStringList() << "0" << "25" << "50" << "75");
    fontWeightCombo->setCurrentText(QString::number(QApplication::font().weight()));

    connect(fontWeightCombo, static_cast<void(QComboBox::*)(const QString&)> (&QComboBox::currentTextChanged),
            [ = ] (const QString & value){UserPreferences().setFontWeight(value);});

    QFormLayout *fontLayout = new QFormLayout;
    fontLayout->setRowWrapPolicy(QFormLayout::WrapLongRows);
    fontLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
    fontLayout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
    fontLayout->setLabelAlignment(Qt::AlignRight);
    fontLayout->addRow("Font Size", fontSizeCombo);
    fontLayout->addRow("Font Weight", fontWeightCombo);

    fontGroup->setContainerLayout(fontLayout);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);
    mainLayout->addWidget(fontGroup);
    mainLayout->addStretch(1);
    widget->setLayout(mainLayout);
    return widget;
}
Пример #6
0
void MaemoRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
{
    QFormLayout *formLayout = new QFormLayout;
    mainLayout->addLayout(formLayout);
    formLayout->setFormAlignment(Qt::AlignLeft | Qt::AlignVCenter);

    QWidget *devConfWidget = new QWidget;
    QHBoxLayout *devConfLayout = new QHBoxLayout(devConfWidget);
    m_devConfLabel = new QLabel;
    devConfLayout->setMargin(0);
    devConfLayout->addWidget(m_devConfLabel);
    QLabel *addDevConfLabel= new QLabel(tr("<a href=\"%1\">Manage device configurations</a>")
        .arg(QLatin1String("deviceconfig")));
    addDevConfLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
    devConfLayout->addWidget(addDevConfLabel);

    QLabel *debuggerConfLabel = new QLabel(tr("<a href=\"%1\">Set Debugger</a>")
        .arg(QLatin1String("debugger")));
    debuggerConfLabel->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
    devConfLayout->addWidget(debuggerConfLabel);

    formLayout->addRow(new QLabel(tr("Device configuration:")), devConfWidget);
    m_localExecutableLabel
        = new QLabel(m_runConfiguration->localExecutableFilePath());
    formLayout->addRow(tr("Executable on host:"), m_localExecutableLabel);
    m_remoteExecutableLabel = new QLabel;
    formLayout->addRow(tr("Executable on device:"), m_remoteExecutableLabel);
    m_argsLineEdit = new QLineEdit(m_runConfiguration->arguments());
    formLayout->addRow(tr("Arguments:"), m_argsLineEdit);

    QHBoxLayout * const debugButtonsLayout = new QHBoxLayout;
    m_debugCppOnlyButton = new QRadioButton(tr("C++ only"));
    m_debugQmlOnlyButton = new QRadioButton(tr("QML only"));
    m_debugCppAndQmlButton = new QRadioButton(tr("C++ and QML"));
    m_debuggingLanguagesLabel = new QLabel(tr("Debugging type:"));
    QButtonGroup * const buttonGroup = new QButtonGroup;
    buttonGroup->addButton(m_debugCppOnlyButton);
    buttonGroup->addButton(m_debugQmlOnlyButton);
    buttonGroup->addButton(m_debugCppAndQmlButton);
    debugButtonsLayout->addWidget(m_debugCppOnlyButton);
    debugButtonsLayout->addWidget(m_debugQmlOnlyButton);
    debugButtonsLayout->addWidget(m_debugCppAndQmlButton);
    debugButtonsLayout->addStretch(1);
    formLayout->addRow(m_debuggingLanguagesLabel, debugButtonsLayout);
    if (m_runConfiguration->useCppDebugger()) {
        if (m_runConfiguration->useQmlDebugger())
            m_debugCppAndQmlButton->setChecked(true);
        else
            m_debugCppOnlyButton->setChecked(true);
    } else {
        m_debugQmlOnlyButton->setChecked(true);
    }

    connect(addDevConfLabel, SIGNAL(linkActivated(QString)), this,
        SLOT(showDeviceConfigurationsDialog(QString)));
    connect(debuggerConfLabel, SIGNAL(linkActivated(QString)), this,
        SLOT(showDeviceConfigurationsDialog(QString)));
    connect(m_argsLineEdit, SIGNAL(textEdited(QString)), this,
        SLOT(argumentsEdited(QString)));
    connect(m_debugCppOnlyButton, SIGNAL(toggled(bool)), this,
        SLOT(handleDebuggingTypeChanged()));
    connect(m_debugQmlOnlyButton, SIGNAL(toggled(bool)), this,
        SLOT(handleDebuggingTypeChanged()));
    connect(m_debugCppAndQmlButton, SIGNAL(toggled(bool)), this,
        SLOT(handleDebuggingTypeChanged()));
    connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this,
        SLOT(updateTargetInformation()));
    connect(m_runConfiguration, SIGNAL(deploySpecsChanged()), SLOT(handleDeploySpecsChanged()));
    handleDeploySpecsChanged();
}
Пример #7
0
/// Display a form layout with an edit box
/// \param const QString& title title to display
/// \param const QScriptValue form to display (array containing labels and values)
/// \return QScriptValue result form (unchanged is dialog canceled)
QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptValue form) {
    if (form.isArray() && form.property("length").toInt32() > 0) {
        QDialog* editDialog = new QDialog(Application::getInstance()->getWindow());
        editDialog->setWindowTitle(title);
        
        QVBoxLayout* layout = new QVBoxLayout();
        editDialog->setLayout(layout);
        
        QScrollArea* area = new QScrollArea();
        layout->addWidget(area);
        area->setWidgetResizable(true);
        QWidget* container = new QWidget();
        QFormLayout* formLayout = new QFormLayout();
        container->setLayout(formLayout);
        container->sizePolicy().setHorizontalStretch(1);
        formLayout->setRowWrapPolicy(QFormLayout::DontWrapRows);
        formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
        formLayout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
        formLayout->setLabelAlignment(Qt::AlignLeft);
        
        area->setWidget(container);
        
        QVector<QLineEdit*> edits;
        for (int i = 0; i < form.property("length").toInt32(); ++i) {
            QScriptValue item = form.property(i);
            edits.push_back(new QLineEdit(item.property("value").toString()));
            formLayout->addRow(item.property("label").toString(), edits.back());
        }
        QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok);
        connect(buttons, SIGNAL(accepted()), editDialog, SLOT(accept()));
        layout->addWidget(buttons);
        
        if (editDialog->exec() == QDialog::Accepted) {
            for (int i = 0; i < form.property("length").toInt32(); ++i) {
                QScriptValue item = form.property(i);
                QScriptValue value = item.property("value");
                bool ok = true;
                if (value.isNumber()) {
                    value = edits.at(i)->text().toDouble(&ok);
                } else if (value.isString()) {
                    value = edits.at(i)->text();
                } else if (value.isBool()) {
                    if (edits.at(i)->text() == "true") {
                        value = true;
                    } else if (edits.at(i)->text() == "false") {
                        value = false;
                    } else {
                        ok = false;
                    }
                }
                if (ok) {
                    item.setProperty("value", value);
                    form.setProperty(i, item);
                }
            }
        }
        
        delete editDialog;
    }
    
    return form;
}
Пример #8
0
SVNCommitDialog::SVNCommitDialog(QWidget *parent, const QString &workingDir,
                                 const QStringList &files, bool folderOnly,
                                 int sceneIconAdded)
    : Dialog(TApp::instance()->getMainWindow(), true, false)
    , m_commitSceneContentsCheckBox(0)
    , m_workingDir(workingDir)
    , m_files(files)
    , m_folderOnly(folderOnly)
    , m_targetTempFile(0)
    , m_selectionCheckBox(0)
    , m_selectionLabel(0)
    , m_sceneIconAdded(sceneIconAdded)
    , m_folderAdded(0) {
  setModal(false);
  setAttribute(Qt::WA_DeleteOnClose, true);
  setWindowTitle(tr("Version Control: Put changes"));

  if (m_folderOnly)
    setMinimumSize(320, 320);
  else
    setMinimumSize(300, 180);

  QWidget *container = new QWidget;

  QVBoxLayout *mainLayout = new QVBoxLayout;
  mainLayout->setAlignment(Qt::AlignHCenter);
  mainLayout->setMargin(0);

  m_treeWidget = new QTreeWidget;
  m_treeWidget->header()->hide();
  m_treeWidget->hide();

  if (m_folderOnly) {
    m_treeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
    m_treeWidget->setIconSize(QSize(21, 17));
  }
  m_treeWidget->setStyleSheet("QTreeWidget { border: 1px solid gray; }");

  if (m_folderOnly) {
    mainLayout->addWidget(m_treeWidget);

    QHBoxLayout *belowTreeLayout = new QHBoxLayout;
    belowTreeLayout->setMargin(0);

    m_selectionCheckBox = new QCheckBox(tr("Select / Deselect All"), 0);
    connect(m_selectionCheckBox, SIGNAL(clicked(bool)), this,
            SLOT(onSelectionCheckBoxClicked(bool)));

    m_selectionLabel = new QLabel;
    m_selectionLabel->setText(tr("0 Selected / 0 Total"));

    m_selectionCheckBox->hide();
    m_selectionLabel->hide();

    belowTreeLayout->addWidget(m_selectionCheckBox);
    belowTreeLayout->addStretch();
    belowTreeLayout->addWidget(m_selectionLabel);

    mainLayout->addLayout(belowTreeLayout);
  }

  QHBoxLayout *hLayout = new QHBoxLayout;

  m_waitingLabel      = new QLabel;
  QMovie *waitingMove = new QMovie(":Resources/waiting.gif");
  waitingMove->setParent(this);

  m_waitingLabel->setMovie(waitingMove);
  waitingMove->setCacheMode(QMovie::CacheAll);
  waitingMove->start();

  m_textLabel = new QLabel;
  m_textLabel->setText(tr("Getting repository status..."));

  hLayout->addStretch();
  hLayout->addWidget(m_waitingLabel);
  hLayout->addWidget(m_textLabel);
  hLayout->addStretch();

  mainLayout->addLayout(hLayout);

  if (!m_folderOnly)
    mainLayout->addWidget(m_treeWidget);
  else
    mainLayout->addSpacing(10);

  QFormLayout *formLayout = new QFormLayout;
  formLayout->setLabelAlignment(Qt::AlignRight);
  formLayout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
  formLayout->setSpacing(10);
  formLayout->setMargin(0);

  m_commentTextEdit = new QPlainTextEdit;
  m_commentTextEdit->setMaximumHeight(50);
  m_commentTextEdit->hide();

  m_commentLabel = new QLabel(tr("Comment:"));
  m_commentLabel->setFixedWidth(55);
  m_commentLabel->hide();

  formLayout->addRow(m_commentLabel, m_commentTextEdit);

  if (!m_folderOnly) {
    m_commitSceneContentsCheckBox = new QCheckBox(this);
    connect(m_commitSceneContentsCheckBox, SIGNAL(toggled(bool)), this,
            SLOT(onCommiSceneContentsToggled(bool)));
    m_commitSceneContentsCheckBox->setChecked(false);
    m_commitSceneContentsCheckBox->hide();
    m_commitSceneContentsCheckBox->setText(tr("Put Scene Contents"));
    formLayout->addRow("", m_commitSceneContentsCheckBox);
  }
Пример #9
0
void wFileProps::createGUI() {

	QString mimeType = getMimeType( fileName );

	QFontDatabase fdb = QFontDatabase();
	fdb.addApplicationFont( ":/fonts/ArchitectsDaughter.ttf" );
	setStyleSheet( "font-family: Architects Daughter; font-size: 10;" );

	iconLbl = new QLabel();
	iconLbl->setPixmap( getPixmap( fileName ).scaled( 64, 64, Qt::KeepAspectRatio ) );

	nameLbl = new QLabel();
	nameLbl->setText( "<b>" + QFileInfo( fileName ).fileName() + "</b>" );
	nameLbl->setFont( QFont( "Architects Daughter", 15 ) );

	linesLbl = new QLabel( lines );
	wordsLbl = new QLabel( words );
	charsLbl= new QLabel( chars );

	if ( !noFileProps ) {
		typeLbl = new QLabel( mimeType );
		sizeLbl = new QLabel( formatSize( getSize( fileName ) ) );
		locLbl = new QLabel( QFileInfo( fileName ).absolutePath() );

		time1Lbl = new QLabel( QFileInfo( fileName ).created().toString( "ddd MMM dd, yyyy hh:mm:ss" ) );
		time2Lbl = new QLabel( QFileInfo( fileName ).lastRead().toString( "ddd MMM dd, yyyy hh:mm:ss" ) );
		time3Lbl = new QLabel( QFileInfo( fileName ).lastModified().toString( "ddd MMM dd, yyyy hh:mm:ss" ) );
	}

	QPushButton *closeBtn = new QPushButton();
	closeBtn->setText( "&Close" );
	connect( closeBtn, SIGNAL( clicked() ), this, SLOT( close() ) );

	QVBoxLayout *baseLyt = new QVBoxLayout();
	QHBoxLayout *nameLyt = new QHBoxLayout();
	QFormLayout *textInfoLyt = new QFormLayout();
	QFormLayout *fileInfoLyt = new QFormLayout();
	QHBoxLayout *btnLyt = new QHBoxLayout();

	nameLyt->setAlignment( Qt::AlignCenter );
	nameLyt->addWidget( iconLbl );
	nameLyt->addWidget( nameLbl );

	textInfoLyt->addRow( new QLabel( "<b>Lines: </b>" ), linesLbl );
	textInfoLyt->addRow( new QLabel( "<b>Words: </b>" ), wordsLbl );
	textInfoLyt->addRow( new QLabel( "<b>Chars: </b>" ), charsLbl );
	textInfoLyt->setFormAlignment( Qt::AlignHCenter | Qt::AlignTop );

	if ( !noFileProps ) {
		fileInfoLyt->addRow( new QLabel( "<b>Type: </b>" ), typeLbl );
		fileInfoLyt->addRow( new QLabel( "<b>Size: </b>" ), sizeLbl );
		fileInfoLyt->addRow( new QLabel( "<b>Location: </b>" ), locLbl );
		fileInfoLyt->addRow( new QLabel( "<b>Created: </b>" ), time1Lbl );
		fileInfoLyt->addRow( new QLabel( "<b>Accessed: </b>" ), time2Lbl );
		fileInfoLyt->addRow( new QLabel( "<b>Modified: </b>" ), time3Lbl );
	}

	btnLyt->addStretch( 0 );
	btnLyt->addWidget( closeBtn );
	btnLyt->addStretch( 0 );

	QFrame *textFrame = new QFrame();
	textFrame->setFrameStyle( QFrame::StyledPanel | QFrame::Plain );
	textFrame->setLayout( textInfoLyt );

	QFrame *fileFrame = new QFrame();
	fileFrame->setFrameStyle( QFrame::StyledPanel | QFrame::Plain );
	fileFrame->setLayout( fileInfoLyt );

	baseLyt->addLayout( nameLyt );
	baseLyt->addStretch( 0 );
	baseLyt->addWidget( textFrame );
	if ( !noFileProps ) {
		baseLyt->addStretch( 0 );
		baseLyt->addWidget( fileFrame );
	}
	baseLyt->addStretch( 0 );
	baseLyt->addLayout( btnLyt );

	setLayout( baseLyt );
};
Пример #10
0
void msg_dialog_frame::Create(const std::string& msg)
{
	if (m_dialog)
	{
		m_dialog->close();
		delete m_dialog;
	}

	m_dialog = new custom_dialog(type.disable_cancel);
	m_dialog->setWindowTitle(type.se_normal ? "Normal dialog" : "Error dialog");
	m_dialog->setWindowFlags(m_dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint);
	m_dialog->setWindowOpacity(type.bg_invisible ? 1.0 : 192.0 / 255.0);

	m_text = new QLabel(qstr(msg));
	m_text->setAlignment(Qt::AlignCenter);

	//Layout
	QFormLayout* layout = new QFormLayout(m_dialog);
	layout->setFormAlignment(Qt::AlignHCenter);
	layout->addRow(m_text);

	auto l_AddGauge = [=] (QProgressBar* &bar, QLabel* &text)
	{
		text = new QLabel("", m_dialog);
		bar = new QProgressBar(m_dialog);
		bar->setRange(0, m_gauge_max);
		bar->setFixedWidth(300);
		bar->setAlignment(Qt::AlignCenter);

		QHBoxLayout* barLayout = new QHBoxLayout;
		barLayout->addStretch();
		barLayout->addWidget(bar);
		barLayout->addStretch();

		QHBoxLayout* textLayout = new QHBoxLayout;
		textLayout->setAlignment(Qt::AlignCenter);
		textLayout->addWidget(text);

		layout->addRow(textLayout);
		layout->addRow(barLayout);
	};

	if (type.progress_bar_count >= 1)
	{
		l_AddGauge(m_gauge1, m_text1);

#ifdef _WIN32
		m_tb_button = new QWinTaskbarButton();
		m_tb_button->setWindow(m_taskbarTarget);
		m_tb_progress = m_tb_button->progress();
		m_tb_progress->setRange(0, m_gauge_max);
		m_tb_progress->setVisible(true);
#endif
	}

	if (type.progress_bar_count >= 2)
	{
		l_AddGauge(m_gauge2, m_text2);
	}

	if (type.button_type.unshifted() == CELL_MSGDIALOG_TYPE_BUTTON_TYPE_YESNO)
	{
		m_dialog->setModal(true);

		m_button_yes = new QPushButton("&Yes", m_dialog);
		m_button_no = new QPushButton("&No", m_dialog);

		QHBoxLayout* hBoxButtons = new QHBoxLayout;
		hBoxButtons->setAlignment(Qt::AlignCenter);
		hBoxButtons->addWidget(m_button_yes);
		hBoxButtons->addWidget(m_button_no);
		layout->addRow(hBoxButtons);

		if (type.default_cursor == 1)
		{
			m_button_no->setFocus();
		}
		else
		{
			m_button_yes->setFocus();
		}
		connect(m_button_yes, &QAbstractButton::clicked, [=] {on_close(CELL_MSGDIALOG_BUTTON_YES); m_dialog->accept(); });
		connect(m_button_no, &QAbstractButton::clicked, [=] {on_close(CELL_MSGDIALOG_BUTTON_NO); m_dialog->accept(); });
	}

	if (type.button_type.unshifted() == CELL_MSGDIALOG_TYPE_BUTTON_TYPE_OK)
	{
		m_dialog->setModal(true);

		m_button_ok = new QPushButton("&OK", m_dialog);
		m_button_ok->setFixedWidth(50);

		QHBoxLayout* hBoxButtons = new QHBoxLayout;
		hBoxButtons->setAlignment(Qt::AlignCenter);
		hBoxButtons->addWidget(m_button_ok);
		layout->addRow(hBoxButtons);

		if (type.default_cursor == 0)
		{
			m_button_ok->setFocus();
		}
		connect(m_button_ok, &QAbstractButton::clicked, [=] { on_close(CELL_MSGDIALOG_BUTTON_OK); m_dialog->accept(); });
	}

	m_dialog->setLayout(layout);

	connect(m_dialog, &QDialog::rejected, [=] {if (!type.disable_cancel) { on_close(CELL_MSGDIALOG_BUTTON_ESCAPE); }});

	//Fix size
	m_dialog->setFixedSize(m_dialog->sizeHint());
	m_dialog->show();
}
Пример #11
0
QWidget* ProcessingManager::setupQueueContainer() {
    queueModel_ = new ProcessingModel(this);
    connect(&projectData, &ProjectData::toBeAddedToProcessingQueue, queueModel_, &ProcessingModel::addProcesses);
    
    QFormLayout* layout = new QFormLayout;
    layout->setHorizontalSpacing(10);
    layout->setVerticalSpacing(2);
    layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
    layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
    layout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
    layout->setLabelAlignment(Qt::AlignLeft);

    int numberOfThreads = QThread::idealThreadCount();
    if(numberOfThreads < 1) numberOfThreads = 1;
    
    processesBox_ = new QSpinBox;
    processesBox_->setFrame(false);
    processesBox_->setMinimum(1);
    processesBox_->setMaximum(numberOfThreads);
    processesBox_->setValue(ProjectPreferences().processJobs());
    connect(processesBox_, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), [=](int value){
        ProjectPreferences().setProcessJobs(value);
    });
    layout->addRow("Number of jobs to run in parallel", processesBox_);
    
    QLabel* introLabel = new QLabel("The maximum number of threads on your system is: " + QString::number(numberOfThreads));
    introLabel->setWordWrap(true);
    QPalette pal = introLabel->palette();
    pal.setColor(QPalette::WindowText, Qt::darkGray);
    introLabel->setPalette(pal);
    layout->addRow(introLabel);
    
    GroupContainer* jobcontainer = new GroupContainer;
    jobcontainer->setTitle("Concurrency Selection");
    jobcontainer->setContainerLayout(layout);
    
    QToolButton* addSelectedButton = getButton("add_queue", "Add Images", "Add selected images from the project library to the processing queue");
    connect(addSelectedButton, &GraphicalButton::clicked, [=]() {
        projectData.addSelectedToQueue();
    });
    
    QToolButton* clearSelectedButton = getButton("remove_highlighted", "Clear Selected", "Remove highlighted images from the processing queue");
    connect(clearSelectedButton, &GraphicalButton::clicked, [=]() {
        while(!queueView_->selectionModel()->selectedIndexes().isEmpty()) {
            QModelIndex i = queueView_->selectionModel()->selectedIndexes().first();
            if(!i.parent().isValid()) {
                queueModel_->removeRow(i.row());
            }
        }
        
        setQueueCount(queueModel_->rowCount());
    });
    
    QToolButton* clearAllButton = getButton("remove_all", "Clear All", "Remove all images from queue");
    connect(clearAllButton, &GraphicalButton::clicked, queueModel_, &ProcessingModel::clearAll);
    
    QToolButton* prioritizeButton = getButton("prioritize_highlighted", "Prioritize", "Prioritize the processing of highlighted images");
    connect(prioritizeButton, &GraphicalButton::clicked, [=]() {
        for(QModelIndex i : queueView_->selectionModel()->selectedRows(0)) {
            if(!i.parent().isValid()) {
                queueModel_->insertRow(0, queueModel_->takeRow(i.row()));
            }
        }
    });
    
    QHBoxLayout* buttonLayout = new QHBoxLayout();
    buttonLayout->addStretch(0);
    buttonLayout->addWidget(addSelectedButton, 0);
    buttonLayout->addStretch(1);
    buttonLayout->addWidget(prioritizeButton, 0);
    buttonLayout->addWidget(clearAllButton, 0);
    buttonLayout->addWidget(clearSelectedButton, 0);
    
    
    queueView_ = new QTreeView(this);
    queueView_->setAttribute(Qt::WA_MacShowFocusRect, 0);
    queueView_->setModel(queueModel_);
    queueView_->setSelectionMode(QAbstractItemView::ExtendedSelection);
    queueView_->setSortingEnabled(true);
    queueView_->setAllColumnsShowFocus(true);
    queueView_->setAlternatingRowColors(true);
    queueView_->setFrameStyle(QFrame::StyledPanel | QFrame::Plain);
    queueView_->setHeaderHidden(true);
    
    BlockContainer* queueContainer = new BlockContainer("Images in queue", queueView_);
    
    QVBoxLayout *queueLayout = new QVBoxLayout;
    queueLayout->setMargin(10);
    queueLayout->setSpacing(10);
    queueLayout->addLayout(buttonLayout, 0);
    queueLayout->addWidget(queueContainer, 1);

    GroupContainer* container = new GroupContainer;
    container->setTitle("Processing Queue");
    container->setContainerLayout(queueLayout);
    
    
    QVBoxLayout* mainLayout = new QVBoxLayout();
    mainLayout->setMargin(0);
    mainLayout->setSpacing(10);
    mainLayout->addStretch(0);
    mainLayout->addWidget(jobcontainer, 0);
    mainLayout->addWidget(container, 1);
    
    QWidget* mainContainer = new QWidget;
    mainContainer->setLayout(mainLayout);
    mainContainer->setMaximumWidth(500);
    
    return mainContainer;
}
Пример #12
0
HistoryWidget::HistoryWidget(QWidget *parent)
    : QDialog(parent)
{
    setObjectName("HistoryWidget");
    setWindowTitle(tr("History Data View"));

    // layout - top
    QHBoxLayout *horiLayoutTop = new QHBoxLayout();

    QPushButton *buttonQuit = new QPushButton(this);
    buttonQuit->setObjectName("buttonQuit");
    horiLayoutTop->addSpacing(25);
    horiLayoutTop->addWidget(buttonQuit, 0, Qt::AlignLeft);
    horiLayoutTop->addStretch();

    // button-export
    QPushButton *buttonExport = new QPushButton(this);
    buttonExport->setObjectName("buttonExport");
    horiLayoutTop->addWidget(buttonExport);
    horiLayoutTop->addStretch();

    // button-open
    QPushButton *buttonOpen = new QPushButton(this);
    buttonOpen->setObjectName("buttonOpen");
    horiLayoutTop->addWidget(buttonOpen);
    horiLayoutTop->addStretch();

    QFormLayout *formLayoutTime = new QFormLayout();
    formLayoutTime->setFormAlignment(Qt::AlignVCenter);
    horiLayoutTop->addLayout(formLayoutTime);
    horiLayoutTop->addStretch();

    QDateTimeEdit *dateTimeEditStart = new QDateTimeEdit(this);
    dateTimeEditStart->setObjectName("dateTimeEditStart");
    dateTimeEditStart->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
    formLayoutTime->addRow(tr("Start Time:"), dateTimeEditStart);

    QDateTimeEdit *dateTimeEditEnd = new QDateTimeEdit(this);
    dateTimeEditEnd->setObjectName("dateTimeEditEnd");
    dateTimeEditEnd->setDisplayFormat("yyyy-MM-dd HH:mm:ss");
    formLayoutTime->addRow(tr("End Time:"), dateTimeEditEnd);

    //LBP
    QFormLayout *formLayoutLBP = new QFormLayout();
    formLayoutLBP->setFormAlignment(Qt::AlignVCenter);
    formLayoutLBP->setLabelAlignment(Qt::AlignRight);
    horiLayoutTop->addLayout(formLayoutLBP);
    horiLayoutTop->addStretch();
    QCheckBox *checkBoxLBPMajor = new QCheckBox(tr("Major"), this);
    checkBoxLBPMajor->setProperty("curveColor", "#101010");
    QCheckBox *checkBoxLBPMinor = new QCheckBox(tr("Minor"), this);
    checkBoxLBPMinor->setProperty("curveColor", "#101010");
    formLayoutLBP->addRow(tr("LBP:"), checkBoxLBPMajor);
    formLayoutLBP->addRow("", checkBoxLBPMinor);

    //RBP
    QFormLayout *formLayoutRBP = new QFormLayout();
    formLayoutRBP->setFormAlignment(Qt::AlignVCenter);
    formLayoutRBP->setLabelAlignment(Qt::AlignRight);
    horiLayoutTop->addLayout(formLayoutRBP);
    horiLayoutTop->addStretch();
    QCheckBox *checkBoxRBPMajor = new QCheckBox(tr("Major"), this);
    checkBoxRBPMajor->setProperty("curveColor", "#101010");
    QCheckBox *checkBoxRBPMinor = new QCheckBox(tr("Minor"), this);
    checkBoxRBPMinor->setProperty("curveColor", "#101010");
    formLayoutRBP->addRow(tr("RBP:"), checkBoxRBPMajor);
    formLayoutRBP->addRow("", checkBoxRBPMinor);

    //LRP
    QFormLayout *formLayoutLRP = new QFormLayout();
    formLayoutLRP->setFormAlignment(Qt::AlignVCenter);
    formLayoutLRP->setLabelAlignment(Qt::AlignRight);
    horiLayoutTop->addLayout(formLayoutLRP);
    horiLayoutTop->addStretch();
    QCheckBox *checkBoxLRPTheory = new QCheckBox(tr("Theory"), this);
    checkBoxLRPTheory->setProperty("curveColor", "#101010");
    QCheckBox *checkBoxLRPReal = new QCheckBox(tr("Real"), this);
    checkBoxLRPReal->setProperty("curveColor", "#101010");
    formLayoutLRP->addRow(tr("LRP:"), checkBoxLRPTheory);
    formLayoutLRP->addRow("", checkBoxLRPReal);

    //RRP
    QFormLayout *formLayoutRRP = new QFormLayout();
    formLayoutRRP->setFormAlignment(Qt::AlignVCenter);
    formLayoutRRP->setLabelAlignment(Qt::AlignRight);
    horiLayoutTop->addLayout(formLayoutRRP);
    horiLayoutTop->addStretch();
    QCheckBox *checkBoxRRPTheory = new QCheckBox(tr("Theory"), this);
    checkBoxRRPTheory->setProperty("curveColor", "#101010");
    QCheckBox *checkBoxRRPReal = new QCheckBox(tr("Real"), this);
    checkBoxRRPReal->setProperty("curveColor", "#101010");
    formLayoutRRP->addRow(tr("RRP:"), checkBoxRRPTheory);
    formLayoutRRP->addRow("", checkBoxRRPReal);

    // button-update
    QPushButton *buttonUpdate = new QPushButton(this);
    buttonUpdate->setObjectName("buttonUpdate");
    horiLayoutTop->addWidget(buttonUpdate);
    horiLayoutTop->addStretch();
/*
    // button-undo
    QPushButton *buttonUndo = new QPushButton(this);
    buttonUndo->setObjectName("buttonUndo");
    horiLayoutTop->addWidget(buttonUndo);
    horiLayoutTop->addStretch();
*/
    // middle - curves
    CurveWidget* curveHistory = new CurveWidget(tr("History Data View"), this, true);
    curveHistory->setMaximumWidth(10000000);
    curveHistory->setScaleLabelFormat("yyyy/MM/dd\n  HH:mm:ss");
    curveHistory->clear();

    QVBoxLayout *vertLayoutMain = new QVBoxLayout(this);
    vertLayoutMain->addLayout(horiLayoutTop);
    vertLayoutMain->addWidget(curveHistory);

    connect(buttonQuit, &QPushButton::clicked, this, [=](){
        this->accept();
    });

    connect(buttonOpen, &QPushButton::clicked, this, [=](){
        QFileDialog fileDialog(this,
                               tr("Open history database files"),
                               QApplication::applicationDirPath().append("/../data"),
                               tr("Data Base File (*.db *.mdb)"));
        if (fileDialog.exec() == QDialog::Rejected) {
            return;
        }

        // clear curve
        curveHistory->clear();

        //
        QStringList filePaths = fileDialog.selectedFiles();
        if (filePaths.isEmpty()) {
            return;
        }

        QString filePath = filePaths.first();
        if (filePath.isEmpty()) {
            return;
        }

        // open database
        if (!DataBaseMgr::instance().open(filePath)) {
            Q_ASSERT(false);
            return;
        }

        //
        QDateTime startTime = QDateTime::fromMSecsSinceEpoch(DataBaseMgr::instance().startTime());
        QDateTime endTime = QDateTime::fromMSecsSinceEpoch(DataBaseMgr::instance().endTime());
        dateTimeEditStart->setDateTimeRange(startTime, endTime);
        dateTimeEditEnd->setDateTimeRange(startTime, endTime);
        dateTimeEditEnd->setDateTime(endTime);
        dateTimeEditStart->setDateTime(startTime);

        // curve title
        curveHistory->setTitle(tr("History Data View")
                               .append(" (")
                               .append(QFileInfo(filePath).fileName())
                               .append(")"));
    });
    connect(buttonExport, &QPushButton::clicked, this, [=](){
        QStringList filePaths = QFileDialog::getOpenFileNames(this,
                                                              tr("Convert data base files to txt format and save..."),
                                                              QApplication::applicationDirPath().append("/../data"),
                                                              tr("Data Base File (*.db *.mdb)"));
        if (filePaths.isEmpty()) {
            return;
        }

        //
        if (DataBaseMgr::instance().convertToText(filePaths)) {
            QMessageBox::information(this, tr("Convert Database file"), tr("Convert successfully!"));
        } else {
            QMessageBox::information(this, tr("Convert Database file"), tr("Convert failed!"));
        }
    });

    connect(dateTimeEditStart, &QDateTimeEdit::dateTimeChanged, this, [=](const QDateTime &dateTime){
        QDateTime endDateTime = dateTimeEditEnd->dateTime();
        if (dateTime > endDateTime) {
            dateTimeEditStart->setDateTime(endDateTime);
        }
    });

    connect(dateTimeEditEnd, &QDateTimeEdit::dateTimeChanged, this, [=](const QDateTime &dateTime){
        QDateTime startDateTime = dateTimeEditStart->dateTime();
        if (dateTime < startDateTime) {
            dateTimeEditEnd->setDateTime(startDateTime);
        }
    });

    connect(checkBoxLBPMajor, &QCheckBox::toggled, this, [=](bool checked){
        _v_curve_checked[0] = checked;
    });
    connect(checkBoxLBPMinor, &QCheckBox::toggled, this, [=](bool checked){
        _v_curve_checked[1] = checked;
    });
    connect(checkBoxRBPMajor, &QCheckBox::toggled, this, [=](bool checked){
        _v_curve_checked[2] = checked;
    });
    connect(checkBoxRBPMinor, &QCheckBox::toggled, this, [=](bool checked){
        _v_curve_checked[3] = checked;
    });
    connect(checkBoxLRPTheory, &QCheckBox::toggled, this, [=](bool checked){
        _v_curve_checked[4] = checked;
    });
    connect(checkBoxLRPReal, &QCheckBox::toggled, this, [=](bool checked){
        _v_curve_checked[5] = checked;
    });
    connect(checkBoxRRPTheory, &QCheckBox::toggled, this, [=](bool checked){
        _v_curve_checked[6] = checked;
    });
    connect(checkBoxRRPReal, &QCheckBox::toggled, this, [=](bool checked){
        _v_curve_checked[7] = checked;
    });

    connect(buttonUpdate, &QPushButton::clicked, this, [=](){
        // clear curve
        curveHistory->clear();

        QVector<QPointF> points;
        quint64 startTime = dateTimeEditStart->dateTime().toMSecsSinceEpoch();
        quint64 endTime = dateTimeEditEnd->dateTime().toMSecsSinceEpoch();

        // LBP-Major
        if (checkBoxLBPMajor->isChecked()) {
            // read
            points.clear();
            if (DataBaseMgr::instance().read("lMBrakeP", points, startTime, endTime)) {
                curveHistory->addCurve(tr("LBP-Major"), QPen(randomColor(0)), points);
            }
        }

        //QApplication::processEvents();

        // LBP-Minor
        if (checkBoxLBPMinor->isChecked()) {
            // read
            points.clear();
            if (DataBaseMgr::instance().read("lABrakeP", points, startTime, endTime)) {
                curveHistory->addCurve(tr("LBP-Minor"), QPen(randomColor(1)), points);
            }
        }

        //QApplication::processEvents();

        // RBP-Major
        if (checkBoxRBPMajor->isChecked()) {
            // read
            points.clear();
            if (DataBaseMgr::instance().read("rMBrakeP", points, startTime, endTime)) {
                curveHistory->addCurve(tr("RBP-Major"), QPen(randomColor(2)), points);
            }
        }

        //QApplication::processEvents();

        // RBP-Minor
        if (checkBoxRBPMinor->isChecked()) {
            // read
            points.clear();
            if (DataBaseMgr::instance().read("rABrakeP", points, startTime, endTime)) {
                curveHistory->addCurve(tr("RBP-Minor"), QPen(randomColor(3)), points);
            }
        }

        //QApplication::processEvents();

        // LRP-Theory
        if (checkBoxLRPTheory->isChecked()) {
            // read
            points.clear();
            if (DataBaseMgr::instance().read("lTheorySpd", points, startTime, endTime)) {
                curveHistory->addCurve(tr("LRP-Theory"), QPen(randomColor(4)), points);
            }
        }

        //QApplication::processEvents();

        // LRP-Real
        if (checkBoxLRPReal->isChecked()) {
            // read
            points.clear();
            if (DataBaseMgr::instance().read("lWheelSpd", points, startTime, endTime)) {
                curveHistory->addCurve(tr("LRP-Real"), QPen(randomColor(5)), points);
            }
        }

        //QApplication::processEvents();

        // RRP-Theory
        if (checkBoxRRPTheory->isChecked()) {
            // read
            points.clear();
            if (DataBaseMgr::instance().read("rTheorySpd", points, startTime, endTime)) {
                curveHistory->addCurve(tr("RRP-Theory"), QPen(randomColor(6)), points);
            }
        }

        //QApplication::processEvents();

        // RRP-Real
        if (checkBoxRRPReal->isChecked()) {
            // read
            points.clear();
            if (DataBaseMgr::instance().read("rWheelSpd", points, startTime, endTime)) {
                curveHistory->addCurve(tr("RRP-Real"), QPen(randomColor(7)), points);
            }
        }
    });
/*
    connect(buttonUndo, &QPushButton::clicked, this, [=](){
        curveHistory->setNormalScale();
    });
*/
    // finaly initialize
    checkBoxLBPMajor->setChecked(_v_curve_checked[0]);
    checkBoxLBPMinor->setChecked(_v_curve_checked[1]);
    checkBoxRBPMajor->setChecked(_v_curve_checked[2]);
    checkBoxRBPMinor->setChecked(_v_curve_checked[3]);
    checkBoxLRPTheory->setChecked(_v_curve_checked[4]);
    checkBoxLRPReal->setChecked(_v_curve_checked[5]);
    checkBoxRRPTheory->setChecked(_v_curve_checked[6]);
    checkBoxRRPReal->setChecked(_v_curve_checked[7]);
}
Пример #13
0
void osk_dialog_frame::Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 options)
{
	state = OskDialogState::Open;

	static const auto& lineEditWidth = []() {return QLabel("This is the very length of the lineedit due to hidpi reasons.").sizeHint().width(); };

	if (m_dialog)
	{
		m_dialog->close();
		delete m_dialog;
	}

	m_dialog = new custom_dialog(false);
	m_dialog->setModal(true);

	// Title
	m_dialog->setWindowTitle(qstr(title));

	// Message
	QLabel* message_label = new QLabel(QString::fromStdU16String(message));

	// Text Input Counter
	const QString text = QString::fromStdU16String(std::u16string(init_text));
	QLabel* inputCount = new QLabel(QString("%1/%2").arg(text.length()).arg(charlimit));

	// Ok Button
	QPushButton* button_ok = new QPushButton("Ok", m_dialog);

	// Button Layout
	QHBoxLayout* buttonsLayout = new QHBoxLayout;
	buttonsLayout->setAlignment(Qt::AlignCenter);
	buttonsLayout->addStretch();
	buttonsLayout->addWidget(button_ok);
	buttonsLayout->addStretch();

	// Input Layout
	QHBoxLayout* inputLayout = new QHBoxLayout;
	inputLayout->setAlignment(Qt::AlignHCenter);

	// Text Input
	if (options & CELL_OSKDIALOG_NO_RETURN)
	{
		QLineEdit* input = new QLineEdit(m_dialog);
		input->setFixedWidth(lineEditWidth());
		input->setMaxLength(charlimit);
		input->setText(text);
		input->setFocus();

		if (options & CELL_OSKDIALOG_NO_SPACE)
		{
			input->setValidator(new QRegExpValidator(QRegExp("^\\S*$"), this));
		}

		connect(input, &QLineEdit::textChanged, [=](const QString& text)
		{
			inputCount->setText(QString("%1/%2").arg(text.length()).arg(charlimit));
			SetOskText(text);
			on_osk_input_entered();
		});
		connect(input, &QLineEdit::returnPressed, m_dialog, &QDialog::accept);

		inputLayout->addWidget(input);
	}
	else
	{
		QTextEdit* input = new QTextEdit(m_dialog);
		input->setFixedWidth(lineEditWidth());
		input->setText(text);
		input->setFocus();
		input->moveCursor(QTextCursor::End);
		m_text_old = text;

		connect(input, &QTextEdit::textChanged, [=]()
		{
			QString text = input->toPlainText();

			if (text == m_text_old)
			{
				return;
			}

			QTextCursor cursor = input->textCursor();
			const int cursor_pos_new = cursor.position();
			const int cursor_pos_old = cursor_pos_new + m_text_old.length() - text.length();

			// Reset to old state if character limit was reached
			if ((u32)m_text_old.length() >= charlimit && (u32)text.length() > charlimit)
			{
				input->blockSignals(true);
				input->setPlainText(m_text_old);
				cursor.setPosition(cursor_pos_old);
				input->setTextCursor(cursor);
				input->blockSignals(false);
				return;
			}

			int cursor_pos = cursor.position();

			// Clear text of spaces if necessary
			if (options & CELL_OSKDIALOG_NO_SPACE)
			{
				int trim_len = text.length();
				text.remove(QRegExp("\\s+"));
				trim_len -= text.length();
				cursor_pos -= trim_len;
			}

			// Crop if more than one character was pasted and the character limit was exceeded
			text.chop(text.length() - charlimit);

			// Set new text and block signals to prevent infinite loop
			input->blockSignals(true);
			input->setPlainText(text);
			cursor.setPosition(cursor_pos);
			input->setTextCursor(cursor);
			input->blockSignals(false);

			m_text_old = text;

			inputCount->setText(QString("%1/%2").arg(text.length()).arg(charlimit));
			SetOskText(text);
			on_osk_input_entered();
		});

		inputLayout->addWidget(input);
	}

	inputLayout->addWidget(inputCount);

	QFormLayout* layout = new QFormLayout(m_dialog);
	layout->setFormAlignment(Qt::AlignHCenter);
	layout->addRow(message_label);
	layout->addRow(inputLayout);
	layout->addRow(buttonsLayout);
	m_dialog->setLayout(layout);

	// Events
	connect(button_ok, &QAbstractButton::clicked, m_dialog, &QDialog::accept);

	connect(m_dialog, &QDialog::accepted, [=]
	{
		on_osk_close(CELL_MSGDIALOG_BUTTON_OK);
	});

	connect(m_dialog, &QDialog::rejected, [=]
	{
		on_osk_close(CELL_MSGDIALOG_BUTTON_ESCAPE);
	});

	// Fix size
	m_dialog->layout()->setSizeConstraint(QLayout::SetFixedSize);
	m_dialog->show();
}