Files
ResInsight/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp

108 lines
3.6 KiB
C++
Raw Normal View History

2016-06-27 21:01:17 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil ASA
//
2016-06-27 21:01:17 +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-06-27 21:01:17 +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-06-27 21:01:17 +02:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicSnapshotViewToClipboardFeature.h"
#include "RicGridStatisticsDialog.h"
2016-06-27 21:01:17 +02:00
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
2016-06-27 21:01:17 +02:00
#include "RimMainPlotCollection.h"
#include "RimProject.h"
2016-06-27 21:01:17 +02:00
#include "RimViewWindow.h"
2018-04-27 06:28:08 +02:00
#include "RiuPlotMainWindow.h"
#include "cafUtils.h"
2016-06-27 21:01:17 +02:00
#include <QAction>
2016-06-28 11:38:11 +02:00
#include <QClipboard>
#include <QDebug>
#include <QFileDialog>
#include <QFileInfo>
2016-06-28 11:38:11 +02:00
#include <QMdiSubWindow>
2016-06-27 21:01:17 +02:00
CAF_CMD_SOURCE_INIT( RicSnapshotViewToClipboardFeature, "RicSnapshotViewToClipboardFeature" );
2016-06-27 21:01:17 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSnapshotViewToClipboardFeature::copyToClipboard( const QImage& image )
{
QClipboard* clipboard = QApplication::clipboard();
if ( clipboard )
{
clipboard->setImage( image );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QIcon RicSnapshotViewToClipboardFeature::icon()
{
return QIcon( ":/SnapShot.png" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSnapshotViewToClipboardFeature::text()
{
return "Snapshot To Clipboard";
}
2016-06-27 21:01:17 +02:00
//--------------------------------------------------------------------------------------------------
///
2016-06-27 21:01:17 +02:00
//--------------------------------------------------------------------------------------------------
bool RicSnapshotViewToClipboardFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
2016-06-27 21:01:17 +02:00
//--------------------------------------------------------------------------------------------------
void RicSnapshotViewToClipboardFeature::onActionTriggered( bool isChecked )
2016-06-27 21:01:17 +02:00
{
this->disableModelChangeContribution();
RimViewWindow* viewWindow = RiaGuiApplication::activeViewWindow();
2016-06-27 21:01:17 +02:00
if ( viewWindow )
2016-06-27 21:01:17 +02:00
{
QClipboard* clipboard = QApplication::clipboard();
if ( clipboard )
2016-06-27 21:01:17 +02:00
{
QImage image = viewWindow->snapshotWindowContent();
if ( !image.isNull() )
2016-06-27 21:01:17 +02:00
{
clipboard->setImage( image );
2016-06-27 21:01:17 +02:00
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
2016-06-27 21:01:17 +02:00
//--------------------------------------------------------------------------------------------------
void RicSnapshotViewToClipboardFeature::setupActionLook( QAction* actionToSetup )
2016-06-27 21:01:17 +02:00
{
actionToSetup->setText( text() );
actionToSetup->setIcon( icon() );
2016-06-27 21:01:17 +02:00
}