mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add Copy to Clipboard button for file paths
This commit is contained in:
parent
015890841f
commit
a178971835
@ -2,5 +2,6 @@
|
||||
<qresource prefix="/caf">
|
||||
<file>Down16x16.png</file>
|
||||
<file>Up16x16.png</file>
|
||||
<file>duplicate.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -0,0 +1 @@
|
||||
<?xml version="1.0" ?><svg height="22px" version="1.1" viewBox="0 0 21 22" width="21px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><desc/><defs/><g fill="none" fill-rule="evenodd" id="Page-1" stroke="none" stroke-width="1"><g fill="#000000" id="Core" transform="translate(-86.000000, -127.000000)"><g id="content-copy" transform="translate(86.500000, 127.000000)"><path d="M14,0 L2,0 C0.9,0 0,0.9 0,2 L0,16 L2,16 L2,2 L14,2 L14,0 L14,0 Z M17,4 L6,4 C4.9,4 4,4.9 4,6 L4,20 C4,21.1 4.9,22 6,22 L17,22 C18.1,22 19,21.1 19,20 L19,6 C19,4.9 18.1,4 17,4 L17,4 Z M17,20 L6,20 L6,6 L17,6 L17,20 L17,20 Z" id="Shape"/></g></g></g></svg>
|
After Width: | Height: | Size: 725 B |
@ -46,6 +46,7 @@
|
||||
#include "cafQShortenedLabel.h"
|
||||
|
||||
#include <QBoxLayout>
|
||||
#include <QClipboard>
|
||||
#include <QDir>
|
||||
#include <QFileDialog>
|
||||
#include <QIntValidator>
|
||||
@ -69,7 +70,7 @@ void PdmUiFilePathEditor::configureAndUpdateUi( const QString& uiConfigName )
|
||||
PdmUiLineEditor::updateLineEditFromReadOnlyState( m_lineEdit, uiField()->isUiReadOnly( uiConfigName ) );
|
||||
|
||||
m_lineEdit->setToolTip( uiField()->uiToolTip( uiConfigName ) );
|
||||
m_button->setEnabled( !uiField()->isUiReadOnly( uiConfigName ) );
|
||||
m_button->setHidden( uiField()->isUiReadOnly( uiConfigName ) );
|
||||
|
||||
caf::PdmUiObjectHandle* uiObject = uiObj( uiField()->fieldHandle()->ownerObject() );
|
||||
if ( uiObject )
|
||||
@ -102,10 +103,17 @@ QWidget* PdmUiFilePathEditor::createEditorWidget( QWidget* parent )
|
||||
m_button->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) );
|
||||
m_button->setText( QLatin1String( "..." ) );
|
||||
|
||||
m_copyToClipboardButton = new QToolButton( parent );
|
||||
m_copyToClipboardButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred ) );
|
||||
m_copyToClipboardButton->setToolTip( QLatin1String( "Copy to Clipboard" ) );
|
||||
m_copyToClipboardButton->setIcon( QIcon( ":/caf/duplicate.svg" ) );
|
||||
|
||||
layout->addWidget( m_lineEdit );
|
||||
layout->addWidget( m_button );
|
||||
layout->addWidget( m_copyToClipboardButton );
|
||||
|
||||
connect( m_button, SIGNAL( clicked() ), this, SLOT( fileSelectionClicked() ) );
|
||||
connect( m_copyToClipboardButton, SIGNAL( clicked() ), this, SLOT( copyToClipboard() ) );
|
||||
connect( m_lineEdit, SIGNAL( editingFinished() ), this, SLOT( slotEditingFinished() ) );
|
||||
|
||||
return placeholder;
|
||||
@ -217,4 +225,16 @@ void PdmUiFilePathEditor::fileSelectionClicked()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void PdmUiFilePathEditor::copyToClipboard()
|
||||
{
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
if ( clipboard )
|
||||
{
|
||||
clipboard->setText( m_lineEdit->text() );
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace caf
|
||||
|
@ -95,11 +95,13 @@ protected:
|
||||
protected slots:
|
||||
void slotEditingFinished();
|
||||
void fileSelectionClicked();
|
||||
void copyToClipboard();
|
||||
|
||||
private:
|
||||
QPointer<QLineEdit> m_lineEdit;
|
||||
QPointer<QShortenedLabel> m_label;
|
||||
QPointer<QToolButton> m_button;
|
||||
QPointer<QToolButton> m_copyToClipboardButton;
|
||||
|
||||
PdmUiFilePathEditorAttribute m_attributes;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user