mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-23 14:39:43 +00:00
Max subviews setting working. However there is no way to remove the last subview once the title bar is removed and the look of the filter box is broken without the title bar.
This commit is contained in:
parent
62406d5322
commit
ffae816aab
9 changed files with 110 additions and 22 deletions
|
@ -202,18 +202,8 @@ void UserSettings::buildSettingModelDefaults()
|
||||||
spaceText2->setViewLocation(3, 7);
|
spaceText2->setViewLocation(3, 7);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false");
|
|
||||||
|
|
||||||
sh::Factory::getInstance ().setGlobalSetting ("render_refraction", "false");
|
|
||||||
|
|
||||||
sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty<sh::Vector3>(new sh::Vector3(0.5, -0.8, 0.2)));
|
sh::Factory::getInstance ().setSharedParameter ("windDir_windSpeed", sh::makeProperty<sh::Vector3>(new sh::Vector3(0.5, -0.8, 0.2)));
|
||||||
sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty<sh::Vector2>(new sh::Vector2(1, 0.6)));
|
sh::Factory::getInstance ().setSharedParameter ("waterSunFade_sunHeight", sh::makeProperty<sh::Vector2>(new sh::Vector2(1, 0.6)));
|
||||||
sh::Factory::getInstance ().setGlobalSetting ("refraction", Settings::Manager::getBool("refraction", "Water") ? "true" : "false");
|
|
||||||
sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false");
|
|
||||||
sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty<sh::Vector4> (new sh::Vector4(0,0,0,0)));
|
sh::Factory::getInstance ().setSharedParameter ("vpRow2Fix", sh::makeProperty<sh::Vector4> (new sh::Vector4(0,0,0,0)));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#include "subview.hpp"
|
#include "subview.hpp"
|
||||||
|
|
||||||
|
#include "view.hpp"
|
||||||
|
|
||||||
CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id) : mUniversalId (id)
|
CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id) : mUniversalId (id)
|
||||||
{
|
{
|
||||||
/// \todo add a button to the title bar that clones this sub view
|
/// \todo add a button to the title bar that clones this sub view
|
||||||
|
@ -25,3 +27,10 @@ void CSVDoc::SubView::setUniversalId (const CSMWorld::UniversalId& id)
|
||||||
mUniversalId = id;
|
mUniversalId = id;
|
||||||
setWindowTitle (mUniversalId.toString().c_str());
|
setWindowTitle (mUniversalId.toString().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::SubView::closeEvent (QCloseEvent *event)
|
||||||
|
{
|
||||||
|
// update title bars of view and subviews
|
||||||
|
if(mParent)
|
||||||
|
mParent->updateSubViewIndicies(this);
|
||||||
|
}
|
||||||
|
|
|
@ -18,11 +18,14 @@ namespace CSMWorld
|
||||||
|
|
||||||
namespace CSVDoc
|
namespace CSVDoc
|
||||||
{
|
{
|
||||||
|
class View;
|
||||||
|
|
||||||
class SubView : public QDockWidget
|
class SubView : public QDockWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
CSMWorld::UniversalId mUniversalId;
|
CSMWorld::UniversalId mUniversalId;
|
||||||
|
View *mParent;
|
||||||
|
|
||||||
// not implemented
|
// not implemented
|
||||||
SubView (const SubView&);
|
SubView (const SubView&);
|
||||||
|
@ -44,6 +47,12 @@ namespace CSVDoc
|
||||||
virtual void useHint (const std::string& hint);
|
virtual void useHint (const std::string& hint);
|
||||||
///< Default implementation: ignored
|
///< Default implementation: ignored
|
||||||
|
|
||||||
|
void setParent(View *parent) { mParent = parent; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void closeEvent (QCloseEvent *event);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void focusId (const CSMWorld::UniversalId& universalId, const std::string& hint);
|
void focusId (const CSMWorld::UniversalId& universalId, const std::string& hint);
|
||||||
|
|
|
@ -297,7 +297,7 @@ void CSVDoc::View::setupUi()
|
||||||
setupDebugMenu();
|
setupDebugMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::View::updateTitle()
|
void CSVDoc::View::updateTitle(const std::string subview)
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|
||||||
|
@ -309,9 +309,37 @@ void CSVDoc::View::updateTitle()
|
||||||
if (mViewTotal>1)
|
if (mViewTotal>1)
|
||||||
stream << " [" << (mViewIndex+1) << "/" << mViewTotal << "]";
|
stream << " [" << (mViewIndex+1) << "/" << mViewTotal << "]";
|
||||||
|
|
||||||
|
if (subview != "")
|
||||||
|
stream << " - " << subview;
|
||||||
|
|
||||||
setWindowTitle (stream.str().c_str());
|
setWindowTitle (stream.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVDoc::View::updateSubViewIndicies(SubView *view)
|
||||||
|
{
|
||||||
|
if(view && mSubViews.contains(view))
|
||||||
|
mSubViews.removeOne(view);
|
||||||
|
|
||||||
|
if(mSubViews.size() == 1)
|
||||||
|
{
|
||||||
|
mSubViews.at(0)->setTitleBarWidget(new QWidget(this));
|
||||||
|
updateTitle(mSubViews.at(0)->getUniversalId().getTypeName().c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
updateTitle();
|
||||||
|
if(mSubViews.size() > 1)
|
||||||
|
{
|
||||||
|
foreach(SubView * sb, mSubViews)
|
||||||
|
{
|
||||||
|
QWidget * tb = sb->titleBarWidget();
|
||||||
|
if(tb) delete tb;
|
||||||
|
sb->setTitleBarWidget(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CSVDoc::View::updateActions()
|
void CSVDoc::View::updateActions()
|
||||||
{
|
{
|
||||||
bool editing = !(mDocument->getState() & CSMDoc::State_Locked);
|
bool editing = !(mDocument->getState() & CSMDoc::State_Locked);
|
||||||
|
@ -421,11 +449,20 @@ void CSVDoc::View::updateProgress (int current, int max, int type, int threads)
|
||||||
|
|
||||||
void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::string& hint)
|
void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::string& hint)
|
||||||
{
|
{
|
||||||
/// \todo add an user setting for limiting the number of sub views per top level view. Automatically open a new top level view if this
|
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||||
/// number is exceeded
|
|
||||||
|
|
||||||
/// \todo if the sub view limit setting is one, the sub view title bar should be hidden and the text in the main title bar adjusted
|
int maxSubView = 3;
|
||||||
/// accordingly
|
if(userSettings.hasSettingDefinitions("SubView/max subviews"))
|
||||||
|
maxSubView = userSettings.settingValue("SubView/max subviews").toInt();
|
||||||
|
else
|
||||||
|
userSettings.setDefinitions("SubView/max subviews", (QStringList() << QString(maxSubView)));
|
||||||
|
|
||||||
|
if(mSubViews.size() >= maxSubView) // create a new top level view
|
||||||
|
{
|
||||||
|
mViewManager.addView(mDocument, id, hint);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/// \todo add an user setting to reuse sub views (on a per document basis or on a per top level view basis)
|
/// \todo add an user setting to reuse sub views (on a per document basis or on a per top level view basis)
|
||||||
|
|
||||||
|
@ -439,16 +476,29 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
|
||||||
view = mSubViewFactory.makeSubView (id, *mDocument);
|
view = mSubViewFactory.makeSubView (id, *mDocument);
|
||||||
}
|
}
|
||||||
assert(view);
|
assert(view);
|
||||||
|
view->setParent(this);
|
||||||
|
mSubViews.append(view); // only after assert
|
||||||
if (!hint.empty())
|
if (!hint.empty())
|
||||||
view->useHint (hint);
|
view->useHint (hint);
|
||||||
|
|
||||||
int minWidth = 325; // default value if none found
|
int minWidth = 325; // default value to use if none found
|
||||||
if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width"))
|
if(userSettings.hasSettingDefinitions("SubView/minimum width"))
|
||||||
minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt();
|
minWidth = userSettings.settingValue("SubView/minimum width").toInt();
|
||||||
else
|
else
|
||||||
CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth"));
|
userSettings.setDefinitions("SubView/minimum width", (QStringList() << QString(minWidth)));
|
||||||
view->setMinimumWidth(minWidth);
|
view->setMinimumWidth(minWidth);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
if(mSubViews.size() == 1) // remove subview title and add to the main window
|
||||||
|
{
|
||||||
|
updateTitle(id.getTypeName().c_str());
|
||||||
|
// FIXME: search area broken
|
||||||
|
view->setTitleBarWidget(new QWidget(this));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
updateSubViewIndicies();
|
||||||
|
|
||||||
view->setStatusBar (mShowStatusBar->isChecked());
|
view->setStatusBar (mShowStatusBar->isChecked());
|
||||||
// NOTE: only required if show status bar setting should be applied to existing
|
// NOTE: only required if show status bar setting should be applied to existing
|
||||||
// window
|
// window
|
||||||
|
|
|
@ -35,6 +35,7 @@ namespace CSVDoc
|
||||||
CSMDoc::Document *mDocument;
|
CSMDoc::Document *mDocument;
|
||||||
int mViewIndex;
|
int mViewIndex;
|
||||||
int mViewTotal;
|
int mViewTotal;
|
||||||
|
QList<SubView *> mSubViews;
|
||||||
QAction *mUndo;
|
QAction *mUndo;
|
||||||
QAction *mRedo;
|
QAction *mRedo;
|
||||||
QAction *mSave;
|
QAction *mSave;
|
||||||
|
@ -74,7 +75,7 @@ namespace CSVDoc
|
||||||
|
|
||||||
void setupUi();
|
void setupUi();
|
||||||
|
|
||||||
void updateTitle();
|
void updateTitle(const std::string subview = "");
|
||||||
|
|
||||||
void updateActions();
|
void updateActions();
|
||||||
|
|
||||||
|
@ -113,6 +114,9 @@ namespace CSVDoc
|
||||||
/// Function called by view manager when user preferences are updated
|
/// Function called by view manager when user preferences are updated
|
||||||
void updateEditorSetting (const QString &, const QString &);
|
void updateEditorSetting (const QString &, const QString &);
|
||||||
|
|
||||||
|
// called when subviews are added or removed
|
||||||
|
void updateSubViewIndicies(SubView *view = 0);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void newGameRequest();
|
void newGameRequest();
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "../../model/doc/documentmanager.hpp"
|
#include "../../model/doc/documentmanager.hpp"
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
#include "../../model/world/columns.hpp"
|
#include "../../model/world/columns.hpp"
|
||||||
|
#include "../../model/world/universalid.hpp"
|
||||||
|
|
||||||
#include "../world/util.hpp"
|
#include "../world/util.hpp"
|
||||||
#include "../world/enumdelegate.hpp"
|
#include "../world/enumdelegate.hpp"
|
||||||
|
@ -161,6 +162,14 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document)
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document, const CSMWorld::UniversalId& id, const std::string& hint)
|
||||||
|
{
|
||||||
|
View* view = addView(document);
|
||||||
|
view->addSubView(id, hint);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
int CSVDoc::ViewManager::countViews (const CSMDoc::Document *document) const
|
int CSVDoc::ViewManager::countViews (const CSMDoc::Document *document) const
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
|
@ -18,6 +18,11 @@ namespace CSVWorld
|
||||||
class CommandDelegateFactoryCollection;
|
class CommandDelegateFactoryCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace CSMWorld
|
||||||
|
{
|
||||||
|
class UniversalId;
|
||||||
|
}
|
||||||
|
|
||||||
namespace CSVDoc
|
namespace CSVDoc
|
||||||
{
|
{
|
||||||
class View;
|
class View;
|
||||||
|
@ -52,6 +57,8 @@ namespace CSVDoc
|
||||||
View *addView (CSMDoc::Document *document);
|
View *addView (CSMDoc::Document *document);
|
||||||
///< The ownership of the returned view is not transferred.
|
///< The ownership of the returned view is not transferred.
|
||||||
|
|
||||||
|
View *addView (CSMDoc::Document *document, const CSMWorld::UniversalId& id, const std::string& hint);
|
||||||
|
|
||||||
int countViews (const CSMDoc::Document *document) const;
|
int countViews (const CSMDoc::Document *document) const;
|
||||||
///< Return number of views for \a document.
|
///< Return number of views for \a document.
|
||||||
|
|
||||||
|
|
|
@ -305,6 +305,11 @@ void CSVSettings::Dialog::buildPages()
|
||||||
else
|
else
|
||||||
sbMinSubViewWidth->setValue(325);
|
sbMinSubViewWidth->setValue(325);
|
||||||
|
|
||||||
|
if(model()->hasSettingDefinitions("SubView/max subviews"))
|
||||||
|
sbMaxSubViews->setValue(model()->settingValue("SubView/max subview").toInt());
|
||||||
|
else
|
||||||
|
sbMaxSubViews->setValue(3);
|
||||||
|
|
||||||
SettingWindow::createPages ();
|
SettingWindow::createPages ();
|
||||||
|
|
||||||
foreach (Page *page, SettingWindow::pages())
|
foreach (Page *page, SettingWindow::pages())
|
||||||
|
@ -385,6 +390,8 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event)
|
||||||
// subview
|
// subview
|
||||||
model()->setDefinitions("SubView/minimum width",
|
model()->setDefinitions("SubView/minimum width",
|
||||||
QStringList(QString::number(sbMinSubViewWidth->value())));
|
QStringList(QString::number(sbMinSubViewWidth->value())));
|
||||||
|
model()->setDefinitions("SubView/max subviews",
|
||||||
|
QStringList(QString::number(sbMaxSubViews->value())));
|
||||||
|
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,10 +128,13 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QSpinBox" name="spinBox_max_subviews">
|
<widget class="QSpinBox" name="sbMaxSubViews">
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
@ -386,7 +389,7 @@
|
||||||
<tabstop>sbWidth</tabstop>
|
<tabstop>sbWidth</tabstop>
|
||||||
<tabstop>sbHeight</tabstop>
|
<tabstop>sbHeight</tabstop>
|
||||||
<tabstop>cbStatusBar</tabstop>
|
<tabstop>cbStatusBar</tabstop>
|
||||||
<tabstop>spinBox_max_subviews</tabstop>
|
<tabstop>sbMaxSubViews</tabstop>
|
||||||
<tabstop>sbMinSubViewWidth</tabstop>
|
<tabstop>sbMinSubViewWidth</tabstop>
|
||||||
<tabstop>checkBox_reuse_subview</tabstop>
|
<tabstop>checkBox_reuse_subview</tabstop>
|
||||||
<tabstop>cbOverride</tabstop>
|
<tabstop>cbOverride</tabstop>
|
||||||
|
|
Loading…
Reference in a new issue