QString DVGui::getText(const QString &title, const QString &labelText, const QString &text, bool *ok) { Dialog dialog(0, true); dialog.setWindowTitle(title); dialog.setWindowFlags(Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | Qt::CustomizeWindowHint); QVBoxLayout *layout = new QVBoxLayout(&dialog); dialog.addLayout(layout); QLabel *label = new QLabel(labelText, &dialog); layout->addWidget(label); LineEdit *nameFld = new LineEdit(text, &dialog); layout->addWidget(nameFld); QPushButton *okBtn = new QPushButton(dialog.tr("OK"), &dialog); okBtn->setDefault(true); QPushButton *cancelBtn = new QPushButton(dialog.tr("Cancel"), &dialog); QObject::connect(okBtn, SIGNAL(clicked()), &dialog, SLOT(accept())); QObject::connect(cancelBtn, SIGNAL(clicked()), &dialog, SLOT(reject())); dialog.addButtonBarWidget(okBtn, cancelBtn); int ret = dialog.exec(); if (ok) *ok = (ret == QDialog::Accepted); return nameFld->text(); }
NewProjectDialog() { VBoxContainer *vb = memnew( VBoxContainer ); add_child(vb); set_child_rect(vb); Label* l = memnew(Label); l->set_text("Project Path:"); vb->add_child(l); pp=l; project_path = memnew( LineEdit ); MarginContainer *mc = memnew( MarginContainer ); vb->add_child(mc); HBoxContainer *pphb = memnew( HBoxContainer ); mc->add_child(pphb); pphb->add_child(project_path); project_path->set_h_size_flags(SIZE_EXPAND_FILL); Button* browse = memnew( Button ); pphb->add_child(browse); browse->set_text("Browse"); browse->connect("pressed", this,"_browse_path"); l = memnew(Label); l->set_text("Project Name:"); l->set_pos(Point2(5,50)); vb->add_child(l); pn=l; project_name = memnew( LineEdit ); mc = memnew( MarginContainer ); vb->add_child(mc); mc->add_child(project_name); project_name->set_text("New Game Project"); l = memnew(Label); l->set_text("That's a BINGO!"); vb->add_child(l); error=l; l->add_color_override("font_color",Color(1,0.4,0.3,0.8)); l->set_align(Label::ALIGN_CENTER); get_ok()->set_text("Create"); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); project_path->set_text(d->get_current_dir()); memdelete(d); fdialog = memnew( FileDialog ); add_child(fdialog); fdialog->set_access(FileDialog::ACCESS_FILESYSTEM); project_name->connect("text_changed", this,"_text_changed"); project_path->connect("text_changed", this,"_path_text_changed"); fdialog->connect("dir_selected", this,"_path_selected"); fdialog->connect("file_selected", this,"_file_selected"); set_hide_on_ok(false); import_mode=false; }
void create() { setTitle("Test Application"); setGeometry(Geometry(128, 128, 640, 480 )); layout.append(bProcess); layout.append(lvOutput); layout.append(baseN); layout.append(baseR); unsigned bn = integer(baseN.text()), br = integer(baseR.text()); if (br>=0 && br<=bn) { lstring hdr; for (unsigned i = 0; i < br; ++i) { hdr.append((string){i>0?",":"","B",i+1}); } lvOutput.setHeaderText(hdr); } bProcess.setText("Draw!"); bProcess.onActivate = [&]() { lvOutput.reset(); }; //Hook it all up append(layout); onClose = [&layout] { // layout.setSkipGeomUpdates(true); //Example of skipping pointless update calculations. OS::quit(); }; setVisible(); }
EditorMeshImportDialog(EditorMeshImportPlugin *p_plugin) { plugin=p_plugin; set_title(TTR("Single Mesh Import")); set_hide_on_ok(false); VBoxContainer *vbc = memnew( VBoxContainer ); add_child(vbc); //set_child_rect(vbc); HBoxContainer *hbc = memnew( HBoxContainer ); vbc->add_margin_child(TTR("Source Mesh(es):"),hbc); import_path = memnew( LineEdit ); import_path->set_h_size_flags(SIZE_EXPAND_FILL); hbc->add_child(import_path); Button * import_choose = memnew( Button ); import_choose->set_text(" .. "); hbc->add_child(import_choose); import_choose->connect("pressed", this,"_browse"); hbc = memnew( HBoxContainer ); vbc->add_margin_child(TTR("Target Path:"),hbc); save_path = memnew( LineEdit ); save_path->set_h_size_flags(SIZE_EXPAND_FILL); hbc->add_child(save_path); Button * save_choose = memnew( Button ); save_choose->set_text(" .. "); hbc->add_child(save_choose); save_choose->connect("pressed", this,"_browse_target"); file_select = memnew( EditorFileDialog ); file_select->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_select->set_mode(EditorFileDialog::MODE_OPEN_FILES); file_select->add_filter("*.obj ; Wavefront OBJ"); add_child(file_select); file_select->connect("files_selected", this,"_choose_files"); save_select = memnew( EditorDirDialog ); add_child(save_select); save_select->connect("dir_selected", this,"_choose_save_dir"); get_ok()->connect("pressed", this,"_import"); get_ok()->set_text(TTR("Import")); error_dialog = memnew( AcceptDialog ); add_child(error_dialog); options = memnew( _EditorMeshImportOptions ); option_editor = memnew( PropertyEditor ); option_editor->hide_top_label(); vbc->add_margin_child(TTR("Options:"),option_editor,true); }
void HelloGUI::InitControls() { // Create a CheckBox CheckBox* checkBox = new CheckBox(context_); checkBox->SetName("CheckBox"); // Create a Button Button* button = new Button(context_); button->SetName("Button"); button->SetMinHeight(24); // Create a LineEdit LineEdit* lineEdit = new LineEdit(context_); lineEdit->SetName("LineEdit"); lineEdit->SetMinHeight(24); // Add controls to Window window_->AddChild(checkBox); window_->AddChild(button); window_->AddChild(lineEdit); // Apply previously set default style checkBox->SetStyleAuto(); button->SetStyleAuto(); lineEdit->SetStyleAuto(); }
//------------------------------------------------------------------------------ void ConditionValueDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { switch (field(index)) { case AssignmentRule::Date: { QDateEdit* dateEditor = static_cast<QDateEdit*>(editor); QDate date = dateEditor->date(); model->setData(index, date.toString(Qt::ISODate), Qt::EditRole); } break; case AssignmentRule::Amount: { MoneyEdit* moneyEditor = static_cast<MoneyEdit*>(editor); Money amount = moneyEditor->value(); QString newVal = QString("%1,%2") .arg(amount.amount()).arg(amount.currency().code()); model->setData(index, newVal, Qt::EditRole); } break; default: { LineEdit* stringEditor = static_cast<LineEdit*>(editor); model->setData(index, stringEditor->text(), Qt::EditRole); } } }
bool LineEdit::OnDragDropFinish(UIElement* source) { if (source && editable_) { // If the UI element in question has a drag-and-drop content string defined, use it instead of element text if (source->GetVars().Contains(VAR_DRAGDROPCONTENT)) { SetText(source->GetVar(VAR_DRAGDROPCONTENT).GetString()); return true; } StringHash sourceType = source->GetType(); if (sourceType == LineEdit::GetTypeStatic()) { LineEdit* sourceLineEdit = static_cast<LineEdit*>(source); SetText(sourceLineEdit->GetText()); return true; } else if (sourceType == Text::GetTypeStatic()) { Text* sourceText = static_cast<Text*>(source); SetText(sourceText->GetText()); return true; } } return false; }
void popup_import(const String& p_path) { popup_centered(Size2(400,400)); if (p_path!="") { Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_path); ERR_FAIL_COND(!rimd.is_valid()); save_path->set_text(p_path.get_base_dir()); List<String> opts; rimd->get_options(&opts); for(List<String>::Element *E=opts.front();E;E=E->next()) { options->_set(E->get(),rimd->get_option(E->get())); } String src = ""; for(int i=0;i<rimd->get_source_count();i++) { if (i>0) src+=","; src+=EditorImportPlugin::expand_source_path(rimd->get_source_path(i)); } import_path->set_text(src); } }
/* This function is defined here instead of PyGrxUI.cpp so that the message translations can be edited with one file */ std::string GrxUIMenuView::waitInputMessage(const std::string& message) { Dialog dialog; dialog.setWindowTitle(_("Wait input message")); QVBoxLayout* vbox = new QVBoxLayout(); dialog.setLayout(vbox); vbox->addWidget(new QLabel(message.c_str())); LineEdit* lineEdit = new LineEdit(); connect(lineEdit, SIGNAL(returnPressed()), &dialog, SLOT(accept())); vbox->addWidget(lineEdit); PushButton* okButton = new PushButton(_("&OK")); okButton->setDefault(true); connect(okButton, SIGNAL(clicked()), &dialog, SLOT(accept())); vbox->addWidget(okButton); vbox->addStretch(); dialog.show(); MenuButtonBlock block(instance()->impl); QEventLoop eventLoop; connect(&dialog, SIGNAL(finished(int)), &eventLoop, SLOT(quit())); eventLoop.exec(); return lineEdit->string(); }
void EditorSceneImportDialog::_browse_target() { if (save_path->get_text()!="") save_select->set_current_path(save_path->get_text()); save_select->popup_centered_ratio(); }
void EditorSceneImportDialog::_choose_file(const String& p_path) { #if 0 StringName sn = EditorImportDB::get_singleton()->find_source_path(p_path); if (sn!=StringName()) { EditorImportDB::ImportScene isc; if (EditorImportDB::get_singleton()->get_scene(sn,isc)==OK) { save_path->set_text(String(sn).get_base_dir()); texture_options->set_flags( isc.image_flags ); texture_options->set_quality( isc.image_quality ); texture_options->set_format( isc.image_format ); animation_options->set_flags( isc.anim_flags ); script_path->set_text( isc.import_script ); uint32_t f = isc.flags; for(int i=0;i<scene_flags.size();i++) { scene_flags[i]->set_checked(0,f&(1<<i)); } } } else { #endif save_path->set_text(""); //save_path->set_text(p_path.get_file().basename()+".scn"); #if 0 } #endif import_path->set_text(p_path); }
void EditorSceneImportDialog::popup_import(const String &p_from) { popup_centered(Size2(700,500)); if (p_from!="") { Ref<ResourceImportMetadata> rimd = ResourceLoader::load_import_metadata(p_from); if (rimd.is_null()) return; int flags = rimd->get_option("flags"); for(int i=0;i<scene_flags.size();i++) { int md = scene_flags[i]->get_metadata(0); scene_flags[i]->set_checked(0,flags&md); } texture_options->set_flags(rimd->get_option("texture_flags")); texture_options->set_format(EditorTextureImportPlugin::ImageFormat(int(rimd->get_option("texture_format")))); texture_options->set_quality(rimd->get_option("texture_quality")); animation_options->set_flags(rimd->get_option("animation_flags")); script_path->set_text(rimd->get_option("post_import_script")); save_path->set_text(p_from.get_base_dir()); import_path->set_text(EditorImportPlugin::expand_source_path(rimd->get_source_path(0))); } }
bool _test_path() { error->set_text(""); get_ok()->set_disabled(true); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (project_path->get_text() != "" && d->change_dir(project_path->get_text())!=OK) { error->set_text(TTR("Invalid project path, the path must exist!")); memdelete(d); return false; } if (mode!=MODE_IMPORT) { if (d->file_exists("engine.cfg")) { error->set_text(TTR("Invalid project path, engine.cfg must not exist.")); memdelete(d); return false; } } else { if (project_path->get_text() != "" && !d->file_exists("engine.cfg")) { error->set_text(TTR("Invalid project path, engine.cfg must exist.")); memdelete(d); return false; } } memdelete(d); get_ok()->set_disabled(false); return true; }
bool _test_path() { error->set_text(""); get_ok()->set_disabled(true); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); if (project_path->get_text() != "" && d->change_dir(project_path->get_text())!=OK) { error->set_text("Invalid Path for Project, Path Must Exist!"); memdelete(d); return false; } if (!import_mode) { if (d->file_exists("engine.cfg")) { error->set_text("Invalid Project Path (engine.cfg must not exist)."); memdelete(d); return false; } } else { if (project_path->get_text() != "" && !d->file_exists("engine.cfg")) { error->set_text("Invalid Project Path (engine.cfg must exist)."); memdelete(d); return false; } } memdelete(d); get_ok()->set_disabled(false); return true; }
void refresh() override { TDoubleKeyframe kf; TDoubleParam *curve = getCurve(); if (curve) kf = curve->getKeyframeAt(getR0()); if (curve && kf.m_isKeyframe) { TFilePath path; int fieldIndex = 0; std::string unitName = ""; if (kf.m_type == TDoubleKeyframe::File) { path = kf.m_fileParams.m_path; fieldIndex = kf.m_fileParams.m_fieldIndex; if (fieldIndex < 0) fieldIndex = 0; unitName = kf.m_unitName; if (unitName == "") { TMeasure *measure = curve->getMeasure(); if (measure) { const TUnit *unit = measure->getCurrentUnit(); if (unit) unitName = ::to_string(unit->getDefaultExtension()); } } } m_fileFld->setPath(QString::fromStdWString(path.getWideString())); m_fieldIndexFld->setText(QString::number(fieldIndex + 1)); m_measureFld->setText(QString::fromStdString(unitName)); } }
void show_dialog() { project_path->clear(); project_name->clear(); if (import_mode) { set_title("Import Existing Project:"); pp->set_text("Project Path: (Must exist)"); pn->set_text("Project Name:"); pn->hide(); project_name->hide(); popup_centered(Size2(500,125)); } else { set_title("Create New Project:"); pp->set_text("Project Path:"); pn->set_text("Project Name:"); pn->show(); project_name->show(); popup_centered(Size2(500,145)); } _test_path(); }
void _import() { Vector<String> samples = import_path->get_text().split(","); if (samples.size()==0) { error_dialog->set_text(TTR("No samples to import!")); error_dialog->popup_centered(Size2(200,100)); } if (save_path->get_text().strip_edges()=="") { error_dialog->set_text(TTR("Target path is empty.")); error_dialog->popup_centered_minsize(); return; } if (!save_path->get_text().begins_with("res://")) { error_dialog->set_text(TTR("Target path must be full resource path.")); error_dialog->popup_centered_minsize(); return; } if (!DirAccess::exists(save_path->get_text())) { error_dialog->set_text(TTR("Target path must exist.")); error_dialog->popup_centered_minsize(); return; } for(int i=0;i<samples.size();i++) { Ref<ResourceImportMetadata> imd = memnew( ResourceImportMetadata ); List<PropertyInfo> pl; options->_get_property_list(&pl); for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) { Variant v; String opt=E->get().name; options->_get(opt,v); imd->set_option(opt,v); } imd->add_source(EditorImportPlugin::validate_source_path(samples[i])); String dst = save_path->get_text(); if (dst=="") { error_dialog->set_text(TTR("Save path is empty!")); error_dialog->popup_centered(Size2(200,100)); } dst = dst.plus_file(samples[i].get_file().basename()+".smp"); Error err = plugin->import(dst,imd); } hide(); }
Error EditorTextureImportDialog::import(const String& p_from, const String& p_to, const String& p_preset) { import_path->set_text(p_from); save_path->set_text(p_to); _import(); return OK; }
void getGuiValues(TDoubleKeyframe::FileParams &fileParam, std::string &unitName) { QString stringPath = m_fileFld->getPath(); stringPath.replace("\\", "\\\\"); fileParam.m_path = TFilePath(stringPath.toStdWString()); fileParam.m_fieldIndex = qMax(0, m_fieldIndexFld->text().toInt() - 1); unitName = m_measureFld->text().toStdString(); }
int main() { LineEdit edit; while (1) { string s = edit.getData(); cout << s << endl; } }
void DlgCompareDir::DoTreeCursor() { String s = GetTreePath(); if(IsNull(s)) return; String fa = AppendFileName(pa, s), fb = AppendFileName(pb, s); String da = LoadFile(fa), db = LoadFile(fb); if(!IsNull(da) || !IsNull(db)) { if(IsNull(da) || IsNull(db)) { qtf.Hide(); lineedit.Show(); lineedit <<= Nvl(db, da); } else { lineedit.Hide(); qtf.Show(); String comptext = "[C2 "; Vector<String> la = GetStringLineMap(da), lb = GetStringLineMap(db); Array<TextSection> sections = CompareLineMaps(la, lb); for(int s = 0; s < sections.GetCount(); s++) { const TextSection& sec = sections[s]; if(sec.same) { comptext << "[@(0.0.0) \1"; if(sec.count1 <= 6) for(int i = 0; i < sec.count1; i++) comptext << ExpandTabs(la[i + sec.start1]) << '\n'; else { for(int i = 0; i < 3; i++) comptext << ExpandTabs(la[i + sec.start1]) << '\n'; comptext << "...\n"; for(int i = -3; i < 0; i++) comptext << ExpandTabs(la[i + sec.start1 + sec.count1]) << '\n'; } comptext << "\1]"; } else { if(sec.count1) { comptext << "[@(0.160.0) \1"; for(int i = 0; i < sec.count1; i++) comptext << ExpandTabs(la[sec.start1 + i]) << '\n'; comptext << "\1]"; } if(sec.count2) { comptext << "[@(0.0.255) \1"; for(int i = 0; i < sec.count2; i++) comptext << ExpandTabs(lb[sec.start2 + i]) << '\n'; comptext << "\1]"; } } } qtf.SetQTF(comptext); } } }
/** int QWidget::height() * bind/QWidget.h:15 */ static int LineEdit_height(lua_State *L) { try { LineEdit *self = *((LineEdit **)dub_checksdata(L, 1, "mimas.LineEdit")); lua_pushnumber(L, self->height()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "height: %s", e.what()); } catch (...) { lua_pushfstring(L, "height: Unknown exception"); } return dub_error(L); }
/** QVariant QObject::property(const char *name) * bind/QObject.h:9 */ static int LineEdit_property(lua_State *L) { try { LineEdit *self = *((LineEdit **)dub_checksdata(L, 1, "mimas.LineEdit")); const char *name = dub_checkstring(L, 2); return pushVariantInLua(L, self->property(name)); } catch (std::exception &e) { lua_pushfstring(L, "property: %s", e.what()); } catch (...) { lua_pushfstring(L, "property: Unknown exception"); } return dub_error(L); }
/** void QWidget::activateWindow() * bind/QWidget.h:35 */ static int LineEdit_activateWindow(lua_State *L) { try { LineEdit *self = *((LineEdit **)dub_checksdata(L, 1, "mimas.LineEdit")); self->activateWindow(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "activateWindow: %s", e.what()); } catch (...) { lua_pushfstring(L, "activateWindow: Unknown exception"); } return dub_error(L); }
/** void QWidget::setFocus() * bind/QWidget.h:20 */ static int LineEdit_setFocus(lua_State *L) { try { LineEdit *self = *((LineEdit **)dub_checksdata(L, 1, "mimas.LineEdit")); self->setFocus(Qt::OtherFocusReason); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setFocus: %s", e.what()); } catch (...) { lua_pushfstring(L, "setFocus: Unknown exception"); } return dub_error(L); }
/** bool QWidget::isFullScreen() * bind/QWidget.h:36 */ static int LineEdit_isFullScreen(lua_State *L) { try { LineEdit *self = *((LineEdit **)dub_checksdata(L, 1, "mimas.LineEdit")); lua_pushboolean(L, self->isFullScreen()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "isFullScreen: %s", e.what()); } catch (...) { lua_pushfstring(L, "isFullScreen: Unknown exception"); } return dub_error(L); }
/** QString QWidget::windowTitle() * bind/QWidget.h:40 */ static int LineEdit_windowTitle(lua_State *L) { try { LineEdit *self = *((LineEdit **)dub_checksdata(L, 1, "mimas.LineEdit")); lua_pushstring(L, self->windowTitle().toUtf8()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "windowTitle: %s", e.what()); } catch (...) { lua_pushfstring(L, "windowTitle: Unknown exception"); } return dub_error(L); }
/** void QWidget::setStyle(const char *text) * bind/QWidget.h:51 */ static int LineEdit_setStyle(lua_State *L) { try { LineEdit *self = *((LineEdit **)dub_checksdata(L, 1, "mimas.LineEdit")); const char *text = dub_checkstring(L, 2); self->setStyleSheet(QString("%1 { %2 }").arg(self->metaObject()->className()).arg(text)); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setStyle: %s", e.what()); } catch (...) { lua_pushfstring(L, "setStyle: Unknown exception"); } return dub_error(L); }
/** void QWidget::setStyleSheet(const char *text) * bind/QWidget.h:52 */ static int LineEdit_setStyleSheet(lua_State *L) { try { LineEdit *self = *((LineEdit **)dub_checksdata(L, 1, "mimas.LineEdit")); const char *text = dub_checkstring(L, 2); self->setStyleSheet(text); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setStyleSheet: %s", e.what()); } catch (...) { lua_pushfstring(L, "setStyleSheet: Unknown exception"); } return dub_error(L); }
/** QString QObject::objectName() const * bind/QObject.h:7 */ static int LineEdit_objectName(lua_State *L) { try { LineEdit *self = *((LineEdit **)dub_checksdata(L, 1, "mimas.LineEdit")); QByteArray str_(self->objectName().toUtf8()); lua_pushlstring(L, str_.constData(), str_.size()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "objectName: %s", e.what()); } catch (...) { lua_pushfstring(L, "objectName: Unknown exception"); } return dub_error(L); }