Files
ResInsight/ApplicationLibCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp
T

76 lines
2.8 KiB
C++
Raw Normal View History

2016-10-05 08:29:38 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil ASA
//
2016-10-05 08:29:38 +02: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.
//
2016-10-05 08:29:38 +02: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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
2016-10-05 08:29:38 +02:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicOpenProjectFeature.h"
2019-05-06 10:36:05 +02:00
#include "RiaGuiApplication.h"
2016-10-05 08:29:38 +02:00
#include "RiuFileDialogTools.h"
2016-10-05 08:29:38 +02:00
#include "RiuMainWindow.h"
#include <QAction>
#include <QFileInfo>
2016-10-05 08:29:38 +02:00
#include <QStyle>
CAF_CMD_SOURCE_INIT( RicOpenProjectFeature, "RicOpenProjectFeature" );
2016-10-05 08:29:38 +02:00
//--------------------------------------------------------------------------------------------------
///
2016-10-05 08:29:38 +02:00
//--------------------------------------------------------------------------------------------------
bool RicOpenProjectFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
2016-10-05 08:29:38 +02:00
//--------------------------------------------------------------------------------------------------
void RicOpenProjectFeature::onActionTriggered( bool isChecked )
2016-10-05 08:29:38 +02:00
{
2019-05-06 10:36:05 +02:00
RiaGuiApplication* app = RiaGuiApplication::instance();
if ( !app->askUserToSaveModifiedProject() ) return;
QString defaultDir = app->lastUsedDialogDirectory( "BINARY_GRID" );
QString fileName = RiuFileDialogTools::getOpenFileName( nullptr,
"Open ResInsight Project",
defaultDir,
"ResInsight project (*.rsp *.rip);;All files(*.*)" );
2016-10-05 08:29:38 +02:00
if ( fileName.isEmpty() ) return;
2016-10-05 08:29:38 +02:00
// Remember the path to next time
app->setLastUsedDialogDirectory( "BINARY_GRID", QFileInfo( fileName ).absolutePath() );
2016-10-05 08:29:38 +02:00
if ( app->loadProject( fileName ) )
2016-10-05 08:29:38 +02:00
{
app->addToRecentFiles( fileName );
2016-10-05 08:29:38 +02:00
}
}
//--------------------------------------------------------------------------------------------------
///
2016-10-05 08:29:38 +02:00
//--------------------------------------------------------------------------------------------------
void RicOpenProjectFeature::setupActionLook( QAction* actionToSetup )
2016-10-05 08:29:38 +02:00
{
actionToSetup->setText( "Open Project" );
2020-10-01 17:25:19 +02:00
actionToSetup->setIcon( QIcon( ":/OpenFolder.svg" ) );
applyShortcutWithHintToAction( actionToSetup, QKeySequence::Open );
2016-10-05 08:29:38 +02:00
}