mirror of https://github.com/KLayout/klayout.git
WIP
This commit is contained in:
parent
0e15426c9f
commit
a7678c8a57
|
|
@ -157,7 +157,7 @@ EditLineStylesForm::update ()
|
|||
name = tl::sprintf ("#%d", std::distance (m_styles.begin (), i));
|
||||
}
|
||||
QListWidgetItem *item = new QListWidgetItem (icon_from_data (*i), tl::to_qstring (name), mp_ui->style_items);
|
||||
item->setTextColor (cdis);
|
||||
item->setForeground (cdis);
|
||||
}
|
||||
for (std::vector <lay::LineStyles::iterator>::const_iterator i = iters.begin (); i != iters.end (); ++i) {
|
||||
if ((*i)->order_index () > 0) {
|
||||
|
|
|
|||
|
|
@ -90,8 +90,13 @@ HTMLItemDelegate::set_text_width (int w)
|
|||
void
|
||||
HTMLItemDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
#if QT_VERSION >= 0x60000
|
||||
QStyleOptionViewItem option_v4 = option;
|
||||
#else
|
||||
QStyleOptionViewItemV4 option_v4 = option;
|
||||
#endif
|
||||
initStyleOption (&option_v4, index);
|
||||
|
||||
// let the text take all the available space (fixes #144)
|
||||
option_v4.showDecorationSelected = true;
|
||||
|
||||
|
|
@ -140,7 +145,11 @@ HTMLItemDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option,
|
|||
QSize
|
||||
HTMLItemDelegate::sizeHint (const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
#if QT_VERSION >= 0x60000
|
||||
QStyleOptionViewItem option_v4 = option;
|
||||
#else
|
||||
QStyleOptionViewItemV4 option_v4 = option;
|
||||
#endif
|
||||
initStyleOption (&option_v4, index);
|
||||
|
||||
const QAbstractItemView *view = dynamic_cast<const QAbstractItemView *> (option_v4.widget);
|
||||
|
|
@ -169,7 +178,11 @@ HTMLItemDelegate::editorEvent (QEvent *event, QAbstractItemModel * /*model*/, co
|
|||
|
||||
QMouseEvent *mouse_event = static_cast<QMouseEvent *> (event);
|
||||
|
||||
#if QT_VERSION >= 0x60000
|
||||
QStyleOptionViewItem option_v4 = option;
|
||||
#else
|
||||
QStyleOptionViewItemV4 option_v4 = option;
|
||||
#endif
|
||||
initStyleOption (&option_v4, index);
|
||||
|
||||
QTextDocument doc;
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ qt_to_buttons (Qt::MouseButtons b, Qt::KeyboardModifiers m)
|
|||
// BTW: On a MAC's keyboard, the cmd-key is received here as a ControlModifier
|
||||
// while the ctrl-key is received as a MetaModifier
|
||||
return ((b & Qt::LeftButton) ? ((m & Qt::MetaModifier) ? RightButton : LeftButton) : 0) |
|
||||
((b & Qt::MidButton) ? MidButton : 0) |
|
||||
((b & Qt::MiddleButton) ? MidButton : 0) |
|
||||
((b & Qt::RightButton) ? RightButton : 0) |
|
||||
((m & Qt::ShiftModifier) != 0 ? ShiftButton : 0) |
|
||||
((m & Qt::ControlModifier) != 0 ? ControlButton : 0) |
|
||||
|
|
@ -764,36 +764,43 @@ BEGIN_PROTECTED
|
|||
ensure_entered ();
|
||||
begin_mouse_event ();
|
||||
|
||||
#if QT_VERSION < 0x60000
|
||||
int delta = e->delta ();
|
||||
db::DPoint p = pixel_to_um (e->pos ());
|
||||
bool horizontal = (e->orientation () == Qt::Horizontal);
|
||||
#else
|
||||
int delta = e->angleDelta ().y ();
|
||||
db::DPoint p = pixel_to_um (e->position ());
|
||||
bool horizontal = false;
|
||||
#endif
|
||||
|
||||
e->ignore ();
|
||||
|
||||
bool done = false;
|
||||
|
||||
unsigned int buttons = qt_to_buttons (e->buttons (), e->modifiers ());
|
||||
bool horizontal = (e->orientation () == Qt::Horizontal);
|
||||
|
||||
db::DPoint p = pixel_to_um (e->pos ());
|
||||
|
||||
for (std::list<ViewService *>::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) {
|
||||
std::list<ViewService *>::iterator gg = g;
|
||||
++gg;
|
||||
done = ((*g)->enabled () && (*g)->wheel_event (e->delta (), horizontal, p, buttons, true));
|
||||
done = ((*g)->enabled () && (*g)->wheel_event (delta, horizontal, p, buttons, true));
|
||||
g = gg;
|
||||
}
|
||||
|
||||
if (! done && mp_active_service) {
|
||||
done = (mp_active_service->enabled () && mp_active_service->wheel_event (e->delta (), horizontal, p, buttons, true));
|
||||
done = (mp_active_service->enabled () && mp_active_service->wheel_event (delta, horizontal, p, buttons, true));
|
||||
}
|
||||
|
||||
service_iterator svc = begin_services ();
|
||||
while (svc != end_services () && !done) {
|
||||
service_iterator next = svc;
|
||||
++next;
|
||||
done = ((*svc)->enabled () && (*svc)->wheel_event (e->delta (), horizontal, p, buttons, false));
|
||||
done = ((*svc)->enabled () && (*svc)->wheel_event (delta, horizontal, p, buttons, false));
|
||||
svc = next;
|
||||
}
|
||||
|
||||
if (! done) {
|
||||
wheel_event (e->delta (), horizontal, p, buttons);
|
||||
wheel_event (delta, horizontal, p, buttons);
|
||||
}
|
||||
|
||||
end_mouse_event ();
|
||||
|
|
@ -879,6 +886,12 @@ ViewObjectWidget::pixel_to_um (const QPoint &pt) const
|
|||
return m_trans.inverted () * db::DPoint (pt.x (), height () - 1 - pt.y ());
|
||||
}
|
||||
|
||||
db::DPoint
|
||||
ViewObjectWidget::pixel_to_um (const QPointF &pt) const
|
||||
{
|
||||
return m_trans.inverted () * db::DPoint (pt.x (), height () - 1 - pt.y ());
|
||||
}
|
||||
|
||||
void
|
||||
ViewObjectWidget::mouse_event_trans (const db::DCplxTrans &trans)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -992,6 +992,11 @@ public:
|
|||
*/
|
||||
db::DPoint pixel_to_um (const QPoint &pt) const;
|
||||
|
||||
/**
|
||||
* @brief Translates a screen coordinate in micrometer coordinates
|
||||
*/
|
||||
db::DPoint pixel_to_um (const QPointF &pt) const;
|
||||
|
||||
/**
|
||||
* @brief Gets a flag indicating whether the mouse is inside the window
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1009,10 +1009,9 @@ DecoratedLineEdit::DecoratedLineEdit (QWidget *parent)
|
|||
mp_clear_label->setCursor (Qt::ArrowCursor);
|
||||
mp_clear_label->setPixmap (QString::fromUtf8 (":/clear_edit.png"));
|
||||
|
||||
int l = 0, t = 0, r = 0, b = 0;
|
||||
getTextMargins (&l, &t, &r, &b);
|
||||
m_default_left_margin = l;
|
||||
m_default_right_margin = r;
|
||||
QMargins margins = textMargins ();
|
||||
m_default_left_margin = margins.left ();
|
||||
m_default_right_margin = margins.right ();
|
||||
}
|
||||
|
||||
DecoratedLineEdit::~DecoratedLineEdit ()
|
||||
|
|
@ -1079,14 +1078,13 @@ void DecoratedLineEdit::set_clear_button_enabled (bool en)
|
|||
m_clear_button_enabled = en;
|
||||
mp_clear_label->setVisible (en);
|
||||
|
||||
int l = 0, t = 0, r = 0, b = 0;
|
||||
getTextMargins (&l, &t, &r, &b);
|
||||
QMargins margins = textMargins ();
|
||||
if (! en) {
|
||||
r = m_default_right_margin;
|
||||
margins.setRight (m_default_right_margin);
|
||||
} else {
|
||||
r = m_default_right_margin + mp_clear_label->sizeHint ().width () + le_decoration_space;
|
||||
margins.setRight (m_default_right_margin + mp_clear_label->sizeHint ().width () + le_decoration_space);
|
||||
}
|
||||
setTextMargins (l, t, r, b);
|
||||
setTextMargins (margins);
|
||||
|
||||
resizeEvent (0);
|
||||
|
||||
|
|
@ -1100,14 +1098,13 @@ void DecoratedLineEdit::set_options_button_enabled (bool en)
|
|||
m_options_button_enabled = en;
|
||||
mp_options_label->setVisible (en);
|
||||
|
||||
int l = 0, t = 0, r = 0, b = 0;
|
||||
getTextMargins (&l, &t, &r, &b);
|
||||
QMargins margins = textMargins ();
|
||||
if (! en) {
|
||||
l = m_default_left_margin;
|
||||
margins.setLeft (m_default_left_margin);
|
||||
} else {
|
||||
l = m_default_left_margin + mp_options_label->sizeHint ().width () + le_decoration_space;
|
||||
margins.setLeft (m_default_left_margin + mp_options_label->sizeHint ().width () + le_decoration_space);
|
||||
}
|
||||
setTextMargins (l, t, r, b);
|
||||
setTextMargins (margins);
|
||||
|
||||
resizeEvent (0);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue