From 06fda4c5a1e6834c152628fdb4a8073242b0f281 Mon Sep 17 00:00:00 2001 From: unelsson Date: Thu, 15 Apr 2021 22:34:25 +0300 Subject: [PATCH] QLineEdit for setting base animation files --- apps/opencs/model/prefs/state.cpp | 33 +++++------------------ apps/opencs/model/prefs/stringsetting.cpp | 12 ++++----- apps/opencs/model/prefs/stringsetting.hpp | 6 ++--- 3 files changed, 16 insertions(+), 35 deletions(-) diff --git a/apps/opencs/model/prefs/state.cpp b/apps/opencs/model/prefs/state.cpp index 8b9ad2b8a..0958fa8d4 100644 --- a/apps/opencs/model/prefs/state.cpp +++ b/apps/opencs/model/prefs/state.cpp @@ -423,33 +423,14 @@ void CSMPrefs::State::declare() declareShortcut ("script-editor-uncomment", "Uncomment Selection", QKeySequence()); declareCategory ("Models"); - declareString ("baseanim", "3rd person base model with textkeys-data", "meshes/openmwdude.dae"). + declareString ("baseanim", "base animations", "meshes/base_anim.nif"). setTooltip("3rd person base model with textkeys-data"); - -/*# 3rd person base model with textkeys-data -baseanim = meshes/base_anim.nif - -# 1st person base animation model that looks also for corresponding kf-file -xbaseanim1st = meshes/xbase_anim.1st.nif - -# 3rd person beast race base model with textkeys-data -baseanimkna = meshes/base_animkna.nif - -# 1st person beast race base animation model -baseanimkna1st = meshes/base_animkna.1st.nif - -# 3rd person female base model with textkeys-data -baseanimfemale = meshes/base_anim_female.nif - -# 1st person female base model with textkeys-data -baseanimfemale1st = meshes/base_anim_female.1st.nif - -# 3rd person werewolf skin -wolfskin = meshes/wolf/skin.nif - -# 1st person werewolf skin -wolfskin1st = meshes/wolf/skin.1st.nif*/ - + declareString ("baseanimkna", "base animations, kna", "meshes/base_animkna.nif"). + setTooltip("3rd person beast race base model with textkeys-data"); + declareString ("baseanimfemale", "base animations, female", "meshes/base_anim_female.nif"). + setTooltip("3rd person female base model with textkeys-data"); + declareString ("wolfskin", "base animations, wolf", "meshes/wolf/skin.nif"). + setTooltip("3rd person werewolf skin"); } void CSMPrefs::State::declareCategory (const std::string& key) diff --git a/apps/opencs/model/prefs/stringsetting.cpp b/apps/opencs/model/prefs/stringsetting.cpp index 06eeb6c4b..27290b6c7 100644 --- a/apps/opencs/model/prefs/stringsetting.cpp +++ b/apps/opencs/model/prefs/stringsetting.cpp @@ -1,7 +1,7 @@ #include "stringsetting.hpp" -#include +#include #include #include @@ -22,7 +22,7 @@ CSMPrefs::StringSetting& CSMPrefs::StringSetting::setTooltip (const std::string& std::pair CSMPrefs::StringSetting::makeWidgets (QWidget *parent) { - mWidget = new QTextEdit (QString::fromUtf8 (mDefault.c_str()), parent); + mWidget = new QLineEdit (QString::fromUtf8 (mDefault.c_str()), parent); if (!mTooltip.empty()) { @@ -30,7 +30,7 @@ std::pair CSMPrefs::StringSetting::makeWidgets (QWidget *p mWidget->setToolTip (tooltip); } - connect (mWidget, SIGNAL (textChanged (std::string)), this, SLOT (textChanged (std::string))); + connect (mWidget, SIGNAL (textChanged (QString)), this, SLOT (textChanged (QString))); return std::make_pair (static_cast (nullptr), mWidget); } @@ -39,15 +39,15 @@ void CSMPrefs::StringSetting::updateWidget() { if (mWidget) { - //mWidget->setValue(getValues().getString(getKey(), getParent()->getKey())); + mWidget->setText(QString::fromStdString(getValues().getString(getKey(), getParent()->getKey()))); } } -void CSMPrefs::StringSetting::textChanged (std::string text) +void CSMPrefs::StringSetting::textChanged (const QString& text) { { QMutexLocker lock (getMutex()); - getValues().setString (getKey(), getParent()->getKey(), text); + getValues().setString (getKey(), getParent()->getKey(), text.toStdString()); } getParent()->getState()->update (*this); diff --git a/apps/opencs/model/prefs/stringsetting.hpp b/apps/opencs/model/prefs/stringsetting.hpp index f0e66a2ef..36d020f29 100644 --- a/apps/opencs/model/prefs/stringsetting.hpp +++ b/apps/opencs/model/prefs/stringsetting.hpp @@ -3,7 +3,7 @@ #include "setting.hpp" -class QTextEdit; +class QLineEdit; namespace CSMPrefs { @@ -13,7 +13,7 @@ namespace CSMPrefs std::string mTooltip; std::string mDefault; - QTextEdit* mWidget; + QLineEdit* mWidget; public: @@ -29,7 +29,7 @@ namespace CSMPrefs private slots: - void textChanged (std::string text); + void textChanged (const QString& text); }; }