]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/README
rename LFUN enum values according to their command (as used in th minibuffer/bind...
[lyx.git] / src / frontends / qt4 / README
1 This file contains some do's and dont's for the Qt2 frontend.
2
3 General rules
4 -------------
5
6 Every editable field that affects the state of the dialog contents
7 from LyX's point of view should connect its xxxChanged() signal to
8 a the dialog's changed_adaptor() slot, which in turn should call
9 form_->changed(). If you are using a more complicated thing anyway,
10 then remember to call form_->changed() at the end (if it has changed !)
11
12 Every non-trivial widget should have a tooltip. If you don't know
13 what to write, write "FIXME", and it can fixed later. Don't be afraid
14 to use QWhatsThis too, but this must be done in the derived class's
15 constructor, and use _("..."). Non-trivial means that things like "OK"
16 /must not/ have a tooltip.
17
18 *DO NOT USE DESIGNER FROM Qt 3*. You must use a designer from Qt 2 to
19 maintain compatibility.
20
21 moc is incredibly stupid and sometimes you need a fully qualified
22 "std::string" for .connect() statements to work. Be very, very careful.
23
24 Remember to check tab order on a dialog (third icon, with blue bars in designer).
25
26 Remember to check sensible resizing behaviour on a dialog.
27
28 Remember to use Edit->Check Accelerators
29
30 If necessary, you should override Qt2Base::isValid() for determining the validity
31 of the current dialog's contents.
32
33 OK/Apply/Restore/Close should be connected in the derived class's constructor
34 to call form_->slotOK() etc. Refer to close/cancel as close in the source.
35
36 Override update_contents() to update the dialog, not update(), and build_dialog(),
37 not build(). Only these functions may change dialog widgets that may emit changed()
38 during initialisation, to prevent the button controller from changing its state.
39
40 Never call buttoncontroller functions directly from dialogs. In general, you
41 should use Qt2Base::changed() in all circumstances. However, if you must call
42 the buttoncontroller, make sure to respect Qt2Base::updating_
43
44 Don't #undef emit - #include "QtLyXView.h" instead
45
46 Naming conventions
47 ------------------
48
49 QFoo.[Ch]              The file that interacts with the controller
50 QFooDialog.[Ch]        The implementation of the dialog, derived from the generated files
51 ui/QFooDialog.ui       The designer file
52 ui/QFooDialogBase.[Ch] Generated files from QFooDialog.ui
53
54 slots should be named e.g. slotFooClicked(), slotFooSelected(), where foo is the name
55 of the widget.
56
57 Widgets should be named like "fooXX", where XX is one of the following
58 widget types :
59
60 CB - check box
61 CO - combo box
62 ED - line edit
63 LA - label
64 ML -
65 PB - push button
66 (FIXME: complete this)
67
68
69 Stuff to be aware of
70 --------------------
71
72 The connect statement in Qt is a macro and its arguments does not follow
73 the C++ standard as it should. Using the construct "Type const &" as
74 argument will lead to runtime-errors, use "const Type &" instead.
75
76 ex.
77
78 --right--
79
80         connect(list, SIGNAL(selected(const QString &)),
81                 this, SLOT(complete_selected(const QString &)));
82
83 --wrong--
84
85         connect(list, SIGNAL(selected(QString const &)),
86                 this, SLOT(complete_selected(QString const &)));
87
88 Qt, Unicode, and LyX
89 --------------------
90
91 LyX isn't unicoded yet. But you should follow these simple rules :
92
93 o Use qt_() not _() in code
94 o Use fromqstr and toqstr NOT .latin1() / .c_str()
95
96 Using these functions (in qt_helpers.h) will make sure we use
97 the right locale for converting to Qt's QString, which is unicode.