Compare commits
11 Commits
b9dea57200
...
4c7b9444b6
| Author | SHA1 | Date | |
|---|---|---|---|
| 4c7b9444b6 | |||
| 33f4394243 | |||
| b340dfebac | |||
| 6a67442d21 | |||
| 8feb5c240c | |||
| 64f3448b5c | |||
| a93db66d78 | |||
| 071a73f5ba | |||
| 2739cc53ec | |||
| ccf17510d8 | |||
| e0134b3b5e |
@@ -3,7 +3,7 @@ cmake_policy(SET CMP0017 NEW) # need include() with .cmake
|
||||
cmake_policy(SET CMP0072 NEW) # FindOpenGL prefers GLVND by default
|
||||
project(QAD)
|
||||
set(QAD_MAJOR 2)
|
||||
set(QAD_MINOR 22)
|
||||
set(QAD_MINOR 23)
|
||||
set(QAD_REVISION 0)
|
||||
set(QAD_SUFFIX )
|
||||
set(QAD_COMPANY SHS)
|
||||
|
||||
@@ -18,13 +18,13 @@ EDockWidget::EDockWidget(QWidget * parent, Qt::WindowFlags flags): QDockWidget(p
|
||||
|
||||
|
||||
EDockWidget::~EDockWidget() {
|
||||
delete btn_hide;
|
||||
delete btn_dock;
|
||||
delete btn_maximize;
|
||||
delete lbl_title;
|
||||
delete lbl_icon;
|
||||
delete header;
|
||||
delete empty_header;
|
||||
btn_hide->deleteLater();
|
||||
btn_dock->deleteLater();
|
||||
btn_maximize->deleteLater();
|
||||
lbl_title->deleteLater();
|
||||
lbl_icon->deleteLater();
|
||||
header->deleteLater();
|
||||
empty_header->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,10 +52,10 @@ private:
|
||||
void init();
|
||||
void updateStyle();
|
||||
|
||||
QFrame * header;
|
||||
QWidget * empty_header;
|
||||
QLabel *lbl_title, *lbl_icon;
|
||||
QToolButton *btn_hide, *btn_dock, *btn_maximize;
|
||||
QFrame * header = nullptr;
|
||||
QWidget * empty_header = nullptr;
|
||||
QLabel *lbl_title = nullptr, *lbl_icon = nullptr;
|
||||
QToolButton *btn_hide = nullptr, *btn_dock = nullptr, *btn_maximize = nullptr;
|
||||
|
||||
private slots:
|
||||
void dockClicked();
|
||||
|
||||
@@ -6,11 +6,6 @@
|
||||
|
||||
|
||||
Ribbon::Ribbon(QMainWindow * parent_): QToolBar() {
|
||||
tab = 0;
|
||||
scroll_area = 0;
|
||||
delay_e = true;
|
||||
delay = 1000;
|
||||
hovered = -1;
|
||||
setObjectName("ribbon");
|
||||
setProperty("ribbon", true);
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
@@ -67,8 +62,8 @@ void Ribbon::_resize() {
|
||||
|
||||
void Ribbon::_setIconsSize() {
|
||||
// qDebug() << "resize" << preferredIconSize() << QApplication::font();
|
||||
setTabIconSize(preferredIconSize(2, this));
|
||||
setIconSize(preferredIconSize(3, this));
|
||||
setTabIconSize(preferredIconSize(1.6, this));
|
||||
setIconSize(preferredIconSize(2.4, this));
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +77,14 @@ void Ribbon::_setButtonText(QToolButton * b, QAction * a) {
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::tabHovered(int tab) {
|
||||
if (!delay_e) return;
|
||||
hovers.clear();
|
||||
hovered = tab;
|
||||
hovers.insert(startTimer(delay), tab);
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::setVisible(bool yes) {
|
||||
QToolBar::setVisible(yes);
|
||||
if (parent == 0) return;
|
||||
@@ -250,3 +253,15 @@ void Ribbon::setTabIconSize(const QSize & size) {
|
||||
#endif
|
||||
_resize();
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::setButtonStyle(const Qt::ToolButtonStyle & style) {
|
||||
foreach(QToolButton * i, buttons)
|
||||
i->setToolButtonStyle(style);
|
||||
}
|
||||
|
||||
|
||||
void Ribbon::setCurrentTab(int tab_) {
|
||||
if (tab_ < 0 || tab_ >= tab->count()) return;
|
||||
tab->setCurrentIndex(tab_);
|
||||
}
|
||||
|
||||
@@ -46,16 +46,10 @@ public:
|
||||
void retranslate();
|
||||
void setIconSize(const QSize & size);
|
||||
void setTabIconSize(const QSize & size);
|
||||
void setButtonStyle(const Qt::ToolButtonStyle & style) {
|
||||
foreach(QToolButton * i, buttons)
|
||||
i->setToolButtonStyle(style);
|
||||
}
|
||||
void setButtonStyle(const Qt::ToolButtonStyle & style);
|
||||
void setAutoSwitchEnabled(bool yes) { delay_e = yes; }
|
||||
void setAutoSwitchDelay(float delay_s) { delay = delay_s * 1000; }
|
||||
void setCurrentTab(int tab_) {
|
||||
if (tab_ < 0 || tab_ >= tab->count()) return;
|
||||
tab->setCurrentIndex(tab_);
|
||||
}
|
||||
void setCurrentTab(int tab_);
|
||||
int currentTab() const { return tab->currentIndex(); }
|
||||
QTabWidget * tabWidget() const { return tab; }
|
||||
|
||||
@@ -67,21 +61,16 @@ private:
|
||||
void _setIconsSize();
|
||||
void _setButtonText(QToolButton * b, QAction * a);
|
||||
|
||||
int hovered, delay;
|
||||
bool delay_e;
|
||||
int hovered = -1, delay = 1000;
|
||||
bool delay_e = true;
|
||||
QList<QToolButton *> buttons;
|
||||
QMap<int, int> hovers;
|
||||
ETabWidget * tab;
|
||||
QScrollArea * scroll_area;
|
||||
QMainWindow * parent;
|
||||
ETabWidget * tab = nullptr;
|
||||
QScrollArea * scroll_area = nullptr;
|
||||
QMainWindow * parent = nullptr;
|
||||
|
||||
private slots:
|
||||
void tabHovered(int tab) {
|
||||
if (!delay_e) return;
|
||||
hovers.clear();
|
||||
hovered = tab;
|
||||
hovers.insert(startTimer(delay), tab);
|
||||
}
|
||||
void tabHovered(int tab);
|
||||
|
||||
public slots:
|
||||
void setVisible(bool yes);
|
||||
|
||||
@@ -150,6 +150,12 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widgetAlign9" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
@@ -777,9 +783,15 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="checkVLEnabled">
|
||||
<property name="text">
|
||||
@@ -886,6 +898,7 @@
|
||||
<class>IconedLabel</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>iconedlabel.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
|
||||
@@ -955,7 +955,7 @@ void Graphic::setButtonsPosition(Graphic::Alignment a) {
|
||||
|
||||
|
||||
void Graphic::addPoint(const QPointF & p, int graphic, bool update_) {
|
||||
if (graphic >= graphics.size() || graphic < 0) return;
|
||||
if (!checkGraphicIndex(graphic)) return;
|
||||
GraphicType & t(graphics[graphic]);
|
||||
if (!t.cvrect.isNull() && !pause_) {
|
||||
if (t.cvrect.top() < p.y()) t.cvrect.setTop(p.y());
|
||||
@@ -986,6 +986,7 @@ void Graphic::addPoint(double x, double y, bool update) {
|
||||
|
||||
|
||||
void Graphic::addPoint(double y, int graphic, bool update) {
|
||||
if (!checkGraphicIndex(graphic)) return;
|
||||
if (graphics[graphic].polyline.isEmpty()) {
|
||||
addPoint(QPointF(0.0, y), graphic, update);
|
||||
} else {
|
||||
@@ -1000,7 +1001,8 @@ void Graphic::addPoint(double y, bool update) {
|
||||
|
||||
|
||||
void Graphic::addPoints(const QPolygonF & pts, int graphic, bool update_) {
|
||||
if (graphic >= graphics.size() || graphic < 0 || pts.isEmpty()) return;
|
||||
if (!checkGraphicIndex(graphic)) return;
|
||||
if (pts.isEmpty()) return;
|
||||
GraphicType & t(graphics[graphic]);
|
||||
if (!t.cvrect.isNull() && !pause_) {
|
||||
for (const QPointF & p: pts) {
|
||||
@@ -1025,10 +1027,11 @@ void Graphic::addPoints(const QPolygonF & pts, bool update) {
|
||||
|
||||
|
||||
void Graphic::addPoints(const QVector<double> & pts, int graphic, bool update_) {
|
||||
if (!checkGraphicIndex(graphic)) return;
|
||||
QPolygonF ps;
|
||||
ps.reserve(pts.size());
|
||||
double stx = 0;
|
||||
if (!graphics[curGraphic].polyline.isEmpty()) stx = graphics[curGraphic].max_x;
|
||||
if (!graphics[graphic].polyline.isEmpty()) stx = graphics[graphic].max_x;
|
||||
for (int i = 0; i < pts.size(); ++i) {
|
||||
ps << QPointF(stx + i * inc_x, pts[i]);
|
||||
}
|
||||
@@ -1042,7 +1045,7 @@ void Graphic::addPoints(const QVector<double> & pts, bool update) {
|
||||
|
||||
|
||||
void Graphic::setGraphicData(const QVector<QPointF> & g, int graphic, bool update_) {
|
||||
if (graphic >= graphics.size() || graphic < 0) return;
|
||||
if (!checkGraphicIndex(graphic)) return;
|
||||
GraphicType & t(graphics[graphic]);
|
||||
t.cvrect = QRectF();
|
||||
t.polyline.clear();
|
||||
@@ -1076,7 +1079,7 @@ void Graphic::setGraphicProperties(int graphic,
|
||||
Qt::PenStyle style,
|
||||
double width,
|
||||
bool visible) {
|
||||
if (graphic < 0 || graphic >= graphics.size()) return;
|
||||
if (!checkGraphicIndex(graphic)) return;
|
||||
graphics[graphic].name = name;
|
||||
graphics[graphic].pen.setColor(color);
|
||||
graphics[graphic].pen.setStyle(style);
|
||||
@@ -1708,6 +1711,12 @@ void Graphic::askForExport(bool view_only) {
|
||||
}
|
||||
|
||||
|
||||
bool Graphic::checkGraphicIndex(int index) const {
|
||||
if (index < 0 || index >= graphics.size()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Graphic::drawGraphics() {
|
||||
if (isHover && ui->status->isVisible()) {
|
||||
ui->status->setText(tr("Cursor: ") + pointCoords(canvas2real(QPointF(curpos))));
|
||||
@@ -2618,6 +2627,72 @@ QString Graphic::caption() const {
|
||||
}
|
||||
|
||||
|
||||
QString Graphic::graphicName(int index) const {
|
||||
if (!checkGraphicIndex(index)) return {};
|
||||
return graphics[index].name;
|
||||
}
|
||||
|
||||
|
||||
QColor Graphic::graphicColor(int index) const {
|
||||
if (!checkGraphicIndex(index)) return Qt::black;
|
||||
return graphics[index].pen.color();
|
||||
}
|
||||
|
||||
|
||||
Qt::PenStyle Graphic::graphicStyle(int index) const {
|
||||
if (!checkGraphicIndex(index)) return Qt::NoPen;
|
||||
return graphics[index].pen.style();
|
||||
}
|
||||
|
||||
|
||||
double Graphic::graphicLineWidth(int index) const {
|
||||
if (!checkGraphicIndex(index)) return 0.;
|
||||
return graphics[index].pen.widthF();
|
||||
}
|
||||
|
||||
|
||||
double Graphic::graphicPointWidth(int index) const {
|
||||
if (!checkGraphicIndex(index)) return 0.;
|
||||
return graphics[index].pointWidth;
|
||||
}
|
||||
|
||||
|
||||
QColor Graphic::graphicFillColor(int index) const {
|
||||
if (!checkGraphicIndex(index)) return Qt::black;
|
||||
return graphics[index].fill_color;
|
||||
}
|
||||
|
||||
|
||||
bool Graphic::graphicVisible(int index) const {
|
||||
if (!checkGraphicIndex(index)) return false;
|
||||
return graphics[index].visible;
|
||||
}
|
||||
|
||||
|
||||
bool Graphic::graphicLinesEnabled(int index) const {
|
||||
if (!checkGraphicIndex(index)) return false;
|
||||
return graphics[index].lines;
|
||||
}
|
||||
|
||||
|
||||
bool Graphic::graphicPointsEnabled(int index) const {
|
||||
if (!checkGraphicIndex(index)) return false;
|
||||
return graphics[index].points;
|
||||
}
|
||||
|
||||
|
||||
bool Graphic::graphicFillEnabled(int index) const {
|
||||
if (!checkGraphicIndex(index)) return false;
|
||||
return graphics[index].fill;
|
||||
}
|
||||
|
||||
|
||||
QPen Graphic::graphicPen(int index) const {
|
||||
if (!checkGraphicIndex(index)) return {};
|
||||
return graphics[index].pen;
|
||||
}
|
||||
|
||||
|
||||
bool Graphic::borderInputsVisible() const {
|
||||
return ui->widgetLX->isVisible();
|
||||
}
|
||||
@@ -2633,6 +2708,12 @@ bool Graphic::legendVisible() const {
|
||||
}
|
||||
|
||||
|
||||
QVector<QPointF> Graphic::graphicData(int index) const {
|
||||
if (!checkGraphicIndex(index)) return {};
|
||||
return graphics[index].polyline;
|
||||
}
|
||||
|
||||
|
||||
QByteArray Graphic::save() {
|
||||
// QByteArray ba;
|
||||
// QDataStream s(&ba, QIODevice::ReadWrite);
|
||||
@@ -2727,7 +2808,7 @@ void Graphic::load(QByteArray ba) {
|
||||
|
||||
|
||||
GraphicType Graphic::graphic(int arg) {
|
||||
if (arg < 0 || arg >= graphics.size()) return GraphicType();
|
||||
if (!checkGraphicIndex(arg)) return {};
|
||||
return graphics[arg];
|
||||
}
|
||||
|
||||
@@ -2763,6 +2844,7 @@ void Graphic::setLabelY(const QString & str) {
|
||||
|
||||
|
||||
void Graphic::setGraphicName(const QString & str, int index) {
|
||||
if (!checkGraphicIndex(index)) return;
|
||||
graphics[index].name = str;
|
||||
updateLegend();
|
||||
if (aupdate) repaintCanvas();
|
||||
@@ -2770,9 +2852,7 @@ void Graphic::setGraphicName(const QString & str, int index) {
|
||||
|
||||
|
||||
void Graphic::setGraphicName(const QString & str) {
|
||||
graphics[curGraphic].name = str;
|
||||
updateLegend();
|
||||
if (aupdate) repaintCanvas();
|
||||
setGraphicName(str, curGraphic);
|
||||
}
|
||||
|
||||
|
||||
@@ -2790,6 +2870,7 @@ void Graphic::setTextColor(const QColor & color) {
|
||||
|
||||
|
||||
void Graphic::setGraphicColor(const QColor & color, int index) {
|
||||
if (!checkGraphicIndex(index)) return;
|
||||
graphics[index].pen.setColor(color);
|
||||
updateLegend();
|
||||
if (aupdate) repaintCanvas();
|
||||
@@ -2813,6 +2894,7 @@ void Graphic::setSelectionColor(const QColor & color) {
|
||||
|
||||
|
||||
void Graphic::setGraphicStyle(const Qt::PenStyle & style, int index) {
|
||||
if (!checkGraphicIndex(index)) return;
|
||||
graphics[index].pen.setStyle(style);
|
||||
updateLegend();
|
||||
if (aupdate) repaintCanvas();
|
||||
@@ -2836,6 +2918,7 @@ void Graphic::setSelectionStyle(const Qt::PenStyle & style) {
|
||||
|
||||
|
||||
void Graphic::setGraphicVisible(bool visible, int index) {
|
||||
if (!checkGraphicIndex(index)) return;
|
||||
graphics[index].visible = visible;
|
||||
updateLegendChecks();
|
||||
if (isFit) {
|
||||
@@ -2852,6 +2935,7 @@ void Graphic::setGraphicVisible(bool visible) {
|
||||
|
||||
|
||||
void Graphic::setGraphicLineWidth(double w, int index) {
|
||||
if (!checkGraphicIndex(index)) return;
|
||||
if (qRound(w) == w)
|
||||
graphics[index].pen.setWidth(qRound(w));
|
||||
else
|
||||
@@ -2867,6 +2951,7 @@ void Graphic::setGraphicLineWidth(double w) {
|
||||
|
||||
|
||||
void Graphic::setGraphicPointWidth(double w, int index) {
|
||||
if (!checkGraphicIndex(index)) return;
|
||||
graphics[index].pointWidth = w;
|
||||
updateLegend();
|
||||
if (aupdate) repaintCanvas();
|
||||
@@ -2879,6 +2964,7 @@ void Graphic::setGraphicPointWidth(double w) {
|
||||
|
||||
|
||||
void Graphic::setGraphicFillColor(const QColor & w, int index) {
|
||||
if (!checkGraphicIndex(index)) return;
|
||||
graphics[index].fill_color = w;
|
||||
updateLegend();
|
||||
if (aupdate) repaintCanvas();
|
||||
@@ -2891,6 +2977,7 @@ void Graphic::setGraphicFillColor(const QColor & w) {
|
||||
|
||||
|
||||
void Graphic::setGraphicLinesEnabled(bool w, int index) {
|
||||
if (!checkGraphicIndex(index)) return;
|
||||
graphics[index].lines = w;
|
||||
updateLegend();
|
||||
if (aupdate) repaintCanvas();
|
||||
@@ -2903,6 +2990,7 @@ void Graphic::setGraphicLinesEnabled(bool w) {
|
||||
|
||||
|
||||
void Graphic::setGraphicPointsEnabled(bool w, int index) {
|
||||
if (!checkGraphicIndex(index)) return;
|
||||
graphics[index].points = w;
|
||||
updateLegend();
|
||||
if (aupdate) repaintCanvas();
|
||||
@@ -2915,6 +3003,7 @@ void Graphic::setGraphicPointsEnabled(bool w) {
|
||||
|
||||
|
||||
void Graphic::setGraphicFillEnabled(bool w, int index) {
|
||||
if (!checkGraphicIndex(index)) return;
|
||||
graphics[index].fill = w;
|
||||
updateLegend();
|
||||
if (aupdate) repaintCanvas();
|
||||
@@ -2927,6 +3016,7 @@ void Graphic::setGraphicFillEnabled(bool w) {
|
||||
|
||||
|
||||
void Graphic::setGraphicPen(const QPen & pen, int index) {
|
||||
if (!checkGraphicIndex(index)) return;
|
||||
graphics[index].pen = pen;
|
||||
updateLegend();
|
||||
if (aupdate) repaintCanvas();
|
||||
|
||||
@@ -174,34 +174,34 @@ public:
|
||||
QString caption() const;
|
||||
QString labelX() const { return label_x; }
|
||||
QString labelY() const { return label_y; }
|
||||
QString graphicName() const { return graphics[curGraphic].name; }
|
||||
QString graphicName(int index) const { return graphics[index].name; }
|
||||
QString graphicName() const { return graphicName(curGraphic); }
|
||||
QString graphicName(int index) const;
|
||||
QColor backgroundColor() const { return back_color; }
|
||||
QColor textColor() const { return text_color; }
|
||||
QColor graphicColor() const { return graphics[curGraphic].pen.color(); }
|
||||
QColor graphicColor(int index) const { return graphics[index].pen.color(); }
|
||||
QColor graphicColor() const { return graphicColor(curGraphic); }
|
||||
QColor graphicColor(int index) const;
|
||||
QColor gridColor() const { return grid_pen.color(); }
|
||||
QColor selectionColor() const { return selpen.color(); }
|
||||
Qt::PenStyle graphicStyle() const { return graphics[curGraphic].pen.style(); }
|
||||
Qt::PenStyle graphicStyle(int index) const { return graphics[index].pen.style(); }
|
||||
Qt::PenStyle graphicStyle() const { return graphicStyle(curGraphic); }
|
||||
Qt::PenStyle graphicStyle(int index) const;
|
||||
Qt::PenStyle gridStyle() const { return grid_pen.style(); }
|
||||
Qt::PenStyle selectionStyle() const { return selpen.style(); }
|
||||
double graphicLineWidth() const { return graphics[curGraphic].pen.widthF(); }
|
||||
double graphicLineWidth(int index) const { return graphics[index].pen.widthF(); }
|
||||
double graphicPointWidth() const { return graphics[curGraphic].pointWidth; }
|
||||
double graphicPointWidth(int index) const { return graphics[index].pointWidth; }
|
||||
QColor graphicFillColor() const { return graphics[curGraphic].fill_color; }
|
||||
QColor graphicFillColor(int index) const { return graphics[index].fill_color; }
|
||||
bool graphicVisible() const { return graphics[curGraphic].visible; }
|
||||
bool graphicVisible(int index) const { return graphics[index].visible; }
|
||||
bool graphicLinesEnabled() const { return graphics[curGraphic].lines; }
|
||||
bool graphicLinesEnabled(int index) const { return graphics[index].lines; }
|
||||
bool graphicPointsEnabled() const { return graphics[curGraphic].points; }
|
||||
bool graphicPointsEnabled(int index) const { return graphics[index].points; }
|
||||
bool graphicFillEnabled() const { return graphics[curGraphic].fill; }
|
||||
bool graphicFillEnabled(int index) const { return graphics[index].fill; }
|
||||
QPen graphicPen() const { return graphics[curGraphic].pen; }
|
||||
QPen graphicPen(int index) const { return graphics[index].pen; }
|
||||
double graphicLineWidth() const { return graphicLineWidth(curGraphic); }
|
||||
double graphicLineWidth(int index) const;
|
||||
double graphicPointWidth() const { return graphicPointWidth(curGraphic); }
|
||||
double graphicPointWidth(int index) const;
|
||||
QColor graphicFillColor() const { return graphicFillColor(curGraphic); }
|
||||
QColor graphicFillColor(int index) const;
|
||||
bool graphicVisible() const { return graphicVisible(curGraphic); }
|
||||
bool graphicVisible(int index) const;
|
||||
bool graphicLinesEnabled() const { return graphicLinesEnabled(curGraphic); }
|
||||
bool graphicLinesEnabled(int index) const;
|
||||
bool graphicPointsEnabled() const { return graphicPointsEnabled(curGraphic); }
|
||||
bool graphicPointsEnabled(int index) const;
|
||||
bool graphicFillEnabled() const { return graphicFillEnabled(curGraphic); }
|
||||
bool graphicFillEnabled(int index) const;
|
||||
QPen graphicPen() const { return graphicPen(curGraphic); }
|
||||
QPen graphicPen(int index) const;
|
||||
QPen gridPen() const { return grid_pen; }
|
||||
QPen selectionPen() const { return selpen; }
|
||||
QBrush selectionBrush() const { return selbrush; }
|
||||
@@ -239,8 +239,8 @@ public:
|
||||
double graduationStepY() const { return gridy; }
|
||||
AxisType axisType() const { return axis_type_x; }
|
||||
FloatingAxisType floatingAxisType() const { return floating_axis_type; }
|
||||
QVector<QPointF> graphicData() const { return graphics[curGraphic].polyline; }
|
||||
QVector<QPointF> graphicData(int index) const { return graphics[index].polyline; }
|
||||
QVector<QPointF> graphicData() const { return graphicData(curGraphic); }
|
||||
QVector<QPointF> graphicData(int index) const;
|
||||
GraphicsData graphicsData() const;
|
||||
QByteArray graphicsDataRaw() const;
|
||||
QWidget * viewport() const { return canvas; }
|
||||
@@ -433,6 +433,7 @@ protected:
|
||||
QPair<QString, QString> gridMark(double v) const;
|
||||
void fillDateFormats();
|
||||
void askForExport(bool view_only);
|
||||
bool checkGraphicIndex(int index) const;
|
||||
|
||||
Ui::Graphic * ui;
|
||||
UGLWidget * canvas_gl;
|
||||
|
||||
@@ -54,6 +54,7 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent), ui(new Ui::QCodeEdit) {
|
||||
qRegisterMetaType<QTextCursor>();
|
||||
qRegisterMetaType<QCodeEdit::ACEntry>();
|
||||
ui->setupUi(this);
|
||||
detectTheme();
|
||||
overlay = new _QCE_Viewport(ui->textCode->viewport());
|
||||
overlay->ce = this;
|
||||
overlay->show();
|
||||
@@ -548,6 +549,7 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
||||
|
||||
|
||||
void QCodeEdit::showEvent(QShowEvent *) {
|
||||
detectTheme();
|
||||
if (!_first) return;
|
||||
_first = false;
|
||||
completer->installEventFilter(this);
|
||||
@@ -584,6 +586,7 @@ void QCodeEdit::changeEvent(QEvent * e) {
|
||||
ui->retranslateUi(this);
|
||||
lbl_help[lhF1]->setText(tr("Press F1 for details"));
|
||||
break;
|
||||
case QEvent::PaletteChange: detectTheme(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@@ -875,9 +878,36 @@ void QCodeEdit::highlightBrackets() {
|
||||
}
|
||||
|
||||
|
||||
QColor inverseColorValue(const QColor & c) {
|
||||
int hsv[4];
|
||||
c.getHsl(&hsv[0], &hsv[1], &hsv[2], &hsv[3]);
|
||||
return QColor::fromHsl(hsv[0], hsv[1], 255 - hsv[2], hsv[3]);
|
||||
}
|
||||
QBrush QCodeEdit::invertedBrush(const QBrush & b) {
|
||||
auto ret = b;
|
||||
ret.setColor(inverseColorValue(b.color()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
QTextCharFormat QCodeEdit::invertedFormat(const QTextCharFormat & f) {
|
||||
auto ret = f;
|
||||
ret.setForeground(invertedBrush(ret.foreground()));
|
||||
ret.setBackground(invertedBrush(ret.background()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void QCodeEdit::applyExtraSelection() {
|
||||
ui->textCode->setExtraSelections(QList<QTextEdit::ExtraSelection>() << es_line << es_selected << es_custom << es_brackets
|
||||
<< es_search_list << es_cursor << es_link << es_blockselection);
|
||||
QList<QTextEdit::ExtraSelection> esl;
|
||||
esl << es_line << es_selected << es_custom << es_brackets << es_search_list << es_cursor << es_link;
|
||||
if (is_dark_theme) {
|
||||
for (auto & e: esl) {
|
||||
e.format = invertedFormat(e.format);
|
||||
}
|
||||
}
|
||||
esl << es_blockselection;
|
||||
ui->textCode->setExtraSelections(esl);
|
||||
}
|
||||
|
||||
|
||||
@@ -1702,6 +1732,11 @@ QCodeEdit::ACEntry QCodeEdit::findEntryOnCursor(QTextCursor tc, int arg, ACClass
|
||||
}
|
||||
|
||||
|
||||
void QCodeEdit::detectTheme() {
|
||||
is_dark_theme = palette().color(QPalette::Window).valueF() < 0.5;
|
||||
}
|
||||
|
||||
|
||||
void QCodeEdit::raiseHelp(QTextCursor tc, int arg) {
|
||||
ACClass acc;
|
||||
QPair<QStringList, QString> scope;
|
||||
|
||||
@@ -110,6 +110,10 @@ public:
|
||||
|
||||
void registerAutoCompletitionClass(int id, ACClassType ac_class, const QString & name, const QIcon & icon = QIcon());
|
||||
bool wordCompletitionEnabled() const { return word_complete; }
|
||||
bool isDarkTheme() const { return is_dark_theme; }
|
||||
|
||||
static QBrush invertedBrush(const QBrush & b);
|
||||
static QTextCharFormat invertedFormat(const QTextCharFormat & f);
|
||||
|
||||
protected:
|
||||
typedef QPair<QString, QString> StringsPair;
|
||||
@@ -230,6 +234,7 @@ private:
|
||||
void createBlockSelection();
|
||||
void cancelDragCursor();
|
||||
ACEntry findEntryOnCursor(QTextCursor tc, int arg = -1, ACClass * acc = nullptr, QPair<QStringList, QString> * scope = nullptr);
|
||||
void detectTheme();
|
||||
|
||||
Ui::QCodeEdit * ui;
|
||||
QCodeEditCompleter * completer;
|
||||
@@ -245,6 +250,7 @@ private:
|
||||
QTextCursor block_start_cursor, drag_cursor;
|
||||
int prev_lc, auto_comp_pl, timer_parse, timer_blink, cur_search_ind, pos_press, pos_el_press;
|
||||
int cursor_width;
|
||||
bool is_dark_theme = false;
|
||||
bool spaces_, _ignore_focus_out, _first, _destructor, _replacing;
|
||||
bool word_complete, help_visible, cursor_state, block_sel_state;
|
||||
};
|
||||
|
||||
@@ -60,7 +60,7 @@ void QCodeEditCompleter::addItems(QFont f, const QCodeEdit::ACClass & cl, const
|
||||
gi->setTextAlignment(0, Qt::AlignCenter);
|
||||
gi->setTextAlignment(1, Qt::AlignCenter);
|
||||
gi->setFont(0, f);
|
||||
gi->setBackground(0, Qt::lightGray);
|
||||
gi->setBackground(0, palette().window());
|
||||
gi->setFlags(Qt::ItemIsEnabled);
|
||||
addTopLevelItem(gi);
|
||||
gi->setFirstColumnSpanned(true);
|
||||
|
||||
Reference in New Issue
Block a user