2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-04-26 03:53:02 +00:00
|
|
|
* \file IconPalette.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2007-04-19 22:01:28 +00:00
|
|
|
* \author Edwin Leuven
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-04-26 03:53:02 +00:00
|
|
|
#include "IconPalette.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
2006-08-17 08:49:05 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QPixmap>
|
2006-05-08 11:44:37 +00:00
|
|
|
#include <QGridLayout>
|
2007-04-19 20:29:27 +00:00
|
|
|
#include <QToolButton>
|
2006-08-17 08:49:05 +00:00
|
|
|
#include <QToolTip>
|
2007-04-19 20:29:27 +00:00
|
|
|
#include <QToolBar>
|
|
|
|
#include <QApplication>
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#if QT_VERSION < 0x060000
|
2007-04-19 20:29:27 +00:00
|
|
|
#include <QDesktopWidget>
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#endif
|
2007-04-19 20:29:27 +00:00
|
|
|
#include <QPainter>
|
|
|
|
#include <QStyle>
|
|
|
|
#include <QStyleOptionFrame>
|
2007-06-17 17:55:36 +00:00
|
|
|
#include <QMouseEvent>
|
2007-06-21 09:51:50 +00:00
|
|
|
#include <QVBoxLayout>
|
2021-03-16 09:39:05 +01:00
|
|
|
#if QT_VERSION >= 0x060000
|
2021-03-15 18:35:58 +01:00
|
|
|
#include <QWindow>
|
2021-03-16 09:39:05 +01:00
|
|
|
#endif
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
2006-11-19 17:12:33 +00:00
|
|
|
namespace frontend {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2017-07-03 13:53:14 -04:00
|
|
|
TearOff::TearOff(QWidget * parent)
|
2007-06-21 09:51:50 +00:00
|
|
|
: QWidget(parent)
|
2007-06-17 17:55:36 +00:00
|
|
|
{
|
2007-06-21 09:51:50 +00:00
|
|
|
highlighted_ = false;
|
|
|
|
// + 2 because the default is a bit tight, see also:
|
|
|
|
// http://trolltech.com/developer/task-tracker/index_html?id=167954&method=entry
|
|
|
|
setMinimumHeight(style()->pixelMetric(QStyle::PM_MenuTearoffHeight) + 2);
|
|
|
|
setToolTip(qt_("Click to detach"));
|
|
|
|
// trigger tooltip (children of popups do not receive mousemove events)
|
|
|
|
setMouseTracking(true);
|
2007-06-17 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-10 20:14:54 +00:00
|
|
|
void TearOff::mouseReleaseEvent(QMouseEvent * /*event*/)
|
2007-06-17 17:55:36 +00:00
|
|
|
{
|
2007-06-21 09:51:50 +00:00
|
|
|
// signal
|
|
|
|
tearOff();
|
2007-06-17 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-21 09:51:50 +00:00
|
|
|
void TearOff::enterEvent(QEvent * event)
|
2007-06-17 17:55:36 +00:00
|
|
|
{
|
2007-06-21 09:51:50 +00:00
|
|
|
highlighted_ = true;
|
|
|
|
update();
|
|
|
|
event->ignore();
|
2007-06-17 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-21 09:51:50 +00:00
|
|
|
void TearOff::leaveEvent(QEvent * event)
|
2007-06-17 17:55:36 +00:00
|
|
|
{
|
2007-06-21 09:51:50 +00:00
|
|
|
highlighted_ = false;
|
|
|
|
update();
|
|
|
|
event->ignore();
|
2007-06-17 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-10 20:14:54 +00:00
|
|
|
void TearOff::paintEvent(QPaintEvent * /*event*/)
|
2007-06-17 17:55:36 +00:00
|
|
|
{
|
2007-06-21 09:51:50 +00:00
|
|
|
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;
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#if QT_VERSION < 0x060000
|
2007-06-21 09:51:50 +00:00
|
|
|
menuOpt.tabWidth = 0;
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#endif
|
2007-06-21 09:51:50 +00:00
|
|
|
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);
|
2007-06-17 17:55:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-19 22:01:28 +00:00
|
|
|
IconPalette::IconPalette(QWidget * parent)
|
2007-06-21 09:51:50 +00:00
|
|
|
: QWidget(parent, Qt::Popup), tornoff_(false)
|
2007-04-19 20:29:27 +00:00
|
|
|
{
|
2007-06-21 09:51:50 +00:00
|
|
|
QVBoxLayout * v = new QVBoxLayout(this);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#if QT_VERSION < 0x060000
|
2007-06-21 09:51:50 +00:00
|
|
|
v->setMargin(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#else
|
|
|
|
v->setContentsMargins(0, 0, 0, 0);
|
|
|
|
#endif
|
2007-06-21 09:51:50 +00:00
|
|
|
v->setSpacing(0);
|
|
|
|
layout_ = new QGridLayout;
|
2007-06-17 18:24:27 +00:00
|
|
|
layout_->setSpacing(0);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#if QT_VERSION < 0x060000
|
2021-03-21 12:30:01 +01:00
|
|
|
const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this);
|
2007-06-21 09:51:50 +00:00
|
|
|
layout_->setMargin(fw);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#else
|
|
|
|
layout_->setContentsMargins(0, 0, 0, 0);
|
|
|
|
#endif
|
2007-06-21 09:51:50 +00:00
|
|
|
tearoffwidget_ = new TearOff(this);
|
|
|
|
connect(tearoffwidget_, SIGNAL(tearOff()), this, SLOT(tearOff()));
|
|
|
|
v->addWidget(tearoffwidget_);
|
|
|
|
v->addLayout(layout_);
|
2007-04-19 20:29:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-19 22:01:28 +00:00
|
|
|
void IconPalette::addButton(QAction * action)
|
2007-04-19 20:29:27 +00:00
|
|
|
{
|
|
|
|
actions_.push_back(action);
|
|
|
|
QToolButton * tb = new QToolButton;
|
|
|
|
tb->setAutoRaise(true);
|
|
|
|
tb->setDefaultAction(action);
|
2007-06-21 09:51:50 +00:00
|
|
|
// trigger tooltip (children of popups do not receive mousemove events)
|
|
|
|
tb->setMouseTracking(true);
|
|
|
|
|
2007-04-19 20:29:27 +00:00
|
|
|
connect(tb, SIGNAL(triggered(QAction *)),
|
|
|
|
this, SLOT(clicked(QAction *)));
|
|
|
|
QToolBar * toolbar = qobject_cast<QToolBar *>(parentWidget()->parentWidget());
|
|
|
|
connect(toolbar, SIGNAL(iconSizeChanged(const QSize &)),
|
|
|
|
tb, SLOT(setIconSize(const QSize &)));
|
2010-09-24 12:59:43 +00:00
|
|
|
tb->setIconSize(toolbar->iconSize());
|
2007-04-19 20:29:27 +00:00
|
|
|
|
|
|
|
int const i = actions_.size();
|
|
|
|
int const ncols = qMin(6, i);
|
|
|
|
int const row = (i - 1)/ncols + 1;
|
|
|
|
int const col = qMax(1, i - (row - 1) * 6);
|
|
|
|
layout_->addWidget(tb, row, col);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-21 09:51:50 +00:00
|
|
|
void IconPalette::tearOff()
|
|
|
|
{
|
|
|
|
blockSignals(true);
|
|
|
|
hide();
|
|
|
|
setWindowFlags(Qt::Tool);
|
|
|
|
tornoff_ = true;
|
|
|
|
tearoffwidget_->setVisible(!tornoff_);
|
|
|
|
show();
|
|
|
|
blockSignals(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-19 22:01:28 +00:00
|
|
|
void IconPalette::clicked(QAction * action)
|
2007-04-19 20:29:27 +00:00
|
|
|
{
|
|
|
|
triggered(action);
|
2007-06-21 09:51:50 +00:00
|
|
|
if (!tornoff_)
|
|
|
|
setVisible(false);
|
2007-04-19 20:29:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-10 20:14:54 +00:00
|
|
|
void IconPalette::showEvent(QShowEvent * /*event*/)
|
2007-04-19 20:29:27 +00:00
|
|
|
{
|
2007-06-21 09:51:50 +00:00
|
|
|
resize(sizeHint());
|
|
|
|
setMaximumSize(sizeHint());
|
|
|
|
|
2007-04-19 20:29:27 +00:00
|
|
|
int hoffset = - parentWidget()->pos().x();
|
|
|
|
int voffset = - parentWidget()->pos().y();
|
|
|
|
int const parwidth = parentWidget()->geometry().width();
|
|
|
|
int const parheight = parentWidget()->geometry().height();
|
|
|
|
|
|
|
|
// vertical toolbar?
|
|
|
|
QToolBar * toolbar = qobject_cast<QToolBar *>(parentWidget()->parentWidget());
|
|
|
|
if (toolbar && toolbar->orientation() == Qt::Vertical) {
|
|
|
|
hoffset += parwidth;
|
|
|
|
voffset -= parheight;
|
|
|
|
}
|
|
|
|
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#if QT_VERSION < 0x060000
|
2007-04-19 20:29:27 +00:00
|
|
|
QRect const screen = qApp->desktop()->availableGeometry(this);
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#else
|
2021-03-15 18:35:58 +01:00
|
|
|
QRect const screen = window()->windowHandle()->screen()->availableGeometry();
|
Allow compiling with Qt6
This commit allows compiling LyX with Qt6 when using autotools.
For a successful compilation the following 2 conditions must be met.
1) The Qt6 qmake has to come first in PATH, so that the command
"qmake -v | grep -o 'Qt version .'" returns "Qt version 6".
2) The --enable-qt6 switch has to be passed to the configure command.
If --enable-qt6 is used but Qt6 is not found, Qt5 is tried as a fallback.
If also Qt5 is not found, configuring for Qt4 is attempted.
If --enable-qt6 is not used, then things go as usual. This means that Qt5
is tried first and then Qt4, unless --disable-qt5 is used, in which case
Qt4 is directly attempted. This means that existing scripts should
continue working unmodified.
LyX should compile with Qt6 on windows and linux, and possibly also on
mac, but I could not test that. However, it is not guaranteed that it
works as it should. In particular I am not sure that I got right the
conversion from QRegExp to QRegularExpression. For sure, the syntax
highlighting seems to not work right. Someone in the know should take
a look at that. I am able to load documents and compile them but some
thourough testing is needed. However, when compiling for Qt5 or Qt4,
I tried to make sure that the functionality is preserved.
2021-03-15 17:09:09 +01:00
|
|
|
#endif
|
2007-04-19 20:29:27 +00:00
|
|
|
QPoint const gpos = parentWidget()->mapToGlobal(
|
|
|
|
parentWidget()->geometry().bottomLeft());
|
|
|
|
|
|
|
|
// space to the right?
|
|
|
|
if (gpos.x() + hoffset + width() > screen.width()) {
|
|
|
|
hoffset -= 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 (toolbar && toolbar->orientation() == Qt::Horizontal)
|
|
|
|
voffset -= parheight;
|
|
|
|
else
|
|
|
|
voffset += parheight;
|
|
|
|
}
|
|
|
|
|
2007-06-21 09:51:50 +00:00
|
|
|
QRect r = rect();
|
|
|
|
r.moveTo(gpos.x() + hoffset, gpos.y() + voffset);
|
2017-07-03 13:53:14 -04:00
|
|
|
setGeometry(r);
|
2007-04-19 20:29:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-19 22:01:28 +00:00
|
|
|
void IconPalette::hideEvent(QHideEvent * event )
|
2007-04-19 20:29:27 +00:00
|
|
|
{
|
|
|
|
QWidget::hideEvent(event);
|
2007-06-21 09:51:50 +00:00
|
|
|
visible(false);
|
|
|
|
if (tornoff_) {
|
|
|
|
setWindowFlags(Qt::Popup);
|
|
|
|
tornoff_ = false;
|
|
|
|
tearoffwidget_->setVisible(!tornoff_);
|
|
|
|
}
|
2007-04-19 20:29:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-10 20:14:54 +00:00
|
|
|
void IconPalette::paintEvent(QPaintEvent * /*event*/)
|
2007-04-19 20:29:27 +00:00
|
|
|
{
|
|
|
|
// draw border
|
|
|
|
const int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, 0, this);
|
2007-06-21 09:51:50 +00:00
|
|
|
if (fw && !tornoff_) {
|
|
|
|
QPainter p(this);
|
2007-04-19 20:29:27 +00:00
|
|
|
QRegion borderReg;
|
2008-09-19 10:04:06 +00:00
|
|
|
borderReg += QRegion(QRect(0, 0, fw, height())); //left
|
|
|
|
borderReg += QRegion(QRect(width() - fw, 0, fw, height())); //right
|
|
|
|
borderReg += QRegion(QRect(0, 0, width(), fw)); //top
|
|
|
|
borderReg += QRegion(QRect(0, height() - fw, width(), fw)); //bottom
|
2007-04-19 20:29:27 +00:00
|
|
|
p.setClipRegion(borderReg);
|
|
|
|
QStyleOptionFrame frame;
|
|
|
|
frame.rect = rect();
|
|
|
|
frame.palette = palette();
|
|
|
|
frame.state = QStyle::State_None;
|
|
|
|
frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuPanelWidth);
|
|
|
|
frame.midLineWidth = 0;
|
|
|
|
style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, &p, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ButtonMenu::ButtonMenu(const QString & title, QWidget * parent)
|
|
|
|
: QMenu(title, parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ButtonMenu::add(QAction * action)
|
|
|
|
{
|
|
|
|
addAction(action);
|
|
|
|
actions_.push_back(action);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ButtonMenu::updateParent()
|
|
|
|
{
|
|
|
|
bool enable = false;
|
2007-10-01 13:17:56 +00:00
|
|
|
// FIXME: so this is commented out for speed considerations
|
|
|
|
// true fix is to repair the updating mechanism of the toolbar
|
|
|
|
#if 0
|
2007-05-28 22:27:45 +00:00
|
|
|
for (int i = 0; i < actions_.size(); ++i)
|
2007-04-19 20:29:27 +00:00
|
|
|
if (actions_.at(i)->isEnabled()) {
|
|
|
|
enable = true;
|
|
|
|
break;
|
|
|
|
}
|
2007-10-01 13:17:56 +00:00
|
|
|
#else
|
|
|
|
// we check only the first action to enable/disable the menu
|
2007-10-01 17:40:42 +00:00
|
|
|
if (!actions_.isEmpty())
|
2007-10-01 13:17:56 +00:00
|
|
|
enable = actions_.at(0)->isEnabled();
|
|
|
|
#endif
|
2007-04-19 20:29:27 +00:00
|
|
|
|
|
|
|
parentWidget()->setEnabled(enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-19 17:12:33 +00:00
|
|
|
} // namespace frontend
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_IconPalette.cpp"
|