Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 02:09:34PM +0200, Abdelrazak Younes wrote: Enrico Forestieri wrote: On Mon, Jun 18, 2007 at 12:06:50PM +0200, Leuven, E. wrote: --- src/frontends/qt4/IconPalette.h(revision 18812) +++ src/frontends/qt4/IconPalette.h(working copy) @@ -20,7 +20,7 @@ // FIXME: this can go when we move to Qt 4.3 #define QT_VERSION_CHECK(major, minor, patch) ((major16)|(minor8)|(patch)) -#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) !Q_WS_MACX #include QWidgetAction #endif Edwin, moc doesn't perform like the preprocessor. It doesn't parse included files, such that QT_VERSION is undefined, and doesn't understand macros. In the check above, moc chooses randomly one branch or another. See what I wrote in the thread tear-off math panel. I think there are two solutions: 1) require Qt4.2 While tearing away math panels maybe a nice feature, it is not essential, so requiring Qt4.2 only for that is a lame excuse, IMHO. This is so also for the requirement of Qt4.1 minimum, as it is only dictated by the syntax highlighting thing. This is only mitigated by the fact that Qt4.0 was somewhat buggy. On the contrary, Qt4.1 is a quite good version. 2) Modify the build system(s) to selectively compile IconPalette_42.{h,cpp} when Qt = 4.2 is detected and IconPalette.{h,cpp} otherwise. As 1) is not an option for some of us the only solution is 2). Maybe. Let's see what our experts are able to do. Personally, I don't have any problem with whatever version is required. -- Enrico
Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 02:09:34PM +0200, Abdelrazak Younes wrote: > Enrico Forestieri wrote: > > On Mon, Jun 18, 2007 at 12:06:50PM +0200, Leuven, E. wrote: > > > >> --- src/frontends/qt4/IconPalette.h(revision 18812) > >> +++ src/frontends/qt4/IconPalette.h(working copy) > >> @@ -20,7 +20,7 @@ > >> // FIXME: this can go when we move to Qt 4.3 > >> #define QT_VERSION_CHECK(major, minor, patch) > >> ((major<<16)|(minor<<8)|(patch)) > >> > >> -#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) > >> +#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) && !Q_WS_MACX > >> #include > >> #endif > > > > Edwin, moc doesn't perform like the preprocessor. It doesn't parse > > included files, such that QT_VERSION is undefined, and doesn't > > understand macros. In the check above, moc chooses randomly one > > branch or another. See what I wrote in the thread "tear-off math panel". > > I think there are two solutions: > 1) require Qt4.2 While tearing away math panels maybe a nice feature, it is not essential, so requiring Qt4.2 only for that is a lame excuse, IMHO. This is so also for the requirement of Qt4.1 minimum, as it is only dictated by the syntax highlighting thing. This is only mitigated by the fact that Qt4.0 was somewhat buggy. On the contrary, Qt4.1 is a quite good version. > 2) Modify the build system(s) to selectively compile > IconPalette_42.{h,cpp} when Qt >= 4.2 is detected and > IconPalette.{h,cpp} otherwise. > > As 1) is not an option for some of us the only solution is 2). Maybe. Let's see what our experts are able to do. Personally, I don't have any problem with whatever version is required. -- Enrico
RE: Re: Empty Math Panel Popups
Alfredo wrote: Edwin Leuven wrote: unless someone shouts out i am gonna put this in by noon tomorrow (thu 21) (shouting) You have my ok :-) enjoy: http://www.lyx.org/trac/changeset/18842
RE: Re: Empty Math Panel Popups
Alfredo wrote: >> Edwin Leuven wrote: >> unless someone shouts out i am gonna put this in by noon tomorrow (thu 21) > > (shouting) You have my ok :-) enjoy: http://www.lyx.org/trac/changeset/18842
Re: Empty Math Panel Popups
Bennett Helm wrote: Bennett Helm wrote: It works on Mac, though it's not obvious that it should. What I meant is that when the panel pops up, there's no clear indication from its appearance that tearing it off can work, and so people won't likely try clicking there and discover the tear-off feature. Is there some other way to make this function more apparent? i managed to get tooltips going. see attached. am still hesitating between: click to tear off click to detach click to make floating ... in the meantime it would be good to put the patch in. PING! inline: tearoff.png
Re: Empty Math Panel Popups
On Jun 20, 2007, at 1:17 PM, Edwin Leuven wrote: Bennett Helm wrote: Bennett Helm wrote: It works on Mac, though it's not obvious that it should. What I meant is that when the panel pops up, there's no clear indication from its appearance that tearing it off can work, and so people won't likely try clicking there and discover the tear- off feature. Is there some other way to make this function more apparent? i managed to get tooltips going. see attached. Looks good -- should be discoverable this way. am still hesitating between: click to tear off click to detach click to make floating I'd say click to detach. Bennett
Re: Empty Math Panel Popups
Edwin Leuven wrote: PING! just for the record: unless someone shouts out i am gonna put this in by noon tomorrow (thu 21)
Re: Empty Math Panel Popups
Edwin Leuven wrote: Edwin Leuven wrote: PING! just for the record: unless someone shouts out i am gonna put this in by noon tomorrow (thu 21) (shouting) You have my ok :-) A/
Re: Empty Math Panel Popups
Bennett Helm wrote: Bennett Helm wrote: It works on Mac, though it's not obvious that it should. What I meant is that when the panel pops up, there's no clear indication from its appearance that tearing it off can work, and so people won't likely try clicking there and discover the tear-off feature. Is there some other way to make this function more apparent? i managed to get tooltips going. see attached. am still hesitating between: click to tear off click to detach click to make floating ... in the meantime it would be good to put the patch in. PING! <>
Re: Empty Math Panel Popups
On Jun 20, 2007, at 1:17 PM, Edwin Leuven wrote: Bennett Helm wrote: Bennett Helm wrote: It works on Mac, though it's not obvious that it should. What I meant is that when the panel pops up, there's no clear indication from its appearance that tearing it off can work, and so people won't likely try clicking there and discover the tear- off feature. Is there some other way to make this function more apparent? i managed to get tooltips going. see attached. Looks good -- should be discoverable this way. am still hesitating between: click to tear off click to detach click to make floating I'd say "click to detach". Bennett
Re: Empty Math Panel Popups
Edwin Leuven wrote: PING! just for the record: unless someone shouts out i am gonna put this in by noon tomorrow (thu 21)
Re: Empty Math Panel Popups
Edwin Leuven wrote: > Edwin Leuven wrote: >> PING! > > just for the record: > > unless someone shouts out i am gonna put this in by noon tomorrow (thu 21) (shouting) You have my ok :-) A/
RE: RE: RE: Re: Empty Math Panel Popups
another approach: here i use the old math panel (the one that works for everyone) and draw a tear-off widget ourselves works fine for me so am seeking volunteers (esp mac and linux)! any takers? ;-) Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18822) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -25,99 +25,82 @@ #include QStyle #include QStyleOptionFrame #include QMouseEvent +#include QVBoxLayout namespace lyx { namespace frontend { -#if QT_VERSION = 0x040200 - - -class MathButton : public QToolButton +TearOff::TearOff(QWidget * parent) + : QWidget(parent) { -public: - MathButton(QWidget * parent = 0) {} - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); -}; + highlighted_ = false; + //setMinimumHeight(QStyle::PM_MenuTearoffHeight); + setMinimumHeight(10); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); +} -void MathButton::mouseReleaseEvent(QMouseEvent *event) +void TearOff::mouseReleaseEvent ( QMouseEvent * event ) { - QToolButton::mouseReleaseEvent(event); - event-ignore(); + // signal + tearOff(); } -void MathButton::mousePressEvent(QMouseEvent *event) +void TearOff::enterEvent(QEvent * event) { - QToolButton::mousePressEvent(event); + highlighted_ = true; + update(); event-ignore(); } -IconPalette::IconPalette(QWidget * parent) - : QWidgetAction(parent), size_(QSize(22, 22)) +void TearOff::leaveEvent(QEvent * event) { + highlighted_ = false; + update(); + event-ignore(); } - -void IconPalette::addButton(QAction * action) +void TearOff::paintEvent(QPaintEvent * event) { - actions_.push_back(action); -} +QPainter p(this); +QRegion emptyArea = QRegion(rect()); - -QWidget * IconPalette::createWidget(QWidget * parent) -{ - QWidget * widget = new QWidget(parent); - QGridLayout * layout = new QGridLayout(widget); - layout-setSpacing(0); - - for (int i = 0; i actions_.size(); ++i) { - MathButton * tb = new MathButton(widget); - tb-setAutoRaise(true); - tb-setDefaultAction(actions_.at(i)); - tb-setIconSize(size_); - connect(this, SIGNAL(iconSizeChanged(const QSize )), - tb, SLOT(setIconSize(const QSize ))); - - int const row = i/qMin(6, i + 1) + 1; - int const col = qMax(1, i + 1 - (row - 1) * 6); - layout-addWidget(tb, row, col); - } - - return widget; +const int fw = style()-pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); +QStyleOptionMenuItem menuOpt; +menuOpt.initFrom(this); +menuOpt.palette = palette(); +menuOpt.state = QStyle::State_None; +menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; +menuOpt.menuRect = rect(); +menuOpt.maxIconWidth = 0; +menuOpt.tabWidth = 0; +menuOpt.menuItemType = QStyleOptionMenuItem::TearOff; +menuOpt.rect.setRect(fw, fw, width() - (fw * 2), + style()-pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); +emptyArea -= QRegion(menuOpt.rect); +p.setClipRect(menuOpt.rect); +menuOpt.state = QStyle::State_None; +if (highlighted_) +menuOpt.state |= QStyle::State_Selected; +style()-drawControl(QStyle::CE_MenuTearoff, menuOpt, p, this); } - -void IconPalette::setIconSize(const QSize size) -{ - size_ = size; - // signal - iconSizeChanged(size); -} - - -void IconPalette::updateParent() -{ - bool enable = false; - for (int i = 0; i actions_.size(); ++i) - if (actions_.at(i)-isEnabled()) { - enable = true; - break; - } - // signal - enabled(enable); -} - -#else // QT_VERSION = 0x040200 - IconPalette::IconPalette(QWidget * parent) : QWidget(parent, Qt::Popup) { - layout_ = new QGridLayout(this); + tornoff_ = false; + QVBoxLayout * v = new QVBoxLayout(this); + v-setMargin(0); + layout_ = new QGridLayout; layout_-setSpacing(0); - layout_-setMargin(3); + layout_-setMargin(2); + tearoffwidget_ = new TearOff(this); + connect(tearoffwidget_, SIGNAL(tearOff()), this, SLOT(tearOff())); + tearoffwidget_-setMaximumSize(QSize(16777215, 10)); + v-addWidget(tearoffwidget_); + v-addLayout(layout_); } @@ -141,10 +124,20 @@ } +void IconPalette::tearOff() +{ + setWindowFlags(Qt::Tool); + tornoff_ = true; + tearoffwidget_-setVisible(!tornoff_); + show(); +} + + void IconPalette::clicked(QAction * action) { triggered(action); - setVisible(false); + if (!tornoff_) + setVisible(false); } @@ -191,6 +184,9 @@ void IconPalette::hideEvent(QHideEvent * event ) { visible(false); + setWindowFlags(Qt::Popup); + tornoff_ = false; + tearoffwidget_-setVisible(!tornoff_); QWidget::hideEvent(event); } @@ -234,7 +230,6 @@ // draw the rest (buttons) QWidget::paintEvent(event); } -#endif // QT_VERSION = 0x040200 ButtonMenu::ButtonMenu(const QString title, QWidget * parent) Index: src/frontends/qt4/IconPalette.h === --- src/frontends/qt4/IconPalette.h (revision 18822) +++
RE: RE: RE: Re: Empty Math Panel Popups
Leuven, E. wrote: another approach: here i use the old math panel (the one that works for everyone) and draw a tear-off widget ourselves works fine for me so am seeking volunteers (esp mac and linux)! any takers? ;-) Works fine here (linux, qt 4.2.3). Nice stuff. A/
Re: Empty Math Panel Popups
On Jun 19, 2007, at 6:08 AM, Leuven, E. wrote: another approach: here i use the old math panel (the one that works for everyone) and draw a tear-off widget ourselves works fine for me so am seeking volunteers (esp mac and linux)! any takers? ;-) tearoff2.diff It works on Mac, though it's not obvious that it should. The panel that pops up has a wider border on the top with an extra horizontal line, but nothing that looks like a title bar. Clicking on that wide border switches from the pop-up panel to the tear-off panel, complete with title bar; this tear-off panel can then be relocated and resized (though resizing does not result in a rearrangement of the icons). Bennett
RE: RE: RE: RE: Re: Empty Math Panel Popups
From: news on behalf of Alfredo Braunstein Works fine here (linux, qt 4.2.3). Nice stuff. great. so if now some mac people can chime in...
RE: Empty Math Panel Popups
Bennett Helm wrote: It works on Mac, though it's not obvious that it should. don't know what this means The panel that pops up has a wider border on the top with an extra horizontal line, but nothing that looks like a title bar. sounds like intended behavior: this is the regular popup (click and it disappears) Clicking on that wide border switches from the pop-up panel to the tear-off panel, complete with title bar; you got it this tear-off panel can then be relocated and should stay on top (allow you to enter multiple symbols in a row) until you explicitly close it... and resized (though resizing does not result in a rearrangement of the icons). nope
Re: Empty Math Panel Popups
On Jun 19, 2007, at 9:13 AM, Leuven, E. wrote: Bennett Helm wrote: It works on Mac, though it's not obvious that it should. don't know what this means What I meant is that when the panel pops up, there's no clear indication from its appearance that tearing it off can work, and so people won't likely try clicking there and discover the tear-off feature. Is there some other way to make this function more apparent? The panel that pops up has a wider border on the top with an extra horizontal line, but nothing that looks like a title bar. sounds like intended behavior: this is the regular popup (click and it disappears) Clicking on that wide border switches from the pop-up panel to the tear-off panel, complete with title bar; you got it this tear-off panel can then be relocated and should stay on top (allow you to enter multiple symbols in a row) until you explicitly close it... and resized (though resizing does not result in a rearrangement of the icons). nope But then it should not be resizable. Bennett
RE: Empty Math Panel Popups
Bennett Helm wrote: What I meant is that when the panel pops up, there's no clear indication from its appearance that tearing it off can work, and so people won't likely try clicking there and discover the tear-off feature. Is there some other way to make this function more apparent? i've added a tooltip but for the moment tooltips don't show in the panels i don't know why: when we tear off the panel (ie set windowflags to Qt:Tool) they *do* show so i am afraid that for the moment this is just the way it is (unless someone else comes up with the solution)... But then it should not be resizable. the attached patch does that ... in summary: - allow panels to tear off using only qt 4.1 functionality - reported to work on windows, linux and mac seeking 2 ok's Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18822) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -25,99 +25,80 @@ #include QStyle #include QStyleOptionFrame #include QMouseEvent +#include QVBoxLayout namespace lyx { namespace frontend { -#if QT_VERSION = 0x040200 - - -class MathButton : public QToolButton +TearOff::TearOff(QWidget * parent) + : QWidget(parent) { -public: - MathButton(QWidget * parent = 0) {} - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); -}; + highlighted_ = false; + setMinimumHeight(8); + setToolTip(qt_(Click to tear off)); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); +} -void MathButton::mouseReleaseEvent(QMouseEvent *event) +void TearOff::mouseReleaseEvent(QMouseEvent * event) { - QToolButton::mouseReleaseEvent(event); - event-ignore(); + // signal + tearOff(); } -void MathButton::mousePressEvent(QMouseEvent *event) +void TearOff::enterEvent(QEvent * event) { - QToolButton::mousePressEvent(event); + highlighted_ = true; + update(); event-ignore(); } -IconPalette::IconPalette(QWidget * parent) - : QWidgetAction(parent), size_(QSize(22, 22)) +void TearOff::leaveEvent(QEvent * event) { + highlighted_ = false; + update(); + event-ignore(); } -void IconPalette::addButton(QAction * action) +void TearOff::paintEvent(QPaintEvent * event) { - actions_.push_back(action); + QPainter p(this); + const int fw = style()-pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); + QStyleOptionMenuItem menuOpt; + menuOpt.initFrom(this); + menuOpt.palette = palette(); + menuOpt.state = QStyle::State_None; + menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; + menuOpt.menuRect = rect(); + menuOpt.maxIconWidth = 0; + menuOpt.tabWidth = 0; + menuOpt.menuItemType = QStyleOptionMenuItem::TearOff; + menuOpt.rect.setRect(fw, fw, width() - (fw * 2), + style()-pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); + p.setClipRect(menuOpt.rect); + menuOpt.state = QStyle::State_None; + if (highlighted_) + menuOpt.state |= QStyle::State_Selected; + style()-drawControl(QStyle::CE_MenuTearoff, menuOpt, p, this); } -QWidget * IconPalette::createWidget(QWidget * parent) -{ - QWidget * widget = new QWidget(parent); - QGridLayout * layout = new QGridLayout(widget); - layout-setSpacing(0); - - for (int i = 0; i actions_.size(); ++i) { - MathButton * tb = new MathButton(widget); - tb-setAutoRaise(true); - tb-setDefaultAction(actions_.at(i)); - tb-setIconSize(size_); - connect(this, SIGNAL(iconSizeChanged(const QSize )), - tb, SLOT(setIconSize(const QSize ))); - - int const row = i/qMin(6, i + 1) + 1; - int const col = qMax(1, i + 1 - (row - 1) * 6); - layout-addWidget(tb, row, col); - } - - return widget; -} - - -void IconPalette::setIconSize(const QSize size) -{ - size_ = size; - // signal - iconSizeChanged(size); -} - - -void IconPalette::updateParent() -{ - bool enable = false; - for (int i = 0; i actions_.size(); ++i) - if (actions_.at(i)-isEnabled()) { - enable = true; - break; - } - // signal - enabled(enable); -} - -#else // QT_VERSION = 0x040200 - IconPalette::IconPalette(QWidget * parent) - : QWidget(parent, Qt::Popup) + : QWidget(parent, Qt::Popup), tornoff_(false) { - layout_ = new QGridLayout(this); + QVBoxLayout * v = new QVBoxLayout(this); + v-setMargin(0); + v-setSpacing(0); + layout_ = new QGridLayout; layout_-setSpacing(0); - layout_-setMargin(3); + layout_-setMargin(2); + tearoffwidget_ = new TearOff(this); + connect(tearoffwidget_, SIGNAL(tearOff()), this, SLOT(tearOff())); + v-addWidget(tearoffwidget_); + v-addLayout(layout_); } @@ -141,15 +122,30 @@ } +void IconPalette::tearOff() +{ + blockSignals(true); + setWindowFlags(Qt::Tool); + tornoff_ = true; + tearoffwidget_-setVisible(!tornoff_); + show(); + blockSignals(false); +} + + void IconPalette::clicked(QAction * action) { triggered(action); - setVisible(false); + if (!tornoff_) + setVisible(false); } void IconPalette::showEvent(QShowEvent * event) { + resize(sizeHint()); + setMaximumSize(sizeHint()); + int
Re: Empty Math Panel Popups
On Tue, Jun 19, 2007 at 04:14:18PM +0200, Leuven, E. wrote: in summary: - allow panels to tear off using only qt 4.1 functionality - reported to work on windows, linux and mac seeking 2 ok's Edwin, I really appreciate your effort for trying to provide this feature with Qt 4.1. However, I think that we should not jump through hoops if something is hard to obtain with older Qt versions. It suffices to let the thing compile, even with reduced functionality. I tried the patch with Qt 4.1 and it almost works (I am really impressed). There's a quirk, though. After detaching a panel and trying to close it again, LyX freezes. There's no cpu load, LyX simply doesn't respond anymore and after a Ctrl-C an emergency file is created. Taking into account the time and effort you put in this, I am really afraid to suggest leaving things as they are now and simply applying that small patch curing the moc problem. What do you (and others) think? -- Enrico
Re: Empty Math Panel Popups
Enrico Forestieri wrote: Edwin, I really appreciate your effort for trying to provide this feature with Qt 4.1. However, I think that we should not jump through hoops if something is hard to obtain with older Qt versions. It suffices to let the thing compile, even with reduced functionality. I tried the patch with Qt 4.1 and it almost works (I am really impressed). There's a quirk, though. After detaching a panel and trying to close it again, LyX freezes. There's no cpu load, LyX simply doesn't respond anymore and after a Ctrl-C an emergency file is created. i admit i was using qt 4.2 i now compiled with 4.1 and it turns out we cannot change windowflags on visible windows hiding the widget before changing the windowflags solves the problem for me could you try the attached? Taking into account the time and effort you put in this, I am really afraid to suggest leaving things as they are now and simply applying that small patch curing the moc problem. What do you (and others) think? the attached patch has the advantage that it also allows tearoff panels on the mac i would be very surprised if this one doesn't work for you Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18822) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -25,99 +25,81 @@ #include QStyle #include QStyleOptionFrame #include QMouseEvent +#include QVBoxLayout namespace lyx { namespace frontend { -#if QT_VERSION = 0x040200 - - -class MathButton : public QToolButton +TearOff::TearOff(QWidget * parent) + : QWidget(parent) { -public: - MathButton(QWidget * parent = 0) {} - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); -}; + highlighted_ = false; + setMinimumHeight(8); + setToolTip(qt_(Click to tear off)); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); +} -void MathButton::mouseReleaseEvent(QMouseEvent *event) +void TearOff::mouseReleaseEvent(QMouseEvent * event) { - QToolButton::mouseReleaseEvent(event); - event-ignore(); + // signal + tearOff(); } -void MathButton::mousePressEvent(QMouseEvent *event) +void TearOff::enterEvent(QEvent * event) { - QToolButton::mousePressEvent(event); + highlighted_ = true; + update(); event-ignore(); } -IconPalette::IconPalette(QWidget * parent) - : QWidgetAction(parent), size_(QSize(22, 22)) +void TearOff::leaveEvent(QEvent * event) { + highlighted_ = false; + update(); + event-ignore(); } -void IconPalette::addButton(QAction * action) +void TearOff::paintEvent(QPaintEvent * event) { - actions_.push_back(action); + QPainter p(this); + const int fw = style()-pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); + QStyleOptionMenuItem menuOpt; + menuOpt.initFrom(this); + menuOpt.palette = palette(); + menuOpt.state = QStyle::State_None; + menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; + menuOpt.menuRect = rect(); + menuOpt.maxIconWidth = 0; + menuOpt.tabWidth = 0; + menuOpt.menuItemType = QStyleOptionMenuItem::TearOff; + menuOpt.rect.setRect(fw, fw, width() - (fw * 2), + style()-pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); + p.setClipRect(menuOpt.rect); + menuOpt.state = QStyle::State_None; + if (highlighted_) + menuOpt.state |= QStyle::State_Selected; + style()-drawControl(QStyle::CE_MenuTearoff, menuOpt, p, this); } -QWidget * IconPalette::createWidget(QWidget * parent) -{ - QWidget * widget = new QWidget(parent); - QGridLayout * layout = new QGridLayout(widget); - layout-setSpacing(0); - - for (int i = 0; i actions_.size(); ++i) { - MathButton * tb = new MathButton(widget); - tb-setAutoRaise(true); - tb-setDefaultAction(actions_.at(i)); - tb-setIconSize(size_); - connect(this, SIGNAL(iconSizeChanged(const QSize )), - tb, SLOT(setIconSize(const QSize ))); - - int const row = i/qMin(6, i + 1) + 1; - int const col = qMax(1, i + 1 - (row - 1) * 6); - layout-addWidget(tb, row, col); - } - - return widget; -} - - -void IconPalette::setIconSize(const QSize size) -{ - size_ = size; - // signal - iconSizeChanged(size); -} - - -void IconPalette::updateParent() -{ - bool enable = false; - for (int i = 0; i actions_.size(); ++i) - if (actions_.at(i)-isEnabled()) { - enable = true; - break; - } - // signal - enabled(enable); -} - -#else // QT_VERSION = 0x040200 - IconPalette::IconPalette(QWidget * parent) - : QWidget(parent, Qt::Popup) + : QWidget(parent, Qt::Popup), tornoff_(false) { - layout_ = new QGridLayout(this); + QVBoxLayout * v = new QVBoxLayout(this); + v-setMargin(0); + v-setSpacing(0); + layout_ = new QGridLayout; layout_-setSpacing(0); - layout_-setMargin(3); + const int fw = style()-pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); + layout_-setMargin(fw); + tearoffwidget_ = new TearOff(this); + connect(tearoffwidget_, SIGNAL(tearOff()), this, SLOT(tearOff())); + v-addWidget(tearoffwidget_); + v-addLayout(layout_); } @@ -141,15 +123,31
Re: Empty Math Panel Popups
in summary: - allow panels to tear off using only qt 4.1 functionality - reported to work on windows, linux and mac seeking 2 ok's tearoff2.diff works for me with latest svn, qt4.3.0 and mac os x. andi
Re: Empty Math Panel Popups
On Tue, Jun 19, 2007 at 08:40:52PM +0200, Edwin Leuven wrote: the attached patch has the advantage that it also allows tearoff panels on the mac i would be very surprised if this one doesn't work for you You did it! Works like a charm. A big thank you! -- Enrico
Re: Empty Math Panel Popups
Enrico Forestieri wrote: You did it! Works like a charm. :) A big thank you! thanks for testing! ... will collect 2 ok's tomorrow. josé?
RE: RE: RE: Re: Empty Math Panel Popups
another approach: here i use the old math panel (the one that works for everyone) and draw a tear-off widget ourselves works fine for me so am seeking volunteers (esp mac and linux)! any takers? ;-) Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18822) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -25,99 +25,82 @@ #include #include #include +#include namespace lyx { namespace frontend { -#if QT_VERSION >= 0x040200 - - -class MathButton : public QToolButton +TearOff::TearOff(QWidget * parent) + : QWidget(parent) { -public: - MathButton(QWidget * parent = 0) {} - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); -}; + highlighted_ = false; + //setMinimumHeight(QStyle::PM_MenuTearoffHeight); + setMinimumHeight(10); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); +} -void MathButton::mouseReleaseEvent(QMouseEvent *event) +void TearOff::mouseReleaseEvent ( QMouseEvent * event ) { - QToolButton::mouseReleaseEvent(event); - event->ignore(); + // signal + tearOff(); } -void MathButton::mousePressEvent(QMouseEvent *event) +void TearOff::enterEvent(QEvent * event) { - QToolButton::mousePressEvent(event); + highlighted_ = true; + update(); event->ignore(); } -IconPalette::IconPalette(QWidget * parent) - : QWidgetAction(parent), size_(QSize(22, 22)) +void TearOff::leaveEvent(QEvent * event) { + highlighted_ = false; + update(); + event->ignore(); } - -void IconPalette::addButton(QAction * action) +void TearOff::paintEvent(QPaintEvent * event) { - actions_.push_back(action); -} +QPainter p(this); +QRegion emptyArea = QRegion(rect()); - -QWidget * IconPalette::createWidget(QWidget * parent) -{ - QWidget * widget = new QWidget(parent); - QGridLayout * layout = new QGridLayout(widget); - layout->setSpacing(0); - - for (int i = 0; i < actions_.size(); ++i) { - MathButton * tb = new MathButton(widget); - tb->setAutoRaise(true); - tb->setDefaultAction(actions_.at(i)); - tb->setIconSize(size_); - connect(this, SIGNAL(iconSizeChanged(const QSize &)), - tb, SLOT(setIconSize(const QSize &))); - - int const row = i/qMin(6, i + 1) + 1; - int const col = qMax(1, i + 1 - (row - 1) * 6); - layout->addWidget(tb, row, col); - } - - return widget; +const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); +QStyleOptionMenuItem menuOpt; +menuOpt.initFrom(this); +menuOpt.palette = palette(); +menuOpt.state = QStyle::State_None; +menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; +menuOpt.menuRect = rect(); +menuOpt.maxIconWidth = 0; +menuOpt.tabWidth = 0; +menuOpt.menuItemType = QStyleOptionMenuItem::TearOff; +menuOpt.rect.setRect(fw, fw, width() - (fw * 2), + style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); +emptyArea -= QRegion(menuOpt.rect); +p.setClipRect(menuOpt.rect); +menuOpt.state = QStyle::State_None; +if (highlighted_) +menuOpt.state |= QStyle::State_Selected; +style()->drawControl(QStyle::CE_MenuTearoff, , , this); } - -void IconPalette::setIconSize(const QSize & size) -{ - size_ = size; - // signal - iconSizeChanged(size); -} - - -void IconPalette::updateParent() -{ - bool enable = false; - for (int i = 0; i < actions_.size(); ++i) - if (actions_.at(i)->isEnabled()) { - enable = true; - break; - } - // signal - enabled(enable); -} - -#else // QT_VERSION >= 0x040200 - IconPalette::IconPalette(QWidget * parent) : QWidget(parent, Qt::Popup) { - layout_ = new QGridLayout(this); + tornoff_ = false; + QVBoxLayout * v = new QVBoxLayout(this); + v->setMargin(0); + layout_ = new QGridLayout; layout_->setSpacing(0); - layout_->setMargin(3); + layout_->setMargin(2); + tearoffwidget_ = new TearOff(this); + connect(tearoffwidget_, SIGNAL(tearOff()), this, SLOT(tearOff())); + tearoffwidget_->setMaximumSize(QSize(16777215, 10)); + v->addWidget(tearoffwidget_); + v->addLayout(layout_); } @@ -141,10 +124,20 @@ } +void IconPalette::tearOff() +{ + setWindowFlags(Qt::Tool); + tornoff_ = true; + tearoffwidget_->setVisible(!tornoff_); + show(); +} + + void IconPalette::clicked(QAction * action) { triggered(action); - setVisible(false); + if (!tornoff_) + setVisible(false); } @@ -191,6 +184,9 @@ void IconPalette::hideEvent(QHideEvent * event ) { visible(false); + setWindowFlags(Qt::Popup); + tornoff_ = false; + tearoffwidget_->setVisible(!tornoff_); QWidget::hideEvent(event); } @@ -234,7 +230,6 @@ // draw the rest (buttons) QWidget::paintEvent(event); } -#endif // QT_VERSION >= 0x040200 ButtonMenu::ButtonMenu(const QString & title, QWidget * parent) Index: src/frontends/qt4/IconPalette.h === --- src/frontends/qt4/IconPalette.h (revision 18822) +++
RE: RE: RE: Re: Empty Math Panel Popups
Leuven, E. wrote: > another approach: > > here i use the old math panel (the one that works for everyone) > > and draw a tear-off widget ourselves > > works fine for me > > so am seeking volunteers (esp mac and linux)! > > any takers? ;-) Works fine here (linux, qt 4.2.3). Nice stuff. A/
Re: Empty Math Panel Popups
On Jun 19, 2007, at 6:08 AM, Leuven, E. wrote: another approach: here i use the old math panel (the one that works for everyone) and draw a tear-off widget ourselves works fine for me so am seeking volunteers (esp mac and linux)! any takers? ;-) It works on Mac, though it's not obvious that it should. The panel that pops up has a wider border on the top with an extra horizontal line, but nothing that looks like a title bar. Clicking on that wide border switches from the pop-up panel to the tear-off panel, complete with title bar; this tear-off panel can then be relocated and resized (though resizing does not result in a rearrangement of the icons). Bennett
RE: RE: RE: RE: Re: Empty Math Panel Popups
From: news on behalf of Alfredo Braunstein > Works fine here (linux, qt 4.2.3). Nice stuff. great. so if now some mac people can chime in...
RE: Empty Math Panel Popups
Bennett Helm wrote: > It works on Mac, though it's not obvious that it should. don't know what this means > The panel > that pops up has a wider border on the top with an extra horizontal > line, but nothing that looks like a title bar. sounds like intended behavior: this is the regular popup (click and it disappears) > Clicking on that wide > border switches from the pop-up panel to the tear-off panel, complete > with title bar; you got it > this tear-off panel can then be relocated and should stay on top (allow you to enter multiple symbols in a row) until you explicitly close it... > and > resized (though resizing does not result in a rearrangement of the > icons). nope
Re: Empty Math Panel Popups
On Jun 19, 2007, at 9:13 AM, Leuven, E. wrote: Bennett Helm wrote: It works on Mac, though it's not obvious that it should. don't know what this means What I meant is that when the panel pops up, there's no clear indication from its appearance that tearing it off can work, and so people won't likely try clicking there and discover the tear-off feature. Is there some other way to make this function more apparent? The panel that pops up has a wider border on the top with an extra horizontal line, but nothing that looks like a title bar. sounds like intended behavior: this is the regular popup (click and it disappears) Clicking on that wide border switches from the pop-up panel to the tear-off panel, complete with title bar; you got it this tear-off panel can then be relocated and should stay on top (allow you to enter multiple symbols in a row) until you explicitly close it... and resized (though resizing does not result in a rearrangement of the icons). nope But then it should not be resizable. Bennett
RE: Empty Math Panel Popups
Bennett Helm wrote: > What I meant is that when the panel pops up, there's no clear indication > from its appearance that tearing it off can work, and so people won't > likely try clicking there and discover the tear-off feature. Is there > some other way to make this function more apparent? i've added a tooltip but for the moment tooltips don't show in the panels i don't know why: when we tear off the panel (ie set windowflags to Qt:Tool) they *do* show so i am afraid that for the moment this is just the way it is (unless someone else comes up with the solution)... > But then it should not be resizable. the attached patch does that ... in summary: - allow panels to tear off using only qt 4.1 functionality - reported to work on windows, linux and mac seeking 2 ok's Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18822) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -25,99 +25,80 @@ #include #include #include +#include namespace lyx { namespace frontend { -#if QT_VERSION >= 0x040200 - - -class MathButton : public QToolButton +TearOff::TearOff(QWidget * parent) + : QWidget(parent) { -public: - MathButton(QWidget * parent = 0) {} - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); -}; + highlighted_ = false; + setMinimumHeight(8); + setToolTip(qt_("Click to tear off")); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); +} -void MathButton::mouseReleaseEvent(QMouseEvent *event) +void TearOff::mouseReleaseEvent(QMouseEvent * event) { - QToolButton::mouseReleaseEvent(event); - event->ignore(); + // signal + tearOff(); } -void MathButton::mousePressEvent(QMouseEvent *event) +void TearOff::enterEvent(QEvent * event) { - QToolButton::mousePressEvent(event); + highlighted_ = true; + update(); event->ignore(); } -IconPalette::IconPalette(QWidget * parent) - : QWidgetAction(parent), size_(QSize(22, 22)) +void TearOff::leaveEvent(QEvent * event) { + highlighted_ = false; + update(); + event->ignore(); } -void IconPalette::addButton(QAction * action) +void TearOff::paintEvent(QPaintEvent * event) { - actions_.push_back(action); + QPainter p(this); + const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); + QStyleOptionMenuItem menuOpt; + menuOpt.initFrom(this); + menuOpt.palette = palette(); + menuOpt.state = QStyle::State_None; + menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; + menuOpt.menuRect = rect(); + menuOpt.maxIconWidth = 0; + menuOpt.tabWidth = 0; + menuOpt.menuItemType = QStyleOptionMenuItem::TearOff; + menuOpt.rect.setRect(fw, fw, width() - (fw * 2), + style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); + p.setClipRect(menuOpt.rect); + menuOpt.state = QStyle::State_None; + if (highlighted_) + menuOpt.state |= QStyle::State_Selected; + style()->drawControl(QStyle::CE_MenuTearoff, , , this); } -QWidget * IconPalette::createWidget(QWidget * parent) -{ - QWidget * widget = new QWidget(parent); - QGridLayout * layout = new QGridLayout(widget); - layout->setSpacing(0); - - for (int i = 0; i < actions_.size(); ++i) { - MathButton * tb = new MathButton(widget); - tb->setAutoRaise(true); - tb->setDefaultAction(actions_.at(i)); - tb->setIconSize(size_); - connect(this, SIGNAL(iconSizeChanged(const QSize &)), - tb, SLOT(setIconSize(const QSize &))); - - int const row = i/qMin(6, i + 1) + 1; - int const col = qMax(1, i + 1 - (row - 1) * 6); - layout->addWidget(tb, row, col); - } - - return widget; -} - - -void IconPalette::setIconSize(const QSize & size) -{ - size_ = size; - // signal - iconSizeChanged(size); -} - - -void IconPalette::updateParent() -{ - bool enable = false; - for (int i = 0; i < actions_.size(); ++i) - if (actions_.at(i)->isEnabled()) { - enable = true; - break; - } - // signal - enabled(enable); -} - -#else // QT_VERSION >= 0x040200 - IconPalette::IconPalette(QWidget * parent) - : QWidget(parent, Qt::Popup) + : QWidget(parent, Qt::Popup), tornoff_(false) { - layout_ = new QGridLayout(this); + QVBoxLayout * v = new QVBoxLayout(this); + v->setMargin(0); + v->setSpacing(0); + layout_ = new QGridLayout; layout_->setSpacing(0); - layout_->setMargin(3); + layout_->setMargin(2); + tearoffwidget_ = new TearOff(this); + connect(tearoffwidget_, SIGNAL(tearOff()), this, SLOT(tearOff())); + v->addWidget(tearoffwidget_); + v->addLayout(layout_); } @@ -141,15 +122,30 @@ } +void IconPalette::tearOff() +{ + blockSignals(true); + setWindowFlags(Qt::Tool); + tornoff_ = true; + tearoffwidget_->setVisible(!tornoff_); + show(); + blockSignals(false); +} + + void IconPalette::clicked(QAction * action) { triggered(action); - setVisible(false); + if (!tornoff_) + setVisible(false); } void IconPalette::showEvent(QShowEvent * event) { + resize(sizeHint()); + setMaximumSize(sizeHint()); + int hoffset = -
Re: Empty Math Panel Popups
On Tue, Jun 19, 2007 at 04:14:18PM +0200, Leuven, E. wrote: > in summary: > > - allow panels to tear off using only qt 4.1 functionality > > - reported to work on windows, linux and mac > > seeking 2 ok's Edwin, I really appreciate your effort for trying to provide this feature with Qt 4.1. However, I think that we should not jump through hoops if something is hard to obtain with older Qt versions. It suffices to let the thing compile, even with reduced functionality. I tried the patch with Qt 4.1 and it almost works (I am really impressed). There's a quirk, though. After detaching a panel and trying to close it again, LyX freezes. There's no cpu load, LyX simply doesn't respond anymore and after a Ctrl-C an emergency file is created. Taking into account the time and effort you put in this, I am really afraid to suggest leaving things as they are now and simply applying that small patch curing the moc problem. What do you (and others) think? -- Enrico
Re: Empty Math Panel Popups
Enrico Forestieri wrote: Edwin, I really appreciate your effort for trying to provide this feature with Qt 4.1. However, I think that we should not jump through hoops if something is hard to obtain with older Qt versions. It suffices to let the thing compile, even with reduced functionality. I tried the patch with Qt 4.1 and it almost works (I am really impressed). There's a quirk, though. After detaching a panel and trying to close it again, LyX freezes. There's no cpu load, LyX simply doesn't respond anymore and after a Ctrl-C an emergency file is created. i admit i was using qt 4.2 i now compiled with 4.1 and it turns out we cannot change windowflags on visible windows hiding the widget before changing the windowflags solves the problem for me could you try the attached? Taking into account the time and effort you put in this, I am really afraid to suggest leaving things as they are now and simply applying that small patch curing the moc problem. What do you (and others) think? the attached patch has the advantage that it also allows tearoff panels on the mac i would be very surprised if this one doesn't work for you Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18822) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -25,99 +25,81 @@ #include #include #include +#include namespace lyx { namespace frontend { -#if QT_VERSION >= 0x040200 - - -class MathButton : public QToolButton +TearOff::TearOff(QWidget * parent) + : QWidget(parent) { -public: - MathButton(QWidget * parent = 0) {} - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); -}; + highlighted_ = false; + setMinimumHeight(8); + setToolTip(qt_("Click to tear off")); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); +} -void MathButton::mouseReleaseEvent(QMouseEvent *event) +void TearOff::mouseReleaseEvent(QMouseEvent * event) { - QToolButton::mouseReleaseEvent(event); - event->ignore(); + // signal + tearOff(); } -void MathButton::mousePressEvent(QMouseEvent *event) +void TearOff::enterEvent(QEvent * event) { - QToolButton::mousePressEvent(event); + highlighted_ = true; + update(); event->ignore(); } -IconPalette::IconPalette(QWidget * parent) - : QWidgetAction(parent), size_(QSize(22, 22)) +void TearOff::leaveEvent(QEvent * event) { + highlighted_ = false; + update(); + event->ignore(); } -void IconPalette::addButton(QAction * action) +void TearOff::paintEvent(QPaintEvent * event) { - actions_.push_back(action); + QPainter p(this); + const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); + QStyleOptionMenuItem menuOpt; + menuOpt.initFrom(this); + menuOpt.palette = palette(); + menuOpt.state = QStyle::State_None; + menuOpt.checkType = QStyleOptionMenuItem::NotCheckable; + menuOpt.menuRect = rect(); + menuOpt.maxIconWidth = 0; + menuOpt.tabWidth = 0; + menuOpt.menuItemType = QStyleOptionMenuItem::TearOff; + menuOpt.rect.setRect(fw, fw, width() - (fw * 2), + style()->pixelMetric(QStyle::PM_MenuTearoffHeight, 0, this)); + p.setClipRect(menuOpt.rect); + menuOpt.state = QStyle::State_None; + if (highlighted_) + menuOpt.state |= QStyle::State_Selected; + style()->drawControl(QStyle::CE_MenuTearoff, , , this); } -QWidget * IconPalette::createWidget(QWidget * parent) -{ - QWidget * widget = new QWidget(parent); - QGridLayout * layout = new QGridLayout(widget); - layout->setSpacing(0); - - for (int i = 0; i < actions_.size(); ++i) { - MathButton * tb = new MathButton(widget); - tb->setAutoRaise(true); - tb->setDefaultAction(actions_.at(i)); - tb->setIconSize(size_); - connect(this, SIGNAL(iconSizeChanged(const QSize &)), - tb, SLOT(setIconSize(const QSize &))); - - int const row = i/qMin(6, i + 1) + 1; - int const col = qMax(1, i + 1 - (row - 1) * 6); - layout->addWidget(tb, row, col); - } - - return widget; -} - - -void IconPalette::setIconSize(const QSize & size) -{ - size_ = size; - // signal - iconSizeChanged(size); -} - - -void IconPalette::updateParent() -{ - bool enable = false; - for (int i = 0; i < actions_.size(); ++i) - if (actions_.at(i)->isEnabled()) { - enable = true; - break; - } - // signal - enabled(enable); -} - -#else // QT_VERSION >= 0x040200 - IconPalette::IconPalette(QWidget * parent) - : QWidget(parent, Qt::Popup) + : QWidget(parent, Qt::Popup), tornoff_(false) { - layout_ = new QGridLayout(this); + QVBoxLayout * v = new QVBoxLayout(this); + v->setMargin(0); + v->setSpacing(0); + layout_ = new QGridLayout; layout_->setSpacing(0); - layout_->setMargin(3); + const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this); + layout_->setMargin(fw); + tearoffwidget_ = new TearOff(this); + connect(tearoffwidget_, SIGNAL(tearOff()), this, SLOT(tearOff())); + v->addWidget(tearoffwidget_); + v->addLayout(layout_); } @@ -141,15 +123,31 @@ } +void
Re: Empty Math Panel Popups
in summary: - allow panels to tear off using only qt 4.1 functionality - reported to work on windows, linux and mac seeking 2 ok's works for me with latest svn, qt4.3.0 and mac os x. andi
Re: Empty Math Panel Popups
On Tue, Jun 19, 2007 at 08:40:52PM +0200, Edwin Leuven wrote: > the attached patch has the advantage that it also allows tearoff panels > on the mac > > i would be very surprised if this one doesn't work for you You did it! Works like a charm. A big thank you! -- Enrico
Re: Empty Math Panel Popups
Enrico Forestieri wrote: You did it! Works like a charm. :) A big thank you! thanks for testing! ... will collect 2 ok's tomorrow. josé?
RE: Empty Math Panel Popups
Andreas Neustifter wrote: I yesterday finally had the time to compile the latest SVN version and give it a try, unfortunately I had a problem with the math toolbars: After firing LyX up and turning on the math panel all the pop-up windows (to select Greek letters for example or to select AMS symbols) are empty. It seems that all pop-ups (don't know the proper lyx name for it...) with latex symbols in that have the problem. Setup: Mac OS X, all patches Qt 4.3.0 (self compiled) LyX (rev 18814) i cannot reproduce this because i am not on a mac (things work fine on linux and windows), and can only guess: a problem with your installation? missing pixmaps? perhaps some other mac people on the list can have a look?
Re: Empty Math Panel Popups
Am 18.06.2007 um 11:39 schrieb Leuven, E.: Andreas Neustifter wrote: I yesterday finally had the time to compile the latest SVN version and give it a try, unfortunately I had a problem with the math toolbars: After firing LyX up and turning on the math panel all the pop-up windows (to select Greek letters for example or to select AMS symbols) are empty. It seems that all pop-ups (don't know the proper lyx name for it...) with latex symbols in that have the problem. Setup: Mac OS X, all patches Qt 4.3.0 (self compiled) LyX (rev 18814) i cannot reproduce this because i am not on a mac (things work fine on linux and windows), and can only guess: a problem with your installation? missing pixmaps? perhaps some other mac people on the list can have a look? Yes, they are empty! I am also on Mac. Never use them though, so I never noticed. This is a show stopper for mac. Stefan PGP.sig Description: Signierter Teil der Nachricht
RE: Empty Math Panel Popups
Stefan Schimanski wrote: Yes, they are empty! I am also on Mac. Never use them though, so I never noticed. This is a show stopper for mac. well, then the tear-off version needs to be disabled for mac until someone finds a solution. would the attached do this? Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18813) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -29,7 +29,7 @@ namespace lyx { namespace frontend { -#if QT_VERSION = 0x040200 +#if QT_VERSION = 0x040200 !Q_WS_MACX class MathButton : public QToolButton Index: src/frontends/qt4/IconPalette.h === --- src/frontends/qt4/IconPalette.h (revision 18812) +++ src/frontends/qt4/IconPalette.h (working copy) @@ -20,7 +20,7 @@ // FIXME: this can go when we move to Qt 4.3 #define QT_VERSION_CHECK(major, minor, patch) ((major16)|(minor8)|(patch)) -#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) !Q_WS_MACX #include QWidgetAction #endif @@ -30,7 +30,7 @@ /** * For holding an arbitrary set of icons. */ -#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) +#if (QT_VERSION = QT_VERSION_CHECK(4, 2, 0)) !Q_WS_MACX class IconPalette : public QWidgetAction { Q_OBJECT Index: src/frontends/qt4/QLToolbar.cpp === --- src/frontends/qt4/QLToolbar.cpp (revision 18813) +++ src/frontends/qt4/QLToolbar.cpp (working copy) @@ -212,7 +212,7 @@ connect(this, SIGNAL(iconSizeChanged(const QSize )), tb, SLOT(setIconSize(const QSize ))); -#if QT_VERSION = 0x040200 +#if QT_VERSION = 0x040200 !Q_WS_MACX IconPalette * panel = new IconPalette(owner_); connect(panel, SIGNAL(enabled(bool)), tb, SLOT(setEnabled(bool))); @@ -239,7 +239,7 @@ tb-setIcon(QPixmap(getIcon(it-func_).c_str())); } -#if QT_VERSION = 0x040200 +#if QT_VERSION = 0x040200 !Q_WS_MACX QMenu * m = new QMenu(tb); m-addAction(panel); m-setTearOffEnabled(true);
Re: Empty Math Panel Popups
It does not even compile: #if QT_VERSION = 0x040200 !Q_WS_MACX gives operator '!' has no right operand. Stefan Am 18.06.2007 um 12:06 schrieb Leuven, E.: disabletearoff.diff PGP.sig Description: Signierter Teil der Nachricht
Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 12:06:50PM +0200, Leuven, E. wrote: --- src/frontends/qt4/IconPalette.h (revision 18812) +++ src/frontends/qt4/IconPalette.h (working copy) @@ -20,7 +20,7 @@ // FIXME: this can go when we move to Qt 4.3 #define QT_VERSION_CHECK(major, minor, patch) ((major16)|(minor8)|(patch)) -#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) !Q_WS_MACX #include QWidgetAction #endif Edwin, moc doesn't perform like the preprocessor. It doesn't parse included files, such that QT_VERSION is undefined, and doesn't understand macros. In the check above, moc chooses randomly one branch or another. See what I wrote in the thread tear-off math panel. -- Enrico
Re: Empty Math Panel Popups
Enrico Forestieri wrote: On Mon, Jun 18, 2007 at 12:06:50PM +0200, Leuven, E. wrote: --- src/frontends/qt4/IconPalette.h (revision 18812) +++ src/frontends/qt4/IconPalette.h (working copy) @@ -20,7 +20,7 @@ // FIXME: this can go when we move to Qt 4.3 #define QT_VERSION_CHECK(major, minor, patch) ((major16)|(minor8)|(patch)) -#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) !Q_WS_MACX #include QWidgetAction #endif Edwin, moc doesn't perform like the preprocessor. It doesn't parse included files, such that QT_VERSION is undefined, and doesn't understand macros. In the check above, moc chooses randomly one branch or another. See what I wrote in the thread tear-off math panel. I think there are two solutions: 1) require Qt4.2 2) Modify the build system(s) to selectively compile IconPalette_42.{h,cpp} when Qt = 4.2 is detected and IconPalette.{h,cpp} otherwise. As 1) is not an option for some of us the only solution is 2). Abdel.
Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 02:09:34PM +0200, Abdelrazak Younes wrote: Enrico Forestieri wrote: On Mon, Jun 18, 2007 at 12:06:50PM +0200, Leuven, E. wrote: --- src/frontends/qt4/IconPalette.h(revision 18812) +++ src/frontends/qt4/IconPalette.h(working copy) @@ -20,7 +20,7 @@ // FIXME: this can go when we move to Qt 4.3 #define QT_VERSION_CHECK(major, minor, patch) ((major16)|(minor8)|(patch)) -#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) !Q_WS_MACX #include QWidgetAction #endif Edwin, moc doesn't perform like the preprocessor. It doesn't parse included files, such that QT_VERSION is undefined, and doesn't understand macros. In the check above, moc chooses randomly one branch or another. See what I wrote in the thread tear-off math panel. I think there are two solutions: 1) require Qt4.2 While tearing away math panels maybe a nice feature, it is not essential, so requiring Qt4.2 only for that is a lame excuse, IMHO. This is so also for the requirement of Qt4.1 minimum, as it is only dictated by the syntax highlighting thing. This is only mitigated by the fact that Qt4.0 was somewhat buggy. On the contrary, Qt4.1 is a quite good version. 2) Modify the build system(s) to selectively compile IconPalette_42.{h,cpp} when Qt = 4.2 is detected and IconPalette.{h,cpp} otherwise. As 1) is not an option for some of us the only solution is 2). Maybe. Let's see what our experts are able to do. Personally, I don't have any problem with whatever version is required. -- Enrico
Re: Empty Math Panel Popups
Enrico Forestieri wrote: On Mon, Jun 18, 2007 at 02:09:34PM +0200, Abdelrazak Younes wrote: I think there are two solutions: 1) require Qt4.2 While tearing away math panels maybe a nice feature, it is not essential, So are a lot of features of LyX :-). But I personally won't use that feature. so requiring Qt4.2 only for that is a lame excuse, IMHO. This is so also for the requirement of Qt4.1 minimum, as it is only dictated by the syntax highlighting thing. This is only mitigated by the fact that Qt4.0 was somewhat buggy. On the contrary, Qt4.1 is a quite good version. That's why I stated that 1) is not an option for some of us ;-) and I am perfectly OK with this requirement (IOW: I don't care ;-)) Abdel.
RE: Re: Empty Math Panel Popups
can people try the attached? it is another approach to tear off the panels: simply move the panel this time only using 4.1 stuff ... Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18813) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -13,6 +13,7 @@ #include IconPalette.h #include qt_helpers.h #include controllers/ControlMath.h // for find_xpm +#include debug.h #include QPixmap #include QGridLayout @@ -24,103 +25,43 @@ #include QPainter #include QStyle #include QStyleOptionFrame -#include QMouseEvent +#include QEvent namespace lyx { namespace frontend { -#if QT_VERSION = 0x040200 - - -class MathButton : public QToolButton -{ -public: - MathButton(QWidget * parent = 0) {} - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); -}; - - -void MathButton::mouseReleaseEvent(QMouseEvent *event) -{ - QToolButton::mouseReleaseEvent(event); - event-ignore(); -} - - -void MathButton::mousePressEvent(QMouseEvent *event) -{ - QToolButton::mousePressEvent(event); - event-ignore(); -} - - IconPalette::IconPalette(QWidget * parent) - : QWidgetAction(parent), size_(QSize(22, 22)) + : QWidget(parent, Qt::Tool) { + layout_ = new QGridLayout(this); + layout_-setSpacing(0); + layout_-setMargin(3); + detached_ = false; + active_ = false; } -void IconPalette::addButton(QAction * action) +bool IconPalette::event(QEvent * event) { - actions_.push_back(action); -} - - -QWidget * IconPalette::createWidget(QWidget * parent) -{ - QWidget * widget = new QWidget(parent); - QGridLayout * layout = new QGridLayout(widget); - layout-setSpacing(0); - - for (int i = 0; i actions_.size(); ++i) { - MathButton * tb = new MathButton(widget); - tb-setAutoRaise(true); - tb-setDefaultAction(actions_.at(i)); - tb-setIconSize(size_); - connect(this, SIGNAL(iconSizeChanged(const QSize )), - tb, SLOT(setIconSize(const QSize ))); - - int const row = i/qMin(6, i + 1) + 1; - int const col = qMax(1, i + 1 - (row - 1) * 6); - layout-addWidget(tb, row, col); + /* i didn't find a smarter way to find out + * whether a move was made by the user + * because we also move the widget ourselves + * to make it popup in the right position... + */ + switch (event-type()) { + case QEvent::WindowActivate: + active_ = true; + case QEvent::WindowDeactivate: + active_ = false; + case QEvent::Move: + if (active_) +detached_ = true; } - return widget; + return QWidget::event(event); } -void IconPalette::setIconSize(const QSize size) -{ - size_ = size; - // signal - iconSizeChanged(size); -} - - -void IconPalette::updateParent() -{ - bool enable = false; - for (int i = 0; i actions_.size(); ++i) - if (actions_.at(i)-isEnabled()) { - enable = true; - break; - } - // signal - enabled(enable); -} - -#else // QT_VERSION = 0x040200 - -IconPalette::IconPalette(QWidget * parent) - : QWidget(parent, Qt::Popup) -{ - layout_ = new QGridLayout(this); - layout_-setSpacing(0); - layout_-setMargin(3); -} - - void IconPalette::addButton(QAction * action) { actions_.push_back(action); @@ -144,22 +85,24 @@ void IconPalette::clicked(QAction * action) { triggered(action); - setVisible(false); + if (!detached_) + setVisible(false); } void IconPalette::showEvent(QShowEvent * event) { - int hoffset = - parentWidget()-pos().x(); - int voffset = - parentWidget()-pos().y(); + int const framewidth = (frameGeometry().width() - width()) / 2; int const parwidth = parentWidget()-geometry().width(); int const parheight = parentWidget()-geometry().height(); + int hoffset = - parentWidget()-pos().x() + framewidth; + int voffset = - parentWidget()-pos().y() + parheight - 2 * framewidth; // vertical toolbar? QToolBar * toolbar = qobject_castQToolBar *(parentWidget()-parentWidget()); if (toolbar toolbar-orientation() == Qt::Vertical) { hoffset += parwidth; - voffset -= parheight; + voffset -= parheight - framewidth; } QRect const screen = qApp-desktop()-availableGeometry(this); @@ -167,29 +110,33 @@ parentWidget()-geometry().bottomLeft()); // space to the right? - if (gpos.x() + hoffset + width() screen.width()) { - hoffset -= width(); + if (gpos.x() + hoffset + frameGeometry().width() screen.width()) { + hoffset -= frameGeometry().width(); if (toolbar toolbar-orientation() == Qt::Vertical) hoffset -= parwidth; else hoffset += parwidth; } // space at the bottom? - if (gpos.y() + voffset + height() screen.height()) { - voffset -= height(); + if (gpos.y() + voffset + frameGeometry().height() screen.height()) { + voffset -= frameGeometry().height(); if (toolbar toolbar-orientation() == Qt::Horizontal) - voffset -= parheight; + voffset -= parheight - framewidth; else voffset += parheight; } - move(gpos.x() + hoffset, gpos.y() + voffset); + QRect r = geometry(); + r.moveTo(gpos.x() + hoffset, gpos.y()
Re: Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 04:22:09PM +0200, Leuven, E. wrote: can people try the attached? it is another approach to tear off the panels: simply move the panel this time only using 4.1 stuff ... Works for me with both Qt 4.1.4 and 4.2.2. However, the panel disappears after making a choice, so I think that this behavior is not different with respect to the preious one. -- Enrico
RE: Re: Empty Math Panel Popups
Leuven, E. wrote: can people try the attached? it is another approach to tear off the panels: simply move the panel this time only using 4.1 stuff ... Tried it (qt 4.2.3 here). Doesn't seem to work well: the panel gets a decoration like normal windows when opened (so it's already detached), and moreover closes itself when clicking on a symbol. A/
RE: RE: Re: Empty Math Panel Popups
Tried it (qt 4.2.3 here). Doesn't seem to work well: the panel gets a decoration like normal windows when opened (so it's already detached) , and moreover closes itself when clicking on a symbol. no! no! no! ;-) the idea is the following: detaching makes the panel stay on top so that you can enter multple symbols in a row so on popup the panel is attached (after clicking it disappears) to detach it you can *move* the panel. for this you need the title bar. try it, you will see that now it stays on top. i hope i am clearer now
Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 01:14:44PM +0200, Stefan Schimanski wrote: It does not even compile: #if QT_VERSION = 0x040200 !Q_WS_MACX gives operator '!' has no right operand. Maybe !defined(Q_WS_MACX) is better. Andre'
Re: Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 04:22:09PM +0200, Leuven, E. wrote: + /* i didn't find a smarter way to find out + * whether a move was made by the user + * because we also move the widget ourselves + * to make it popup in the right position... + */ + switch (event-type()) { + case QEvent::WindowActivate: + active_ = true; + case QEvent::WindowDeactivate: + active_ = false; So active_ == false in both cases? (missing 'break'?) + case QEvent::Move: + if (active_) + detached_ = true; } Andre'
Re: RE: Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 06:20:07PM +0200, Leuven, E. wrote: Tried it (qt 4.2.3 here). Doesn't seem to work well: the panel gets a decoration like normal windows when opened (so it's already detached) , and moreover closes itself when clicking on a symbol. no! no! no! ;-) the idea is the following: detaching makes the panel stay on top so that you can enter multple symbols in a row so on popup the panel is attached (after clicking it disappears) to detach it you can *move* the panel. for this you need the title bar. try it, you will see that now it stays on top. i hope i am clearer now What about the attached patch, instead? I tested it with Qt 4.1.4 and 4.2.2. Something similar can be done with scons. -- Enrico Index: src/frontends/qt4/Makefile.am === --- src/frontends/qt4/Makefile.am (revision 18815) +++ src/frontends/qt4/Makefile.am (working copy) @@ -11,6 +11,11 @@ libqt4_la_DEPENDENCIES = $(MOCEDFILES) MOCEDFILES = $(MOCFILES:.cpp=_moc.cpp) +IconPalette_moc.cpp: $(srcdir)/IconPalette.h + sed -e s/QT4_VERSION/%%$(QT4_VERSION)%%/ \ + -e s|%%\(.\)\.\(.\)\.\(.\)%%|0x0\10\20\3| $ IconPalette_moc.h + $(MOC4) -o IconPalette_moc.cpp IconPalette_moc.h + %_moc.cpp: %.h $(MOC4) -o $@ $ Index: src/frontends/qt4/IconPalette.h === --- src/frontends/qt4/IconPalette.h (revision 18815) +++ src/frontends/qt4/IconPalette.h (working copy) @@ -17,10 +17,11 @@ #include QLayout #include Action.h -// FIXME: this can go when we move to Qt 4.3 -#define QT_VERSION_CHECK(major, minor, patch) ((major16)|(minor8)|(patch)) +#ifndef QT_VERSION +#define QT_VERSION QT4_VERSION +#endif -#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION = 0x040200 #include QWidgetAction #endif @@ -30,7 +31,7 @@ namespace frontend { /** * For holding an arbitrary set of icons. */ -#if QT_VERSION = QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION = 0x040200 class IconPalette : public QWidgetAction { Q_OBJECT @@ -77,7 +78,7 @@ private: QListQAction * actions_; }; -#endif // QT_VERSION = QT_VERSION_CHECK(4, 2, 0) +#endif // QT_VERSION = 0x040200 /** * Popup menu for a toolbutton.
Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 06:44:15PM +0200, Andre Poenitz wrote: On Mon, Jun 18, 2007 at 01:14:44PM +0200, Stefan Schimanski wrote: It does not even compile: #if QT_VERSION = 0x040200 !Q_WS_MACX gives operator '!' has no right operand. Maybe !defined(Q_WS_MACX) is better. Nope. Seems that moc doesn't parse included files, so Q_WS_MACX will always be undefined. -- Enrico
RE: Re: Empty Math Panel Popups
Andre Poenitz wrote: On Mon, Jun 18, 2007 at 04:22:09PM +0200, Leuven, E. wrote: +/* i didn't find a smarter way to find out + * whether a move was made by the user + * because we also move the widget ourselves + * to make it popup in the right position... + */ +switch (event-type()) { +case QEvent::WindowActivate: +active_ = true; +case QEvent::WindowDeactivate: +active_ = false; So active_ == false in both cases? (missing 'break'?) i changed it to the attached... Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18813) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -13,6 +13,7 @@ #include IconPalette.h #include qt_helpers.h #include controllers/ControlMath.h // for find_xpm +#include debug.h #include QPixmap #include QGridLayout @@ -24,100 +25,40 @@ #include QPainter #include QStyle #include QStyleOptionFrame -#include QMouseEvent +#include QEvent namespace lyx { namespace frontend { -#if QT_VERSION = 0x040200 - - -class MathButton : public QToolButton -{ -public: - MathButton(QWidget * parent = 0) {} - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); -}; - - -void MathButton::mouseReleaseEvent(QMouseEvent *event) -{ - QToolButton::mouseReleaseEvent(event); - event-ignore(); -} - - -void MathButton::mousePressEvent(QMouseEvent *event) -{ - QToolButton::mousePressEvent(event); - event-ignore(); -} - - IconPalette::IconPalette(QWidget * parent) - : QWidgetAction(parent), size_(QSize(22, 22)) + : QWidget(parent, Qt::Tool) { + layout_ = new QGridLayout(this); + layout_-setSpacing(0); + layout_-setMargin(3); + detached_ = false; } -void IconPalette::addButton(QAction * action) +void IconPalette::moveEvent(QMoveEvent * event) { - actions_.push_back(action); -} + // if active we know the user is moving + if (isActiveWindow()) + detached_ = true; - -QWidget * IconPalette::createWidget(QWidget * parent) -{ - QWidget * widget = new QWidget(parent); - QGridLayout * layout = new QGridLayout(widget); - layout-setSpacing(0); - - for (int i = 0; i actions_.size(); ++i) { - MathButton * tb = new MathButton(widget); - tb-setAutoRaise(true); - tb-setDefaultAction(actions_.at(i)); - tb-setIconSize(size_); - connect(this, SIGNAL(iconSizeChanged(const QSize )), - tb, SLOT(setIconSize(const QSize ))); - - int const row = i/qMin(6, i + 1) + 1; - int const col = qMax(1, i + 1 - (row - 1) * 6); - layout-addWidget(tb, row, col); - } - - return widget; + event-ignore(); } -void IconPalette::setIconSize(const QSize size) +bool IconPalette::event(QEvent * event) { - size_ = size; - // signal - iconSizeChanged(size); -} - - -void IconPalette::updateParent() -{ - bool enable = false; - for (int i = 0; i actions_.size(); ++i) - if (actions_.at(i)-isEnabled()) { - enable = true; - break; + if (event-type() == QEvent::WindowDeactivate) + if (!detached_) { + setVisible(false); + return true; } - // signal - enabled(enable); -} -#else // QT_VERSION = 0x040200 - -IconPalette::IconPalette(QWidget * parent) - : QWidget(parent, Qt::Popup) -{ - layout_ = new QGridLayout(this); - layout_-setSpacing(0); - layout_-setMargin(3); + return QWidget::event(event); } @@ -144,22 +85,24 @@ void IconPalette::clicked(QAction * action) { triggered(action); - setVisible(false); + if (!detached_) + setVisible(false); } void IconPalette::showEvent(QShowEvent * event) { - int hoffset = - parentWidget()-pos().x(); - int voffset = - parentWidget()-pos().y(); + int const framewidth = (frameGeometry().width() - width()) / 2; int const parwidth = parentWidget()-geometry().width(); int const parheight = parentWidget()-geometry().height(); + int hoffset = - parentWidget()-pos().x() + framewidth; + int voffset = - parentWidget()-pos().y() + parheight - 2 * framewidth; // vertical toolbar? QToolBar * toolbar = qobject_castQToolBar *(parentWidget()-parentWidget()); if (toolbar toolbar-orientation() == Qt::Vertical) { hoffset += parwidth; - voffset -= parheight; + voffset -= parheight - framewidth; } QRect const screen = qApp-desktop()-availableGeometry(this); @@ -167,29 +110,33 @@ parentWidget()-geometry().bottomLeft()); // space to the right? - if (gpos.x() + hoffset + width() screen.width()) { - hoffset -= width(); + if (gpos.x() + hoffset + frameGeometry().width() screen.width()) { + hoffset -= frameGeometry().width(); if (toolbar toolbar-orientation() == Qt::Vertical) hoffset -= parwidth; else hoffset += parwidth; } // space at the bottom? - if (gpos.y() + voffset + height() screen.height()) { - voffset -= height(); + if (gpos.y() + voffset + frameGeometry().height() screen.height()) { + voffset -= frameGeometry().height(); if (toolbar toolbar-orientation() ==
Re: Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 06:58:32PM +0200, Leuven, E. wrote: Andre Poenitz wrote: On Mon, Jun 18, 2007 at 04:22:09PM +0200, Leuven, E. wrote: +/* i didn't find a smarter way to find out + * whether a move was made by the user + * because we also move the widget ourselves + * to make it popup in the right position... + */ +switch (event-type()) { +case QEvent::WindowActivate: +active_ = true; +case QEvent::WindowDeactivate: +active_ = false; So active_ == false in both cases? (missing 'break'?) i changed it to the attached... I get a compile error. What about my proposed patch which leaves things as they are now but allows compilation with any Qt version? g++ -DHAVE_CONFIG_H -I. -I../../../../src/frontends/qt4 -I../../../src -DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL -DQT_NO_KEYWORDS -DQ_CYGWIN_WIN -I../../../../src -I../../../../src/frontends -I../../../../images -I/usr/local/qt4-cygwin/include -I/usr/local/qt4-cygwin/include/QtCore -I/usr/local/qt4-cygwin/include/QtGui -I../../../../boost -I../../../../src/frontends/controllers -Wno-uninitialized -O2 -MT IconPalette.lo -MD -MP -MF .deps/IconPalette.Tpo -c ../../../../src/frontends/qt4/IconPalette.cpp -o IconPalette.o ../../../../src/frontends/qt4/IconPalette.cpp: In member function `virtual void lyx::frontend::IconPalette::moveEvent(QMoveEvent*)': ../../../../src/frontends/qt4/IconPalette.cpp:49: error: invalid use of undefined type `struct QMoveEvent' /usr/local/qt4-cygwin/include/QtGui/qwidget.h:61: error: forward declaration of `struct QMoveEvent' make[7]: *** [IconPalette.lo] Error 1 -- Enrico
RE: RE: Re: Empty Math Panel Popups
Leuven, E. wrote: Tried it (qt 4.2.3 here). Doesn't seem to work well: the panel gets a decoration like normal windows when opened (so it's already detached) , and moreover closes itself when clicking on a symbol. no! no! no! ;-) the idea is the following: detaching makes the panel stay on top so that you can enter multple symbols in a row so on popup the panel is attached (after clicking it disappears) to detach it you can *move* the panel. for this you need the title bar. try it, you will see that now it stays on top. i hope i am clearer now You were perfectly clear before. It doesn't work(*). I hope I am clearer now ;-) A/ (*) moving the panel doesn't detach it any further, it still closes when clicking.
RE: Empty Math Panel Popups
Andreas Neustifter wrote: > I yesterday finally had the time to compile the latest SVN version and > give it a try, unfortunately I had a problem with the math toolbars: > > After firing LyX up and turning on the math panel all the pop-up windows > (to select Greek letters for example or to select AMS symbols) are > empty. It seems that all pop-ups (don't know the proper lyx name for > it...) with latex symbols in that have the problem. > > Setup: > Mac OS X, all patches > Qt 4.3.0 (self compiled) > LyX (rev 18814) i cannot reproduce this because i am not on a mac (things work fine on linux and windows), and can only guess: a problem with your installation? missing pixmaps? perhaps some other mac people on the list can have a look?
Re: Empty Math Panel Popups
Am 18.06.2007 um 11:39 schrieb Leuven, E.: Andreas Neustifter wrote: I yesterday finally had the time to compile the latest SVN version and give it a try, unfortunately I had a problem with the math toolbars: After firing LyX up and turning on the math panel all the pop-up windows (to select Greek letters for example or to select AMS symbols) are empty. It seems that all pop-ups (don't know the proper lyx name for it...) with latex symbols in that have the problem. Setup: Mac OS X, all patches Qt 4.3.0 (self compiled) LyX (rev 18814) i cannot reproduce this because i am not on a mac (things work fine on linux and windows), and can only guess: a problem with your installation? missing pixmaps? perhaps some other mac people on the list can have a look? Yes, they are empty! I am also on Mac. Never use them though, so I never noticed. This is a show stopper for mac. Stefan PGP.sig Description: Signierter Teil der Nachricht
RE: Empty Math Panel Popups
Stefan Schimanski wrote: > Yes, they are empty! I am also on Mac. Never use them though, so I never > noticed. This is a show stopper for mac. well, then the tear-off version needs to be disabled for mac until someone finds a solution. would the attached do this? Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18813) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -29,7 +29,7 @@ namespace lyx { namespace frontend { -#if QT_VERSION >= 0x040200 +#if QT_VERSION >= 0x040200 && !Q_WS_MACX class MathButton : public QToolButton Index: src/frontends/qt4/IconPalette.h === --- src/frontends/qt4/IconPalette.h (revision 18812) +++ src/frontends/qt4/IconPalette.h (working copy) @@ -20,7 +20,7 @@ // FIXME: this can go when we move to Qt 4.3 #define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) -#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) && !Q_WS_MACX #include #endif @@ -30,7 +30,7 @@ /** * For holding an arbitrary set of icons. */ -#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) +#if (QT_VERSION >= QT_VERSION_CHECK(4, 2, 0)) && !Q_WS_MACX class IconPalette : public QWidgetAction { Q_OBJECT Index: src/frontends/qt4/QLToolbar.cpp === --- src/frontends/qt4/QLToolbar.cpp (revision 18813) +++ src/frontends/qt4/QLToolbar.cpp (working copy) @@ -212,7 +212,7 @@ connect(this, SIGNAL(iconSizeChanged(const QSize &)), tb, SLOT(setIconSize(const QSize &))); -#if QT_VERSION >= 0x040200 +#if QT_VERSION >= 0x040200 && !Q_WS_MACX IconPalette * panel = new IconPalette(_); connect(panel, SIGNAL(enabled(bool)), tb, SLOT(setEnabled(bool))); @@ -239,7 +239,7 @@ tb->setIcon(QPixmap(getIcon(it->func_).c_str())); } -#if QT_VERSION >= 0x040200 +#if QT_VERSION >= 0x040200 && !Q_WS_MACX QMenu * m = new QMenu(tb); m->addAction(panel); m->setTearOffEnabled(true);
Re: Empty Math Panel Popups
It does not even compile: #if QT_VERSION >= 0x040200 && !Q_WS_MACX gives "operator '!' has no right operand". Stefan Am 18.06.2007 um 12:06 schrieb Leuven, E.: PGP.sig Description: Signierter Teil der Nachricht
Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 12:06:50PM +0200, Leuven, E. wrote: > --- src/frontends/qt4/IconPalette.h (revision 18812) > +++ src/frontends/qt4/IconPalette.h (working copy) > @@ -20,7 +20,7 @@ > // FIXME: this can go when we move to Qt 4.3 > #define QT_VERSION_CHECK(major, minor, patch) > ((major<<16)|(minor<<8)|(patch)) > > -#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) > +#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) && !Q_WS_MACX > #include > #endif Edwin, moc doesn't perform like the preprocessor. It doesn't parse included files, such that QT_VERSION is undefined, and doesn't understand macros. In the check above, moc chooses randomly one branch or another. See what I wrote in the thread "tear-off math panel". -- Enrico
Re: Empty Math Panel Popups
Enrico Forestieri wrote: On Mon, Jun 18, 2007 at 12:06:50PM +0200, Leuven, E. wrote: --- src/frontends/qt4/IconPalette.h (revision 18812) +++ src/frontends/qt4/IconPalette.h (working copy) @@ -20,7 +20,7 @@ // FIXME: this can go when we move to Qt 4.3 #define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) -#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) && !Q_WS_MACX #include #endif Edwin, moc doesn't perform like the preprocessor. It doesn't parse included files, such that QT_VERSION is undefined, and doesn't understand macros. In the check above, moc chooses randomly one branch or another. See what I wrote in the thread "tear-off math panel". I think there are two solutions: 1) require Qt4.2 2) Modify the build system(s) to selectively compile IconPalette_42.{h,cpp} when Qt >= 4.2 is detected and IconPalette.{h,cpp} otherwise. As 1) is not an option for some of us the only solution is 2). Abdel.
Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 02:09:34PM +0200, Abdelrazak Younes wrote: > Enrico Forestieri wrote: > > On Mon, Jun 18, 2007 at 12:06:50PM +0200, Leuven, E. wrote: > > > >> --- src/frontends/qt4/IconPalette.h(revision 18812) > >> +++ src/frontends/qt4/IconPalette.h(working copy) > >> @@ -20,7 +20,7 @@ > >> // FIXME: this can go when we move to Qt 4.3 > >> #define QT_VERSION_CHECK(major, minor, patch) > >> ((major<<16)|(minor<<8)|(patch)) > >> > >> -#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) > >> +#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) && !Q_WS_MACX > >> #include > >> #endif > > > > Edwin, moc doesn't perform like the preprocessor. It doesn't parse > > included files, such that QT_VERSION is undefined, and doesn't > > understand macros. In the check above, moc chooses randomly one > > branch or another. See what I wrote in the thread "tear-off math panel". > > I think there are two solutions: > 1) require Qt4.2 While tearing away math panels maybe a nice feature, it is not essential, so requiring Qt4.2 only for that is a lame excuse, IMHO. This is so also for the requirement of Qt4.1 minimum, as it is only dictated by the syntax highlighting thing. This is only mitigated by the fact that Qt4.0 was somewhat buggy. On the contrary, Qt4.1 is a quite good version. > 2) Modify the build system(s) to selectively compile > IconPalette_42.{h,cpp} when Qt >= 4.2 is detected and > IconPalette.{h,cpp} otherwise. > > As 1) is not an option for some of us the only solution is 2). Maybe. Let's see what our experts are able to do. Personally, I don't have any problem with whatever version is required. -- Enrico
Re: Empty Math Panel Popups
Enrico Forestieri wrote: On Mon, Jun 18, 2007 at 02:09:34PM +0200, Abdelrazak Younes wrote: I think there are two solutions: 1) require Qt4.2 While tearing away math panels maybe a nice feature, it is not essential, So are a lot of features of LyX :-). But I personally won't use that feature. so requiring Qt4.2 only for that is a lame excuse, IMHO. This is so also for the requirement of Qt4.1 minimum, as it is only dictated by the syntax highlighting thing. This is only mitigated by the fact that Qt4.0 was somewhat buggy. On the contrary, Qt4.1 is a quite good version. That's why I stated that 1) is not an option for some of us ;-) and I am perfectly OK with this requirement (IOW: I don't care ;-)) Abdel.
RE: Re: Empty Math Panel Popups
can people try the attached? it is another approach to tear off the panels: simply move the panel this time only using 4.1 stuff ... Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18813) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -13,6 +13,7 @@ #include "IconPalette.h" #include "qt_helpers.h" #include "controllers/ControlMath.h" // for find_xpm +#include "debug.h" #include #include @@ -24,103 +25,43 @@ #include #include #include -#include +#include namespace lyx { namespace frontend { -#if QT_VERSION >= 0x040200 - - -class MathButton : public QToolButton -{ -public: - MathButton(QWidget * parent = 0) {} - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); -}; - - -void MathButton::mouseReleaseEvent(QMouseEvent *event) -{ - QToolButton::mouseReleaseEvent(event); - event->ignore(); -} - - -void MathButton::mousePressEvent(QMouseEvent *event) -{ - QToolButton::mousePressEvent(event); - event->ignore(); -} - - IconPalette::IconPalette(QWidget * parent) - : QWidgetAction(parent), size_(QSize(22, 22)) + : QWidget(parent, Qt::Tool) { + layout_ = new QGridLayout(this); + layout_->setSpacing(0); + layout_->setMargin(3); + detached_ = false; + active_ = false; } -void IconPalette::addButton(QAction * action) +bool IconPalette::event(QEvent * event) { - actions_.push_back(action); -} - - -QWidget * IconPalette::createWidget(QWidget * parent) -{ - QWidget * widget = new QWidget(parent); - QGridLayout * layout = new QGridLayout(widget); - layout->setSpacing(0); - - for (int i = 0; i < actions_.size(); ++i) { - MathButton * tb = new MathButton(widget); - tb->setAutoRaise(true); - tb->setDefaultAction(actions_.at(i)); - tb->setIconSize(size_); - connect(this, SIGNAL(iconSizeChanged(const QSize &)), - tb, SLOT(setIconSize(const QSize &))); - - int const row = i/qMin(6, i + 1) + 1; - int const col = qMax(1, i + 1 - (row - 1) * 6); - layout->addWidget(tb, row, col); + /* i didn't find a smarter way to find out + * whether a move was made by the user + * because we also move the widget ourselves + * to make it popup in the right position... + */ + switch (event->type()) { + case QEvent::WindowActivate: + active_ = true; + case QEvent::WindowDeactivate: + active_ = false; + case QEvent::Move: + if (active_) +detached_ = true; } - return widget; + return QWidget::event(event); } -void IconPalette::setIconSize(const QSize & size) -{ - size_ = size; - // signal - iconSizeChanged(size); -} - - -void IconPalette::updateParent() -{ - bool enable = false; - for (int i = 0; i < actions_.size(); ++i) - if (actions_.at(i)->isEnabled()) { - enable = true; - break; - } - // signal - enabled(enable); -} - -#else // QT_VERSION >= 0x040200 - -IconPalette::IconPalette(QWidget * parent) - : QWidget(parent, Qt::Popup) -{ - layout_ = new QGridLayout(this); - layout_->setSpacing(0); - layout_->setMargin(3); -} - - void IconPalette::addButton(QAction * action) { actions_.push_back(action); @@ -144,22 +85,24 @@ void IconPalette::clicked(QAction * action) { triggered(action); - setVisible(false); + if (!detached_) + setVisible(false); } void IconPalette::showEvent(QShowEvent * event) { - int hoffset = - parentWidget()->pos().x(); - int voffset = - parentWidget()->pos().y(); + int const framewidth = (frameGeometry().width() - width()) / 2; int const parwidth = parentWidget()->geometry().width(); int const parheight = parentWidget()->geometry().height(); + int hoffset = - parentWidget()->pos().x() + framewidth; + int voffset = - parentWidget()->pos().y() + parheight - 2 * framewidth; // vertical toolbar? QToolBar * toolbar = qobject_cast(parentWidget()->parentWidget()); if (toolbar && toolbar->orientation() == Qt::Vertical) { hoffset += parwidth; - voffset -= parheight; + voffset -= parheight - framewidth; } QRect const screen = qApp->desktop()->availableGeometry(this); @@ -167,29 +110,33 @@ parentWidget()->geometry().bottomLeft()); // space to the right? - if (gpos.x() + hoffset + width() > screen.width()) { - hoffset -= width(); + if (gpos.x() + hoffset + frameGeometry().width() > screen.width()) { + hoffset -= frameGeometry().width(); if (toolbar && toolbar->orientation() == Qt::Vertical) hoffset -= parwidth; else hoffset += parwidth; } // space at the bottom? - if (gpos.y() + voffset + height() > screen.height()) { - voffset -= height(); + if (gpos.y() + voffset + frameGeometry().height() > screen.height()) { + voffset -= frameGeometry().height(); if (toolbar && toolbar->orientation() == Qt::Horizontal) - voffset -= parheight; + voffset -= parheight - framewidth; else voffset += parheight; } - move(gpos.x() + hoffset, gpos.y() + voffset); + QRect r = geometry(); + r.moveTo(gpos.x() + hoffset, gpos.y() + voffset); +
Re: Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 04:22:09PM +0200, Leuven, E. wrote: > can people try the attached? > > it is another approach to tear off the panels: simply move the panel > > this time only using 4.1 stuff ... Works for me with both Qt 4.1.4 and 4.2.2. However, the panel disappears after making a choice, so I think that this behavior is not different with respect to the preious one. -- Enrico
RE: Re: Empty Math Panel Popups
Leuven, E. wrote: > can people try the attached? > > it is another approach to tear off the panels: simply move the panel > > this time only using 4.1 stuff ... Tried it (qt 4.2.3 here). Doesn't seem to work well: the panel gets a decoration like normal windows when opened (so it's already detached), and moreover closes itself when clicking on a symbol. A/
RE: RE: Re: Empty Math Panel Popups
> Tried it (qt 4.2.3 here). Doesn't seem to work well: > the panel gets a decoration like normal windows when opened (so it's already > detached) >, and moreover closes itself when clicking on a symbol. no! no! no! ;-) the idea is the following: "detaching" makes the panel stay on top so that you can enter multple symbols in a row so on popup the panel is "attached" (after clicking it disappears) to "detach" it you can *move* the panel. for this you need the title bar. try it, you will see that now it stays on top. i hope i am clearer now
Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 01:14:44PM +0200, Stefan Schimanski wrote: > It does not even compile: > > #if QT_VERSION >= 0x040200 && !Q_WS_MACX > > gives "operator '!' has no right operand". Maybe !defined(Q_WS_MACX) is better. Andre'
Re: Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 04:22:09PM +0200, Leuven, E. wrote: > + /* i didn't find a smarter way to find out > + * whether a move was made by the user > + * because we also move the widget ourselves > + * to make it popup in the right position... > + */ > + switch (event->type()) { > + case QEvent::WindowActivate: > + active_ = true; > + case QEvent::WindowDeactivate: > + active_ = false; So active_ == false in both cases? (missing 'break'?) > + case QEvent::Move: > + if (active_) > + detached_ = true; > } Andre'
Re: RE: Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 06:20:07PM +0200, Leuven, E. wrote: > > Tried it (qt 4.2.3 here). Doesn't seem to work well: > > the panel gets a decoration like normal windows when opened (so it's > > already detached) > >, and moreover closes itself when clicking on a symbol. > > no! no! no! ;-) > > the idea is the following: > > "detaching" makes the panel stay on top so that you can enter multple symbols > in a row > > so on popup the panel is "attached" (after clicking it disappears) > > to "detach" it you can *move* the panel. for this you need the title bar. try > it, you will see that now it stays on top. > > i hope i am clearer now What about the attached patch, instead? I tested it with Qt 4.1.4 and 4.2.2. Something similar can be done with scons. -- Enrico Index: src/frontends/qt4/Makefile.am === --- src/frontends/qt4/Makefile.am (revision 18815) +++ src/frontends/qt4/Makefile.am (working copy) @@ -11,6 +11,11 @@ libqt4_la_DEPENDENCIES = $(MOCEDFILES) MOCEDFILES = $(MOCFILES:.cpp=_moc.cpp) +IconPalette_moc.cpp: $(srcdir)/IconPalette.h + sed -e "s/QT4_VERSION/%%$(QT4_VERSION)%%/" \ + -e "s|%%\(.\)\.\(.\)\.\(.\)%%|0x0\10\20\3|" $< > IconPalette_moc.h + $(MOC4) -o IconPalette_moc.cpp IconPalette_moc.h + %_moc.cpp: %.h $(MOC4) -o $@ $< Index: src/frontends/qt4/IconPalette.h === --- src/frontends/qt4/IconPalette.h (revision 18815) +++ src/frontends/qt4/IconPalette.h (working copy) @@ -17,10 +17,11 @@ #include #include "Action.h" -// FIXME: this can go when we move to Qt 4.3 -#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) +#ifndef QT_VERSION +#define QT_VERSION QT4_VERSION +#endif -#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION >= 0x040200 #include #endif @@ -30,7 +31,7 @@ namespace frontend { /** * For holding an arbitrary set of icons. */ -#if QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) +#if QT_VERSION >= 0x040200 class IconPalette : public QWidgetAction { Q_OBJECT @@ -77,7 +78,7 @@ private: QList actions_; }; -#endif // QT_VERSION >= QT_VERSION_CHECK(4, 2, 0) +#endif // QT_VERSION >= 0x040200 /** * Popup menu for a toolbutton.
Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 06:44:15PM +0200, Andre Poenitz wrote: > On Mon, Jun 18, 2007 at 01:14:44PM +0200, Stefan Schimanski wrote: > > It does not even compile: > > > > #if QT_VERSION >= 0x040200 && !Q_WS_MACX > > > > gives "operator '!' has no right operand". > > Maybe !defined(Q_WS_MACX) is better. Nope. Seems that moc doesn't parse included files, so Q_WS_MACX will always be undefined. -- Enrico
RE: Re: Empty Math Panel Popups
Andre Poenitz wrote: > On Mon, Jun 18, 2007 at 04:22:09PM +0200, Leuven, E. wrote: >> +/* i didn't find a smarter way to find out >> + * whether a move was made by the user >> + * because we also move the widget ourselves >> + * to make it popup in the right position... >> + */ >> +switch (event->type()) { >> +case QEvent::WindowActivate: >> +active_ = true; >> +case QEvent::WindowDeactivate: >> +active_ = false; > > So active_ == false in both cases? (missing 'break'?) i changed it to the attached... Index: src/frontends/qt4/IconPalette.cpp === --- src/frontends/qt4/IconPalette.cpp (revision 18813) +++ src/frontends/qt4/IconPalette.cpp (working copy) @@ -13,6 +13,7 @@ #include "IconPalette.h" #include "qt_helpers.h" #include "controllers/ControlMath.h" // for find_xpm +#include "debug.h" #include #include @@ -24,100 +25,40 @@ #include #include #include -#include +#include namespace lyx { namespace frontend { -#if QT_VERSION >= 0x040200 - - -class MathButton : public QToolButton -{ -public: - MathButton(QWidget * parent = 0) {} - void mouseReleaseEvent(QMouseEvent *event); - void mousePressEvent(QMouseEvent *event); -}; - - -void MathButton::mouseReleaseEvent(QMouseEvent *event) -{ - QToolButton::mouseReleaseEvent(event); - event->ignore(); -} - - -void MathButton::mousePressEvent(QMouseEvent *event) -{ - QToolButton::mousePressEvent(event); - event->ignore(); -} - - IconPalette::IconPalette(QWidget * parent) - : QWidgetAction(parent), size_(QSize(22, 22)) + : QWidget(parent, Qt::Tool) { + layout_ = new QGridLayout(this); + layout_->setSpacing(0); + layout_->setMargin(3); + detached_ = false; } -void IconPalette::addButton(QAction * action) +void IconPalette::moveEvent(QMoveEvent * event) { - actions_.push_back(action); -} + // if active we know the user is moving + if (isActiveWindow()) + detached_ = true; - -QWidget * IconPalette::createWidget(QWidget * parent) -{ - QWidget * widget = new QWidget(parent); - QGridLayout * layout = new QGridLayout(widget); - layout->setSpacing(0); - - for (int i = 0; i < actions_.size(); ++i) { - MathButton * tb = new MathButton(widget); - tb->setAutoRaise(true); - tb->setDefaultAction(actions_.at(i)); - tb->setIconSize(size_); - connect(this, SIGNAL(iconSizeChanged(const QSize &)), - tb, SLOT(setIconSize(const QSize &))); - - int const row = i/qMin(6, i + 1) + 1; - int const col = qMax(1, i + 1 - (row - 1) * 6); - layout->addWidget(tb, row, col); - } - - return widget; + event->ignore(); } -void IconPalette::setIconSize(const QSize & size) +bool IconPalette::event(QEvent * event) { - size_ = size; - // signal - iconSizeChanged(size); -} - - -void IconPalette::updateParent() -{ - bool enable = false; - for (int i = 0; i < actions_.size(); ++i) - if (actions_.at(i)->isEnabled()) { - enable = true; - break; + if (event->type() == QEvent::WindowDeactivate) + if (!detached_) { + setVisible(false); + return true; } - // signal - enabled(enable); -} -#else // QT_VERSION >= 0x040200 - -IconPalette::IconPalette(QWidget * parent) - : QWidget(parent, Qt::Popup) -{ - layout_ = new QGridLayout(this); - layout_->setSpacing(0); - layout_->setMargin(3); + return QWidget::event(event); } @@ -144,22 +85,24 @@ void IconPalette::clicked(QAction * action) { triggered(action); - setVisible(false); + if (!detached_) + setVisible(false); } void IconPalette::showEvent(QShowEvent * event) { - int hoffset = - parentWidget()->pos().x(); - int voffset = - parentWidget()->pos().y(); + int const framewidth = (frameGeometry().width() - width()) / 2; int const parwidth = parentWidget()->geometry().width(); int const parheight = parentWidget()->geometry().height(); + int hoffset = - parentWidget()->pos().x() + framewidth; + int voffset = - parentWidget()->pos().y() + parheight - 2 * framewidth; // vertical toolbar? QToolBar * toolbar = qobject_cast(parentWidget()->parentWidget()); if (toolbar && toolbar->orientation() == Qt::Vertical) { hoffset += parwidth; - voffset -= parheight; + voffset -= parheight - framewidth; } QRect const screen = qApp->desktop()->availableGeometry(this); @@ -167,29 +110,33 @@ parentWidget()->geometry().bottomLeft()); // space to the right? - if (gpos.x() + hoffset + width() > screen.width()) { - hoffset -= width(); + if (gpos.x() + hoffset + frameGeometry().width() > screen.width()) { + hoffset -= frameGeometry().width(); if (toolbar && toolbar->orientation() == Qt::Vertical) hoffset -= parwidth; else hoffset += parwidth; } // space at the bottom? - if (gpos.y() + voffset + height() > screen.height()) { - voffset -= height(); + if (gpos.y() + voffset + frameGeometry().height() > screen.height()) { + voffset -= frameGeometry().height(); if (toolbar && toolbar->orientation() ==
Re: Re: Empty Math Panel Popups
On Mon, Jun 18, 2007 at 06:58:32PM +0200, Leuven, E. wrote: > Andre Poenitz wrote: > > On Mon, Jun 18, 2007 at 04:22:09PM +0200, Leuven, E. wrote: > >> +/* i didn't find a smarter way to find out > >> + * whether a move was made by the user > >> + * because we also move the widget ourselves > >> + * to make it popup in the right position... > >> + */ > >> +switch (event->type()) { > >> +case QEvent::WindowActivate: > >> +active_ = true; > >> +case QEvent::WindowDeactivate: > >> +active_ = false; > > > > So active_ == false in both cases? (missing 'break'?) > > i changed it to the attached... I get a compile error. What about my proposed patch which leaves things as they are now but allows compilation with any Qt version? g++ -DHAVE_CONFIG_H -I. -I../../../../src/frontends/qt4 -I../../../src -DQT_CLEAN_NAMESPACE -DQT_GENUINE_STR -DQT_NO_STL -DQT_NO_KEYWORDS -DQ_CYGWIN_WIN -I../../../../src -I../../../../src/frontends -I../../../../images -I/usr/local/qt4-cygwin/include -I/usr/local/qt4-cygwin/include/QtCore -I/usr/local/qt4-cygwin/include/QtGui -I../../../../boost -I../../../../src/frontends/controllers -Wno-uninitialized -O2 -MT IconPalette.lo -MD -MP -MF .deps/IconPalette.Tpo -c ../../../../src/frontends/qt4/IconPalette.cpp -o IconPalette.o ../../../../src/frontends/qt4/IconPalette.cpp: In member function `virtual void lyx::frontend::IconPalette::moveEvent(QMoveEvent*)': ../../../../src/frontends/qt4/IconPalette.cpp:49: error: invalid use of undefined type `struct QMoveEvent' /usr/local/qt4-cygwin/include/QtGui/qwidget.h:61: error: forward declaration of `struct QMoveEvent' make[7]: *** [IconPalette.lo] Error 1 -- Enrico
RE: RE: Re: Empty Math Panel Popups
Leuven, E. wrote: >> Tried it (qt 4.2.3 here). Doesn't seem to work well: >> the panel gets a decoration like normal windows when opened (so it's >> already detached) >>, and moreover closes itself when clicking on a symbol. > > no! no! no! ;-) > > the idea is the following: > > "detaching" makes the panel stay on top so that you can enter multple > symbols in a row > > so on popup the panel is "attached" (after clicking it disappears) > > to "detach" it you can *move* the panel. for this you need the title bar. > try it, you will see that now it stays on top. > > i hope i am clearer now You were perfectly clear before. It doesn't work(*). I hope I am clearer now ;-) A/ (*) moving the panel doesn't detach it any further, it still closes when clicking.