mirror of https://github.com/KLayout/klayout.git
Bugfix: crash on exit
This crash started to happen with the bugfix for the black-on-black tree expander icon. It was caused by the styling that was attached to the widgets in order to fix this. Apparently Qt does not like to attach proxy styles dyna- mically. Now, the styling is applied globally and this issue is fixed.
This commit is contained in:
parent
af640086e6
commit
7ddc6bf9df
|
|
@ -27,12 +27,12 @@
|
|||
#include "layMainWindow.h"
|
||||
#include "layMacroEditorDialog.h"
|
||||
#include "layVersion.h"
|
||||
#include "tlExceptions.h"
|
||||
#include "layMacro.h"
|
||||
#include "layCrashMessage.h"
|
||||
#include "layRuntimeErrorForm.h"
|
||||
#include "layProgress.h"
|
||||
#include "layTextProgress.h"
|
||||
#include "layBackgroundAwareTreeStyle.h"
|
||||
#include "gtf.h"
|
||||
#include "gsiDecl.h"
|
||||
#include "gsiInterpreter.h"
|
||||
|
|
@ -42,6 +42,7 @@
|
|||
#include "dbStatic.h"
|
||||
#include "dbLibrary.h"
|
||||
#include "dbLibraryManager.h"
|
||||
#include "tlExceptions.h"
|
||||
#include "tlException.h"
|
||||
#include "tlAssert.h"
|
||||
#include "tlLog.h"
|
||||
|
|
@ -498,6 +499,11 @@ Application::Application (int &argc, char **argv, bool non_ui_mode)
|
|||
|
||||
mp_qapp = this;
|
||||
mp_qapp_gui = (non_ui_mode ? 0 : this);
|
||||
|
||||
// install a special style proxy to overcome the issue of black-on-black tree expanders
|
||||
if (mp_qapp_gui) {
|
||||
mp_qapp_gui->setStyle (new lay::BackgroundAwareTreeStyle (0));
|
||||
}
|
||||
|
||||
// initialize the system codecs (Hint: this must be done after the QApplication is initialized because
|
||||
// it will call setlocale)
|
||||
|
|
|
|||
|
|
@ -1,470 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SimpleCellSelectionForm</class>
|
||||
<widget class="QDialog" name="SimpleCellSelectionForm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>629</width>
|
||||
<height>525</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Select Cell</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame8">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>451</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QFrame" name="frame_4">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_cell_name">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>(* and ? can be used to match any text)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Selected cell</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QToolButton" name="find_next">
|
||||
<property name="toolTip">
|
||||
<string><html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Find next</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../lay/layResources.qrc">
|
||||
<normaloff>:/find.png</normaloff>:/find.png</iconset>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Cell list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QTreeView" name="lv_cells">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_5">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QTreeView" name="lv_parents">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
<widget class="QLabel" name="textLabel1">
|
||||
<property name="text">
|
||||
<string>Parents</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QToolButton" name="tb_set_parent">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../lay/layResources.qrc">:/right.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="textLabel2">
|
||||
<property name="text">
|
||||
<string>Children</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QTreeView" name="lv_children">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QToolButton" name="tb_set_child">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Select</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../lay/layResources.qrc">:/right.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>611</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame5">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>91</width>
|
||||
<height>31</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ok_button">
|
||||
<property name="text">
|
||||
<string>Ok</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancel_button">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
<include location="../lay/layResources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "layBackgroundAwareTreeStyle.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// BackgroundAwareTreeStyle implementation
|
||||
|
||||
BackgroundAwareTreeStyle::BackgroundAwareTreeStyle (QStyle *org_style)
|
||||
: QProxyStyle (org_style)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
BackgroundAwareTreeStyle::drawPrimitive (QStyle::PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const
|
||||
{
|
||||
if (pe == PE_IndicatorBranch) {
|
||||
|
||||
static const int sz = 9;
|
||||
|
||||
int mid_h = opt->rect.x () + opt->rect.width () / 2;
|
||||
int mid_v = opt->rect.y () + opt->rect.height () / 2;
|
||||
|
||||
if (opt->state & State_Children) {
|
||||
|
||||
QColor c;
|
||||
|
||||
QPalette::ColorGroup cg = QPalette::Disabled;
|
||||
if ((w && w->isEnabled ()) || (!w && (opt->state & State_Enabled))) {
|
||||
if ((w && w->hasFocus ()) || (!w && (opt->state & State_HasFocus))) {
|
||||
cg = QPalette::Normal;
|
||||
} else {
|
||||
cg = QPalette::Inactive;
|
||||
}
|
||||
}
|
||||
if (opt->state & State_Selected) {
|
||||
c = opt->palette.color (cg, QPalette::HighlightedText);
|
||||
} else {
|
||||
c = opt->palette.color (cg, QPalette::Text);
|
||||
}
|
||||
if (! (opt->state & State_MouseOver)) {
|
||||
if (c.green () < 128) {
|
||||
c = QColor ((c.red () * 3 + 255) / 4, (c.green () * 3 + 255) / 4, (c.blue () * 3 + 255) / 4);
|
||||
} else {
|
||||
c = QColor ((c.red () * 8) / 9, (c.green () * 8) / 9, (c.blue () * 8) / 9);
|
||||
}
|
||||
}
|
||||
|
||||
QPen old_pen = p->pen ();
|
||||
p->setPen (Qt::NoPen);
|
||||
QBrush old_brush = p->brush ();
|
||||
p->setBrush (c);
|
||||
QPainter::RenderHints old_rh = p->renderHints ();
|
||||
p->setRenderHints (QPainter::Antialiasing);
|
||||
|
||||
if (opt->state & State_Open) {
|
||||
QPoint points[] = {
|
||||
QPoint (mid_h - sz / 2, mid_v - sz / 3),
|
||||
QPoint (mid_h + sz / 2, mid_v - sz / 3),
|
||||
QPoint (mid_h, mid_v + sz / 3)
|
||||
};
|
||||
p->drawPolygon (points, sizeof (points) / sizeof (points[0]));
|
||||
} else {
|
||||
QPoint points[] = {
|
||||
QPoint (mid_h - sz / 3, mid_v - sz / 2),
|
||||
QPoint (mid_h + sz / 3, mid_v),
|
||||
QPoint (mid_h - sz / 3, mid_v + sz / 2)
|
||||
};
|
||||
p->drawPolygon (points, sizeof (points) / sizeof (points[0]));
|
||||
}
|
||||
|
||||
p->setPen (old_pen);
|
||||
p->setBrush (old_brush);
|
||||
p->setRenderHints (old_rh);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QProxyStyle::drawPrimitive (pe, opt, p, w);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2017 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef HDR_layBackgroundAwareTreeStyle
|
||||
#define HDR_layBackgroundAwareTreeStyle
|
||||
|
||||
#include "laybasicCommon.h"
|
||||
|
||||
#include <QProxyStyle>
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief A style tailoring the drawing of the branch indicator
|
||||
* This proxy style is making the branch indicator a triangle and aware of the
|
||||
* palette of the tree.
|
||||
* The default Gtk style is not, hence making the background dark means the
|
||||
* triangles become invisible.
|
||||
*/
|
||||
class LAYBASIC_PUBLIC BackgroundAwareTreeStyle
|
||||
: public QProxyStyle
|
||||
{
|
||||
public:
|
||||
BackgroundAwareTreeStyle (QStyle *org_style);
|
||||
void drawPrimitive (PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const;
|
||||
};
|
||||
|
||||
} // namespace lay
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -332,7 +332,9 @@ HierarchyControlPanel::HierarchyControlPanel (lay::LayoutView *view, QWidget *pa
|
|||
mp_view->cellviews_changed_event.add (this, &HierarchyControlPanel::update_required);
|
||||
mp_view->hier_changed_event.add (this, &HierarchyControlPanel::update_required);
|
||||
|
||||
/* @@@
|
||||
mp_tree_style.reset (new BackgroundAwareTreeStyle (style ()));
|
||||
@@@ */
|
||||
|
||||
do_update_content ();
|
||||
}
|
||||
|
|
@ -895,7 +897,6 @@ HierarchyControlPanel::do_update_content (int cv_index)
|
|||
|
||||
HCPCellTreeWidget *cell_list = new HCPCellTreeWidget (cl_frame, "tree", mp_view->view_object_widget ());
|
||||
cl_ly->addWidget (cell_list);
|
||||
cell_list->setStyle (mp_tree_style.get ());
|
||||
cell_list->setModel (new CellTreeModel (cell_list, mp_view, cv_index, m_flat ? CellTreeModel::Flat : 0, 0, m_sorting));
|
||||
cell_list->setUniformRowHeights (true);
|
||||
|
||||
|
|
|
|||
|
|
@ -400,8 +400,6 @@ LayerControlPanel::LayerControlPanel (lay::LayoutView *view, db::Manager *manage
|
|||
|
||||
mp_model = new lay::LayerTreeModel (this, view);
|
||||
mp_layer_list = new LCPTreeWidget (this, mp_model, "layer_tree");
|
||||
mp_ll_style.reset (new BackgroundAwareTreeStyle (mp_layer_list->style ()));
|
||||
mp_layer_list->setStyle (mp_ll_style.get ());
|
||||
mp_model->set_font (mp_layer_list->font ());
|
||||
/*
|
||||
* At least with Qt 4.2.x setting uniform row heights has a strange side effect:
|
||||
|
|
|
|||
|
|
@ -1108,84 +1108,5 @@ void DecoratedLineEdit::resizeEvent (QResizeEvent * /*event*/)
|
|||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------
|
||||
// BackgroundAwareTreeStyle implementation
|
||||
|
||||
BackgroundAwareTreeStyle::BackgroundAwareTreeStyle (QStyle *org_style)
|
||||
: QProxyStyle (org_style)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
BackgroundAwareTreeStyle::drawPrimitive (QStyle::PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const
|
||||
{
|
||||
if (pe == PE_IndicatorBranch) {
|
||||
|
||||
static const int sz = 9;
|
||||
|
||||
int mid_h = opt->rect.x () + opt->rect.width () / 2;
|
||||
int mid_v = opt->rect.y () + opt->rect.height () / 2;
|
||||
|
||||
if (opt->state & State_Children) {
|
||||
|
||||
QColor c;
|
||||
|
||||
QPalette::ColorGroup cg = QPalette::Disabled;
|
||||
if ((w && w->isEnabled ()) || (!w && (opt->state & State_Enabled))) {
|
||||
if ((w && w->hasFocus ()) || (!w && (opt->state & State_HasFocus))) {
|
||||
cg = QPalette::Normal;
|
||||
} else {
|
||||
cg = QPalette::Inactive;
|
||||
}
|
||||
}
|
||||
if (opt->state & State_Selected) {
|
||||
c = opt->palette.color (cg, QPalette::HighlightedText);
|
||||
} else {
|
||||
c = opt->palette.color (cg, QPalette::Text);
|
||||
}
|
||||
if (! (opt->state & State_MouseOver)) {
|
||||
if (c.green () < 128) {
|
||||
c = QColor ((c.red () * 3 + 255) / 4, (c.green () * 3 + 255) / 4, (c.blue () * 3 + 255) / 4);
|
||||
} else {
|
||||
c = QColor ((c.red () * 8) / 9, (c.green () * 8) / 9, (c.blue () * 8) / 9);
|
||||
}
|
||||
}
|
||||
|
||||
QPen old_pen = p->pen ();
|
||||
p->setPen (Qt::NoPen);
|
||||
QBrush old_brush = p->brush ();
|
||||
p->setBrush (c);
|
||||
QPainter::RenderHints old_rh = p->renderHints ();
|
||||
p->setRenderHints (QPainter::Antialiasing);
|
||||
|
||||
if (opt->state & State_Open) {
|
||||
QPoint points[] = {
|
||||
QPoint (mid_h - sz / 2, mid_v - sz / 3),
|
||||
QPoint (mid_h + sz / 2, mid_v - sz / 3),
|
||||
QPoint (mid_h, mid_v + sz / 3)
|
||||
};
|
||||
p->drawPolygon (points, sizeof (points) / sizeof (points[0]));
|
||||
} else {
|
||||
QPoint points[] = {
|
||||
QPoint (mid_h - sz / 3, mid_v - sz / 2),
|
||||
QPoint (mid_h + sz / 3, mid_v),
|
||||
QPoint (mid_h - sz / 3, mid_v + sz / 2)
|
||||
};
|
||||
p->drawPolygon (points, sizeof (points) / sizeof (points[0]));
|
||||
}
|
||||
|
||||
p->setPen (old_pen);
|
||||
p->setBrush (old_brush);
|
||||
p->setRenderHints (old_rh);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QProxyStyle::drawPrimitive (pe, opt, p, w);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -444,21 +444,6 @@ private:
|
|||
int m_default_left_margin, m_default_right_margin;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A style tailoring the drawing of the branch indicator
|
||||
* This proxy style is making the branch indicator a triangle and aware of the
|
||||
* palette of the tree.
|
||||
* The default Gtk style is not, hence making the background dark means the
|
||||
* triangles become invisible.
|
||||
*/
|
||||
class BackgroundAwareTreeStyle
|
||||
: public QProxyStyle
|
||||
{
|
||||
public:
|
||||
BackgroundAwareTreeStyle (QStyle *org_style);
|
||||
void drawPrimitive (PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w) const;
|
||||
};
|
||||
|
||||
} // namespace lay
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ FORMS = \
|
|||
SaveLayoutOptionsDialog.ui \
|
||||
SaveLayoutAsOptionsDialog.ui \
|
||||
SelectStippleForm.ui \
|
||||
SimpleCellSelectionForm.ui \
|
||||
TipDialog.ui \
|
||||
UserPropertiesForm.ui \
|
||||
UserPropertiesEditForm.ui \
|
||||
|
|
@ -176,7 +175,8 @@ SOURCES = \
|
|||
laySelectLineStyleForm.cc \
|
||||
layLineStylePalette.cc \
|
||||
layEditLineStylesForm.cc \
|
||||
layEditLineStyleWidget.cc
|
||||
layEditLineStyleWidget.cc \
|
||||
layBackgroundAwareTreeStyle.cc
|
||||
|
||||
HEADERS = \
|
||||
gtf.h \
|
||||
|
|
@ -270,7 +270,8 @@ HEADERS = \
|
|||
layEditLineStylesForm.h \
|
||||
layEditLineStyleWidget.h \
|
||||
laybasicCommon.h \
|
||||
laybasicConfig.h
|
||||
laybasicConfig.h \
|
||||
layBackgroundAwareTreeStyle.h
|
||||
|
||||
INCLUDEPATH += ../tl ../gsi ../db ../rdb
|
||||
DEPENDPATH += ../tl ../gsi ../db ../rdb
|
||||
|
|
|
|||
Loading…
Reference in New Issue