#846 Created Open Project command feature

This commit is contained in:
Magne Sjaastad
2016-10-05 08:29:38 +02:00
parent c8b73dad68
commit b62bf68c07
5 changed files with 108 additions and 27 deletions

View File

@@ -10,6 +10,7 @@ ${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.h
${CEE_CURRENT_LIST_DIR}RicShowMainWindowFeature.h
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.h
${CEE_CURRENT_LIST_DIR}RicOpenProjectFeature.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -18,6 +19,7 @@ ${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.cpp
${CEE_CURRENT_LIST_DIR}RicShowMainWindowFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicTilePlotWindowsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicOpenProjectFeature.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicOpenProjectFeature.h"
#include "RiaApplication.h"
#include "RiuMainWindow.h"
#include <QAction>
#include <QFileDialog>
#include <QStyle>
CAF_CMD_SOURCE_INIT(RicOpenProjectFeature, "RicOpenProjectFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicOpenProjectFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicOpenProjectFeature::onActionTriggered(bool isChecked)
{
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID");
QString fileName = QFileDialog::getOpenFileName(NULL, "Open ResInsight Project", defaultDir, "ResInsight project (*.rsp *.rip);;All files(*.*)");
if (fileName.isEmpty()) return;
// Remember the path to next time
app->setLastUsedDialogDirectory("BINARY_GRID", QFileInfo(fileName).absolutePath());
if (app->loadProject(fileName))
{
app->addToRecentFiles(fileName);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicOpenProjectFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Open Project");
actionToSetup->setIcon(QApplication::style()->standardIcon(QStyle::SP_DirOpenIcon));
}

View File

@@ -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 RicOpenProjectFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled();
virtual void onActionTriggered( bool isChecked );
virtual void setupActionLook( QAction* actionToSetup );
};