mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 20:53:50 +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 "
|
||||
"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",
|
||||
"Minimum subview width");
|
||||
minWidth->setDefaultValue (325);
|
||||
|
|
|
@ -36,6 +36,11 @@ void CSVDoc::SubView::closeEvent (QCloseEvent *event)
|
|||
mParent->updateSubViewIndicies(this);
|
||||
}
|
||||
|
||||
std::string CSVDoc::SubView::getTitle() const
|
||||
{
|
||||
return mUniversalId.toString();
|
||||
}
|
||||
|
||||
void CSVDoc::SubView::closeRequest()
|
||||
{
|
||||
emit closeRequest (this);
|
||||
|
|
|
@ -49,6 +49,8 @@ namespace CSVDoc
|
|||
|
||||
void setParent(View *parent) { mParent = parent; }
|
||||
|
||||
virtual std::string getTitle() const;
|
||||
|
||||
private:
|
||||
|
||||
void closeEvent (QCloseEvent *event);
|
||||
|
@ -59,6 +61,8 @@ namespace CSVDoc
|
|||
|
||||
void closeRequest (SubView *subView);
|
||||
|
||||
void updateTitle();
|
||||
|
||||
protected slots:
|
||||
|
||||
void closeRequest();
|
||||
|
|
|
@ -300,7 +300,7 @@ void CSVDoc::View::setupUi()
|
|||
setupDebugMenu();
|
||||
}
|
||||
|
||||
void CSVDoc::View::updateTitle(const std::string subview)
|
||||
void CSVDoc::View::updateTitle()
|
||||
{
|
||||
std::ostringstream stream;
|
||||
|
||||
|
@ -312,8 +312,13 @@ void CSVDoc::View::updateTitle(const std::string subview)
|
|||
if (mViewTotal>1)
|
||||
stream << " [" << (mViewIndex+1) << "/" << mViewTotal << "]";
|
||||
|
||||
if (subview != "")
|
||||
stream << " - " << subview;
|
||||
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -323,24 +328,26 @@ void CSVDoc::View::updateSubViewIndicies(SubView *view)
|
|||
if(view && mSubViews.contains(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));
|
||||
updateTitle(mSubViews.at(0)->getUniversalId().getTypeName().c_str());
|
||||
}
|
||||
if (hideTitle)
|
||||
{
|
||||
subView->setTitleBarWidget (new QWidget (this));
|
||||
subView->setWindowTitle (QString::fromUtf8 (subView->getTitle().c_str()));
|
||||
}
|
||||
else
|
||||
{
|
||||
updateTitle();
|
||||
if(mSubViews.size() > 1)
|
||||
{
|
||||
foreach(SubView * sb, mSubViews)
|
||||
{
|
||||
QWidget * tb = sb->titleBarWidget();
|
||||
if(tb) delete tb;
|
||||
sb->setTitleBarWidget(0);
|
||||
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 (updateTitle()), this, SLOT (updateTitle()));
|
||||
|
||||
view->show();
|
||||
}
|
||||
|
||||
|
@ -731,9 +740,11 @@ void CSVDoc::View::resizeViewHeight (int height)
|
|||
resize (geometry().width(), height);
|
||||
}
|
||||
|
||||
void CSVDoc::View::updateUserSetting
|
||||
(const QString &name, const QStringList &list)
|
||||
{}
|
||||
void CSVDoc::View::updateUserSetting (const QString &name, const QStringList &list)
|
||||
{
|
||||
if (name=="window/hide-subview")
|
||||
updateSubViewIndicies (0);
|
||||
}
|
||||
|
||||
void CSVDoc::View::toggleShowStatusBar (bool show)
|
||||
{
|
||||
|
@ -766,7 +777,10 @@ void CSVDoc::View::stop()
|
|||
|
||||
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();
|
||||
else if (mViewManager.closeRequest (this))
|
||||
mViewManager.removeDocAndView (mDocument);
|
||||
|
|
|
@ -75,8 +75,6 @@ namespace CSVDoc
|
|||
|
||||
void setupUi();
|
||||
|
||||
void updateTitle(const std::string subview = "");
|
||||
|
||||
void updateActions();
|
||||
|
||||
void exitApplication();
|
||||
|
@ -139,6 +137,8 @@ namespace CSVDoc
|
|||
|
||||
void updateUserSetting (const QString &, const QStringList &);
|
||||
|
||||
void updateTitle();
|
||||
|
||||
private slots:
|
||||
|
||||
void newView();
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "../widget/scenetoolmode.hpp"
|
||||
|
||||
CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document)
|
||||
: SubView (id)
|
||||
: SubView (id), mTitle (id.toString().c_str())
|
||||
{
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
|
||||
|
@ -52,10 +52,19 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo
|
|||
|
||||
void CSVWorld::PreviewSubView::setEditLock (bool locked) {}
|
||||
|
||||
std::string CSVWorld::PreviewSubView::getTitle() const
|
||||
{
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
void CSVWorld::PreviewSubView::referenceableIdChanged (const std::string& id)
|
||||
{
|
||||
if (id.empty())
|
||||
setWindowTitle ("Preview: Reference to <nothing>");
|
||||
mTitle = "Preview: Reference to <nothing>";
|
||||
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
|
||||
|
||||
CSVRender::PreviewWidget *mScene;
|
||||
std::string mTitle;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -27,6 +28,8 @@ namespace CSVWorld
|
|||
|
||||
virtual void setEditLock (bool locked);
|
||||
|
||||
virtual std::string getTitle() const;
|
||||
|
||||
private slots:
|
||||
|
||||
void referenceableIdChanged (const std::string& id);
|
||||
|
|
|
@ -150,16 +150,22 @@ void CSVWorld::SceneSubView::useHint (const std::string& hint)
|
|||
mScene->useViewHint (hint);
|
||||
}
|
||||
|
||||
std::string CSVWorld::SceneSubView::getTitle() const
|
||||
{
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::UniversalId& id)
|
||||
{
|
||||
setUniversalId(id);
|
||||
std::ostringstream stream;
|
||||
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)
|
||||
{
|
||||
setUniversalId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Scene, "sys::default"));
|
||||
|
@ -184,7 +190,9 @@ void CSVWorld::SceneSubView::cellSelectionChanged (const CSMWorld::CellSelection
|
|||
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)
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace CSVWorld
|
|||
QHBoxLayout* mLayout;
|
||||
CSMDoc::Document& mDocument;
|
||||
CSVWidget::SceneToolbar* mToolbar;
|
||||
std::string mTitle;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -57,6 +58,8 @@ namespace CSVWorld
|
|||
|
||||
virtual void useHint (const std::string& hint);
|
||||
|
||||
virtual std::string getTitle() const;
|
||||
|
||||
private:
|
||||
|
||||
void makeConnections(CSVRender::PagedWorldspaceWidget* widget);
|
||||
|
|
Loading…
Reference in a new issue