mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-29 19:36:43 +00:00
added new user setting: window/hide-subview (hide subview titlebar if there is only one subview in the window)
This commit is contained in:
parent
aad13e6bff
commit
275bf854ed
9 changed files with 82 additions and 30 deletions
|
@ -127,6 +127,12 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
maxSubView->setToolTip ("If the maximum number is reached and a new subview is opened "
|
maxSubView->setToolTip ("If the maximum number is reached and a new subview is opened "
|
||||||
"it will be placed into a new top-level window.");
|
"it will be placed into a new top-level window.");
|
||||||
|
|
||||||
|
Setting *hide = createSetting (Type_CheckBox, "hide-subview", "Hide single subview");
|
||||||
|
hide->setDefaultValue ("false");
|
||||||
|
hide->setToolTip ("When a view contains only a single subview, hide the subview title "
|
||||||
|
"bar and if this subview is closed also close the view (unless it is the last "
|
||||||
|
"view for this document)");
|
||||||
|
|
||||||
Setting *minWidth = createSetting (Type_SpinBox, "minimum-width",
|
Setting *minWidth = createSetting (Type_SpinBox, "minimum-width",
|
||||||
"Minimum subview width");
|
"Minimum subview width");
|
||||||
minWidth->setDefaultValue (325);
|
minWidth->setDefaultValue (325);
|
||||||
|
|
|
@ -36,6 +36,11 @@ void CSVDoc::SubView::closeEvent (QCloseEvent *event)
|
||||||
mParent->updateSubViewIndicies(this);
|
mParent->updateSubViewIndicies(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CSVDoc::SubView::getTitle() const
|
||||||
|
{
|
||||||
|
return mUniversalId.toString();
|
||||||
|
}
|
||||||
|
|
||||||
void CSVDoc::SubView::closeRequest()
|
void CSVDoc::SubView::closeRequest()
|
||||||
{
|
{
|
||||||
emit closeRequest (this);
|
emit closeRequest (this);
|
||||||
|
|
|
@ -49,6 +49,8 @@ namespace CSVDoc
|
||||||
|
|
||||||
void setParent(View *parent) { mParent = parent; }
|
void setParent(View *parent) { mParent = parent; }
|
||||||
|
|
||||||
|
virtual std::string getTitle() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void closeEvent (QCloseEvent *event);
|
void closeEvent (QCloseEvent *event);
|
||||||
|
@ -59,6 +61,8 @@ namespace CSVDoc
|
||||||
|
|
||||||
void closeRequest (SubView *subView);
|
void closeRequest (SubView *subView);
|
||||||
|
|
||||||
|
void updateTitle();
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
void closeRequest();
|
void closeRequest();
|
||||||
|
|
|
@ -300,7 +300,7 @@ void CSVDoc::View::setupUi()
|
||||||
setupDebugMenu();
|
setupDebugMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::View::updateTitle(const std::string subview)
|
void CSVDoc::View::updateTitle()
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|
||||||
|
@ -312,8 +312,13 @@ void CSVDoc::View::updateTitle(const std::string subview)
|
||||||
if (mViewTotal>1)
|
if (mViewTotal>1)
|
||||||
stream << " [" << (mViewIndex+1) << "/" << mViewTotal << "]";
|
stream << " [" << (mViewIndex+1) << "/" << mViewTotal << "]";
|
||||||
|
|
||||||
if (subview != "")
|
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||||
stream << " - " << subview;
|
|
||||||
|
bool hideTitle = userSettings.setting ("window/hide-subview", QString ("false"))=="true" &&
|
||||||
|
mSubViews.size()==1 && !mSubViews.at (0)->isFloating();
|
||||||
|
|
||||||
|
if (hideTitle)
|
||||||
|
stream << " - " << mSubViews.at (0)->getTitle();
|
||||||
|
|
||||||
setWindowTitle (stream.str().c_str());
|
setWindowTitle (stream.str().c_str());
|
||||||
}
|
}
|
||||||
|
@ -323,24 +328,26 @@ void CSVDoc::View::updateSubViewIndicies(SubView *view)
|
||||||
if(view && mSubViews.contains(view))
|
if(view && mSubViews.contains(view))
|
||||||
mSubViews.removeOne(view);
|
mSubViews.removeOne(view);
|
||||||
|
|
||||||
if (mSubViews.size() == 1)
|
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||||
|
|
||||||
|
bool hideTitle = userSettings.setting ("window/hide-subview", QString ("false"))=="true" &&
|
||||||
|
mSubViews.size()==1 && !mSubViews.at (0)->isFloating();
|
||||||
|
|
||||||
|
updateTitle();
|
||||||
|
|
||||||
|
foreach (SubView *subView, mSubViews)
|
||||||
{
|
{
|
||||||
if(!mSubViews.at(0)->isFloating())
|
if (!subView->isFloating())
|
||||||
{
|
{
|
||||||
mSubViews.at(0)->setTitleBarWidget(new QWidget(this));
|
if (hideTitle)
|
||||||
updateTitle(mSubViews.at(0)->getUniversalId().getTypeName().c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
updateTitle();
|
|
||||||
if(mSubViews.size() > 1)
|
|
||||||
{
|
|
||||||
foreach(SubView * sb, mSubViews)
|
|
||||||
{
|
{
|
||||||
QWidget * tb = sb->titleBarWidget();
|
subView->setTitleBarWidget (new QWidget (this));
|
||||||
if(tb) delete tb;
|
subView->setWindowTitle (QString::fromUtf8 (subView->getTitle().c_str()));
|
||||||
sb->setTitleBarWidget(0);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete subView->titleBarWidget();
|
||||||
|
subView->setTitleBarWidget (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,6 +527,8 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
|
||||||
|
|
||||||
connect (view, SIGNAL (closeRequest (SubView *)), this, SLOT (closeRequest (SubView *)));
|
connect (view, SIGNAL (closeRequest (SubView *)), this, SLOT (closeRequest (SubView *)));
|
||||||
|
|
||||||
|
connect (view, SIGNAL (updateTitle()), this, SLOT (updateTitle()));
|
||||||
|
|
||||||
view->show();
|
view->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -731,9 +740,11 @@ void CSVDoc::View::resizeViewHeight (int height)
|
||||||
resize (geometry().width(), height);
|
resize (geometry().width(), height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVDoc::View::updateUserSetting
|
void CSVDoc::View::updateUserSetting (const QString &name, const QStringList &list)
|
||||||
(const QString &name, const QStringList &list)
|
{
|
||||||
{}
|
if (name=="window/hide-subview")
|
||||||
|
updateSubViewIndicies (0);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVDoc::View::toggleShowStatusBar (bool show)
|
void CSVDoc::View::toggleShowStatusBar (bool show)
|
||||||
{
|
{
|
||||||
|
@ -766,7 +777,10 @@ void CSVDoc::View::stop()
|
||||||
|
|
||||||
void CSVDoc::View::closeRequest (SubView *subView)
|
void CSVDoc::View::closeRequest (SubView *subView)
|
||||||
{
|
{
|
||||||
if (mSubViews.size()>1 || mViewTotal<=1)
|
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||||
|
|
||||||
|
if (mSubViews.size()>1 || mViewTotal<=1 ||
|
||||||
|
userSettings.setting ("window/hide-subview", QString ("false"))!="true")
|
||||||
subView->deleteLater();
|
subView->deleteLater();
|
||||||
else if (mViewManager.closeRequest (this))
|
else if (mViewManager.closeRequest (this))
|
||||||
mViewManager.removeDocAndView (mDocument);
|
mViewManager.removeDocAndView (mDocument);
|
||||||
|
|
|
@ -75,8 +75,6 @@ namespace CSVDoc
|
||||||
|
|
||||||
void setupUi();
|
void setupUi();
|
||||||
|
|
||||||
void updateTitle(const std::string subview = "");
|
|
||||||
|
|
||||||
void updateActions();
|
void updateActions();
|
||||||
|
|
||||||
void exitApplication();
|
void exitApplication();
|
||||||
|
@ -139,6 +137,8 @@ namespace CSVDoc
|
||||||
|
|
||||||
void updateUserSetting (const QString &, const QStringList &);
|
void updateUserSetting (const QString &, const QStringList &);
|
||||||
|
|
||||||
|
void updateTitle();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void newView();
|
void newView();
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "../widget/scenetoolmode.hpp"
|
#include "../widget/scenetoolmode.hpp"
|
||||||
|
|
||||||
CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||||
: SubView (id)
|
: SubView (id), mTitle (id.toString().c_str())
|
||||||
{
|
{
|
||||||
QHBoxLayout *layout = new QHBoxLayout;
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
|
|
||||||
|
@ -52,10 +52,19 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo
|
||||||
|
|
||||||
void CSVWorld::PreviewSubView::setEditLock (bool locked) {}
|
void CSVWorld::PreviewSubView::setEditLock (bool locked) {}
|
||||||
|
|
||||||
|
std::string CSVWorld::PreviewSubView::getTitle() const
|
||||||
|
{
|
||||||
|
return mTitle;
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::PreviewSubView::referenceableIdChanged (const std::string& id)
|
void CSVWorld::PreviewSubView::referenceableIdChanged (const std::string& id)
|
||||||
{
|
{
|
||||||
if (id.empty())
|
if (id.empty())
|
||||||
setWindowTitle ("Preview: Reference to <nothing>");
|
mTitle = "Preview: Reference to <nothing>";
|
||||||
else
|
else
|
||||||
setWindowTitle (("Preview: Reference to " + id).c_str());
|
mTitle = "Preview: Reference to " + id;
|
||||||
|
|
||||||
|
setWindowTitle (QString::fromUtf8 (mTitle.c_str()));
|
||||||
|
|
||||||
|
emit updateTitle();
|
||||||
}
|
}
|
|
@ -20,6 +20,7 @@ namespace CSVWorld
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
CSVRender::PreviewWidget *mScene;
|
CSVRender::PreviewWidget *mScene;
|
||||||
|
std::string mTitle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -27,6 +28,8 @@ namespace CSVWorld
|
||||||
|
|
||||||
virtual void setEditLock (bool locked);
|
virtual void setEditLock (bool locked);
|
||||||
|
|
||||||
|
virtual std::string getTitle() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void referenceableIdChanged (const std::string& id);
|
void referenceableIdChanged (const std::string& id);
|
||||||
|
|
|
@ -150,16 +150,22 @@ void CSVWorld::SceneSubView::useHint (const std::string& hint)
|
||||||
mScene->useViewHint (hint);
|
mScene->useViewHint (hint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string CSVWorld::SceneSubView::getTitle() const
|
||||||
|
{
|
||||||
|
return mTitle;
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::UniversalId& id)
|
void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::UniversalId& id)
|
||||||
{
|
{
|
||||||
setUniversalId(id);
|
setUniversalId(id);
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
stream << "Scene: " << getUniversalId().getId();
|
stream << "Scene: " << getUniversalId().getId();
|
||||||
|
|
||||||
setWindowTitle (QString::fromUtf8 (stream.str().c_str()));
|
mTitle = stream.str();
|
||||||
|
setWindowTitle (QString::fromUtf8 (mTitle.c_str()));
|
||||||
|
emit updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::CellSelection& selection)
|
void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::CellSelection& selection)
|
||||||
{
|
{
|
||||||
setUniversalId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Scene, "sys::default"));
|
setUniversalId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Scene, "sys::default"));
|
||||||
|
@ -184,7 +190,9 @@ void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::CellSelection
|
||||||
stream << "cell around it)";
|
stream << "cell around it)";
|
||||||
}
|
}
|
||||||
|
|
||||||
setWindowTitle (QString::fromUtf8 (stream.str().c_str()));
|
mTitle = stream.str();
|
||||||
|
setWindowTitle (QString::fromUtf8 (mTitle.c_str()));
|
||||||
|
emit updateTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalId >& data)
|
void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalId >& data)
|
||||||
|
|
|
@ -44,6 +44,7 @@ namespace CSVWorld
|
||||||
QHBoxLayout* mLayout;
|
QHBoxLayout* mLayout;
|
||||||
CSMDoc::Document& mDocument;
|
CSMDoc::Document& mDocument;
|
||||||
CSVWidget::SceneToolbar* mToolbar;
|
CSVWidget::SceneToolbar* mToolbar;
|
||||||
|
std::string mTitle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -57,6 +58,8 @@ namespace CSVWorld
|
||||||
|
|
||||||
virtual void useHint (const std::string& hint);
|
virtual void useHint (const std::string& hint);
|
||||||
|
|
||||||
|
virtual std::string getTitle() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void makeConnections(CSVRender::PagedWorldspaceWidget* widget);
|
void makeConnections(CSVRender::PagedWorldspaceWidget* widget);
|
||||||
|
|
Loading…
Reference in a new issue