forked from mirror/openmw-tes3mp
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);
|
||||
|
||||
#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 ("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)));
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "subview.hpp"
|
||||
|
||||
#include "view.hpp"
|
||||
|
||||
CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id) : mUniversalId (id)
|
||||
{
|
||||
/// \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;
|
||||
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
|
||||
{
|
||||
class View;
|
||||
|
||||
class SubView : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
CSMWorld::UniversalId mUniversalId;
|
||||
View *mParent;
|
||||
|
||||
// not implemented
|
||||
SubView (const SubView&);
|
||||
|
@ -44,6 +47,12 @@ namespace CSVDoc
|
|||
virtual void useHint (const std::string& hint);
|
||||
///< Default implementation: ignored
|
||||
|
||||
void setParent(View *parent) { mParent = parent; }
|
||||
|
||||
private:
|
||||
|
||||
void closeEvent (QCloseEvent *event);
|
||||
|
||||
signals:
|
||||
|
||||
void focusId (const CSMWorld::UniversalId& universalId, const std::string& hint);
|
||||
|
|
|
@ -297,7 +297,7 @@ void CSVDoc::View::setupUi()
|
|||
setupDebugMenu();
|
||||
}
|
||||
|
||||
void CSVDoc::View::updateTitle()
|
||||
void CSVDoc::View::updateTitle(const std::string subview)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
|
||||
|
@ -309,9 +309,37 @@ void CSVDoc::View::updateTitle()
|
|||
if (mViewTotal>1)
|
||||
stream << " [" << (mViewIndex+1) << "/" << mViewTotal << "]";
|
||||
|
||||
if (subview != "")
|
||||
stream << " - " << subview;
|
||||
|
||||
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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
/// \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
|
||||
/// number is exceeded
|
||||
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||
|
||||
/// \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
|
||||
/// accordingly
|
||||
int maxSubView = 3;
|
||||
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)
|
||||
|
||||
|
@ -439,16 +476,29 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
|
|||
view = mSubViewFactory.makeSubView (id, *mDocument);
|
||||
}
|
||||
assert(view);
|
||||
view->setParent(this);
|
||||
mSubViews.append(view); // only after assert
|
||||
if (!hint.empty())
|
||||
view->useHint (hint);
|
||||
|
||||
int minWidth = 325; // default value if none found
|
||||
if(CSMSettings::UserSettings::instance().hasSettingDefinitions("SubView/minimum width"))
|
||||
minWidth = CSMSettings::UserSettings::instance().settingValue("SubView/minimum width").toInt();
|
||||
int minWidth = 325; // default value to use if none found
|
||||
if(userSettings.hasSettingDefinitions("SubView/minimum width"))
|
||||
minWidth = userSettings.settingValue("SubView/minimum width").toInt();
|
||||
else
|
||||
CSMSettings::UserSettings::instance().setDefinitions("SubView/minimum width", (QStringList() << "minWidth"));
|
||||
userSettings.setDefinitions("SubView/minimum width", (QStringList() << QString(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());
|
||||
// NOTE: only required if show status bar setting should be applied to existing
|
||||
// window
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace CSVDoc
|
|||
CSMDoc::Document *mDocument;
|
||||
int mViewIndex;
|
||||
int mViewTotal;
|
||||
QList<SubView *> mSubViews;
|
||||
QAction *mUndo;
|
||||
QAction *mRedo;
|
||||
QAction *mSave;
|
||||
|
@ -74,7 +75,7 @@ namespace CSVDoc
|
|||
|
||||
void setupUi();
|
||||
|
||||
void updateTitle();
|
||||
void updateTitle(const std::string subview = "");
|
||||
|
||||
void updateActions();
|
||||
|
||||
|
@ -113,6 +114,9 @@ namespace CSVDoc
|
|||
/// Function called by view manager when user preferences are updated
|
||||
void updateEditorSetting (const QString &, const QString &);
|
||||
|
||||
// called when subviews are added or removed
|
||||
void updateSubViewIndicies(SubView *view = 0);
|
||||
|
||||
signals:
|
||||
|
||||
void newGameRequest();
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "../../model/doc/documentmanager.hpp"
|
||||
#include "../../model/doc/document.hpp"
|
||||
#include "../../model/world/columns.hpp"
|
||||
#include "../../model/world/universalid.hpp"
|
||||
|
||||
#include "../world/util.hpp"
|
||||
#include "../world/enumdelegate.hpp"
|
||||
|
@ -161,6 +162,14 @@ CSVDoc::View *CSVDoc::ViewManager::addView (CSMDoc::Document *document)
|
|||
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 count = 0;
|
||||
|
|
|
@ -18,6 +18,11 @@ namespace CSVWorld
|
|||
class CommandDelegateFactoryCollection;
|
||||
}
|
||||
|
||||
namespace CSMWorld
|
||||
{
|
||||
class UniversalId;
|
||||
}
|
||||
|
||||
namespace CSVDoc
|
||||
{
|
||||
class View;
|
||||
|
@ -52,6 +57,8 @@ namespace CSVDoc
|
|||
View *addView (CSMDoc::Document *document);
|
||||
///< 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;
|
||||
///< Return number of views for \a document.
|
||||
|
||||
|
|
|
@ -305,6 +305,11 @@ void CSVSettings::Dialog::buildPages()
|
|||
else
|
||||
sbMinSubViewWidth->setValue(325);
|
||||
|
||||
if(model()->hasSettingDefinitions("SubView/max subviews"))
|
||||
sbMaxSubViews->setValue(model()->settingValue("SubView/max subview").toInt());
|
||||
else
|
||||
sbMaxSubViews->setValue(3);
|
||||
|
||||
SettingWindow::createPages ();
|
||||
|
||||
foreach (Page *page, SettingWindow::pages())
|
||||
|
@ -385,6 +390,8 @@ void CSVSettings::Dialog::closeEvent (QCloseEvent *event)
|
|||
// subview
|
||||
model()->setDefinitions("SubView/minimum width",
|
||||
QStringList(QString::number(sbMinSubViewWidth->value())));
|
||||
model()->setDefinitions("SubView/max subviews",
|
||||
QStringList(QString::number(sbMaxSubViews->value())));
|
||||
|
||||
saveSettings();
|
||||
}
|
||||
|
|
|
@ -128,10 +128,13 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="spinBox_max_subviews">
|
||||
<widget class="QSpinBox" name="sbMaxSubViews">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
|
@ -386,7 +389,7 @@
|
|||
<tabstop>sbWidth</tabstop>
|
||||
<tabstop>sbHeight</tabstop>
|
||||
<tabstop>cbStatusBar</tabstop>
|
||||
<tabstop>spinBox_max_subviews</tabstop>
|
||||
<tabstop>sbMaxSubViews</tabstop>
|
||||
<tabstop>sbMinSubViewWidth</tabstop>
|
||||
<tabstop>checkBox_reuse_subview</tabstop>
|
||||
<tabstop>cbOverride</tabstop>
|
||||
|
|
Loading…
Reference in a new issue