diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 7d277f814..7dac660c3 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -132,6 +132,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); @@ -155,6 +161,52 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() ritd->setDeclaredValues (values); } + declareSection ("table-input", "Table Input"); + { + QString inPlaceEdit ("Edit in Place"); + QString editRecord ("Edit Record"); + QString view ("View"); + QString editRecordAndClose ("Edit Record and Close"); + + QStringList values; + values + << "None" << inPlaceEdit << editRecord << view << "Revert" << "Delete" + << editRecordAndClose << "View and Close"; + + QString toolTip = "
" + toolTip); + + Setting *shiftDoubleClick = createSetting (Type_ComboBox, "double-s", + "Shift Double Click"); + shiftDoubleClick->setDeclaredValues (values); + shiftDoubleClick->setDefaultValue (editRecord); + shiftDoubleClick->setToolTip ("Action on shift double click in table:
" + toolTip); + + Setting *ctrlDoubleClick = createSetting (Type_ComboBox, "double-c", + "Control Double Click"); + ctrlDoubleClick->setDeclaredValues (values); + ctrlDoubleClick->setDefaultValue (view); + ctrlDoubleClick->setToolTip ("Action on control double click in table:
" + toolTip); + + Setting *shiftCtrlDoubleClick = createSetting (Type_ComboBox, "double-sc", + "Shift Control Double Click"); + shiftCtrlDoubleClick->setDeclaredValues (values); + shiftCtrlDoubleClick->setDefaultValue (editRecordAndClose); + shiftCtrlDoubleClick->setToolTip ("Action on shift control double click in table:
" + toolTip);
+ }
{
/******************************************************************
diff --git a/apps/opencs/view/doc/subview.cpp b/apps/opencs/view/doc/subview.cpp
index ab4325cfc..a9dce25be 100644
--- a/apps/opencs/view/doc/subview.cpp
+++ b/apps/opencs/view/doc/subview.cpp
@@ -3,7 +3,7 @@
#include "view.hpp"
CSVDoc::SubView::SubView (const CSMWorld::UniversalId& id)
- : mUniversalId (id), mParent (NULL)
+ : mUniversalId (id)
{
/// \todo add a button to the title bar that clones this sub view
@@ -31,7 +31,15 @@ void CSVDoc::SubView::setUniversalId (const CSMWorld::UniversalId& id)
void CSVDoc::SubView::closeEvent (QCloseEvent *event)
{
- // update title bars of view and subviews
- if(mParent)
- mParent->updateSubViewIndicies(this);
+ emit updateSubViewIndicies (this);
}
+
+std::string CSVDoc::SubView::getTitle() const
+{
+ return mUniversalId.toString();
+}
+
+void CSVDoc::SubView::closeRequest()
+{
+ emit closeRequest (this);
+}
\ No newline at end of file
diff --git a/apps/opencs/view/doc/subview.hpp b/apps/opencs/view/doc/subview.hpp
index 6a3ddd8bd..a8aa3cda1 100644
--- a/apps/opencs/view/doc/subview.hpp
+++ b/apps/opencs/view/doc/subview.hpp
@@ -25,12 +25,13 @@ namespace CSVDoc
Q_OBJECT
CSMWorld::UniversalId mUniversalId;
- View *mParent;
// not implemented
SubView (const SubView&);
SubView& operator= (SubView&);
+
protected:
+
void setUniversalId(const CSMWorld::UniversalId& id);
public:
@@ -47,7 +48,9 @@ namespace CSVDoc
virtual void useHint (const std::string& hint);
///< Default implementation: ignored
- void setParent(View *parent) { mParent = parent; }
+ virtual std::string getTitle() const;
+
+ virtual void updateUserSetting (const QString& name, const QStringList& value);
private:
@@ -57,9 +60,15 @@ namespace CSVDoc
void focusId (const CSMWorld::UniversalId& universalId, const std::string& hint);
- public slots:
- virtual void updateUserSetting
- (const QString &, const QStringList &);
+ void closeRequest (SubView *subView);
+
+ void updateTitle();
+
+ void updateSubViewIndicies (SubView *view = 0);
+
+ protected slots:
+
+ void closeRequest();
};
}
diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp
index bef0c170d..8a6665cf2 100644
--- a/apps/opencs/view/doc/view.cpp
+++ b/apps/opencs/view/doc/view.cpp
@@ -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)
- {
- if(!mSubViews.at(0)->isFloating())
- {
- mSubViews.at(0)->setTitleBarWidget(new QWidget(this));
- updateTitle(mSubViews.at(0)->getUniversalId().getTypeName().c_str());
- }
- }
- else
+ 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)
{
- updateTitle();
- if(mSubViews.size() > 1)
+ if (!subView->isFloating())
{
- foreach(SubView * sb, mSubViews)
+ if (hideTitle)
{
- QWidget * tb = sb->titleBarWidget();
- if(tb) delete tb;
- sb->setTitleBarWidget(0);
+ subView->setTitleBarWidget (new QWidget (this));
+ subView->setWindowTitle (QString::fromUtf8 (subView->getTitle().c_str()));
+ }
+ else
+ {
+ delete subView->titleBarWidget();
+ subView->setTitleBarWidget (0);
}
}
}
@@ -513,10 +520,12 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
connect (view, SIGNAL (focusId (const CSMWorld::UniversalId&, const std::string&)), this,
SLOT (addSubView (const CSMWorld::UniversalId&, const std::string&)));
- connect (&CSMSettings::UserSettings::instance(),
- SIGNAL (userSettingUpdated (const QString &, const QStringList &)),
- view,
- SLOT (updateUserSetting (const QString &, const QStringList &)));
+ connect (view, SIGNAL (closeRequest (SubView *)), this, SLOT (closeRequest (SubView *)));
+
+ connect (view, SIGNAL (updateTitle()), this, SLOT (updateTitle()));
+
+ connect (view, SIGNAL (updateSubViewIndicies (SubView *)),
+ this, SLOT (updateSubViewIndicies (SubView *)));
view->show();
}
@@ -729,9 +738,16 @@ 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);
+
+ foreach (SubView *subView, mSubViews)
+ {
+ subView->updateUserSetting (name, list);
+ }
+}
void CSVDoc::View::toggleShowStatusBar (bool show)
{
@@ -761,3 +777,14 @@ void CSVDoc::View::stop()
{
mDocument->stopRunning();
}
+
+void CSVDoc::View::closeRequest (SubView *subView)
+{
+ 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);
+}
diff --git a/apps/opencs/view/doc/view.hpp b/apps/opencs/view/doc/view.hpp
index e3ada1f2e..55ea5ee51 100644
--- a/apps/opencs/view/doc/view.hpp
+++ b/apps/opencs/view/doc/view.hpp
@@ -75,8 +75,6 @@ namespace CSVDoc
void setupUi();
- void updateTitle(const std::string subview = "");
-
void updateActions();
void exitApplication();
@@ -114,9 +112,6 @@ 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();
@@ -139,6 +134,11 @@ namespace CSVDoc
void updateUserSetting (const QString &, const QStringList &);
+ void updateTitle();
+
+ // called when subviews are added or removed
+ void updateSubViewIndicies (SubView *view = 0);
+
private slots:
void newView();
@@ -222,6 +222,8 @@ namespace CSVDoc
void run (const std::string& profile, const std::string& startupInstruction = "");
void stop();
+
+ void closeRequest (SubView *subView);
};
}
diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp
index 1e106c69f..1ae466f42 100644
--- a/apps/opencs/view/world/previewsubview.cpp
+++ b/apps/opencs/view/world/previewsubview.cpp
@@ -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,15 +52,19 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo
void CSVWorld::PreviewSubView::setEditLock (bool locked) {}
-void CSVWorld::PreviewSubView::closeRequest()
+std::string CSVWorld::PreviewSubView::getTitle() const
{
- deleteLater();
+ return mTitle;
}
void CSVWorld::PreviewSubView::referenceableIdChanged (const std::string& id)
{
if (id.empty())
- setWindowTitle ("Preview: Reference to