1
0
mirror of https://github.com/woo-j/zint.git synced 2024-12-23 01:33:55 +03:00

Add option to copy to clipboard as BMP

This commit is contained in:
Robin Stuart 2017-05-15 21:12:19 +01:00
parent a1327cbd0d
commit fd8a4f4d35
3 changed files with 42 additions and 11 deletions

View File

@ -561,7 +561,7 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QPushButton" name="btnAbout">
<property name="minimumSize">
<size>
@ -577,7 +577,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="4">
<item row="1" column="5">
<widget class="QPushButton" name="btnSave">
<property name="minimumSize">
<size>
@ -593,7 +593,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="5">
<item row="1" column="6">
<widget class="QPushButton" name="btnExit">
<property name="minimumSize">
<size>
@ -606,7 +606,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -619,8 +619,8 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="btnCopy">
<item row="1" column="3">
<widget class="QPushButton" name="btnCopySVG">
<property name="minimumSize">
<size>
<width>100</width>
@ -631,7 +631,20 @@ p, li { white-space: pre-wrap; }
<string>Copy to clipboard</string>
</property>
<property name="text">
<string>&amp;Copy</string>
<string>Copy S&amp;VG</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="btnCopyBMP">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>&amp;Copy BMP</string>
</property>
</widget>
</item>

View File

@ -150,7 +150,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags fl)
connect(btnMoreData, SIGNAL(clicked( bool )), SLOT(open_data_dialog()));
connect(btnSequence, SIGNAL(clicked( bool )), SLOT(open_sequence_dialog()));
connect(chkHRTHide, SIGNAL(stateChanged( int )), SLOT(update_preview()));
connect(btnCopy, SIGNAL(clicked( bool )), SLOT(copy_to_clipboard()));
connect(btnCopySVG, SIGNAL(clicked( bool )), SLOT(copy_to_clipboard_svg()));
connect(btnCopyBMP, SIGNAL(clicked( bool )), SLOT(copy_to_clipboard_bmp()));
}
MainWindow::~MainWindow()
@ -270,14 +271,14 @@ void MainWindow::quit_now()
close();
}
void MainWindow::copy_to_clipboard()
void MainWindow::copy_to_clipboard_svg()
{
QClipboard *clipboard = QGuiApplication::clipboard();
QMimeData *data = new QMimeData;
QString filename = ".zint.svg";
double scale = spnScale->value();
spnScale->setValue(10);
spnScale->setValue(5);
if (!m_bc.bc.save_to_file(filename)) {
return;
@ -291,6 +292,22 @@ void MainWindow::copy_to_clipboard()
spnScale->setValue(scale);
}
void MainWindow::copy_to_clipboard_bmp()
{
QClipboard *clipboard = QGuiApplication::clipboard();
QMimeData *data = new QMimeData;
QString filename = ".zint.bmp";
if (!m_bc.bc.save_to_file(filename)) {
return;
}
data->setImageData(QImage(filename));
clipboard->setMimeData(data, QClipboard::Clipboard);
QFile::remove(filename);
}
void MainWindow::change_options()
{
QUiLoader uiload;

View File

@ -130,7 +130,8 @@ private slots:
void reset_view();
int open_data_dialog();
int open_sequence_dialog();
void copy_to_clipboard();
void copy_to_clipboard_svg();
void copy_to_clipboard_bmp();
private:
/* void createActions();