35 opened_from_file_(false),
38 tb_template_(nullptr),
39 logo_manager_(nullptr)
42 setAttribute(Qt::WA_DeleteOnClose);
69 QString current_filepath;
110 tr(
"Enregistrer le modèle en cours ?",
"dialog title"),
113 "Voulez-vous enregistrer le modèle %1 ?",
114 "dialog content - %1 is a title block template name" 123 case QMessageBox::Yes: result =
save();
break;
124 default: result =
true;
147 setAttribute(Qt::WA_DeleteOnClose);
149 }
else qce -> ignore();
160 QString proposed_name;
162 proposed_name =
tr(
"nouveau_modele",
"template name suggestion when duplicating the default one");
167 bool accepted =
false;
168 QString new_template_name = QInputDialog::getText(
170 tr(
"Dupliquer un modèle de cartouche",
"input dialog title"),
171 tr(
"Pour dupliquer ce modèle, entrez le nom voulu pour sa copie",
"input dialog text"),
178 saveAs(new_template_location);
195 if (!tb_template_orig) {
216 if (!project)
return(
false);
220 if (template_name.isEmpty())
231 if (!tb_template_orig) {
250 bool loading = tbt -> loadFromXmlFile(file_path);
256 bool editing =
edit(tbt);
262 QFileInfo file_path_info(file_path);
274 if (!tbt)
return(
false);
275 return(
edit(tbt -> clone()));
283 if (!tbt)
return(
false);
302 QDialogButtonBox *buttons =
new QDialogButtonBox(QDialogButtonBox::Close);
304 QVBoxLayout *vlayout0 =
new QVBoxLayout();
306 vlayout0 -> addWidget(buttons);
310 d.setLayout(vlayout0);
311 connect(buttons, SIGNAL(rejected()), &d, SLOT(reject()));
325 qet_template_editor -> show();
358 new_ -> setShortcut(QKeySequence::New);
359 open_ -> setShortcut(QKeySequence::Open);
360 open_from_file_ -> setShortcut(
tr(
"Ctrl+Shift+O",
"shortcut to open a template from a file"));
361 save_ -> setShortcut(QKeySequence::Save);
362 save_as_file_ -> setShortcut(
tr(
"Ctrl+Shift+S",
"shortcut to save a template to a file"));
363 quit_ -> setShortcut(QKeySequence(
tr(
"Ctrl+Q",
"shortcut to quit")));
364 undo_ -> setShortcut(QKeySequence::Undo);
365 redo_ -> setShortcut(QKeySequence::Redo);
366 cut_ -> setShortcut(QKeySequence::Cut);
367 copy_ -> setShortcut(QKeySequence::Copy);
368 paste_ -> setShortcut(QKeySequence::Paste);
369 edit_logos_ -> setShortcut(QKeySequence(
tr(
"Ctrl+T",
"shortcut to manage embedded logos")));
370 edit_info_ -> setShortcut(QKeySequence(
tr(
"Ctrl+Y",
"shortcut to edit extra information")));
371 merge_cells_ -> setShortcut(QKeySequence(
tr(
"Ctrl+J",
"shortcut to merge cells")));
372 split_cell_ -> setShortcut(QKeySequence(
tr(
"Ctrl+K",
"shortcut to split merged cell")));
375 zoom_fit_ -> setShortcut(QKeySequence(
tr(
"Ctrl+9",
"shortcut to enable fit zoom")));
376 zoom_reset_ -> setShortcut(QKeySequence(
tr(
"Ctrl+0",
"shortcut to reset zoom")));
379 connect(
open_, SIGNAL(triggered()),
this, SLOT(
open()));
381 connect(
save_, SIGNAL(triggered()),
this, SLOT(
save()));
384 connect(
quit_, SIGNAL(triggered()),
this, SLOT(
quit()));
404 file_menu_ =
new QMenu(
tr(
"&Fichier",
"menu title"),
this);
405 edit_menu_ =
new QMenu(
tr(
"&Édition",
"menu title"),
this);
445 QToolBar *main_toolbar =
new QToolBar(
tr(
"Outils",
"toolbar title"),
this);
446 main_toolbar -> setObjectName(
"tbt_main_toolbar");
447 main_toolbar -> addAction(
new_);
448 main_toolbar -> addAction(
open_);
449 main_toolbar -> addAction(
save_);
450 main_toolbar -> addAction(
save_as_);
451 addToolBar(Qt::TopToolBarArea, main_toolbar);
453 QToolBar *edit_toolbar =
new QToolBar(
tr(
"Édition",
"toolbar title"),
this);
454 edit_toolbar -> setObjectName(
"tbt_edit_toolbar");
455 edit_toolbar -> addAction(
undo_);
456 edit_toolbar -> addAction(
redo_);
457 edit_toolbar -> addSeparator();
460 addToolBar(Qt::TopToolBarArea, edit_toolbar);
462 QToolBar *display_toolbar =
new QToolBar(
tr(
"Affichage",
"toolbar title"),
this);
463 display_toolbar -> setObjectName(
"tbt_display_toolbar");
464 display_toolbar -> addAction(
zoom_in_);
468 addToolBar(Qt::TopToolBarArea, display_toolbar);
481 undo_view_ -> setEmptyLabel(
tr(
"Aucune modification",
"label displayed in the undo list when empty"));
494 int conf_preview_width = settings.value(
"titleblocktemplateeditor/preview_width", -1).toInt(&conv_ok);
495 if (conv_ok && conf_preview_width != -1) {
532 SIGNAL(previewWidthChanged(
int,
int)),
537 connect(QApplication::clipboard(), SIGNAL(dataChanged()),
this, SLOT(
updateActions()));
559 QString titleblock_title;
567 if (!titleblock_title.isEmpty()) {
570 tag =
tr(
"[Modifié]",
"window title tag");
573 tag =
tr(
"[Lecture seule]",
"window title tag");
575 titleblock_title = QString(
578 "part of the window title - %1 is the filepath or template name, %2 is the [Changed] or [Read only] tag" 580 ).arg(titleblock_title).arg(tag);
583 return(titleblock_title);
595 QVariant geometry = settings.value(
"titleblocktemplateeditor/geometry");
596 if (geometry.isValid()) restoreGeometry(geometry.toByteArray());
599 QVariant state = settings.value(
"titleblocktemplateeditor/state");
600 if (state.isValid()) restoreState(state.toByteArray());
610 settings.setValue(
"titleblocktemplateeditor/geometry", saveGeometry());
611 settings.setValue(
"titleblocktemplateeditor/state", saveState());
619 if (selected_cells.count() == 1) {
660 "QElectroTech - Éditeur de modèle de cartouche",
661 "titleblock template editor: base window title" 670 if (titleblock_title.isEmpty()) {
676 "window title: %1 is the base window title, %2 is a template name" 678 ).arg(min_title).arg(titleblock_title);
680 setWindowTitle(title);
690 bool can_merge =
true;
691 bool can_split =
true;
697 copy_ -> setEnabled(count);
712 if (!collection)
return(
false);
715 QDomElement elmt = doc.createElement(
"root");
718 doc.appendChild(elmt);
720 collection -> setTemplateXmlDescription(
location.
name(), elmt);
736 if (!saving)
return(
false);
751 tr(
"Ouvrir un modèle",
"File > open dialog window title"),
768 QString user_filepath = QFileDialog::getOpenFileName(
770 tr(
"Ouvrir un fichier",
"dialog title"),
773 "Modèles de cartouches QElectroTech (*%1);;" 774 "Fichiers XML (*.xml);;" 775 "Tous les fichiers (*)",
776 "filetypes allowed when opening a title block template file - %1 is the .titleblock extension" 781 if (!user_filepath.isEmpty())
QETApp::instance() -> openTitleBlockTemplate(user_filepath);
791 if (file_path_info.isWritable()) {
811 tr(
"Enregistrer le modèle sous",
"dialog window title"),
828 QString filepath = QFileDialog::getSaveFileName(
830 tr(
"Enregistrer sous",
"dialog title"),
833 "Modèles de cartouches QElectroTech (*%1)",
834 "filetypes allowed when saving a title block template file - %1 is the .titleblock extension" 839 if (filepath.isEmpty())
return(
false);
842 if (!filepath.endsWith(
".titleblock", Qt::CaseInsensitive)) filepath +=
".titleblock";
845 bool saving =
saveAs(filepath);
885 QVBoxLayout *dialog_layout =
new QVBoxLayout();
886 dialog_layout -> addWidget(widget);
887 dialog_layout -> addWidget(buttons);
890 dialog.setWindowTitle(title);
891 dialog.setLayout(dialog_layout);
893 connect(buttons, SIGNAL(accepted()), &dialog, SLOT(accept()));
894 connect(buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
896 if (dialog.exec() == QDialog::Accepted) {
917 Q_UNUSED(former_preview_width)
919 settings.setValue(
"titleblocktemplateeditor/preview_width", new_preview_width);
928 QDialog dialog_author(
this);
929 dialog_author.setModal(
true);
931 dialog_author.setWindowFlags(Qt::Sheet);
933 dialog_author.setMinimumSize(400, 260);
934 dialog_author.setWindowTitle(
tr(
"Éditer les informations complémentaires",
"window title"));
935 QVBoxLayout *dialog_layout =
new QVBoxLayout(&dialog_author);
938 QLabel *information_label =
new QLabel(
tr(
"Vous pouvez utiliser ce champ libre pour mentionner les auteurs du cartouche, sa licence, ou tout autre renseignement que vous jugerez utile."));
939 information_label -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
940 information_label -> setWordWrap(
true);
941 dialog_layout -> addWidget(information_label);
944 QTextEdit *text_field =
new QTextEdit();
945 text_field -> setAcceptRichText(
false);
948 dialog_layout -> addWidget(text_field);
952 dialog_layout -> addWidget(dialog_buttons);
953 connect(dialog_buttons, SIGNAL(accepted()), &dialog_author, SLOT(accept()));
954 connect(dialog_buttons, SIGNAL(rejected()), &dialog_author, SLOT(reject()));
957 if (dialog_author.exec() == QDialog::Accepted && !
read_only_) {
958 QString new_info = text_field -> toPlainText().remove(QChar(13));
static QString customTitleBlockTemplatesDir()
static TitleBlockTemplate * defaultTitleBlockTemplate()
void closeEvent(QCloseEvent *) override
bool editCopyOf(const TitleBlockTemplate *)
QIcon EditTableInsertRowAbove
bool openForDuplication() const
bool read_only_
whether the currently edited template is considered read only
QString filepath_
Filepath of the currently edited template, if opened from a file.
~QETTitleBlockTemplateEditor() override
void pushGridUndoCommand(TitleBlockTemplateCommand *)
void pushUndoCommand(QUndoCommand *)
void setName(const QString &)
QIcon EditTableInsertColumnRight
QAction * open_from_file_
TitleBlockTemplate * tb_template_
Template Object edited.
bool compareCanonicalFilePaths(const QString &, const QString &)
TitleBlockTemplateCellWidget * template_cell_editor_widget_
void duplicateCurrentLocation()
QMenu * settings_menu_
Settings menu.
bool isEditing(const QString &ilepath)
bool event(QEvent *) override
void setOpenForDuplication(bool)
QGraphicsScene * template_edition_area_scene_
Template preview.
TitleBlockTemplateView * template_edition_area_view_
void editTemplateInformation()
void savePreviewWidthToApplicationSettings(int, int)
QETTitleBlockTemplateEditor::savePreviewWidthToApplicationSettings Save the new preview width to appl...
QDockWidget * template_cell_editor_dock_widget_
Individual cell widget edition.
QDockWidget * undo_dock_widget_
TitleBlockTemplateLocation location() const
void pushCellUndoCommand(ModifyTitleBlockCellCommand *)
void writeSettings()
QETTitleBlockTemplateEditor::writeSettings Write the settings.
bool edit(const TitleBlockTemplateLocation &)
void selectedCellsChanged(const QList< TitleBlockCell *> &)
TitleBlockTemplate * getTemplate(const QString &) override
TitleBlockTemplateLocation getTitleBlockTemplateLocationFromUser(const QString &=QString(), bool existing_only=true)
void readSettings()
QETTitleBlockTemplateEditor::readSettings Read settings.
#define TITLEBLOCKS_FILE_EXTENSION
QMenu * file_menu_
menus TODO
TitleBlockTemplateLogoManager * logo_manager_
Logo manager widget.
void firstActivation(QEvent *) override
bool opened_from_file_
Whether to consider the location or the filepath.
void setParentCollection(TitleBlockTemplatesCollection *)
QMessageBox::StandardButton question(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)
QUndoStack * undo_stack_
Undo interface.
QMessageBox::StandardButton information(QWidget *, const QString &, const QString &, QMessageBox::StandardButtons=QMessageBox::Ok, QMessageBox::StandardButton=QMessageBox::NoButton)
void insertMenu(QMenu *, QMenu *, bool=true)
QETTitleBlockTemplateEditor(QWidget *=nullptr)
TitleBlockTemplatesCollection * parentCollection() const
TitleBlockTemplate * getTemplate() const
TitleBlockTemplateLocation location_
Location of the currently edited template.
TitleBlockTemplatesProjectCollection * embeddedTitleBlockTemplatesCollection()
QString currentlyEditedTitle() const
static QETApp * instance()
static QString realPath(const QString &)