mirror of
https://github.com/digarok/buckshot.git
synced 2024-12-04 02:50:25 +00:00
Merge pull request #9 from digarok/save-preview
add option to directly save preview - tested lightly, but not going to let this one bake too long. it's not a big change.
This commit is contained in:
commit
ea97c362dd
@ -9,7 +9,7 @@
|
||||
#include "qformlayout.h"
|
||||
#include "qdialogbuttonbox.h"
|
||||
const QString MainWindow::programName = QString("buckshot");
|
||||
const QString MainWindow::version = QString("0.03h"); // hotfix
|
||||
const QString MainWindow::version = QString("0.04");
|
||||
const QString MainWindow::imageName = QString("saved");
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
@ -102,6 +102,27 @@ MainWindow::~MainWindow()
|
||||
}
|
||||
|
||||
|
||||
bool MainWindow::check_canPreview()
|
||||
{
|
||||
if (ui->label_source->pixmap() == nullptr) {
|
||||
ui->plainTextEdit_lastCmd->setPlainText("Please open a source image to run a preview!");
|
||||
repaint();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MainWindow::check_canSave()
|
||||
{
|
||||
if (ui->label_preview->pixmap() == nullptr) {
|
||||
ui->plainTextEdit_lastCmd->setPlainText("Please open a source image and run a preview first!");
|
||||
repaint();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateDisplayModes() {
|
||||
|
||||
QList<int> disabledList = QList<int>();
|
||||
@ -166,6 +187,7 @@ void MainWindow::updateDisplayModes() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_pushButton_sourceFilename_clicked()
|
||||
{
|
||||
QString filename = QFileDialog::getOpenFileName();
|
||||
@ -181,6 +203,7 @@ void MainWindow::on_pushButton_sourceFilename_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::updateInputSize()
|
||||
{
|
||||
switch (ui->comboBox_inputResolution->currentIndex()) {
|
||||
@ -228,6 +251,7 @@ void MainWindow::updateInputSize()
|
||||
ui->label_scaleFactor->setText(scaleString);
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::livePreview()
|
||||
{
|
||||
if (ui->checkBox_livePreview->isChecked()) {
|
||||
@ -237,15 +261,10 @@ void MainWindow::livePreview()
|
||||
|
||||
|
||||
// This is the actual preview generation/main logic function
|
||||
|
||||
void MainWindow::on_pushButton_preview_clicked()
|
||||
{
|
||||
if (ui->label_source->pixmap() == nullptr) {
|
||||
QString noImage = "Please open a source image first";
|
||||
ui->plainTextEdit_lastCmd->setPlainText(noImage);
|
||||
repaint();
|
||||
return;
|
||||
}
|
||||
if (!check_canPreview()) return;
|
||||
|
||||
// GET SCALE FACTOR
|
||||
updateInputSize();
|
||||
|
||||
@ -345,6 +364,7 @@ void MainWindow::previewTimerTimeout()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_horizontalSlider_crossHatch_valueChanged(int value)
|
||||
{
|
||||
if (value==0){
|
||||
@ -366,6 +386,7 @@ void MainWindow::on_horizontalSlider_colorBleed_valueChanged(int value)
|
||||
updateNeeded = 1;
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_comboBox_outputFormat_currentIndexChanged(int /*unused*/)
|
||||
{
|
||||
updateNeeded = 1;
|
||||
@ -407,12 +428,11 @@ void MainWindow::on_actionWhat_is_this_triggered()
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::on_pushButton_saveImage_clicked()
|
||||
{
|
||||
if (ui->label_preview->pixmap() == nullptr) {
|
||||
ui->plainTextEdit_lastCmd->document()->setPlainText("Please open a source image and run a preview first!");
|
||||
return;
|
||||
}
|
||||
if (!check_canSave()) return;
|
||||
|
||||
QString a2filename;
|
||||
QString suffix;
|
||||
QString filters = QString("All Images (*.A2FC *.BIN *.SLO *.DLO);;HGR (*.BIN);;DHGR (*.A2FC);;LR (*.SLO);;DLR (*.DLO);;All files (*.*)");
|
||||
@ -457,12 +477,7 @@ void MainWindow::on_pushButton_saveImage_clicked()
|
||||
// I consider this small feature a present to the community.
|
||||
void MainWindow::on_pushButton_saveToProdos_clicked()
|
||||
{
|
||||
// @Todo: This isn't appropriate when someone changes res/source and has
|
||||
// a previous preview pixmap, it will think we are all OK.
|
||||
if (ui->label_preview->pixmap() == nullptr) {
|
||||
ui->plainTextEdit_lastCmd->document()->setPlainText("Please open a source image and run a preview first!");
|
||||
return;
|
||||
}
|
||||
if (!check_canSave()) return;
|
||||
|
||||
QString cadiusPath = "/Users/dbrock/appleiigs/tools/Cadius";
|
||||
cadiusPath = QString("%1/Cadius").arg(QCoreApplication::applicationDirPath());
|
||||
@ -653,10 +668,6 @@ void MainWindow::on_pushButton_saveToProdos_clicked()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (ok && !prodosFileName.isEmpty()) {
|
||||
// COPY IT ... OVER EXISTING NAME?
|
||||
QString saveFile = QString("%1/%2").arg(tmpDirPath,prodosFileName);
|
||||
@ -749,3 +760,28 @@ void MainWindow::on_comboBox_previewPalette_currentIndexChanged(int /*unused*/)
|
||||
{
|
||||
updateNeeded = 1;
|
||||
}
|
||||
|
||||
void MainWindow::on_pushButton_savePreview_clicked()
|
||||
{
|
||||
if (!check_canSave()) return;
|
||||
QString a2filename;
|
||||
|
||||
QString filters = QString("All Images (*.BMP *.PNG);;Bitmap (*.BMP);;PNG (*.PNG);;All files (*.*)");
|
||||
QString defaultFilter = "PNG (*.PNG)";
|
||||
QString suffix = ".PNG";
|
||||
|
||||
// PROMPT FOR SAVE FILENAME AND COPY (HOPEFULLY) TO SAVE FILENAME
|
||||
QString saveFile = QFileDialog::getSaveFileName(nullptr, "Save file", QDir::currentPath(), filters, &defaultFilter);
|
||||
if (QFile::exists(saveFile)) {
|
||||
QFile::remove(saveFile);
|
||||
}
|
||||
|
||||
// TRY TO SET CORRECT TYPE FOR SAVE, DEFAULT TO PNG
|
||||
QFileInfo fi(saveFile);
|
||||
QString ext = fi.completeSuffix().toUpper();
|
||||
if (ext == "BMP") {
|
||||
ui->label_preview->pixmap()->save(saveFile,"BMP", 0);
|
||||
} else {
|
||||
ui->label_preview->pixmap()->save(saveFile,"PNG", 0);
|
||||
}
|
||||
}
|
||||
|
@ -43,12 +43,16 @@ private slots:
|
||||
void on_comboBox_dithering_currentIndexChanged(int index);
|
||||
void on_comboBox_previewPalette_currentIndexChanged(int index);
|
||||
|
||||
void on_pushButton_savePreview_clicked();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
void updateInputSize();
|
||||
void livePreview();
|
||||
void updateDisplayModes();
|
||||
bool check_canSave();
|
||||
bool check_canPreview();
|
||||
|
||||
int inputWidth;
|
||||
int inputHeight;
|
||||
bool updateNeeded;
|
||||
|
@ -312,9 +312,9 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>360</x>
|
||||
<y>385</y>
|
||||
<y>370</y>
|
||||
<width>291</width>
|
||||
<height>79</height>
|
||||
<height>71</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
@ -329,14 +329,14 @@
|
||||
<widget class="QPushButton" name="pushButton_saveImage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>410</x>
|
||||
<x>370</x>
|
||||
<y>480</y>
|
||||
<width>121</width>
|
||||
<width>141</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save Image File</string>
|
||||
<string>Save Binary Image</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="Line" name="line">
|
||||
@ -355,14 +355,14 @@
|
||||
<widget class="QPushButton" name="pushButton_saveToProdos">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>530</x>
|
||||
<x>510</x>
|
||||
<y>480</y>
|
||||
<width>121</width>
|
||||
<width>141</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save To ProDOS</string>
|
||||
<string>Save to ProDOS</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_8">
|
||||
@ -395,7 +395,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>360</x>
|
||||
<y>355</y>
|
||||
<y>340</y>
|
||||
<width>131</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
@ -431,7 +431,7 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>490</x>
|
||||
<y>355</y>
|
||||
<y>340</y>
|
||||
<width>141</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
@ -461,6 +461,19 @@
|
||||
<string>Preview</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton_savePreview">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<y>450</y>
|
||||
<width>281</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save preview as PNG/BMP</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
|
Loading…
Reference in New Issue
Block a user