ResInsight/ApplicationLibCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp

99 lines
3.3 KiB
C++
Raw Normal View History

2016-06-27 14:01:17 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2016 Statoil ASA
//
2016-06-27 14:01:17 -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.
//
2016-06-27 14:01:17 -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.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
2016-06-27 14:01:17 -05:00
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicSnapshotViewToClipboardFeature.h"
#include "RicGridStatisticsDialog.h"
2016-06-27 14:01:17 -05:00
#include "RiaGuiApplication.h"
#include "RiaLogging.h"
2016-06-27 14:01:17 -05:00
#include "RimMainPlotCollection.h"
#include "RimProject.h"
2016-06-27 14:01:17 -05:00
#include "RimViewWindow.h"
2018-04-26 23:28:08 -05:00
#include "RiuPlotMainWindow.h"
#include "cafUtils.h"
2016-06-27 14:01:17 -05:00
#include <QAction>
2016-06-28 04:38:11 -05:00
#include <QClipboard>
#include <QDebug>
#include <QFileInfo>
2016-06-28 04:38:11 -05:00
#include <QMdiSubWindow>
2016-06-27 14:01:17 -05:00
CAF_CMD_SOURCE_INIT( RicSnapshotViewToClipboardFeature, "RicSnapshotViewToClipboardFeature" );
2016-06-27 14:01:17 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicSnapshotViewToClipboardFeature::copyToClipboard( const QImage& image )
{
QClipboard* clipboard = QApplication::clipboard();
if ( clipboard )
{
clipboard->setImage( image );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QIcon RicSnapshotViewToClipboardFeature::icon()
{
2020-10-01 10:25:19 -05:00
return QIcon( ":/SnapShot.svg" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicSnapshotViewToClipboardFeature::text()
{
return "Snapshot To Clipboard";
}
2016-06-27 14:01:17 -05:00
//--------------------------------------------------------------------------------------------------
///
2016-06-27 14:01:17 -05:00
//--------------------------------------------------------------------------------------------------
void RicSnapshotViewToClipboardFeature::onActionTriggered( bool isChecked )
2016-06-27 14:01:17 -05:00
{
disableModelChangeContribution();
RimViewWindow* viewWindow = RiaGuiApplication::activeViewWindow();
2016-06-27 14:01:17 -05:00
if ( viewWindow )
2016-06-27 14:01:17 -05:00
{
QClipboard* clipboard = QApplication::clipboard();
if ( clipboard )
2016-06-27 14:01:17 -05:00
{
QImage image = viewWindow->snapshotWindowContent();
if ( !image.isNull() )
2016-06-27 14:01:17 -05:00
{
clipboard->setImage( image );
2016-06-27 14:01:17 -05:00
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
2016-06-27 14:01:17 -05:00
//--------------------------------------------------------------------------------------------------
void RicSnapshotViewToClipboardFeature::setupActionLook( QAction* actionToSetup )
2016-06-27 14:01:17 -05:00
{
actionToSetup->setText( text() );
actionToSetup->setIcon( icon() );
2016-06-27 14:01:17 -05:00
}