#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 );
};

View File

@ -232,7 +232,6 @@ void RiuMainWindow::closeEvent(QCloseEvent* event)
void RiuMainWindow::createActions()
{
// File actions
m_openProjectAction = new QAction(style()->standardIcon(QStyle::SP_DirOpenIcon), "&Open Project", this);
m_openLastUsedProjectAction = new QAction("Open &Last Used Project", this);
m_importGeoMechCaseAction = new QAction(QIcon(":/GeoMechCase48x48.png"), "Import &Geo Mechanical Model", this);
@ -258,7 +257,6 @@ void RiuMainWindow::createActions()
m_exitAction = new QAction("E&xit", this);
connect(m_openProjectAction, SIGNAL(triggered()), SLOT(slotOpenProject()));
connect(m_openLastUsedProjectAction, SIGNAL(triggered()), SLOT(slotOpenLastUsedProject()));
connect(m_importGeoMechCaseAction, SIGNAL(triggered()), SLOT(slotImportGeoMechModel()));
@ -380,7 +378,7 @@ void RiuMainWindow::createMenus()
menuBar()->addMenu(fileMenu);
fileMenu->addAction(m_openProjectAction);
fileMenu->addAction(cmdFeatureMgr->action("RicOpenProjectFeature"));
fileMenu->addAction(m_openLastUsedProjectAction);
fileMenu->addSeparator();
@ -485,7 +483,7 @@ void RiuMainWindow::createToolBars()
m_standardToolBar->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature"));
m_standardToolBar->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature"));
m_standardToolBar->addAction(m_openProjectAction);
m_standardToolBar->addAction(cmdFeatureMgr->action("RicOpenProjectFeature"));
//m_standardToolBar->addAction(m_openLastUsedProjectAction);
m_standardToolBar->addAction(m_saveProjectAction);
@ -849,27 +847,6 @@ void RiuMainWindow::slotImportGeoMechModel()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMainWindow::slotOpenProject()
{
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID");
QString fileName = QFileDialog::getOpenFileName(this, "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);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -140,7 +140,6 @@ private:
private:
// File actions
QAction* m_importGeoMechCaseAction;
QAction* m_openProjectAction;
QAction* m_openLastUsedProjectAction;
QAction* m_saveProjectAction;
QAction* m_saveProjectAsAction;
@ -206,7 +205,6 @@ private slots:
// File slots
void slotImportGeoMechModel();
void slotOpenProject();
void slotOpenLastUsedProject();
void slotSaveProject();
void slotSaveProjectAs();