2015-08-20 04:59:07 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-08-20 04:59:07 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-08-20 04:59:07 -05:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-08-20 04:59:07 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicAddScriptPathFeature.h"
|
|
|
|
|
2016-07-18 08:01:14 -05:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RiaPreferences.h"
|
|
|
|
|
|
|
|
#include "RicRefreshScriptsFeature.h"
|
2015-08-20 04:59:07 -05:00
|
|
|
#include "RicScriptFeatureImpl.h"
|
|
|
|
|
|
|
|
#include "RimScriptCollection.h"
|
2018-02-27 09:37:06 -06:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2020-08-21 11:56:44 -05:00
|
|
|
#include "RiuFileDialogTools.h"
|
2015-08-20 04:59:07 -05:00
|
|
|
|
|
|
|
#include "cvfAssert.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicAddScriptPathFeature, "RicAddScriptPathFeature" );
|
2015-08-20 04:59:07 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-20 04:59:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicAddScriptPathFeature::isCommandEnabled()
|
|
|
|
{
|
|
|
|
std::vector<RimScriptCollection*> selection = RicScriptFeatureImpl::selectedScriptCollections();
|
|
|
|
return selection.size() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-20 04:59:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicAddScriptPathFeature::onActionTriggered( bool isChecked )
|
2015-08-20 04:59:07 -05:00
|
|
|
{
|
2020-02-12 04:43:15 -06:00
|
|
|
QString selectedFolder =
|
2020-08-21 11:56:44 -05:00
|
|
|
RiuFileDialogTools::getExistingDirectory( Riu3DMainWindowTools::mainWindowWidget(), "Select script folder" );
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !selectedFolder.isEmpty() )
|
2015-08-20 04:59:07 -05:00
|
|
|
{
|
2021-04-28 03:29:53 -05:00
|
|
|
QString filePathString = RiaPreferences::current()->scriptDirectories();
|
2015-08-20 04:59:07 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QChar separator( ';' );
|
|
|
|
if ( !filePathString.isEmpty() && !filePathString.endsWith( separator, Qt::CaseInsensitive ) )
|
2015-08-20 04:59:07 -05:00
|
|
|
{
|
|
|
|
filePathString += separator;
|
|
|
|
}
|
|
|
|
|
|
|
|
filePathString += selectedFolder;
|
|
|
|
|
2021-04-28 03:29:53 -05:00
|
|
|
RiaPreferences::current()->scriptDirectories = filePathString;
|
2015-08-20 04:59:07 -05:00
|
|
|
RiaApplication::instance()->applyPreferences();
|
2016-07-18 08:01:14 -05:00
|
|
|
|
|
|
|
RicRefreshScriptsFeature::refreshScriptFolders();
|
2015-08-20 04:59:07 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-08-20 04:59:07 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
void RicAddScriptPathFeature::setupActionLook( QAction* actionToSetup )
|
2015-08-20 04:59:07 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
actionToSetup->setText( "Add Script Path" );
|
2015-08-20 04:59:07 -05:00
|
|
|
}
|