mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Always remember previously used directory
This commit is contained in:
parent
b9f37ebceb
commit
468f44f298
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Zint Barcode Generator - the open source barcode generator
|
Zint Barcode Generator - the open source barcode generator
|
||||||
Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -22,6 +22,7 @@
|
|||||||
#include <QUiLoader>
|
#include <QUiLoader>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#include "datawindow.h"
|
#include "datawindow.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -71,33 +72,31 @@ void DataWindow::okay()
|
|||||||
|
|
||||||
void DataWindow::from_file()
|
void DataWindow::from_file()
|
||||||
{
|
{
|
||||||
//QString fileName;
|
QSettings settings;
|
||||||
//QFileDialog fdialog;
|
QFileDialog open_dialog;
|
||||||
QFile file;
|
QString filename;
|
||||||
|
QFile file;
|
||||||
|
QByteArray outstream;
|
||||||
|
|
||||||
//fdialog.setFileMode(QFileDialog::ExistingFile);
|
open_dialog.setWindowTitle("Open File");
|
||||||
//
|
open_dialog.setDirectory(settings.value("studio/default_dir", QDir::toNativeSeparators(QDir::homePath())).toString());
|
||||||
//if(fdialog.exec()) {
|
|
||||||
// fileName = fdialog.selectedFiles().at(0);
|
|
||||||
//} else {
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(this,
|
if (open_dialog.exec()) {
|
||||||
tr("Open File"),
|
filename = open_dialog.selectedFiles().at(0);
|
||||||
"./",
|
} else {
|
||||||
tr("All Files (*);;Text Files (*.txt)"));
|
return;
|
||||||
if (fileName.isEmpty())
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
file.setFileName(fileName);
|
file.setFileName(filename);
|
||||||
if(!file.open(QIODevice::ReadOnly)) {
|
if(!file.open(QIODevice::ReadOnly)) {
|
||||||
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray outstream = file.readAll();
|
outstream = file.readAll();
|
||||||
|
|
||||||
txtDataInput->setPlainText(QString(outstream));
|
txtDataInput->setPlainText(QString(outstream));
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
settings.setValue("studio/default_dir", filename.mid(0, filename.lastIndexOf(QDir::separator())));
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Zint Barcode Generator - the open source barcode generator
|
Zint Barcode Generator - the open source barcode generator
|
||||||
Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -29,20 +29,25 @@
|
|||||||
ExportWindow::ExportWindow()
|
ExportWindow::ExportWindow()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
linDestPath->setText(QDir::toNativeSeparators(QDir::homePath()));
|
|
||||||
|
|
||||||
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(quit_now()));
|
|
||||||
connect(btnOK, SIGNAL( clicked( bool )), SLOT(process()));
|
|
||||||
connect(btnDestPath, SIGNAL( clicked( bool )), SLOT(get_directory()));
|
|
||||||
|
|
||||||
|
linDestPath->setText(settings.value("studio/export/destination", QDir::toNativeSeparators(QDir::homePath())).toString());
|
||||||
|
linPrefix->setText(settings.value("studio/export/file_prefix", "bcs_").toString());
|
||||||
|
cmbFileName->setCurrentIndex(settings.value("studio/export/name_format", 0).toInt());
|
||||||
cmbFileFormat->setCurrentIndex(settings.value("studio/export/filetype", 0).toInt());
|
cmbFileFormat->setCurrentIndex(settings.value("studio/export/filetype", 0).toInt());
|
||||||
|
|
||||||
|
connect(btnCancel, SIGNAL( clicked( bool )), SLOT(quit_now()));
|
||||||
|
connect(btnOK, SIGNAL( clicked( bool )), SLOT(process()));
|
||||||
|
connect(btnDestPath, SIGNAL( clicked( bool )), SLOT(get_directory()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ExportWindow::~ExportWindow()
|
ExportWindow::~ExportWindow()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
|
settings.setValue("studio/export/destination", linDestPath->text());
|
||||||
|
settings.setValue("studio/export/file_prefix", linPrefix->text());
|
||||||
|
settings.setValue("studio/export/name_format", cmbFileName->currentIndex());
|
||||||
settings.setValue("studio/export/filetype", cmbFileFormat->currentIndex());
|
settings.setValue("studio/export/filetype", cmbFileFormat->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,18 +58,21 @@ void ExportWindow::quit_now()
|
|||||||
|
|
||||||
void ExportWindow::get_directory()
|
void ExportWindow::get_directory()
|
||||||
{
|
{
|
||||||
QString directory;
|
QSettings settings;
|
||||||
QFileDialog fdialog;
|
QString directory;
|
||||||
|
QFileDialog fdialog;
|
||||||
|
|
||||||
fdialog.setFileMode(QFileDialog::Directory);
|
fdialog.setFileMode(QFileDialog::Directory);
|
||||||
|
fdialog.setDirectory(settings.value("studio/default_dir", QDir::toNativeSeparators(QDir::homePath())).toString());
|
||||||
|
|
||||||
if(fdialog.exec()) {
|
if(fdialog.exec()) {
|
||||||
directory = fdialog.selectedFiles().at(0);
|
directory = fdialog.selectedFiles().at(0);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
linDestPath->setText(QDir::toNativeSeparators(directory));
|
linDestPath->setText(QDir::toNativeSeparators(directory));
|
||||||
|
settings.setValue("studio/default_dir", directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExportWindow::process()
|
void ExportWindow::process()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
|
* Copyright (C) 2008 by BogDan Vatra <bogdan@licentia.eu> *
|
||||||
* Copyright (C) 2009-2016 by Robin Stuart <rstuart114@gmail.com> *
|
* Copyright (C) 2009-2017 by Robin Stuart <rstuart114@gmail.com> *
|
||||||
* *
|
* *
|
||||||
* This program is free software: you can redistribute it and/or modify *
|
* This program is free software: you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
@ -198,26 +198,32 @@ void MainWindow::reset_view()
|
|||||||
|
|
||||||
bool MainWindow::save()
|
bool MainWindow::save()
|
||||||
{
|
{
|
||||||
bool status;
|
QSettings settings;
|
||||||
|
QFileDialog save_dialog;
|
||||||
|
QString filename;
|
||||||
|
|
||||||
|
save_dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||||
|
save_dialog.setWindowTitle("Save Barcode Image");
|
||||||
|
save_dialog.setDirectory(settings.value("studio/default_dir", QDir::toNativeSeparators(QDir::homePath())).toString());
|
||||||
#ifdef NO_PNG
|
#ifdef NO_PNG
|
||||||
QString fileName = QFileDialog::getSaveFileName(this,
|
save_dialog.setNameFilter(tr("Encapsulated Post Script (*.eps);;Graphics Interchange Format (*.gif);;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx);;Extended Metafile (*.emf);;Tagged Image File Format (*.tif)"));
|
||||||
tr("Save Barcode Image"), ".",
|
|
||||||
tr("Encapsulated Post Script (*.eps);;Graphics Interchange Format (*.gif);;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx);;Extended Metafile (*.emf);;Tagged Image File Format (*.tif)"));
|
|
||||||
#else
|
#else
|
||||||
QString fileName = QFileDialog::getSaveFileName(this,
|
save_dialog.setNameFilter(tr("Portable Network Graphic (*.png);;Encapsulated Post Script (*.eps);;Graphics Interchange Format (*.gif);;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx);;Extended Metafile (*.emf);;Tagged Image File Format (*.tif)"));
|
||||||
tr("Save Barcode Image"), ".",
|
|
||||||
tr("Portable Network Graphic (*.png);;Encapsulated Post Script (*.eps);;Graphics Interchange Format (*.gif);;Scalable Vector Graphic (*.svg);;Windows Bitmap (*.bmp);;ZSoft PC Painter Image (*.pcx);;Extended Metafile (*.emf);;Tagged Image File Format (*.tif)"));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fileName.isEmpty())
|
if (save_dialog.exec()) {
|
||||||
return false;
|
filename = save_dialog.selectedFiles().at(0);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
status = m_bc.bc.save_to_file(fileName);
|
if(m_bc.bc.save_to_file(filename) == false) {
|
||||||
if(status == false) {
|
|
||||||
QMessageBox::critical(this,tr("Save Error"),m_bc.bc.error_message());
|
QMessageBox::critical(this,tr("Save Error"),m_bc.bc.error_message());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return status;
|
|
||||||
|
settings.setValue("studio/default_dir", filename.mid(0, filename.lastIndexOf(QDir::separator())));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::about()
|
void MainWindow::about()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Zint Barcode Generator - the open source barcode generator
|
Zint Barcode Generator - the open source barcode generator
|
||||||
Copyright (C) 2009-2016 Robin Stuart <rstuart114@gmail.com>
|
Copyright (C) 2009-2017 Robin Stuart <rstuart114@gmail.com>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -22,6 +22,7 @@
|
|||||||
#include <QUiLoader>
|
#include <QUiLoader>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#include "sequencewindow.h"
|
#include "sequencewindow.h"
|
||||||
#include "exportwindow.h"
|
#include "exportwindow.h"
|
||||||
@ -30,8 +31,14 @@
|
|||||||
SequenceWindow::SequenceWindow()
|
SequenceWindow::SequenceWindow()
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
QSettings settings;
|
||||||
QValidator *intvalid = new QIntValidator(this);
|
QValidator *intvalid = new QIntValidator(this);
|
||||||
|
|
||||||
|
linStartVal->setText(settings.value("studio/sequence/start_value", "1").toString());
|
||||||
|
linEndVal->setText(settings.value("studio/sequence/end_value", "10").toString());
|
||||||
|
linIncVal->setText(settings.value("studio/sequence/increment", "1").toString());
|
||||||
|
linFormat->setText(settings.value("studio/sequence/format", "$$$$$$").toString());
|
||||||
|
|
||||||
linStartVal->setValidator(intvalid);
|
linStartVal->setValidator(intvalid);
|
||||||
linEndVal->setValidator(intvalid);
|
linEndVal->setValidator(intvalid);
|
||||||
linIncVal->setValidator(intvalid);
|
linIncVal->setValidator(intvalid);
|
||||||
@ -45,6 +52,12 @@ SequenceWindow::SequenceWindow()
|
|||||||
|
|
||||||
SequenceWindow::~SequenceWindow()
|
SequenceWindow::~SequenceWindow()
|
||||||
{
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
settings.setValue("studio/sequence/start_value", linStartVal->text());
|
||||||
|
settings.setValue("studio/sequence/end_value", linEndVal->text());
|
||||||
|
settings.setValue("studio/sequence/increment", linIncVal->text());
|
||||||
|
settings.setValue("studio/sequence/format", linFormat->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SequenceWindow::quit_now()
|
void SequenceWindow::quit_now()
|
||||||
@ -153,36 +166,33 @@ void SequenceWindow::check_generate()
|
|||||||
|
|
||||||
void SequenceWindow::import()
|
void SequenceWindow::import()
|
||||||
{
|
{
|
||||||
//QString fileName;
|
QSettings settings;
|
||||||
//QFileDialog fdialog;
|
QFileDialog import_dialog;
|
||||||
QFile file;
|
QString filename;
|
||||||
QString selectedFilter;
|
QFile file;
|
||||||
|
QByteArray outstream;
|
||||||
|
|
||||||
//fdialog.setFileMode(QFileDialog::ExistingFile);
|
import_dialog.setWindowTitle("Import File");
|
||||||
|
import_dialog.setDirectory(settings.value("studio/default_dir", QDir::toNativeSeparators(QDir::homePath())).toString());
|
||||||
|
|
||||||
//if(fdialog.exec()) {
|
if (import_dialog.exec()) {
|
||||||
// fileName = fdialog.selectedFiles().at(0);
|
filename = import_dialog.selectedFiles().at(0);
|
||||||
//} else {
|
} else {
|
||||||
// return;
|
return;
|
||||||
//}
|
}
|
||||||
|
|
||||||
QString fileName = QFileDialog::getOpenFileName(this,
|
file.setFileName(filename);
|
||||||
tr("Import File"),
|
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
"./",
|
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
||||||
tr("All Files (*);;Text Files (*.txt)"));
|
return;
|
||||||
if (fileName.isEmpty())
|
}
|
||||||
return;
|
|
||||||
|
|
||||||
file.setFileName(fileName);
|
outstream = file.readAll();
|
||||||
if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
|
||||||
QMessageBox::critical(this, tr("Open Error"), tr("Could not open selected file."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray outstream = file.readAll();
|
txtPreview->setPlainText(QString(outstream));
|
||||||
|
file.close();
|
||||||
|
|
||||||
txtPreview->setPlainText(QString(outstream));
|
settings.setValue("studio/default_dir", filename.mid(0, filename.lastIndexOf(QDir::separator())));
|
||||||
file.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SequenceWindow::generate_sequence()
|
void SequenceWindow::generate_sequence()
|
||||||
|
Loading…
Reference in New Issue
Block a user