mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Fix Qt 6 deprecated QDockWidget::AllDockWidgetFeatures
(Deprecated) The dock widget can be closed, moved, and floated. Since new features might be added in future releases, the look and behavior of dock widgets might change if you use this flag. Please specify individual flags instead.
This commit is contained in:
parent
a917399950
commit
c958d54d01
@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@ -83,7 +83,7 @@ QETElementEditor::QETElementEditor(QWidget *parent) :
|
||||
// la fenetre est maximisee par defaut
|
||||
setMinimumSize(QSize(500, 350));
|
||||
setWindowState(Qt::WindowMaximized);
|
||||
|
||||
|
||||
// lecture des parametres
|
||||
readSettings();
|
||||
slot_updateMenus();
|
||||
@ -165,7 +165,7 @@ void QETElementEditor::setupActions()
|
||||
open_dxf -> setStatusTip(tr("To install the plugin DXFtoQET\nVisit https://download.tuxfamily.org/qet/builds/dxf_to_elmt/\n"
|
||||
"\n"
|
||||
">> Install on Windows\n"
|
||||
"Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
|
||||
"Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
|
||||
));
|
||||
#elif defined(Q_OS_MAC)
|
||||
open_dxf -> setStatusTip(tr("To install the plugin DXFtoQET\nVisit https://download.tuxfamily.org/qet/builds/dxf_to_elmt/\n"
|
||||
@ -188,7 +188,7 @@ void QETElementEditor::setupActions()
|
||||
"Put DXFtoQET binary on your /home/user_name/.qet/ directory\n"
|
||||
"make it executable : chmod +x ./DXFtoQET\n"
|
||||
">> Install on Windows\n"
|
||||
"Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
|
||||
"Put DXFtoQET.exe binary on C:\\Users\\user_name\\AppData\\Roaming\\qet\\ directory \n"
|
||||
"\n"
|
||||
">> Install on macOSX\n"
|
||||
"Put DXFtoQET.app binary on /Users/user_name/.qet/ directory \n"
|
||||
@ -491,7 +491,7 @@ void QETElementEditor::slot_updateMenus()
|
||||
// actions dependant du contenu du presse-papiers
|
||||
paste -> setEnabled(clipboard_elmt);
|
||||
paste_in_area -> setEnabled(clipboard_elmt);
|
||||
|
||||
|
||||
// actions dependant de l'etat de la pile d'annulation
|
||||
save -> setEnabled(!read_only && !m_elmt_scene -> undoStack().isClean());
|
||||
undo -> setEnabled(!read_only && m_elmt_scene -> undoStack().canUndo());
|
||||
@ -534,7 +534,7 @@ void QETElementEditor::setupInterface()
|
||||
// m_tools_dock_scroll_area = new QScrollArea();
|
||||
// m_tools_dock_scroll_area -> setFrameStyle(QFrame::NoFrame);
|
||||
// m_tools_dock_scroll_area -> setAlignment(Qt::AlignHCenter|Qt::AlignTop);
|
||||
|
||||
|
||||
// Pile de widgets pour accueillir les deux widgets precedents
|
||||
m_tools_dock_stack = new QStackedWidget();
|
||||
m_tools_dock_stack -> insertWidget(0, m_default_informations);
|
||||
@ -555,7 +555,10 @@ void QETElementEditor::setupInterface()
|
||||
m_tools_dock = new QDockWidget(tr("Informations", "dock title"), this);
|
||||
m_tools_dock -> setObjectName("informations");
|
||||
m_tools_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
m_tools_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
m_tools_dock -> setFeatures(
|
||||
QDockWidget::DockWidgetClosable
|
||||
|QDockWidget::DockWidgetMovable
|
||||
|QDockWidget::DockWidgetFloatable);
|
||||
//m_tools_dock -> setMinimumWidth(380);
|
||||
addDockWidget(Qt::RightDockWidgetArea, m_tools_dock);
|
||||
m_tools_dock -> setWidget(m_tools_dock_stack);
|
||||
@ -564,7 +567,10 @@ void QETElementEditor::setupInterface()
|
||||
m_undo_dock = new QDockWidget(tr("Annulations", "dock title"), this);
|
||||
m_undo_dock -> setObjectName("undo");
|
||||
m_undo_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
m_undo_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
m_undo_dock -> setFeatures(
|
||||
QDockWidget::DockWidgetClosable
|
||||
|QDockWidget::DockWidgetMovable
|
||||
|QDockWidget::DockWidgetFloatable);
|
||||
m_undo_dock -> setMinimumWidth(290);
|
||||
addDockWidget(Qt::RightDockWidgetArea, m_undo_dock);
|
||||
QUndoView* undo_view = new QUndoView(&(m_elmt_scene -> undoStack()), this);
|
||||
@ -582,7 +588,10 @@ void QETElementEditor::setupInterface()
|
||||
m_parts_dock = new QDockWidget(tr("Parties", "dock title"), this);
|
||||
m_parts_dock -> setObjectName("parts_list");
|
||||
m_parts_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
m_parts_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
m_parts_dock -> setFeatures(
|
||||
QDockWidget::DockWidgetClosable
|
||||
|QDockWidget::DockWidgetMovable
|
||||
|QDockWidget::DockWidgetFloatable);
|
||||
m_parts_dock -> setMinimumWidth(290);
|
||||
tabifyDockWidget(m_undo_dock, m_parts_dock);
|
||||
m_parts_dock -> setWidget(m_parts_list);
|
||||
@ -1126,10 +1135,10 @@ void QETElementEditor::slot_openFile()
|
||||
{
|
||||
// repertoire a afficher initialement dans le dialogue
|
||||
QString open_dir = filename_.isEmpty() ? QETApp::customElementsDir() : QDir(filename_).absolutePath();
|
||||
|
||||
|
||||
// demande un nom de fichier a ouvrir a l'utilisateur
|
||||
QString user_filename = QETElementEditor::getOpenElementFileName(this, open_dir);
|
||||
|
||||
|
||||
// ouvre l'element
|
||||
openElement(user_filename);
|
||||
}
|
||||
@ -1445,7 +1454,7 @@ void QETElementEditor::slot_createPartsList()
|
||||
m_parts_list -> blockSignals(true);
|
||||
m_parts_list -> clear();
|
||||
QList<QGraphicsItem *> qgis = m_elmt_scene -> zItems();
|
||||
|
||||
|
||||
// on ne construit plus la liste a partir de 200 primitives
|
||||
// c'est ingerable : la maj de la liste prend trop de temps et le resultat
|
||||
// est inexploitable
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@ -60,7 +60,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
||||
open_dialog_dir (QStandardPaths::writableLocation(QStandardPaths::DesktopLocation))
|
||||
{
|
||||
activeSubWindowIndex = 0;
|
||||
|
||||
|
||||
QSplitter *splitter_ = new QSplitter(this);
|
||||
splitter_->setChildrenCollapsible(false);
|
||||
splitter_->setOrientation(Qt::Vertical);
|
||||
@ -77,19 +77,19 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
||||
anim->setObjectName("search and replace animator");
|
||||
m_search_and_replace_widget.setHidden(true);
|
||||
anim->setLastShowSize(m_search_and_replace_widget.minimumSizeHint().height());
|
||||
|
||||
|
||||
//Set object name to be retrieved by the stylesheets
|
||||
m_workspace.setBackground(QBrush(Qt::NoBrush));
|
||||
m_workspace.setObjectName("mdiarea");
|
||||
m_workspace.setTabsClosable(true);
|
||||
|
||||
|
||||
//Set the signal mapper
|
||||
connect(&windowMapper, SIGNAL(mapped(QWidget *)), this, SLOT(activateWidget(QWidget *)));
|
||||
|
||||
setWindowTitle(tr("QElectroTech", "window title"));
|
||||
|
||||
setWindowTitle(tr("QElectroTech", "window title"));
|
||||
setWindowIcon(QET::Icons::QETLogo);
|
||||
statusBar() -> showMessage(tr("QElectroTech", "status bar message"));
|
||||
|
||||
|
||||
setUpElementsPanel();
|
||||
setUpElementsCollectionWidget();
|
||||
setUpUndoStack();
|
||||
@ -101,11 +101,11 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
||||
setUpMenu();
|
||||
|
||||
tabifyDockWidget(qdw_undo, qdw_pa);
|
||||
|
||||
|
||||
//By default the windows is maximised
|
||||
setMinimumSize(QSize(500, 350));
|
||||
setWindowState(Qt::WindowMaximized);
|
||||
|
||||
|
||||
connect (&m_workspace,
|
||||
SIGNAL(subWindowActivated(QMdiSubWindow *)),
|
||||
this,
|
||||
@ -117,7 +117,7 @@ QETDiagramEditor::QETDiagramEditor(const QStringList &files, QWidget *parent) :
|
||||
|
||||
readSettings();
|
||||
show();
|
||||
|
||||
|
||||
//If valid file path is given as arguments
|
||||
uint opened_projects = 0;
|
||||
if (files.count())
|
||||
@ -149,7 +149,10 @@ void QETDiagramEditor::setUpElementsPanel()
|
||||
|
||||
qdw_pa -> setObjectName ("projects panel");
|
||||
qdw_pa -> setAllowedAreas (Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
qdw_pa -> setFeatures (QDockWidget::AllDockWidgetFeatures);
|
||||
qdw_pa -> setFeatures (
|
||||
QDockWidget::DockWidgetClosable
|
||||
|QDockWidget::DockWidgetMovable
|
||||
|QDockWidget::DockWidgetFloatable);
|
||||
qdw_pa -> setMinimumWidth (160);
|
||||
qdw_pa -> setWidget (pa = new ElementsPanelWidget(qdw_pa));
|
||||
|
||||
@ -179,7 +182,10 @@ void QETDiagramEditor::setUpElementsCollectionWidget()
|
||||
m_qdw_elmt_collection = new QDockWidget(tr("Collections"), this);
|
||||
m_qdw_elmt_collection->setObjectName("elements_collection_widget");
|
||||
m_qdw_elmt_collection->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
m_qdw_elmt_collection->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
m_qdw_elmt_collection->setFeatures(
|
||||
QDockWidget::DockWidgetClosable
|
||||
|QDockWidget::DockWidgetMovable
|
||||
|QDockWidget::DockWidgetFloatable);
|
||||
|
||||
m_element_collection_widget = new ElementsCollectionWidget(m_qdw_elmt_collection);
|
||||
m_qdw_elmt_collection->setWidget(m_element_collection_widget);
|
||||
@ -205,7 +211,10 @@ void QETDiagramEditor::setUpUndoStack()
|
||||
qdw_undo -> setObjectName("diagram_undo");
|
||||
|
||||
qdw_undo -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
qdw_undo -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
qdw_undo -> setFeatures(
|
||||
QDockWidget::DockWidgetClosable
|
||||
|QDockWidget::DockWidgetMovable
|
||||
|QDockWidget::DockWidgetFloatable);
|
||||
qdw_undo -> setMinimumWidth(160);
|
||||
qdw_undo -> setWidget(undo_view);
|
||||
|
||||
@ -231,7 +240,10 @@ void QETDiagramEditor::setUpAutonumberingWidget()
|
||||
{
|
||||
m_autonumbering_dock = new AutoNumberingDockWidget(this);
|
||||
m_autonumbering_dock -> setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
|
||||
m_autonumbering_dock -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
m_autonumbering_dock -> setFeatures(
|
||||
QDockWidget::DockWidgetClosable
|
||||
|QDockWidget::DockWidgetMovable
|
||||
|QDockWidget::DockWidgetFloatable);
|
||||
addDockWidget(Qt::RightDockWidgetArea, m_autonumbering_dock);
|
||||
}
|
||||
|
||||
@ -251,7 +263,7 @@ void QETDiagramEditor::setUpActions()
|
||||
current_project -> exportProject();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Print
|
||||
m_print = new QAction(QET::Icons::DocumentPrint, tr("Imprimer"), this);
|
||||
m_print->setShortcut(QKeySequence(QKeySequence::Print));
|
||||
@ -262,7 +274,7 @@ void QETDiagramEditor::setUpActions()
|
||||
current_project -> printProject();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Quit editor
|
||||
m_quit_editor = new QAction(QET::Icons::ApplicationExit, tr("&Quitter"), this);
|
||||
m_quit_editor->setShortcut(QKeySequence(tr("Ctrl+Q")));
|
||||
@ -314,7 +326,7 @@ void QETDiagramEditor::setUpActions()
|
||||
if (DiagramView *dv = currentDiagramView())
|
||||
dv->resetConductors();
|
||||
});
|
||||
|
||||
|
||||
//AutoConductor
|
||||
m_auto_conductor = new QAction (QET::Icons::Autoconnect, tr("Création automatique de conducteur(s)","Tool tip of auto conductor"), this);
|
||||
m_auto_conductor->setStatusTip (tr("Utiliser la création automatique de conducteur(s) quand cela est possible", "Status tip of auto conductor"));
|
||||
@ -358,13 +370,13 @@ void QETDiagramEditor::setUpActions()
|
||||
project_view->editCurrentDiagramProperties();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Edit current project properties
|
||||
m_project_edit_properties = new QAction(QET::Icons::ProjectProperties, tr("Propriétés du projet"), this);
|
||||
connect(m_project_edit_properties, &QAction::triggered, [this]() {
|
||||
editProjectProperties(currentProjectView());
|
||||
});
|
||||
|
||||
|
||||
//Add new folio to current project
|
||||
m_project_add_diagram = new QAction(QET::Icons::DiagramAdd, tr("Ajouter un folio"), this);
|
||||
m_project_add_diagram->setShortcut(QKeySequence(tr("Ctrl+T")));
|
||||
@ -373,11 +385,11 @@ void QETDiagramEditor::setUpActions()
|
||||
current_project->project()->addNewDiagram();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//Remove current folio from current project
|
||||
m_remove_diagram_from_project = new QAction(QET::Icons::DiagramDelete, tr("Supprimer le folio"), this);
|
||||
connect(m_remove_diagram_from_project, &QAction::triggered, this, &QETDiagramEditor::removeDiagramFromProject);
|
||||
|
||||
|
||||
//Clean the current project
|
||||
m_clean_project = new QAction(QET::Icons::EditClear, tr("Nettoyer le projet"), this);
|
||||
connect(m_clean_project, &QAction::triggered, [this]() {
|
||||
@ -394,7 +406,7 @@ void QETDiagramEditor::setUpActions()
|
||||
BOMExportDialog bom(currentProjectView()->project(), this);
|
||||
bom.exec();
|
||||
});
|
||||
|
||||
|
||||
//Add a nomenclature item
|
||||
m_add_nomenclature = new QAction(QET::Icons::TableOfContent, tr("Ajouter une nomenclature"), this);
|
||||
connect(m_add_nomenclature, &QAction::triggered, [this]() {
|
||||
@ -430,27 +442,27 @@ void QETDiagramEditor::setUpActions()
|
||||
connect(m_export_project_db, &QAction::triggered, [this]() {
|
||||
projectDataBase::exportDb(this->currentProject()->dataBase(), this);
|
||||
});
|
||||
|
||||
|
||||
//MDI view style
|
||||
m_tabbed_view_mode = new QAction(tr("en utilisant des onglets"), this);
|
||||
m_tabbed_view_mode->setStatusTip(tr("Présente les différents projets ouverts des onglets", "status bar tip"));
|
||||
m_tabbed_view_mode->setCheckable(true);
|
||||
connect(m_tabbed_view_mode, &QAction::triggered, this, &QETDiagramEditor::setTabbedMode);
|
||||
|
||||
|
||||
m_windowed_view_mode = new QAction(tr("en utilisant des fenêtres"), this);
|
||||
m_windowed_view_mode->setStatusTip(tr("Présente les différents projets ouverts dans des sous-fenêtres", "status bar tip"));
|
||||
m_windowed_view_mode->setCheckable(true);
|
||||
connect(m_windowed_view_mode, &QAction::triggered, this, &QETDiagramEditor::setWindowedMode);
|
||||
|
||||
|
||||
m_group_view_mode = new QActionGroup(this);
|
||||
m_group_view_mode -> addAction(m_windowed_view_mode);
|
||||
m_group_view_mode -> addAction(m_tabbed_view_mode);
|
||||
m_group_view_mode -> setExclusive(true);
|
||||
|
||||
|
||||
m_tile_window = new QAction(tr("&Mosaïque"), this);
|
||||
m_tile_window->setStatusTip(tr("Dispose les fenêtres en mosaïque", "status bar tip"));
|
||||
connect(m_tile_window, &QAction::triggered, &m_workspace, &QMdiArea::tileSubWindows);
|
||||
|
||||
|
||||
m_cascade_window = new QAction(tr("&Cascade"), this);
|
||||
m_cascade_window->setStatusTip(tr("Dispose les fenêtres en cascade", "status bar tip"));
|
||||
connect(m_cascade_window, &QAction::triggered, &m_workspace, &QMdiArea::cascadeSubWindows);
|
||||
@ -467,7 +479,7 @@ void QETDiagramEditor::setUpActions()
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
m_mode_visualise = new QAction(QET::Icons::ViewMove, tr("Mode Visualisation"), this);
|
||||
m_mode_visualise->setStatusTip(tr("Permet de visualiser le folio sans pouvoir le modifier", "status bar tip"));
|
||||
m_mode_visualise->setCheckable(true);
|
||||
@ -489,7 +501,7 @@ void QETDiagramEditor::setUpActions()
|
||||
m_next_window->setShortcut(QKeySequence::NextChild);
|
||||
m_next_window->setStatusTip(tr("Active le projet suivant", "status bar tip"));
|
||||
connect(m_next_window, &QAction::triggered, &m_workspace, &QMdiArea::activateNextSubWindow);
|
||||
|
||||
|
||||
m_previous_window = new QAction(tr("Projet précédent"), this);
|
||||
m_previous_window->setShortcut(QKeySequence::PreviousChild);
|
||||
m_previous_window->setStatusTip(tr("Active le projet précédent", "status bar tip"));
|
||||
@ -645,11 +657,11 @@ void QETDiagramEditor::setUpActions()
|
||||
//Depth action
|
||||
m_depth_action_group = QET::depthActionGroup(this);
|
||||
m_depth_action_group->setDisabled(true);
|
||||
|
||||
|
||||
connect(m_depth_action_group, &QActionGroup::triggered, [this](QAction *action) {
|
||||
this->currentDiagramView()->diagram()->changeZValue(action->data().value<QET::DepthOption>());
|
||||
});
|
||||
|
||||
|
||||
m_find = new QAction(tr("Chercher/remplacer"), this);
|
||||
m_find->setShortcut(QKeySequence::Find);
|
||||
connect(m_find, &QAction::triggered, [this]()
|
||||
@ -705,7 +717,7 @@ void QETDiagramEditor::setUpToolBar()
|
||||
m_add_item_tool_bar = new QToolBar(tr("Ajouter"), this);
|
||||
m_add_item_tool_bar->setObjectName("adding");
|
||||
m_add_item_tool_bar->addActions(m_add_item_actions_group.actions());
|
||||
|
||||
|
||||
m_depth_tool_bar = new QToolBar(tr("Profondeur", "toolbar title"));
|
||||
m_depth_tool_bar->setObjectName("diagram_depth_toolbar");
|
||||
m_depth_tool_bar->addActions(m_depth_action_group->actions());
|
||||
@ -792,7 +804,7 @@ void QETDiagramEditor::setUpMenu()
|
||||
diagram_tool_bar -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la barre d'outils Schéma"));
|
||||
qdw_pa -> toggleViewAction() -> setStatusTip(tr("Affiche ou non le panel d'appareils"));
|
||||
qdw_undo -> toggleViewAction() -> setStatusTip(tr("Affiche ou non la liste des modifications"));
|
||||
|
||||
|
||||
|
||||
// menu Affichage
|
||||
QMenu *projects_view_mode = menu_affichage -> addMenu(QET::Icons::ConfigureToolbars, tr("Afficher les projets"));
|
||||
@ -848,7 +860,7 @@ void QETDiagramEditor::closeEvent(QCloseEvent *qce)
|
||||
Reimplemented to :
|
||||
-Load elements collection when WindowActivate.
|
||||
@param e
|
||||
@return
|
||||
@return
|
||||
*/
|
||||
bool QETDiagramEditor::event(QEvent *e)
|
||||
{
|
||||
@ -916,10 +928,10 @@ void QETDiagramEditor::saveAs()
|
||||
bool QETDiagramEditor::newProject()
|
||||
{
|
||||
auto new_project = new QETProject(this);
|
||||
|
||||
|
||||
// add new diagram
|
||||
new_project -> addNewDiagram();
|
||||
|
||||
|
||||
return addProject(new_project);
|
||||
}
|
||||
|
||||
@ -952,10 +964,10 @@ bool QETDiagramEditor::openProject()
|
||||
tr("Projets QElectroTech (*.qet);;Fichiers XML (*.xml);;Tous les fichiers (*)")
|
||||
);
|
||||
if (filepath.isEmpty()) return(false);
|
||||
|
||||
|
||||
// retient le dossier contenant le dernier projet ouvert
|
||||
open_dialog_dir = QDir(filepath);
|
||||
|
||||
|
||||
// ouvre le fichier
|
||||
return(openAndAddProject(filepath));
|
||||
}
|
||||
@ -1002,7 +1014,7 @@ bool QETDiagramEditor::openAndAddProject(
|
||||
bool interactive)
|
||||
{
|
||||
if (filepath.isEmpty()) return(false);
|
||||
|
||||
|
||||
QFileInfo filepath_info(filepath);
|
||||
|
||||
//Check if project is not open in another editor
|
||||
@ -1024,7 +1036,7 @@ bool QETDiagramEditor::openAndAddProject(
|
||||
return(diagram_editor -> openAndAddProject(filepath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// check the file exists
|
||||
if (!filepath_info.exists())
|
||||
{
|
||||
@ -1056,7 +1068,7 @@ bool QETDiagramEditor::openAndAddProject(
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
//Check if file is read only
|
||||
if (!filepath_info.isWritable())
|
||||
{
|
||||
@ -1070,10 +1082,10 @@ bool QETDiagramEditor::openAndAddProject(
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Create the project
|
||||
DialogWaiting::instance(this);
|
||||
|
||||
|
||||
QETProject *project = new QETProject(filepath);
|
||||
if (project -> state() != QETProject::Ok)
|
||||
{
|
||||
@ -1120,14 +1132,14 @@ bool QETDiagramEditor::addProject(QETProject *project, bool update_panel)
|
||||
undo_group.addStack(project -> undoStack());
|
||||
|
||||
m_element_collection_widget->addProject(project);
|
||||
|
||||
|
||||
// met a jour le panel d'elements
|
||||
if (update_panel) {
|
||||
pa -> elementsPanel().projectWasOpened(project);
|
||||
if (currentDiagramView() != nullptr)
|
||||
m_autonumbering_dock->setProject(project, project_view);
|
||||
}
|
||||
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@ -1154,10 +1166,10 @@ ProjectView *QETDiagramEditor::currentProjectView() const
|
||||
{
|
||||
QMdiSubWindow *current_window = m_workspace.activeSubWindow();
|
||||
if (!current_window) return(nullptr);
|
||||
|
||||
|
||||
QWidget *current_widget = current_window -> widget();
|
||||
if (!current_widget) return(nullptr);
|
||||
|
||||
|
||||
if (ProjectView *project_view = qobject_cast<ProjectView *>(current_widget)) {
|
||||
return(project_view);
|
||||
}
|
||||
@ -1203,11 +1215,11 @@ Element *QETDiagramEditor::currentElement() const
|
||||
DiagramView *dv = currentDiagramView();
|
||||
if (!dv)
|
||||
return(nullptr);
|
||||
|
||||
|
||||
QList<Element *> selected_elements = DiagramContent(dv->diagram()).m_elements;
|
||||
if (selected_elements.count() != 1)
|
||||
return(nullptr);
|
||||
|
||||
|
||||
return(selected_elements.first());
|
||||
}
|
||||
|
||||
@ -1426,7 +1438,7 @@ void QETDiagramEditor::selectionGroupTriggered(QAction *action)
|
||||
QList<DynamicElementTextItem *> deti_list = dc.m_element_texts.values();
|
||||
if(deti_list.size() <= 1)
|
||||
return;
|
||||
|
||||
|
||||
diagram->undoStack().push(new AddTextsGroupCommand(deti_list.first()->parentElement(), tr("Groupe"), deti_list));
|
||||
}
|
||||
}
|
||||
@ -1441,7 +1453,7 @@ void QETDiagramEditor::rowColumnGroupTriggered(QAction *action)
|
||||
Diagram *d = dv->diagram();
|
||||
BorderProperties old_bp = d->border_and_titleblock.exportBorder();
|
||||
BorderProperties new_bp = d->border_and_titleblock.exportBorder();
|
||||
|
||||
|
||||
if (value == "add_column")
|
||||
new_bp.columns_count += 1;
|
||||
else if (value == "remove_column")
|
||||
@ -1450,7 +1462,7 @@ void QETDiagramEditor::rowColumnGroupTriggered(QAction *action)
|
||||
new_bp.rows_count += 1;
|
||||
else if (value == "remove_row")
|
||||
new_bp.rows_count -= 1;
|
||||
|
||||
|
||||
d->undoStack().push(new ChangeBorderCommand(d, old_bp, new_bp));
|
||||
}
|
||||
|
||||
@ -1542,23 +1554,23 @@ void QETDiagramEditor::slot_updateComplexActions()
|
||||
<< m_group_selected_texts;
|
||||
for(QAction *action : action_list)
|
||||
action->setEnabled(false);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Diagram *diagram_ = dv->diagram();
|
||||
DiagramContent dc(diagram_);
|
||||
bool ro = diagram_->isReadOnly();
|
||||
|
||||
|
||||
|
||||
//Number of selected conductors
|
||||
int selected_conductors_count = diagram_->selectedConductors().count();
|
||||
m_conductor_reset->setEnabled(!ro && selected_conductors_count);
|
||||
|
||||
|
||||
// number of selected elements
|
||||
int selected_elements_count = dc.count(DiagramContent::Elements);
|
||||
m_find_element->setEnabled(selected_elements_count == 1);
|
||||
|
||||
|
||||
//Action that need items (elements, conductors, texts...) selected, to be enabled
|
||||
bool copiable_items = dc.hasCopiableItems();
|
||||
bool deletable_items = dc.hasDeletableItems();
|
||||
@ -1584,7 +1596,7 @@ void QETDiagramEditor::slot_updateComplexActions()
|
||||
selected_dynamic_elmt_text++;
|
||||
}
|
||||
m_rotate_texts->setEnabled(!ro && (selected_texts || groups.size()));
|
||||
|
||||
|
||||
//Action that need only element text selected
|
||||
QList<DynamicElementTextItem *> deti_list = dc.m_element_texts.values();
|
||||
if(deti_list.size() > 1 && dc.count() == deti_list.count())
|
||||
@ -1653,7 +1665,7 @@ void QETDiagramEditor::slot_updateComplexActions()
|
||||
m_edit_selection -> setIcon(QET::Icons::ElementEdit);
|
||||
m_edit_selection -> setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
//Actions for edit Z value
|
||||
QList<QGraphicsItem *> list = dc.items(
|
||||
DiagramContent::SelectedOnly
|
||||
@ -1670,7 +1682,7 @@ void QETDiagramEditor::slot_updateComplexActions()
|
||||
void QETDiagramEditor::slot_updateModeActions()
|
||||
{
|
||||
DiagramView *dv = currentDiagramView();
|
||||
|
||||
|
||||
if (!dv)
|
||||
grp_visu_sel -> setEnabled(false);
|
||||
else
|
||||
@ -1708,7 +1720,7 @@ void QETDiagramEditor::slot_updatePasteAction()
|
||||
{
|
||||
DiagramView *dv = currentDiagramView();
|
||||
bool editable_diagram = (dv && !dv -> diagram() -> isReadOnly());
|
||||
|
||||
|
||||
// pour coller, il faut un schema ouvert et un schema dans le presse-papier
|
||||
m_paste -> setEnabled(editable_diagram && Diagram::clipboardMayContainDiagram());
|
||||
}
|
||||
@ -1725,7 +1737,7 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
|
||||
|
||||
foreach(DiagramView *dv, project_view -> diagram_views())
|
||||
diagramWasAdded(dv);
|
||||
|
||||
|
||||
//Manage the close event of project
|
||||
connect(project_view, SIGNAL(projectClosed(ProjectView*)),
|
||||
this, SLOT(projectWasClosed(ProjectView *)));
|
||||
@ -1736,13 +1748,13 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
|
||||
if (QETProject *project = project_view -> project())
|
||||
connect(project, SIGNAL(readOnlyChanged(QETProject *, bool)),
|
||||
this, SLOT(slot_updateActions()));
|
||||
|
||||
|
||||
//Manage request for edit or find element and titleblock
|
||||
connect (project_view, &ProjectView::findElementRequired,
|
||||
this, &QETDiagramEditor::findElementInPanel);
|
||||
connect (project_view, &ProjectView::editElementRequired,
|
||||
this, &QETDiagramEditor::editElementInEditor);
|
||||
|
||||
|
||||
// display error messages sent by the project view
|
||||
connect(project_view, SIGNAL(errorEncountered(QString)),
|
||||
this, SLOT(showError(const QString &)));
|
||||
@ -1757,7 +1769,7 @@ void QETDiagramEditor::addProjectView(ProjectView *project_view)
|
||||
QMdiSubWindow *sub_window = m_workspace.addSubWindow(project_view);
|
||||
sub_window -> setWindowIcon(project_view -> windowIcon());
|
||||
sub_window -> systemMenu() -> clear();
|
||||
|
||||
|
||||
//By defaut QMdiSubWindow have a QAction "close" with shortcut QKeySequence::Close
|
||||
//But the QAction m_close_file of this class have the same shortcut too.
|
||||
//We remove the shortcut of the QAction of QMdiSubWindow for avoid conflic
|
||||
@ -1796,7 +1808,7 @@ QList<QString> QETDiagramEditor::editedFiles() const
|
||||
ProjectView *QETDiagramEditor::viewForFile(const QString &filepath) const
|
||||
{
|
||||
if (filepath.isEmpty()) return(nullptr);
|
||||
|
||||
|
||||
QString searched_can_file_path = QFileInfo(filepath).canonicalFilePath();
|
||||
if (searched_can_file_path.isEmpty()) {
|
||||
// QFileInfo returns an empty path for non-existent files
|
||||
@ -1858,29 +1870,29 @@ void QETDiagramEditor::slot_updateWindowsMenu()
|
||||
{
|
||||
// nettoyage du menu
|
||||
foreach(QAction *a, windows_menu -> actions()) windows_menu -> removeAction(a);
|
||||
|
||||
|
||||
// actions de fermeture
|
||||
windows_menu -> addAction(m_close_file);
|
||||
//windows_menu -> addAction(closeAllAct);
|
||||
|
||||
|
||||
// actions de reorganisation des fenetres
|
||||
windows_menu -> addSeparator();
|
||||
windows_menu -> addAction(m_tile_window);
|
||||
windows_menu -> addAction(m_cascade_window);
|
||||
|
||||
|
||||
// actions de deplacement entre les fenetres
|
||||
windows_menu -> addSeparator();
|
||||
windows_menu -> addAction(m_next_window);
|
||||
windows_menu -> addAction(m_previous_window);
|
||||
|
||||
|
||||
// liste des fenetres
|
||||
QList<ProjectView *> windows = openedProjects();
|
||||
|
||||
|
||||
m_tile_window -> setEnabled(!windows.isEmpty() && m_workspace.viewMode() == QMdiArea::SubWindowView);
|
||||
m_cascade_window -> setEnabled(!windows.isEmpty() && m_workspace.viewMode() == QMdiArea::SubWindowView);
|
||||
m_next_window -> setEnabled(windows.count() > 1);
|
||||
m_previous_window -> setEnabled(windows.count() > 1);
|
||||
|
||||
|
||||
if (!windows.isEmpty()) windows_menu -> addSeparator();
|
||||
QActionGroup *windows_actions = new QActionGroup(this);
|
||||
foreach(ProjectView *project_view, windows) {
|
||||
@ -1946,15 +1958,15 @@ void QETDiagramEditor::setTabbedMode()
|
||||
void QETDiagramEditor::readSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
|
||||
// dimensions et position de la fenetre
|
||||
QVariant geometry = settings.value("diagrameditor/geometry");
|
||||
if (geometry.isValid()) restoreGeometry(geometry.toByteArray());
|
||||
|
||||
|
||||
// etat de la fenetre (barres d'outils, docks...)
|
||||
QVariant state = settings.value("diagrameditor/state");
|
||||
if (state.isValid()) restoreState(state.toByteArray());
|
||||
|
||||
|
||||
// gestion des projets (onglets ou fenetres)
|
||||
bool tabbed = settings.value("diagrameditor/viewmode", "tabbed") == "tabbed";
|
||||
if (tabbed) {
|
||||
@ -2018,7 +2030,7 @@ void QETDiagramEditor::activateProject(ProjectView *project_view)
|
||||
void QETDiagramEditor::projectWasClosed(ProjectView *project_view)
|
||||
{
|
||||
QETProject *project = project_view -> project();
|
||||
if (project)
|
||||
if (project)
|
||||
{
|
||||
pa -> elementsPanel().projectWasClosed(project);
|
||||
m_element_collection_widget->removeProject(project);
|
||||
@ -2064,7 +2076,7 @@ void QETDiagramEditor::addDiagramToProject(QETProject *project)
|
||||
if (!project) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (ProjectView *project_view = findProject(project))
|
||||
{
|
||||
activateProject(project);
|
||||
@ -2079,15 +2091,15 @@ void QETDiagramEditor::addDiagramToProject(QETProject *project)
|
||||
void QETDiagramEditor::removeDiagram(Diagram *diagram)
|
||||
{
|
||||
if (!diagram) return;
|
||||
|
||||
|
||||
// recupere le projet contenant le schema
|
||||
if (QETProject *diagram_project = diagram -> project()) {
|
||||
// recupere la vue sur ce projet
|
||||
if (ProjectView *project_view = findProject(diagram_project)) {
|
||||
|
||||
|
||||
// affiche le schema en question
|
||||
project_view -> showDiagram(diagram);
|
||||
|
||||
|
||||
// supprime le schema
|
||||
project_view -> removeDiagram(diagram);
|
||||
}
|
||||
@ -2102,11 +2114,11 @@ void QETDiagramEditor::removeDiagram(Diagram *diagram)
|
||||
void QETDiagramEditor::moveDiagramUp(Diagram *diagram)
|
||||
{
|
||||
if (!diagram) return;
|
||||
|
||||
|
||||
// recupere le projet contenant le schema
|
||||
if (QETProject *diagram_project = diagram -> project()) {
|
||||
if (diagram_project -> isReadOnly()) return;
|
||||
|
||||
|
||||
// recupere la vue sur ce projet
|
||||
if (ProjectView *project_view = findProject(diagram_project)) {
|
||||
project_view -> moveDiagramUp(diagram);
|
||||
@ -2122,11 +2134,11 @@ void QETDiagramEditor::moveDiagramUp(Diagram *diagram)
|
||||
void QETDiagramEditor::moveDiagramDown(Diagram *diagram)
|
||||
{
|
||||
if (!diagram) return;
|
||||
|
||||
|
||||
// recupere le projet contenant le schema
|
||||
if (QETProject *diagram_project = diagram -> project()) {
|
||||
if (diagram_project -> isReadOnly()) return;
|
||||
|
||||
|
||||
// recupere la vue sur ce projet
|
||||
if (ProjectView *project_view = findProject(diagram_project)) {
|
||||
project_view -> moveDiagramDown(diagram);
|
||||
@ -2313,7 +2325,7 @@ void QETDiagramEditor::generateTerminalBlock()
|
||||
{
|
||||
bool success;
|
||||
QProcess *process = new QProcess(qApp);
|
||||
|
||||
|
||||
// If launched under control:
|
||||
//connect(process, SIGNAL(errorOcurred(int error)), this, SLOT(slot_generateTerminalBlock_error()));
|
||||
//process->start("qet_tb_generator");
|
||||
@ -2351,7 +2363,7 @@ void QETDiagramEditor::generateTerminalBlock()
|
||||
else {
|
||||
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator.app", {("")});
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
if (openedProjects().count()){
|
||||
success = process->startDetached("qet_tb_generator", {(QETDiagramEditor::currentProjectView()->project()->filePath())});
|
||||
@ -2365,7 +2377,7 @@ void QETDiagramEditor::generateTerminalBlock()
|
||||
else {
|
||||
success = process->startDetached(QDir::homePath() + "/.qet/qet_tb_generator", {("")});
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64)
|
||||
QString message=QObject::tr(
|
||||
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
Copyright 2006-2020 The QElectroTech Team
|
||||
This file is part of QElectroTech.
|
||||
|
||||
|
||||
QElectroTech is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
|
||||
QElectroTech is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@ -40,7 +40,7 @@ QETTitleBlockTemplateEditor::QETTitleBlockTemplateEditor(QWidget *parent) :
|
||||
{
|
||||
setWindowIcon(QET::Icons::QETLogo);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
|
||||
initWidgets();
|
||||
initActions();
|
||||
initMenus();
|
||||
@ -74,7 +74,7 @@ bool QETTitleBlockTemplateEditor::isEditing(const QString &filepath)
|
||||
} else {
|
||||
current_filepath = QETApp::realPath(location_.toString());
|
||||
}
|
||||
|
||||
|
||||
return(
|
||||
QET::compareCanonicalFilePaths(
|
||||
current_filepath,
|
||||
@ -166,7 +166,7 @@ void QETTitleBlockTemplateEditor::duplicateCurrentLocation()
|
||||
{
|
||||
// this method does not work for templates edited from the filesystem
|
||||
if (opened_from_file_) return;
|
||||
|
||||
|
||||
QString proposed_name;
|
||||
if (location_.name().isEmpty()) {
|
||||
proposed_name = tr("nouveau_modele",
|
||||
@ -174,7 +174,7 @@ void QETTitleBlockTemplateEditor::duplicateCurrentLocation()
|
||||
} else {
|
||||
proposed_name = QString("%1_copy").arg(location_.name());
|
||||
}
|
||||
|
||||
|
||||
bool accepted = false;
|
||||
QString new_template_name = QInputDialog::getText(
|
||||
this,
|
||||
@ -212,7 +212,7 @@ bool QETTitleBlockTemplateEditor::edit(
|
||||
/// TODO The TBT does not exist, manage error
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
opened_from_file_ = false;
|
||||
location_ = location;
|
||||
setReadOnly(location.isReadOnly());
|
||||
@ -231,7 +231,7 @@ bool QETTitleBlockTemplateEditor::edit(
|
||||
{
|
||||
// we require a project we will rattach templates to
|
||||
if (!project) return(false);
|
||||
|
||||
|
||||
// the template name may be empty to create a new one
|
||||
const TitleBlockTemplate *tb_template_orig;
|
||||
if (template_name.isEmpty())
|
||||
@ -244,12 +244,12 @@ bool QETTitleBlockTemplateEditor::edit(
|
||||
{
|
||||
tb_template_orig = project->embeddedTitleBlockTemplatesCollection()->getTemplate(template_name);
|
||||
}
|
||||
|
||||
|
||||
if (!tb_template_orig) {
|
||||
/// TODO The TBT does not exist, manage error
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
opened_from_file_ = false;
|
||||
location_.setParentCollection(project -> embeddedTitleBlockTemplatesCollection());
|
||||
location_.setName(template_name);
|
||||
@ -270,13 +270,13 @@ bool QETTitleBlockTemplateEditor::edit(const QString &file_path)
|
||||
/// TODO the file opening failed, warn the user?
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
bool editing = edit(tbt);
|
||||
if (!editing) {
|
||||
/// TODO the file editing failed, warn the user?
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
QFileInfo file_path_info(file_path);
|
||||
filepath_ = file_path;
|
||||
opened_from_file_ = true;
|
||||
@ -318,20 +318,20 @@ void QETTitleBlockTemplateEditor::editLogos()
|
||||
if (!logo_manager_) {
|
||||
initLogoManager();
|
||||
}
|
||||
|
||||
|
||||
logo_manager_ -> layout() -> setContentsMargins(0, 0, 0, 0);
|
||||
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Close);
|
||||
|
||||
|
||||
QVBoxLayout *vlayout0 = new QVBoxLayout();
|
||||
vlayout0 -> addWidget(logo_manager_);
|
||||
vlayout0 -> addWidget(buttons);
|
||||
|
||||
|
||||
QDialog d(this);
|
||||
d.setWindowTitle(logo_manager_ -> windowTitle());
|
||||
d.setLayout(vlayout0);
|
||||
connect(buttons, SIGNAL(rejected()), &d, SLOT(reject()));
|
||||
d.exec();
|
||||
|
||||
|
||||
// prevent the logo manager from being deleted along with the dialog
|
||||
logo_manager_ -> setParent(this);
|
||||
}
|
||||
@ -374,10 +374,10 @@ void QETTitleBlockTemplateEditor::initActions()
|
||||
add_col_ = new QAction(QET::Icons::EditTableInsertColumnRight, tr("Ajouter une &colonne", "menu entry"), this);
|
||||
merge_cells_ = new QAction(QET::Icons::EditTableCellMerge, tr("&Fusionner les cellules", "menu entry"), this);
|
||||
split_cell_ = new QAction(QET::Icons::EditTableCellSplit, tr("&Séparer les cellules", "menu entry"), this);
|
||||
|
||||
|
||||
undo_ -> setIcon(QET::Icons::EditUndo);
|
||||
redo_ -> setIcon(QET::Icons::EditRedo);
|
||||
|
||||
|
||||
new_ -> setShortcut(QKeySequence::New);
|
||||
open_ -> setShortcut(QKeySequence::Open);
|
||||
open_from_file_ -> setShortcut(tr("Ctrl+Shift+O", "shortcut to open a template from a file"));
|
||||
@ -397,7 +397,7 @@ void QETTitleBlockTemplateEditor::initActions()
|
||||
zoom_out_ -> setShortcut(QKeySequence::ZoomOut);
|
||||
zoom_fit_ -> setShortcut(QKeySequence(tr("Ctrl+9", "shortcut to enable fit zoom")));
|
||||
zoom_reset_ -> setShortcut(QKeySequence(tr("Ctrl+0", "shortcut to reset zoom")));
|
||||
|
||||
|
||||
connect(new_, SIGNAL(triggered()), this, SLOT(newTemplate()));
|
||||
connect(open_, SIGNAL(triggered()), this, SLOT(open()));
|
||||
connect(open_from_file_, SIGNAL(triggered()), this, SLOT(openFromFile()));
|
||||
@ -428,7 +428,7 @@ void QETTitleBlockTemplateEditor::initMenus()
|
||||
file_menu_ = new QMenu(tr("&Fichier", "menu title"), this);
|
||||
edit_menu_ = new QMenu(tr("&Édition", "menu title"), this);
|
||||
display_menu_ = new QMenu(tr("Afficha&ge", "menu title"), this);
|
||||
|
||||
|
||||
file_menu_ -> addAction(new_);
|
||||
file_menu_ -> addAction(open_);
|
||||
file_menu_ -> addAction(open_from_file_);
|
||||
@ -437,7 +437,7 @@ void QETTitleBlockTemplateEditor::initMenus()
|
||||
file_menu_ -> addAction(save_as_file_);
|
||||
file_menu_ -> addSeparator();
|
||||
file_menu_ -> addAction(quit_);
|
||||
|
||||
|
||||
edit_menu_ -> addAction(undo_);
|
||||
edit_menu_ -> addAction(redo_);
|
||||
edit_menu_ -> addSeparator();
|
||||
@ -456,7 +456,7 @@ void QETTitleBlockTemplateEditor::initMenus()
|
||||
display_menu_ -> addAction(zoom_out_);
|
||||
display_menu_ -> addAction(zoom_fit_);
|
||||
display_menu_ -> addAction(zoom_reset_);
|
||||
|
||||
|
||||
insertMenu(settings_menu_, file_menu_);
|
||||
insertMenu(settings_menu_, edit_menu_);
|
||||
insertMenu(settings_menu_, display_menu_);
|
||||
@ -474,7 +474,7 @@ void QETTitleBlockTemplateEditor::initToolbars()
|
||||
main_toolbar -> addAction(save_);
|
||||
main_toolbar -> addAction(save_as_);
|
||||
addToolBar(Qt::TopToolBarArea, main_toolbar);
|
||||
|
||||
|
||||
QToolBar *edit_toolbar = new QToolBar(tr("Édition", "toolbar title"), this);
|
||||
edit_toolbar -> setObjectName("tbt_edit_toolbar");
|
||||
edit_toolbar -> addAction(undo_);
|
||||
@ -483,7 +483,7 @@ void QETTitleBlockTemplateEditor::initToolbars()
|
||||
edit_toolbar -> addAction(merge_cells_);
|
||||
edit_toolbar -> addAction(split_cell_);
|
||||
addToolBar(Qt::TopToolBarArea, edit_toolbar);
|
||||
|
||||
|
||||
QToolBar *display_toolbar = new QToolBar(tr("Affichage", "toolbar title"), this);
|
||||
display_toolbar -> setObjectName("tbt_display_toolbar");
|
||||
display_toolbar -> addAction(zoom_in_);
|
||||
@ -499,19 +499,22 @@ void QETTitleBlockTemplateEditor::initToolbars()
|
||||
void QETTitleBlockTemplateEditor::initWidgets()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
|
||||
// undo list on the right
|
||||
undo_stack_ = new QUndoStack(this);
|
||||
undo_view_ = new QUndoView(undo_stack_);
|
||||
undo_view_ -> setEmptyLabel(tr("Aucune modification", "label displayed in the undo list when empty"));
|
||||
|
||||
|
||||
undo_dock_widget_ = new QDockWidget(tr("Annulations", "dock title"));
|
||||
undo_dock_widget_ -> setObjectName("tbt_undo_dock");
|
||||
undo_dock_widget_ -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
undo_dock_widget_ -> setFeatures(
|
||||
QDockWidget::DockWidgetClosable
|
||||
|QDockWidget::DockWidgetMovable
|
||||
|QDockWidget::DockWidgetFloatable);
|
||||
undo_dock_widget_ -> setWidget(undo_view_);
|
||||
undo_dock_widget_ -> setMinimumWidth(290);
|
||||
addDockWidget(Qt::RightDockWidgetArea, undo_dock_widget_);
|
||||
|
||||
|
||||
// WYSIWYG editor as central widget
|
||||
template_edition_area_scene_ = new QGraphicsScene(this);
|
||||
template_edition_area_view_ = new TitleBlockTemplateView(template_edition_area_scene_);
|
||||
@ -521,18 +524,21 @@ void QETTitleBlockTemplateEditor::initWidgets()
|
||||
template_edition_area_view_ -> setPreviewWidth(conf_preview_width);
|
||||
}
|
||||
setCentralWidget(template_edition_area_view_);
|
||||
|
||||
|
||||
// cell edition widget at the bottom
|
||||
template_cell_editor_widget_ = new TitleBlockTemplateCellWidget(tb_template_);
|
||||
template_cell_editor_dock_widget_ = new QDockWidget(tr("Propriétés de la cellule", "dock title"), this);
|
||||
template_cell_editor_dock_widget_ -> setObjectName("tbt_celleditor_dock");
|
||||
template_cell_editor_dock_widget_ -> setFeatures(QDockWidget::AllDockWidgetFeatures);
|
||||
template_cell_editor_dock_widget_ -> setFeatures(
|
||||
QDockWidget::DockWidgetClosable
|
||||
|QDockWidget::DockWidgetMovable
|
||||
|QDockWidget::DockWidgetFloatable);
|
||||
template_cell_editor_dock_widget_ -> setWidget(template_cell_editor_widget_);
|
||||
template_cell_editor_dock_widget_ -> setMinimumWidth(180);
|
||||
template_cell_editor_dock_widget_ -> setMinimumHeight(250);
|
||||
addDockWidget(Qt::BottomDockWidgetArea, template_cell_editor_dock_widget_);
|
||||
template_cell_editor_widget_ -> setVisible(false);
|
||||
|
||||
|
||||
connect(
|
||||
template_edition_area_view_,
|
||||
SIGNAL(selectedCellsChanged(QList<TitleBlockCell *>)),
|
||||
@ -592,7 +598,7 @@ QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const
|
||||
} else {
|
||||
titleblock_title = location_.name();
|
||||
}
|
||||
|
||||
|
||||
// if a (file)name has been added, also add a "[Changed]" tag if needed
|
||||
if (!titleblock_title.isEmpty()) {
|
||||
QString tag;
|
||||
@ -609,7 +615,7 @@ QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const
|
||||
)
|
||||
).arg(titleblock_title).arg(tag);
|
||||
}
|
||||
|
||||
|
||||
return(titleblock_title);
|
||||
}
|
||||
|
||||
@ -620,11 +626,11 @@ QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const
|
||||
void QETTitleBlockTemplateEditor::readSettings()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
|
||||
// window size and position
|
||||
QVariant geometry = settings.value("titleblocktemplateeditor/geometry");
|
||||
if (geometry.isValid()) restoreGeometry(geometry.toByteArray());
|
||||
|
||||
|
||||
// window state (toolbars, docks...)
|
||||
QVariant state = settings.value("titleblocktemplateeditor/state");
|
||||
if (state.isValid()) restoreState(state.toByteArray());
|
||||
@ -698,10 +704,10 @@ void QETTitleBlockTemplateEditor::updateEditorTitle()
|
||||
"titleblock template editor: base window title"
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// get the currently edited template (file)name
|
||||
QString titleblock_title = currentlyEditedTitle();
|
||||
|
||||
|
||||
// generate the final window title
|
||||
QString title;
|
||||
if (titleblock_title.isEmpty()) {
|
||||
@ -724,7 +730,7 @@ void QETTitleBlockTemplateEditor::updateEditorTitle()
|
||||
void QETTitleBlockTemplateEditor::updateActions()
|
||||
{
|
||||
save_ -> setEnabled(!read_only_);
|
||||
|
||||
|
||||
bool can_merge = true;
|
||||
bool can_split = true;
|
||||
int count = 0;
|
||||
@ -748,15 +754,15 @@ void QETTitleBlockTemplateEditor::updateActions()
|
||||
bool QETTitleBlockTemplateEditor::saveAs(const TitleBlockTemplateLocation &location) {
|
||||
TitleBlockTemplatesCollection *collection = location.parentCollection();
|
||||
if (!collection) return(false);
|
||||
|
||||
|
||||
QDomDocument doc;
|
||||
QDomElement elmt = doc.createElement("root");
|
||||
tb_template_ -> saveToXmlElement(elmt);
|
||||
elmt.setAttribute("name", location.name());
|
||||
doc.appendChild(elmt);
|
||||
|
||||
|
||||
collection -> setTemplateXmlDescription(location.name(), elmt);
|
||||
|
||||
|
||||
opened_from_file_ = false;
|
||||
location_ = location;
|
||||
undo_stack_ -> setClean();
|
||||
@ -772,7 +778,7 @@ bool QETTitleBlockTemplateEditor::saveAs(const TitleBlockTemplateLocation &locat
|
||||
bool QETTitleBlockTemplateEditor::saveAs(const QString &filepath) {
|
||||
bool saving = tb_template_ -> saveToXmlFile(filepath);
|
||||
if (!saving) return(false);
|
||||
|
||||
|
||||
opened_from_file_ = true;
|
||||
filepath_ = filepath;
|
||||
undo_stack_ -> setClean();
|
||||
@ -805,7 +811,7 @@ void QETTitleBlockTemplateEditor::openFromFile()
|
||||
QString initial_dir = filepath_.isEmpty()
|
||||
? QETApp::customTitleBlockTemplatesDir()
|
||||
: QDir(filepath_).absolutePath();
|
||||
|
||||
|
||||
// ask the user to choose a filepath
|
||||
QString user_filepath = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
@ -819,8 +825,8 @@ void QETTitleBlockTemplateEditor::openFromFile()
|
||||
" - %1 is the .titleblock extension"
|
||||
).arg(QString(TITLEBLOCKS_FILE_EXTENSION))
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
if (!user_filepath.isEmpty()) QETApp::instance() -> openTitleBlockTemplate(user_filepath);
|
||||
}
|
||||
|
||||
@ -871,7 +877,7 @@ bool QETTitleBlockTemplateEditor::saveAsFile()
|
||||
QString initial_dir = filepath_.isEmpty()
|
||||
? QETApp::customTitleBlockTemplatesDir()
|
||||
: QDir(filepath_).absolutePath();
|
||||
|
||||
|
||||
// ask the user to choose a target file
|
||||
QString filepath = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
@ -882,16 +888,16 @@ bool QETTitleBlockTemplateEditor::saveAsFile()
|
||||
"filetypes allowed when saving a title block template file - %1 is the .titleblock extension"
|
||||
).arg(QString(TITLEBLOCKS_FILE_EXTENSION))
|
||||
);
|
||||
|
||||
|
||||
// if no name was entered, return false
|
||||
if (filepath.isEmpty()) return(false);
|
||||
|
||||
|
||||
// if the name does not end with ".titleblock", add it
|
||||
if (!filepath.endsWith(".titleblock", Qt::CaseInsensitive)) filepath += ".titleblock";
|
||||
|
||||
|
||||
// attempts to save the file
|
||||
bool saving = saveAs(filepath);
|
||||
|
||||
|
||||
// retourne un booleen representatif de la reussite de l'enregistrement
|
||||
return(saving);
|
||||
}
|
||||
@ -932,18 +938,18 @@ TitleBlockTemplateLocation QETTitleBlockTemplateEditor::getTitleBlockTemplateLoc
|
||||
}
|
||||
QDialogButtonBox *buttons = new QDialogButtonBox(
|
||||
QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout();
|
||||
dialog_layout -> addWidget(widget);
|
||||
dialog_layout -> addWidget(buttons);
|
||||
|
||||
|
||||
QDialog dialog;
|
||||
dialog.setWindowTitle(title);
|
||||
dialog.setLayout(dialog_layout);
|
||||
|
||||
|
||||
connect(buttons, SIGNAL(accepted()), &dialog, SLOT(accept()));
|
||||
connect(buttons, SIGNAL(rejected()), &dialog, SLOT(reject()));
|
||||
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
return(widget -> location());
|
||||
}
|
||||
@ -978,7 +984,7 @@ void QETTitleBlockTemplateEditor::savePreviewWidthToApplicationSettings(
|
||||
void QETTitleBlockTemplateEditor::editTemplateInformation()
|
||||
{
|
||||
if (!tb_template_) return;
|
||||
|
||||
|
||||
QDialog dialog_author(this);
|
||||
dialog_author.setModal(true);
|
||||
#ifdef Q_OS_MACOS
|
||||
@ -987,20 +993,20 @@ void QETTitleBlockTemplateEditor::editTemplateInformation()
|
||||
dialog_author.setMinimumSize(400, 260);
|
||||
dialog_author.setWindowTitle(tr("Éditer les informations complémentaires", "window title"));
|
||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_author);
|
||||
|
||||
|
||||
// explanation label
|
||||
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."));
|
||||
information_label -> setAlignment(Qt::AlignJustify | Qt::AlignVCenter);
|
||||
information_label -> setWordWrap(true);
|
||||
dialog_layout -> addWidget(information_label);
|
||||
|
||||
|
||||
// add a QTextEdit to the dialog
|
||||
QTextEdit *text_field = new QTextEdit();
|
||||
text_field -> setAcceptRichText(false);
|
||||
text_field -> setPlainText(tb_template_ -> information());
|
||||
text_field -> setReadOnly(read_only_);
|
||||
dialog_layout -> addWidget(text_field);
|
||||
|
||||
|
||||
// add two buttons to the dialog
|
||||
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(
|
||||
read_only_
|
||||
@ -1012,7 +1018,7 @@ void QETTitleBlockTemplateEditor::editTemplateInformation()
|
||||
&dialog_author, SLOT(accept()));
|
||||
connect(dialog_buttons, SIGNAL(rejected()),
|
||||
&dialog_author, SLOT(reject()));
|
||||
|
||||
|
||||
// run the dialog
|
||||
if (dialog_author.exec() == QDialog::Accepted && !read_only_) {
|
||||
QString new_info = text_field -> toPlainText().remove(QChar(13)); // CR-less text
|
||||
|
Loading…
x
Reference in New Issue
Block a user