mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#916 Created feature for edit of preferences and added to main plot Edit menu
This commit is contained in:
@@ -16,6 +16,7 @@ ${CEE_CURRENT_LIST_DIR}RicSaveProjectAsFeature.h
|
|||||||
${CEE_CURRENT_LIST_DIR}RicExitApplicationFeature.h
|
${CEE_CURRENT_LIST_DIR}RicExitApplicationFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicCloseProjectFeature.h
|
${CEE_CURRENT_LIST_DIR}RicCloseProjectFeature.h
|
||||||
${CEE_CURRENT_LIST_DIR}RicHelpFeatures.h
|
${CEE_CURRENT_LIST_DIR}RicHelpFeatures.h
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicEditPreferencesFeature.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set (SOURCE_GROUP_SOURCE_FILES
|
set (SOURCE_GROUP_SOURCE_FILES
|
||||||
@@ -30,6 +31,7 @@ ${CEE_CURRENT_LIST_DIR}RicSaveProjectAsFeature.cpp
|
|||||||
${CEE_CURRENT_LIST_DIR}RicExitApplicationFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicExitApplicationFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicCloseProjectFeature.cpp
|
${CEE_CURRENT_LIST_DIR}RicCloseProjectFeature.cpp
|
||||||
${CEE_CURRENT_LIST_DIR}RicHelpFeatures.cpp
|
${CEE_CURRENT_LIST_DIR}RicHelpFeatures.cpp
|
||||||
|
${CEE_CURRENT_LIST_DIR}RicEditPreferencesFeature.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND CODE_HEADER_FILES
|
list(APPEND CODE_HEADER_FILES
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Statoil ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "RicEditPreferencesFeature.h"
|
||||||
|
|
||||||
|
#include "RiaApplication.h"
|
||||||
|
#include "RiaPreferences.h"
|
||||||
|
|
||||||
|
#include "RiuPropertyViewTabWidget.h"
|
||||||
|
|
||||||
|
#include "cafPdmSettings.h"
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
CAF_CMD_SOURCE_INIT(RicEditPreferencesFeature, "RicEditPreferencesFeature");
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RicEditPreferencesFeature::isCommandEnabled()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicEditPreferencesFeature::onActionTriggered(bool isChecked)
|
||||||
|
{
|
||||||
|
RiaApplication* app = RiaApplication::instance();
|
||||||
|
|
||||||
|
QStringList tabNames = app->preferences()->tabNames();
|
||||||
|
RiuPropertyViewTabWidget propertyDialog(NULL, app->preferences(), "Preferences", tabNames);
|
||||||
|
if (propertyDialog.exec() == QDialog::Accepted)
|
||||||
|
{
|
||||||
|
// Write preferences using QSettings and apply them to the application
|
||||||
|
caf::PdmSettings::writeFieldsToApplicationStore(app->preferences());
|
||||||
|
app->applyPreferences();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Read back currently stored values using QSettings
|
||||||
|
caf::PdmSettings::readFieldsFromApplicationStore(app->preferences());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RicEditPreferencesFeature::setupActionLook(QAction* actionToSetup)
|
||||||
|
{
|
||||||
|
actionToSetup->setText("&Preferences...");
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Copyright (C) 2016 Statoil ASA
|
||||||
|
//
|
||||||
|
// ResInsight is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||||
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
//
|
||||||
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||||
|
// for more details.
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "cafCmdFeature.h"
|
||||||
|
|
||||||
|
|
||||||
|
//==================================================================================================
|
||||||
|
///
|
||||||
|
//==================================================================================================
|
||||||
|
class RicEditPreferencesFeature : public caf::CmdFeature
|
||||||
|
{
|
||||||
|
CAF_CMD_HEADER_INIT;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// Overrides
|
||||||
|
virtual bool isCommandEnabled() override;
|
||||||
|
virtual void onActionTriggered( bool isChecked ) override;
|
||||||
|
virtual void setupActionLook( QAction* actionToSetup ) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -190,6 +190,8 @@ void RiuMainPlotWindow::createMenus()
|
|||||||
// Edit menu
|
// Edit menu
|
||||||
QMenu* editMenu = menuBar()->addMenu("&Edit");
|
QMenu* editMenu = menuBar()->addMenu("&Edit");
|
||||||
editMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToClipboardFeature"));
|
editMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToClipboardFeature"));
|
||||||
|
editMenu->addSeparator();
|
||||||
|
editMenu->addAction(cmdFeatureMgr->action("RicEditPreferencesFeature"));
|
||||||
|
|
||||||
// View menu
|
// View menu
|
||||||
QMenu* viewMenu = menuBar()->addMenu("&View");
|
QMenu* viewMenu = menuBar()->addMenu("&View");
|
||||||
|
|||||||
@@ -231,10 +231,6 @@ void RiuMainWindow::createActions()
|
|||||||
connect(m_showRegressionTestDialog, SIGNAL(triggered()), SLOT(slotShowRegressionTestDialog()));
|
connect(m_showRegressionTestDialog, SIGNAL(triggered()), SLOT(slotShowRegressionTestDialog()));
|
||||||
connect(m_executePaintEventPerformanceTest, SIGNAL(triggered()), SLOT(slotExecutePaintEventPerformanceTest()));
|
connect(m_executePaintEventPerformanceTest, SIGNAL(triggered()), SLOT(slotExecutePaintEventPerformanceTest()));
|
||||||
|
|
||||||
// Edit actions
|
|
||||||
m_editPreferences = new QAction("&Preferences...", this);
|
|
||||||
connect(m_editPreferences, SIGNAL(triggered()), SLOT(slotEditPreferences()));
|
|
||||||
|
|
||||||
// View actions
|
// View actions
|
||||||
m_viewFromNorth = new QAction(QIcon(":/SouthViewArrow.png"), "Look South", this);
|
m_viewFromNorth = new QAction(QIcon(":/SouthViewArrow.png"), "Look South", this);
|
||||||
m_viewFromNorth->setToolTip("Look South");
|
m_viewFromNorth->setToolTip("Look South");
|
||||||
@@ -364,7 +360,7 @@ void RiuMainWindow::createMenus()
|
|||||||
QMenu* editMenu = menuBar()->addMenu("&Edit");
|
QMenu* editMenu = menuBar()->addMenu("&Edit");
|
||||||
editMenu->addAction(m_snapshotToClipboard);
|
editMenu->addAction(m_snapshotToClipboard);
|
||||||
editMenu->addSeparator();
|
editMenu->addSeparator();
|
||||||
editMenu->addAction(m_editPreferences);
|
editMenu->addAction(cmdFeatureMgr->action("RicEditPreferencesFeature"));
|
||||||
|
|
||||||
connect(editMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshEditActions()));
|
connect(editMenu, SIGNAL(aboutToShow()), SLOT(slotRefreshEditActions()));
|
||||||
|
|
||||||
@@ -1086,29 +1082,6 @@ void RiuMainWindow::slotShowPerformanceInfo(bool enable)
|
|||||||
RiaApplication::instance()->setShowPerformanceInfo(enable);
|
RiaApplication::instance()->setShowPerformanceInfo(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RiuMainWindow::slotEditPreferences()
|
|
||||||
{
|
|
||||||
RiaApplication* app = RiaApplication::instance();
|
|
||||||
|
|
||||||
QStringList tabNames = app->preferences()->tabNames();
|
|
||||||
RiuPropertyViewTabWidget propertyDialog(this, app->preferences(), "Preferences", tabNames);
|
|
||||||
if (propertyDialog.exec() == QDialog::Accepted)
|
|
||||||
{
|
|
||||||
// Write preferences using QSettings and apply them to the application
|
|
||||||
caf::PdmSettings::writeFieldsToApplicationStore(app->preferences());
|
|
||||||
app->applyPreferences();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Read back currently stored values using QSettings
|
|
||||||
caf::PdmSettings::readFieldsFromApplicationStore(app->preferences());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Edit actions
|
// Edit actions
|
||||||
QAction* m_editPreferences;
|
|
||||||
QAction* m_newPropertyView;
|
QAction* m_newPropertyView;
|
||||||
|
|
||||||
// View actions
|
// View actions
|
||||||
@@ -177,7 +176,6 @@ private slots:
|
|||||||
|
|
||||||
// Edit slots
|
// Edit slots
|
||||||
void slotRefreshEditActions();
|
void slotRefreshEditActions();
|
||||||
void slotEditPreferences();
|
|
||||||
void slotNewObjectPropertyView();
|
void slotNewObjectPropertyView();
|
||||||
|
|
||||||
// View slots
|
// View slots
|
||||||
|
|||||||
Reference in New Issue
Block a user