mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
TBT editor: logos manager: added an "export" button.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@1803 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
parent
5f006e7ece
commit
3e4b948fd6
@ -85,6 +85,7 @@ void TitleBlockTemplateLogoManager::initWidgets() {
|
||||
logos_view_ -> setMovement(QListView::Static);
|
||||
logos_view_ -> setResizeMode(QListView::Adjust);
|
||||
add_button_ = new QPushButton(QET::Icons::Add, tr("Ajouter un logo"));
|
||||
export_button_ = new QPushButton(QET::Icons::DocumentExport, tr("Exporter ce logo"));
|
||||
delete_button_ = new QPushButton(QET::Icons::Remove, tr("Supprimer ce logo"));
|
||||
logo_box_ = new QGroupBox(tr("Propri\351t\351s"));
|
||||
logo_name_label_ = new QLabel(tr("Nom :"));
|
||||
@ -99,7 +100,7 @@ void TitleBlockTemplateLogoManager::initWidgets() {
|
||||
hlayout1_ -> addWidget(rename_button_);
|
||||
|
||||
hlayout0_ = new QHBoxLayout();
|
||||
hlayout0_ -> addWidget(add_button_);
|
||||
hlayout0_ -> addWidget(export_button_);
|
||||
hlayout0_ -> addWidget(delete_button_);
|
||||
|
||||
vlayout1_ = new QVBoxLayout();
|
||||
@ -110,6 +111,7 @@ void TitleBlockTemplateLogoManager::initWidgets() {
|
||||
vlayout0_ = new QVBoxLayout();
|
||||
vlayout0_ -> addWidget(logos_label_);
|
||||
vlayout0_ -> addWidget(logos_view_);
|
||||
vlayout0_ -> addWidget(add_button_);
|
||||
vlayout0_ -> addLayout(hlayout0_);
|
||||
vlayout0_ -> addWidget(logo_box_);
|
||||
setLayout(vlayout0_);
|
||||
@ -121,6 +123,7 @@ void TitleBlockTemplateLogoManager::initWidgets() {
|
||||
SLOT(updateLogoInformations(QListWidgetItem *, QListWidgetItem *))
|
||||
);
|
||||
connect(add_button_, SIGNAL(released()), this, SLOT(addLogo()));
|
||||
connect(export_button_, SIGNAL(released()), this, SLOT(exportLogo()));
|
||||
connect(delete_button_, SIGNAL(released()), this, SLOT(removeLogo()));
|
||||
connect(rename_button_, SIGNAL(released()), this, SLOT(renameLogo()));
|
||||
}
|
||||
@ -285,6 +288,29 @@ void TitleBlockTemplateLogoManager::addLogo() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Export the currently selected logo
|
||||
*/
|
||||
void TitleBlockTemplateLogoManager::exportLogo() {
|
||||
QString current_logo = currentLogo();
|
||||
if (current_logo.isNull()) return;
|
||||
|
||||
QString filepath = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
tr("Choisir un fichier pour exporter ce logo"),
|
||||
open_dialog_dir_.absolutePath() + "/" + current_logo,
|
||||
tr("Tous les fichiers (*);;Images vectorielles (*.svg);;Images bitmap (*.png *.jpg *.jpeg *.gif *.bmp *.xpm)")
|
||||
);
|
||||
if (filepath.isEmpty()) return;
|
||||
|
||||
bool save_logo = managed_template_ -> saveLogoToFile(current_logo, filepath);
|
||||
if (!save_logo) {
|
||||
QMessageBox::critical(this, tr("Erreur"), QString(tr("Impossible d'exporter vers le fichier sp\351cifi\351")));
|
||||
} else {
|
||||
open_dialog_dir_ = QDir(filepath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Delete the currently selected logo.
|
||||
*/
|
||||
|
@ -52,6 +52,7 @@ class TitleBlockTemplateLogoManager : public QWidget {
|
||||
private slots:
|
||||
void updateLogoInformations(QListWidgetItem *, QListWidgetItem *);
|
||||
void addLogo();
|
||||
void exportLogo();
|
||||
void removeLogo();
|
||||
void renameLogo();
|
||||
|
||||
@ -63,7 +64,8 @@ class TitleBlockTemplateLogoManager : public QWidget {
|
||||
QLabel *logos_label_; ///< simple displayed label
|
||||
QListWidget *logos_view_; ///< area showing the logos
|
||||
QPushButton *add_button_; ///< button to add a new logo
|
||||
QPushButton *delete_button_; ///< button to delete an embeded logo
|
||||
QPushButton *export_button_; ///< button to export an embedded logo
|
||||
QPushButton *delete_button_; ///< button to delete an embedded logo
|
||||
QGroupBox *logo_box_; ///< current logo properties box
|
||||
QLabel *logo_name_label_; ///< "name:" label
|
||||
QLineEdit *logo_name_; ///< current logo name
|
||||
|
@ -1079,7 +1079,7 @@ bool TitleBlockTemplate::addLogo(const QString &logo_name, QByteArray *logo_data
|
||||
|
||||
/**
|
||||
@param filepath Path of the image file to add as a logo
|
||||
@param logo_name Name used to store the logo; if none is provided, the
|
||||
@param name Name used to store the logo; if none is provided, the
|
||||
basename of the first argument is used.
|
||||
@return true if the logo could be deleted, false otherwise
|
||||
*/
|
||||
@ -1100,6 +1100,26 @@ bool TitleBlockTemplate::addLogoFromFile(const QString &filepath, const QString
|
||||
return addLogo(filename, &file_content, filepath_info.suffix(), "base64");
|
||||
}
|
||||
|
||||
/*
|
||||
@param logo_name Name used to store the logo
|
||||
@param filepath Path the logo will be saved as
|
||||
@return true if the logo could be exported, false otherwise
|
||||
*/
|
||||
bool TitleBlockTemplate::saveLogoToFile(const QString &logo_name, const QString &filepath) {
|
||||
if (!data_logos_.contains(logo_name)) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
QFile target_file(filepath);
|
||||
if (!target_file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
return(false);
|
||||
}
|
||||
|
||||
target_file.write(data_logos_[logo_name]);
|
||||
target_file.close();
|
||||
return(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@param logo_name Name of the logo to remove
|
||||
@return true if the logo could be deleted, false otherwise
|
||||
|
@ -87,6 +87,7 @@ class TitleBlockTemplate : public QObject {
|
||||
void setAllSpans(const QHash<TitleBlockCell *, QPair<int, int> > &);
|
||||
bool addLogo(const QString &, QByteArray *, const QString & = "svg", const QString & = "xml");
|
||||
bool addLogoFromFile(const QString &, const QString & = QString());
|
||||
bool saveLogoToFile(const QString &, const QString &);
|
||||
bool removeLogo(const QString &);
|
||||
bool renameLogo(const QString &, const QString &);
|
||||
void setLogoStorage(const QString &, const QString &);
|
||||
|
Loading…
x
Reference in New Issue
Block a user