[qet] [1573] Implemented QETMainWindow::firstActivation, used it to fit view when editing an element. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 1573
Author: xavier
Date: 2012-03-16 19:01:32 +0100 (Fri, 16 Mar 2012)
Log Message:
-----------
Implemented QETMainWindow::firstActivation, used it to fit view when editing an element.
Modified Paths:
--------------
branches/0.3/sources/editor/qetelementeditor.cpp
branches/0.3/sources/editor/qetelementeditor.h
branches/0.3/sources/qetmainwindow.cpp
branches/0.3/sources/qetmainwindow.h
branches/0.3/sources/titleblock/qettemplateeditor.cpp
branches/0.3/sources/titleblock/qettemplateeditor.h
Modified: branches/0.3/sources/editor/qetelementeditor.cpp
===================================================================
--- branches/0.3/sources/editor/qetelementeditor.cpp 2012-03-16 16:33:04 UTC (rev 1572)
+++ branches/0.3/sources/editor/qetelementeditor.cpp 2012-03-16 18:01:32 UTC (rev 1573)
@@ -1117,6 +1117,14 @@
}
/**
+
+*/
+void QETElementEditor::firstActivation(QEvent *event) {
+ Q_UNUSED(event)
+ if (ce_view) ce_view -> zoomFit();
+}
+
+/**
Remplit la liste des parties
*/
void QETElementEditor::slot_createPartsList() {
Modified: branches/0.3/sources/editor/qetelementeditor.h
===================================================================
--- branches/0.3/sources/editor/qetelementeditor.h 2012-03-16 16:33:04 UTC (rev 1572)
+++ branches/0.3/sources/editor/qetelementeditor.h 2012-03-16 18:01:32 UTC (rev 1573)
@@ -121,6 +121,7 @@
protected:
void closeEvent(QCloseEvent *);
+ virtual void firstActivation(QEvent *);
private:
void setupActions();
Modified: branches/0.3/sources/qetmainwindow.cpp
===================================================================
--- branches/0.3/sources/qetmainwindow.cpp 2012-03-16 16:33:04 UTC (rev 1572)
+++ branches/0.3/sources/qetmainwindow.cpp 2012-03-16 18:01:32 UTC (rev 1573)
@@ -24,7 +24,8 @@
*/
QETMainWindow::QETMainWindow(QWidget *widget, Qt::WindowFlags flags) :
QMainWindow(widget, flags),
- display_toolbars_(0)
+ display_toolbars_(0),
+ first_activation_(true)
{
initCommonActions();
initCommonMenus();
@@ -144,6 +145,15 @@
bool QETMainWindow::event(QEvent *e) {
if (e -> type() == QEvent::WindowStateChange) {
updateFullScreenAction();
+ } else if (first_activation_ && e -> type() == QEvent::WindowActivate) {
+ firstActivation(e);
+ first_activation_ = false;
}
return(QMainWindow::event(e));
}
+
+/**
+ Base implementation of firstActivation (does nothing).
+*/
+void QETMainWindow::firstActivation(QEvent *) {
+}
Modified: branches/0.3/sources/qetmainwindow.h
===================================================================
--- branches/0.3/sources/qetmainwindow.h 2012-03-16 16:33:04 UTC (rev 1572)
+++ branches/0.3/sources/qetmainwindow.h 2012-03-16 18:01:32 UTC (rev 1573)
@@ -39,7 +39,8 @@
QAction *actionForMenu(QMenu *);
protected:
- bool event(QEvent *);
+ virtual bool event(QEvent *);
+ virtual void firstActivation(QEvent *);
// slots
public slots:
@@ -57,5 +58,6 @@
QMenu *help_menu_; ///< Help menu
QMenu *display_toolbars_; ///< Show/hide toolbars/docks
QHash<QMenu *, QAction *> menu_actions_; ///< Store actions retrieved when inserting menus
+ bool first_activation_; ///< Used to detect whether the window is activated for the first time
};
#endif
Modified: branches/0.3/sources/titleblock/qettemplateeditor.cpp
===================================================================
--- branches/0.3/sources/titleblock/qettemplateeditor.cpp 2012-03-16 16:33:04 UTC (rev 1572)
+++ branches/0.3/sources/titleblock/qettemplateeditor.cpp 2012-03-16 18:01:32 UTC (rev 1573)
@@ -35,7 +35,6 @@
opened_from_file_(false),
read_only_(false),
duplicate_(false),
- first_activation_(true),
tb_template_(0),
logo_manager_(0)
{
@@ -108,15 +107,12 @@
/**
@param event Object describing the received event.
*/
-bool QETTitleBlockTemplateEditor::event(QEvent *event) {
- if (first_activation_ && event -> type() == QEvent::WindowActivate) {
- if (duplicate_ && !opened_from_file_ && location_.parentCollection()) {
- // this editor is supposed to duplicate its current location
- QTimer::singleShot(250, this, SLOT(duplicateCurrentLocation()));
- }
- first_activation_ = false;
+void QETTitleBlockTemplateEditor::firstActivation(QEvent *event) {
+ Q_UNUSED(event)
+ if (duplicate_ && !opened_from_file_ && location_.parentCollection()) {
+ // this editor is supposed to duplicate its current location
+ QTimer::singleShot(250, this, SLOT(duplicateCurrentLocation()));
}
- return(QETMainWindow::event(event));
}
/**
Modified: branches/0.3/sources/titleblock/qettemplateeditor.h
===================================================================
--- branches/0.3/sources/titleblock/qettemplateeditor.h 2012-03-16 16:33:04 UTC (rev 1572)
+++ branches/0.3/sources/titleblock/qettemplateeditor.h 2012-03-16 18:01:32 UTC (rev 1573)
@@ -89,7 +89,7 @@
protected:
bool canClose();
- bool event(QEvent *);
+ virtual void firstActivation(QEvent *);
void closeEvent(QCloseEvent *);
private: