mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-03-22 04:59:59 +01:00
Merge pull request #329 from plc-user/master
Set default-location for projects to documents-dir.
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "conductornumexport.h"
|
#include "conductornumexport.h"
|
||||||
|
|
||||||
|
#include "qetapp.h"
|
||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "diagramcontent.h"
|
#include "diagramcontent.h"
|
||||||
#include "qetgraphicsitem/conductor.h"
|
#include "qetgraphicsitem/conductor.h"
|
||||||
@@ -45,7 +46,10 @@ ConductorNumExport::ConductorNumExport(QETProject *project, QWidget *parent) :
|
|||||||
*/
|
*/
|
||||||
bool ConductorNumExport::toCsv()
|
bool ConductorNumExport::toCsv()
|
||||||
{
|
{
|
||||||
QString name = QObject::tr("numero_de_fileries_") + m_project->title() + ".csv";
|
//save in csv file in same directory as project by default
|
||||||
|
QString dir = m_project->currentDir();
|
||||||
|
if (dir.isEmpty()) dir = QETApp::documentDir();
|
||||||
|
QString name = dir + "/" + QObject::tr("numero_de_fileries_") + m_project->title() + ".csv";
|
||||||
// if(!name.endsWith(".csv")) {
|
// if(!name.endsWith(".csv")) {
|
||||||
// name += ".csv";
|
// name += ".csv";
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -670,8 +670,7 @@ void projectDataBase::exportDb(projectDataBase *db,
|
|||||||
if(dir_.isEmpty()) {
|
if(dir_.isEmpty()) {
|
||||||
dir_ = db->project()->filePath();
|
dir_ = db->project()->filePath();
|
||||||
if (dir_.isEmpty()) {
|
if (dir_.isEmpty()) {
|
||||||
dir_ = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).first();
|
dir_ = QETApp::documentDir() + "/" + tr("sans_nom") + ".sqlite";
|
||||||
dir_ += QString("/") += tr("sans_nom") += ".sqlite";
|
|
||||||
} else {
|
} else {
|
||||||
dir_.remove(".qet");
|
dir_.remove(".qet");
|
||||||
dir_.append(".sqlite");
|
dir_.append(".sqlite");
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "diagrameventaddimage.h"
|
#include "diagrameventaddimage.h"
|
||||||
|
|
||||||
|
#include "../qetapp.h"
|
||||||
#include "../diagram.h"
|
#include "../diagram.h"
|
||||||
#include "../undocommand/addgraphicsobjectcommand.h"
|
#include "../undocommand/addgraphicsobjectcommand.h"
|
||||||
#include "../qetgraphicsitem/diagramimageitem.h"
|
#include "../qetgraphicsitem/diagramimageitem.h"
|
||||||
@@ -155,7 +156,7 @@ void DiagramEventAddImage::openDialog()
|
|||||||
if (m_diagram -> isReadOnly()) return;
|
if (m_diagram -> isReadOnly()) return;
|
||||||
|
|
||||||
//Open dialog to select image
|
//Open dialog to select image
|
||||||
QString pathPictures = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
|
QString pathPictures = QETApp::pictureDir();
|
||||||
QString fileName = QFileDialog::getOpenFileName(m_diagram->views().isEmpty()? nullptr : m_diagram->views().first(), QObject::tr("Selectionner une image..."), pathPictures, QObject::tr("Image Files (*.png *.jpg *.jpeg *.bmp *.svg)"));
|
QString fileName = QFileDialog::getOpenFileName(m_diagram->views().isEmpty()? nullptr : m_diagram->views().first(), QObject::tr("Selectionner une image..."), pathPictures, QObject::tr("Image Files (*.png *.jpg *.jpeg *.bmp *.svg)"));
|
||||||
|
|
||||||
if (fileName.isEmpty()) return;
|
if (fileName.isEmpty()) return;
|
||||||
|
|||||||
@@ -16,21 +16,18 @@
|
|||||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "exportproperties.h"
|
#include "exportproperties.h"
|
||||||
|
#include "qetapp.h"
|
||||||
#include <QStandardPaths>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur par defaut :
|
Constructeur par defaut :
|
||||||
* le repertoire de destination est le Bureau de l'utilisateur
|
* le repertoire de destination est l'emplacement des documents de l'utilisateur
|
||||||
* le format d'export est PNG
|
* le format d'export est PNG
|
||||||
* la grille et les bornes ne doivent pas etre dessinees
|
* la grille et les bornes ne doivent pas etre dessinees
|
||||||
* la bordure et le cartouche doivent etre dessines
|
* la bordure et le cartouche doivent etre dessines
|
||||||
* la zone exportee est le schema avec son cadre et son cartouche
|
* la zone exportee est le schema avec son cadre et son cartouche
|
||||||
*/
|
*/
|
||||||
ExportProperties::ExportProperties() :
|
ExportProperties::ExportProperties() :
|
||||||
destination_directory(
|
destination_directory(QETApp::documentDir()),
|
||||||
QStandardPaths::writableLocation(
|
|
||||||
QStandardPaths::DesktopLocation)),
|
|
||||||
format("PNG"),
|
format("PNG"),
|
||||||
draw_grid(false),
|
draw_grid(false),
|
||||||
draw_border(true),
|
draw_border(true),
|
||||||
@@ -85,14 +82,13 @@ void ExportProperties::toSettings(QSettings &settings,
|
|||||||
*/
|
*/
|
||||||
void ExportProperties::fromSettings(QSettings &settings,
|
void ExportProperties::fromSettings(QSettings &settings,
|
||||||
const QString &prefix) {
|
const QString &prefix) {
|
||||||
QString desktop_path = QStandardPaths::writableLocation(
|
QString export_path = QETApp::documentDir();
|
||||||
QStandardPaths::DesktopLocation);
|
|
||||||
destination_directory.setPath(
|
destination_directory.setPath(
|
||||||
settings.value(
|
settings.value(
|
||||||
prefix + "path",
|
prefix + "path",
|
||||||
desktop_path).toString());
|
export_path).toString());
|
||||||
if (!destination_directory.exists())
|
if (!destination_directory.exists())
|
||||||
destination_directory.setPath(desktop_path);
|
destination_directory.setPath(export_path);
|
||||||
|
|
||||||
format = settings.value(prefix + "format").toString();
|
format = settings.value(prefix + "format").toString();
|
||||||
|
|
||||||
|
|||||||
@@ -869,6 +869,44 @@ QString QETApp::dataDir()
|
|||||||
return datadir;
|
return datadir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief QETApp::documentDir
|
||||||
|
Return the standard-folder where to save users documents
|
||||||
|
This directory is generally
|
||||||
|
C:/Users/<USER>/Documents
|
||||||
|
on Windows and
|
||||||
|
~/Documents
|
||||||
|
under UNIX-like systems.
|
||||||
|
\~ @return The path of users document-folder
|
||||||
|
*/
|
||||||
|
QString QETApp::documentDir()
|
||||||
|
{
|
||||||
|
QString docdir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
|
||||||
|
if (docdir.endsWith('/')) {
|
||||||
|
docdir.remove(docdir.length()-1, 1);
|
||||||
|
}
|
||||||
|
return docdir;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief QETApp::pictureDir
|
||||||
|
Returns the standard-folder of users pictures
|
||||||
|
This directory is generally
|
||||||
|
C:/Users/<USER>/Pictures
|
||||||
|
on Windows and
|
||||||
|
~/Pictures
|
||||||
|
under UNIX-like systems.
|
||||||
|
\~ @return The path of users picture-folder
|
||||||
|
*/
|
||||||
|
QString QETApp::pictureDir()
|
||||||
|
{
|
||||||
|
QString picturedir = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
|
||||||
|
if (picturedir.endsWith('/')) {
|
||||||
|
picturedir.remove(picturedir.length()-1, 1);
|
||||||
|
}
|
||||||
|
return picturedir;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@brief QETApp::realPath
|
@brief QETApp::realPath
|
||||||
Allows you to know the absolute path of the * .elmt file
|
Allows you to know the absolute path of the * .elmt file
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ class QETApp : public QObject
|
|||||||
static int projectId(const QETProject *);
|
static int projectId(const QETProject *);
|
||||||
static QString configDir();
|
static QString configDir();
|
||||||
static QString dataDir();
|
static QString dataDir();
|
||||||
|
static QString documentDir();
|
||||||
|
static QString pictureDir();
|
||||||
static QString languagesPath();
|
static QString languagesPath();
|
||||||
static QString realPath(const QString &);
|
static QString realPath(const QString &);
|
||||||
static QString symbolicPath(const QString &);
|
static QString symbolicPath(const QString &);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
|||||||
m_zoom_actions_group (this),
|
m_zoom_actions_group (this),
|
||||||
m_select_actions_group (this),
|
m_select_actions_group (this),
|
||||||
m_file_actions_group (this),
|
m_file_actions_group (this),
|
||||||
open_dialog_dir (QStandardPaths::writableLocation(QStandardPaths::DesktopLocation))
|
open_dialog_dir (QETApp::documentDir())
|
||||||
{
|
{
|
||||||
//Trivial property use to set the graphics handler size
|
//Trivial property use to set the graphics handler size
|
||||||
setProperty("graphics_handler_size", 10);
|
setProperty("graphics_handler_size", 10);
|
||||||
|
|||||||
@@ -36,7 +36,6 @@
|
|||||||
#include "qetversion.h"
|
#include "qetversion.h"
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QStandardPaths>
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
@@ -361,15 +360,17 @@ void QETProject::setFilePath(const QString &filepath)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return le dossier contenant le fichier projet si celui-ci a ete
|
@return the folder containing the project file if it has been saved;
|
||||||
enregistre ; dans le cas contraire, cette methode retourne l'emplacement
|
otherwise, this method returns the location of the user's documents.
|
||||||
du bureau de l'utilisateur.
|
en français:
|
||||||
|
@return le dossier contenant le fichier du projet s'il a été enregistré ;
|
||||||
|
sinon, cette méthode renvoie l'emplacement des documents de l'utilisateur.
|
||||||
*/
|
*/
|
||||||
QString QETProject::currentDir() const
|
QString QETProject::currentDir() const
|
||||||
{
|
{
|
||||||
QString current_directory;
|
QString current_directory;
|
||||||
if (m_file_path.isEmpty()) {
|
if (m_file_path.isEmpty()) {
|
||||||
current_directory = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
current_directory = QETApp::documentDir();
|
||||||
} else {
|
} else {
|
||||||
current_directory = QFileInfo(m_file_path).absoluteDir().absolutePath();
|
current_directory = QFileInfo(m_file_path).absoluteDir().absolutePath();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,11 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "templatelogomanager.h"
|
#include "templatelogomanager.h"
|
||||||
|
|
||||||
|
#include "../qetapp.h"
|
||||||
#include "../qeticons.h"
|
#include "../qeticons.h"
|
||||||
#include "../titleblocktemplate.h"
|
#include "../titleblocktemplate.h"
|
||||||
|
|
||||||
#include <QStandardPaths>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructor
|
Constructor
|
||||||
@param managed_template Title block template this widget manages logos for.
|
@param managed_template Title block template this widget manages logos for.
|
||||||
@@ -78,7 +77,7 @@ void TitleBlockTemplateLogoManager::emitLogosChangedSignal()
|
|||||||
*/
|
*/
|
||||||
void TitleBlockTemplateLogoManager::initWidgets()
|
void TitleBlockTemplateLogoManager::initWidgets()
|
||||||
{
|
{
|
||||||
open_dialog_dir_.setPath(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
|
open_dialog_dir_.setPath(QETApp::documentDir());
|
||||||
|
|
||||||
setWindowTitle(tr("Gestionnaire de logos"));
|
setWindowTitle(tr("Gestionnaire de logos"));
|
||||||
setWindowIcon(QET::Icons::InsertImage);
|
setWindowIcon(QET::Icons::InsertImage);
|
||||||
|
|||||||
@@ -62,8 +62,10 @@ int BOMExportDialog::exec()
|
|||||||
auto r = QDialog::exec();
|
auto r = QDialog::exec();
|
||||||
if (r == QDialog::Accepted)
|
if (r == QDialog::Accepted)
|
||||||
{
|
{
|
||||||
//save in csv file
|
//save in csv file in same directory as project by default
|
||||||
QString file_name = tr("nomenclature_") + QString(m_project ->title() + ".csv");
|
QString dir = m_project->currentDir();
|
||||||
|
if (dir.isEmpty()) dir = QETApp::documentDir();
|
||||||
|
QString file_name = dir + "/" + tr("nomenclature_") + QString(m_project ->title() + ".csv");
|
||||||
QString file_path = QFileDialog::getSaveFileName(this, tr("Enregister sous... "), file_name, tr("Fichiers csv (*.csv)"));
|
QString file_path = QFileDialog::getSaveFileName(this, tr("Enregister sous... "), file_name, tr("Fichiers csv (*.csv)"));
|
||||||
QFile file(file_path);
|
QFile file(file_path);
|
||||||
if (!file_path.isEmpty())
|
if (!file_path.isEmpty())
|
||||||
|
|||||||
Reference in New Issue
Block a user