调整输出debug的接口,补全widget对象为空的判断

This commit is contained in:
tanjing 2024-01-18 11:39:05 +08:00
parent ea60b48fae
commit aff805d377
10 changed files with 166 additions and 173 deletions

View File

@ -40,7 +40,6 @@ MenuToolButton::MenuToolButton(QWidget *parent) : QToolButton(parent)
void MenuToolButton::tableModeChanged(bool isTableMode)
{
qDebug() << "tableModeChanged......" << isTableMode;
setStyle(ToolButtonStyle::getStyle());
}

View File

@ -305,7 +305,6 @@ QPlatformDialogHelper *Qt5UKUIPlatformTheme::createPlatformDialogHelper(DialogTy
QObject* plugin = nullptr;
const char* c = UKUIPLATFORMTHEME_DIR;
QString path = QString::fromUtf8(c);
qDebug() << "UKUIPLATFORMTHEME_DIR..." << path;
//QString path = UKUIPLATFORMTHEME_DIR;
if (QFile::exists(QString("%1/platformthemes/libqt5-ukui-filedialog.so").arg(path))) {

View File

@ -197,10 +197,10 @@ bool BlurHelper::shouldSkip(QWidget *w)
}
bool skip = true;
if (w->inherits("QComboBoxPrivateContainer"))
if (w && w->inherits("QComboBoxPrivateContainer"))
return true;
if (w->inherits("QMenu") || w->inherits("QTipLabel")) {
if (w && w->inherits("QMenu") || w->inherits("QTipLabel")) {
return false;
}

View File

@ -0,0 +1,102 @@
/*
* Qt5-UKUI's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see <https://www.gnu.org/licenses/>.
*
* Authors: Jing Tan <tanjing@kylinos.cn>
*
*/
#ifndef PLATFORMTHEMEDEBUG_H
#define PLATFORMTHEMEDEBUG_H
#include <QDebug>
//#define UKUIStyle_Debug
//#define AnimationSlider_Debug
//#define AnimationScrollbar_Debug
//#define UKUIStyle_Warning
class Debug
{
public:
template<typename T>
Debug & operator <<(const T&){return *this;}
};
inline Debug debug(){return Debug();}
#ifdef UKUIStyle_Debug
# define cDebug qDebug() << "UKUIStyle input:"
#else
# define cDebug Debug()
#endif
#ifdef AnimationSlider_Debug
# define aSliderDebug qDebug() << "UKUIStyle input:"
#else
# define aSliderDebug Debug()
#endif
#ifdef AnimationScrollbar_Debug
# define aScrollBarDebug qDebug() << "UKUIStyle input:"
#else
# define aScrollBarDebug Debug()
#endif
class Warning
{
public:
template<typename T>
Warning & operator <<(const T&){return *this;}
};
inline Warning warning(){return Warning();}
#ifdef UKUIStyle_Warning
# define cWarning qWarning() << "UKUIStyle input:"
#else
# define cWarning Warning()
#endif
#endif // PLATFORMTHEMEDEBUG_H

View File

@ -143,7 +143,7 @@ void UKUIConfigStyle::viewItemDrawText(QPainter *painter, const QStyleOptionView
QTextOption textOption;
textOption.setWrapMode(wrapText ? QTextOption::WordWrap : QTextOption::ManualWrap);
//FIX ME,bug106749::QTablewidget text cannot be aligned, forced changed it wrap mode to wrapanywhere
if(wrapText && (widget->inherits("QTableWidget") || widget->inherits("QTableView")))
if(wrapText && widget && (widget->inherits("QTableWidget") || widget->inherits("QTableView")))
{
textOption.setWrapMode(QTextOption::WrapAnywhere);
}

View File

@ -39,6 +39,7 @@
#include "settings/ukui-style-settings.h"
#include "ukui-config-style-parameters.h"
#include "settings/black-list.h"
#include "../platformthemedebug.h"
extern QColor configMixColor(const QColor &c1, const QColor &c2, qreal bias);
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
@ -3632,7 +3633,7 @@ void UKUIConfigStyleParameters::initConfigMenuParameters(bool isDark, const QSty
}
auto color = menuColorCfg.menuBackgroundBrush;
if (!widget->inherits("QComboBoxPrivateContainer") && UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) {
if (widget && !widget->inherits("QComboBoxPrivateContainer") && UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) {
auto opacity = UKUIStyleSettings::globalInstance()->get("menuTransparency").toInt()/100.0;
color.setAlphaF(opacity);
}

View File

@ -52,6 +52,7 @@
#include "../blur-helper.h"
#include "../gesture-helper.h"
#include "../window-manager.h"
#include "../platformthemedebug.h"
#include "settings/application-style-settings.h"
#include "settings/ukui-style-settings.h"
#include "effects/highlight-effect.h"
@ -319,10 +320,10 @@ bool UKUIConfigStyle::shouldBeTransparent(const QWidget *w) const
{
bool should = false;
if (w->inherits("QComboBoxPrivateContainer"))
if (w && w->inherits("QComboBoxPrivateContainer"))
return true;
if (w->inherits("QTipLabel")) {
if (w && w->inherits("QTipLabel")) {
return true;
}
@ -383,13 +384,10 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
if((e->type() ==QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) && (proxy()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons) == mousePressEvent->button() ||
proxy()->styleHint(QStyle::SH_Slider_PageSetButtons) == mousePressEvent->button())){
// qDebug() << "e->type:" << e->type() << mousePressEvent->button();
aSliderDebug << "e->type:" << e->type() << mousePressEvent->button();
if(obj->property("animation").isValid() && !obj->property("animation").toBool())
return false;
// if(!sp->m_SliderParameters.animation)
// return false;
auto *slider = qobject_cast<QSlider *>(obj);
if(slider == nullptr || !slider->isEnabled())
return false;
@ -400,19 +398,10 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
const bool horizontal = slider->orientation() == Qt::Horizontal;
// qDebug() << "MouseButtonPress............";
// if(mousePressEvent->button() != Qt::LeftButton)
// return false;
// if(mousePressEvent)
// qDebug() << "mousepressevent....." << mousePressEvent->pos() << mousePressEvent->localPos() << slider->geometry();
// QStyleOptionSlider *opt = new QStyleOptionSlider();
// opt->init(slider);
// qDebug() << "pppppppp;;;;;;;;;:" << subControlRect(CC_Slider, opt, SC_SliderHandle, slider);
aSliderDebug << "MouseButtonPress............";
QRect handleRect = sliderHandleRec(slider);
if(horizontal){
// qDebug() << "mousepressevent1111 pos...." << mousePressEvent->pos().x() << handleRect.x();
aSliderDebug << "mousepressevent1111 pos...." << mousePressEvent->pos().x() << handleRect.x();
if(mousePressEvent->pos().x() <= handleRect.x()){
animator->setExtraProperty("addValue", false);
@ -425,7 +414,7 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
return false;
}
else{
// qDebug() << "mousepressevent1111 pos...." << mousePressEvent->pos().y() << handleRect.y();
aSliderDebug << "mousepressevent1111 pos...." << mousePressEvent->pos().y() << handleRect.y();
if(mousePressEvent->pos().y() <= handleRect.y()){
animator->setExtraProperty("addValue", true);
@ -442,9 +431,9 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
if(startPosition <= slider->maximum() && startPosition >= slider->minimum()){
if(animator->value("move_position") != 1.0){
if(animator->getExtraProperty("addValue").isValid()){
// qDebug() << "pagestep..." << slider->pageStep() << animator->getExtraProperty("addValue").toBool();
aSliderDebug << "pagestep..." << slider->pageStep() << animator->getExtraProperty("addValue").toBool();
int step = (animator->getExtraProperty("addValue").toBool() ? 1 : -1) * slider->pageStep();
// qDebug() << "step............" << step;
aSliderDebug << "step............" << step;
bool absoluteButton = proxy()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons) == mousePressEvent->button();
if(absoluteButton)
{
@ -462,37 +451,37 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
sliderMin = gr.x();
sliderMax = gr.right() - sliderLength + 1;
pos = (mousePressEvent->pos() - center).x();
// qDebug() << "Horizontal pos....:" << mousePressEvent->pos() << center << pos;
aSliderDebug << "Horizontal pos....:" << mousePressEvent->pos() << center << pos;
} else {
sliderLength = sr.height();
sliderMin = gr.y();
sliderMax = gr.bottom() - sliderLength + 1;
pos = (mousePressEvent->pos() - center).y();
// qDebug() << "vertical pos....:" << mousePressEvent->pos() << center << pos;
aSliderDebug << "vertical pos....:" << mousePressEvent->pos() << center << pos;
}
// qDebug() << "minumum..." << slider->minimum() << slider->maximum() << sliderMin << sliderMax << pos << opt->upsideDown;
aSliderDebug << "minumum..." << slider->minimum() << slider->maximum() << sliderMin << sliderMax << pos << opt->upsideDown;
bool upsideDown = (slider->orientation() == Qt::Horizontal) ?
(slider->invertedAppearance() != (slider->layoutDirection() == Qt::RightToLeft))
: (!slider->invertedAppearance());
int sliderValue = sliderValueFromPosition(slider->minimum(), slider->maximum(), pos - sliderMin, sliderMax - sliderMin, upsideDown);//opt->upsideDown);
// qDebug() << "sliderValue....." << sliderValue << slider->value();
aSliderDebug << "sliderValue....." << sliderValue << slider->value();
step = sliderValue - slider->value();
// qDebug() << "step0000...." << step;
// qDebug() << "addValue........." << animator->getExtraProperty("addValue");
aSliderDebug << "step0000...." << step;
aSliderDebug << "addValue........." << animator->getExtraProperty("addValue");
}
animator->startAnimator("move_position");
int endPos = (startPosition + step) - (absoluteButton ? 0 : (startPosition + step)%step);
// qDebug() << "endPos0000....." << endPos;
aSliderDebug << "endPos0000....." << endPos;
if(!animator->getExtraProperty("addValue").toBool())
endPos = (startPosition + step) + (absoluteButton ? 0 : (((startPosition + step)%step > 0) ?(qAbs(step) - (startPosition + step)%step) : 0));
// qDebug() << "endPos1111....." << endPos;
aSliderDebug << "endPos1111....." << endPos;
if(animator->getExtraProperty("addValue").toBool())
endPos = qMin(endPos, slider->maximum());
else
endPos = qMax(endPos, slider->minimum());
// qDebug() << "endPos....." << endPos;
aSliderDebug << "endPos....." << endPos;
animator->setExtraProperty("end_position", endPos);
animator->setExtraProperty("start_position", startPosition);
@ -518,7 +507,6 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
bool midButtonAbsPos = proxy()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition, 0, scrollbar);
// if(mousePressEvent->button() != Qt::LeftButton)
// return false;
// qDebug() << "e->type......" << e->type();
if ((e->type() != QEvent::MouseButtonPress && e->type() != QEvent::MouseButtonDblClick)
|| (!(mousePressEvent->button() == Qt::LeftButton || (midButtonAbsPos && mousePressEvent->button() == Qt::MidButton))))
return false;
@ -529,7 +517,7 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
auto animator = m_scrollbar_animation_helper->animator(scrollbar);
if(!animator)
return false;
// qDebug() << "event..." << e->type() << mousePressEvent->button();
aScrollBarDebug << "event..." << e->type() << mousePressEvent->button();
const bool horizontal = scrollbar->orientation() == Qt::Horizontal;
QRect handleRect = scrollbarSliderRec(scrollbar);
@ -556,28 +544,26 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
}
if(!animator->isRunning("move_position")){
int startPosition = scrollbar->value();//scrollbar->sliderPosition();//sliderPositionFromValue(bar->minimum, bar->maximum, scrollBar->value(), maxlen - sliderlen, bar->upsideDown);
// qDebug() << "startPosition......." << startPosition << scrollbar->value();
int startPosition = scrollbar->value();
aScrollBarDebug << "startPosition......." << startPosition << scrollbar->value();
if(startPosition <= scrollbar->maximum() && startPosition >= scrollbar->minimum()){
// qDebug() << "CC_ScrollBar............" << animator->isRunning("move_position") << animator->currentAnimatorTime("move_position");
aScrollBarDebug << "CC_ScrollBar............" << animator->isRunning("move_position") << animator->currentAnimatorTime("move_position");
if(animator->value("move_position") != 1.0){
if(animator->getExtraProperty("addValue").isValid()){
// qDebug() << "pagestep..." << scrollbar->pageStep() << animator->getExtraProperty("addValue").toBool();
aScrollBarDebug << "pagestep..." << scrollbar->pageStep() << animator->getExtraProperty("addValue").toBool();
int step = (animator->getExtraProperty("addValue").toBool() ? 1 : -1) * scrollbar->pageStep();
// qDebug() << "step............" << step << animator->getExtraProperty("addValue").toBool();
aScrollBarDebug << "step............" << step << animator->getExtraProperty("addValue").toBool();
QStyleOptionSlider *opt = new QStyleOptionSlider();
opt->init(scrollbar);
// qDebug() << "scrollbar。。。。。。" << scrollbar;
// qDebug() << "11111111" << scrollbar->property("ScrollBarSliderRect").isValid();
aScrollBarDebug << "11111111" << scrollbar->property("ScrollBarSliderRect").isValid();
QRect sr = scrollbar->property("ScrollBarSliderRect").isValid() ?
scrollbar->property("ScrollBarSliderRect").value<QRect>() :
QRect();
// qDebug() << "sr......." << sr;
// qDebug() << "12333333" << scrollbar->property("ScrollBarGrooveRect").isValid();
aScrollBarDebug << "12333333" << scrollbar->property("ScrollBarGrooveRect").isValid();
QRect gr = scrollbar->property("ScrollBarGrooveRect").isValid() ?
scrollbar->property("ScrollBarGrooveRect").value<QRect>() :
QRect();
@ -592,7 +578,7 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
sliderLength = sr.width();
sliderMin = gr.x();
sliderMax = gr.right() - sliderLength + 1;
// qDebug() << "sliderLength....." << sliderLength << gr << gr.right();
aScrollBarDebug << "sliderLength....." << sliderLength << gr << gr.right();
pos = mousePressEvent->pos().x() - sliderLength / 2;
if (scrollbar->layoutDirection() == Qt::RightToLeft)
opt->upsideDown = !opt->upsideDown;
@ -605,31 +591,29 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
}
bool upsideDown = scrollbar->invertedAppearance();
// if(scrollbar->layoutDirection() == Qt::RightToLeft && scrollbar->orientation() == Qt::Horizontal)
// upsideDown = !upsideDown;
// qDebug() << "minimum..." << scrollbar->minimum() << scrollbar->maximum() << pos << sliderMin << sliderMax;
aScrollBarDebug << "minimum..." << scrollbar->minimum() << scrollbar->maximum() << pos << sliderMin << sliderMax;
int scrollValue = sliderValueFromPosition(scrollbar->minimum(), scrollbar->maximum(), pos - sliderMin,
sliderMax - sliderMin, upsideDown);//opt->upsideDown);
// qDebug() << "scrollValue....." << scrollValue << scrollbar->value();
aScrollBarDebug << "scrollValue....." << scrollValue << scrollbar->value();
step = scrollValue - scrollbar->value();
// qDebug() << "step0000...." << step;
// qDebug() << "addValue........." << animator->getExtraProperty("addValue");
aScrollBarDebug << "step0000...." << step;
aScrollBarDebug << "addValue........." << animator->getExtraProperty("addValue");
}
animator->startAnimator("move_position");
int endPos = (startPosition + step) - (absoluteButton ? 0 : (startPosition + step)%step);
// qDebug() << "endPos000....." << startPosition << step << endPos;
aScrollBarDebug << "endPos000....." << startPosition << step << endPos;
if(!animator->getExtraProperty("addValue").toBool())
endPos = (startPosition + step) + (absoluteButton ? 0 : (((startPosition + step)%step > 0) ?(qAbs(step) - (startPosition + step)%step) : 0));
// qDebug() << "endPos1111....." << endPos;
aScrollBarDebug << "endPos1111....." << endPos;
if(animator->getExtraProperty("addValue").toBool())
endPos = qMin(endPos, scrollbar->maximum());
else
endPos = qMax(endPos, scrollbar->minimum());
// qDebug() << "endPos....." << endPos;
aScrollBarDebug << "endPos....." << endPos;
animator->setExtraProperty("end_position", endPos);
animator->setExtraProperty("start_position", startPosition);
@ -963,7 +947,7 @@ void UKUIConfigStyle::polish(QWidget *widget)
}
}
if (qAppName() != "ukui-menu" || (qAppName() == "ukui-menu" && widget->inherits("QMenu"))) {
if (qAppName() != "ukui-menu" || (qAppName() == "ukui-menu" && widget && widget->inherits("QMenu"))) {
if (widget && widget->testAttribute(Qt::WA_TranslucentBackground) && widget->isTopLevel()) {
//FIXME:
#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
@ -1047,11 +1031,6 @@ void UKUIConfigStyle::polish(QWidget *widget)
if(qobject_cast<QSlider*>(widget)){
m_slider_animation_helper->registerWidget(widget);
// auto slider = qobject_cast<QSlider*>(widget);
// connect(slider, &QSlider::valueChanged, this, [=](int value){
// slide
// qDebug() << "slider valueChanged:" << value;
// });
}
/*!
\todo QDateTimeEdit widget affected with calendarPopup() draw QComboBox style or QSpinBox style.
@ -1143,7 +1122,6 @@ void UKUIConfigStyle::polish(QWidget *widget)
if(widget != nullptr && widget->inherits("QListView"))
{
auto listview = qobject_cast<QListView *>(widget);
// qDebug() << "listview is null0000: " << (listview == nullptr);
if(listview != nullptr)
{
connect(listview->selectionModel(), &QItemSelectionModel::selectionChanged, [listview](const QItemSelection &selected, const QItemSelection &deselected){
@ -1171,8 +1149,6 @@ void UKUIConfigStyle::polish(QWidget *widget)
if(!animator)
return;
//qDebug() <<"expanded index:" << index.internalId();
animator->setExtraProperty("expandItem", QString::number(index.internalId()));
if(animator->isRunning("collaps")){
@ -1191,8 +1167,6 @@ void UKUIConfigStyle::polish(QWidget *widget)
if(!animator)
return;
qDebug() <<"collapsed index:" << index.internalId();
animator->setExtraProperty("collapsItem", QString::number(index.internalId()));
if(animator->isRunning("expand")){
@ -1222,7 +1196,7 @@ void UKUIConfigStyle::unpolish(QWidget *widget)
qWarning() << "Can't resolve unregisterWidget from" << GESTURE_LIB << gestureLib.errorString();
}
}
if (qAppName() != "ukui-menu" || (qAppName() == "ukui-menu" && widget->inherits("QMenu"))) {
if (qAppName() != "ukui-menu" || (qAppName() == "ukui-menu" && widget && widget->inherits("QMenu"))) {
if (widget->testAttribute(Qt::WA_TranslucentBackground) && widget->isTopLevel()) {
#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
m_blur_helper->unregisterWidget(widget);
@ -1453,15 +1427,9 @@ QPixmap UKUIConfigStyle::testGeneratedSVGPixmap(QPixmap pixmap) const
QColor c(pixel);
int h, s, l, a;
c.getHsl(&h, &s, &l, &a);
qDebug() << "cccccccc0:" << h << s << l << a;
if(x ==0 && y ==0)
qDebug() << "000000000" << c.red() << c.green() << c.blue() << c.alpha();
s += a > 0 ? 82 : 0;
l += a > 0 ? 78 : 0;
c.setHsl(h, s, l, a);
if(x ==0 && y ==0)
qDebug() << "000000000" << c.red() << c.green() << c.blue() << c.alpha();
qDebug() << "cccccccc1:" << h << s << l << a;
*scanLine = c.rgba();//qRgba(c.red(), c.green(), c.blue(), c.alpha());
++scanLine;
@ -2338,7 +2306,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
QPixmap pixmap = icon.pixmap(iconsize, mode, QIcon::Off);
pixmap = proxy()->generatedIconPixmap(mode, pixmap, option);
QPixmap target = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget);
if(!sp->indicatorIconHoverNeedHighLight && !widget->inherits("QMenu"))
if(!sp->indicatorIconHoverNeedHighLight && widget && !widget->inherits("QMenu"))
target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget);
painter->save();
painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
@ -2382,7 +2350,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
QPixmap pixmap = icon.pixmap(iconsize, mode, QIcon::Off);
pixmap = proxy()->generatedIconPixmap(mode, pixmap, option);
QPixmap target = HighLightEffect::bothOrdinaryAndHoverGeneratePixmap(pixmap, option, widget);
if(!sp->indicatorIconHoverNeedHighLight && !widget->inherits("QMenu"))
if(!sp->indicatorIconHoverNeedHighLight && widget && !widget->inherits("QMenu"))
target = HighLightEffect::ordinaryGeneratePixmap(pixmap, option, widget);
painter->save();
painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
@ -2430,7 +2398,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
frameColor.blue() + value * (onDefaultPenColor.blue() - frameColor.blue()),
frameColor.alpha() + value * (onDefaultPenColor.alpha() - frameColor.alpha())));
QColor penColor = frameBrush.color();
// qDebug()<<"onDefaultPenColor......." << onDefaultPenColor.red() << onDefaultPenColor.green() << onDefaultPenColor.blue() << onDefaultPenColor.alphaF();
penColor.setAlphaF(onDefaultPenColor.alphaF());
painter->setPen(QPen(QBrush(penColor), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
@ -2451,7 +2418,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
else if (enable && hasAnimation &&
animator != nullptr && animator->isRunning("Off")) {
float value = animator->value("Off").toFloat();
// qDebug() << "off SunKenOn value......" << qobject_cast<const QRadioButton *>(widget)->text() << value;
QPen pen = sp->m_RadioButtonParameters.radioButtonDefaultPen;
pen.color().setAlphaF(sp->m_RadioButtonParameters.radioButtonDefaultPen.color().alphaF() * (1.0 - value));
painter->setPen(pen);
@ -2478,11 +2444,9 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
if (on) {
if (animator != nullptr) {
if (hasAnimation && !animator->isRunning("SunKenOn") ) {
// qDebug() << "SunKenOn time....:" << qobject_cast<const QRadioButton *>(widget)->text() << animator->currentAnimatorTime("SunKenOn");
if(animator->currentAnimatorTime("SunKenOn") == 0){
animator->startAnimator("SunKenOn");
animator->setAnimatorCurrentTime("Off", 0);
// qDebug() << "startAnimator SunKenOn......" << qobject_cast<const QRadioButton *>(widget)->text() << animator->currentAnimatorTime("Off");
painter->setPen(sp->m_RadioButtonParameters.radioButtonDefaultPen);
painter->setBrush(sp->m_RadioButtonParameters.radioButtonDefaultBrush);
painter->drawEllipse(rect);
@ -2582,7 +2546,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
if(animator->isRunning("OnBase"))
{
float value = animator->value("OnBase").toFloat();
// qDebug() << "onBase.....value:" << value;
margin = sp->m_CheckBoxParameters.checkBoxDefaultPen.width();
QColor onDefaultColor = mouseOver ? (!sp->m_CheckBoxParameters.onHoverBrushIslinearGradient ?
@ -2630,7 +2593,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
{
float value = animator->value("OnOpacity").toFloat();
// qDebug() << "OnOpacity.....value00000:" << value;
if (on) {
QBrush brush = sp->m_CheckBoxParameters.checkBoxContentPen.brush();
QColor color = brush.color();
@ -2656,7 +2618,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
if (hasAnimation && animator != nullptr && animator->isRunning("OnScale")) {
float value = animator->value("OnScale").toFloat();
// qDebug() << "OnScale.....value:" << value;
if (on) {
path.moveTo(pathrect.left() + width / 2 - 0.4 * width/4.0 - value * 0.6 * width /4.0, pathrect.top() + heigth / 2);
path.lineTo(pathrect.left() + width * 0.45, pathrect.bottom() - heigth / 3 - (1.0 - value) * heigth /8);
@ -2691,7 +2652,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
if (hasAnimation && animator != nullptr && animator->isRunning("Off")) {
float value = animator->value("Off").toFloat();
// qDebug() << "Off.....value:" << value;
margin = sp->m_CheckBoxParameters.checkBoxDefaultPen.width();
QPen pen = mouseOver ? sp->m_CheckBoxParameters.checkBoxHoverPen : sp->m_CheckBoxParameters.checkBoxDefaultPen;
@ -2705,7 +2665,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
defaultColor.green() + value * (onDefaultColor.green() - defaultColor.green()),
defaultColor.blue() + value * (onDefaultColor.blue() - defaultColor.blue()),
defaultColor.alpha() + value * (onDefaultColor.alpha() - defaultColor.alpha())));
// qDebug() << "sunkenon brush...." << brush.color().red() << brush.color().green() << brush.color().blue();
painter->setBrush(brush);
if(painter->pen().width() == 1 && sp->m_CheckBoxParameters.radius != 0)
painter->translate(0.5, 0.5);
@ -2713,9 +2672,7 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
painter->restore();
painter->save();
bool _nochange = animator->getExtraProperty("noChange").toBool();
// qDebug() << "_nochange.........." << _nochange;
if (!_nochange) {
// qDebug() << "off ......on,,,,,,,,,,,";
path.moveTo(pathrect.left() + width / 2 - 0.4 * width/4.0 - value * 0.6 * width /4.0, pathrect.top() + heigth / 2);
path.lineTo(pathrect.left() + width * 0.45, pathrect.bottom() - heigth / 3 - (1.0 - value) * heigth /8);
path.lineTo(pathrect.right() - width / 4 - (1.0 - value) * 0.6 * width /4.0, pathrect.top() + heigth / 3 + (1.0 - value) * heigth /6);
@ -2727,7 +2684,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
painter->setPen(QPen(brush, 1.5, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter->setRenderHint(QPainter::Antialiasing, true);
} else if (_nochange) {
// qDebug() << "off ......noChange,,,,,,,,,,,";
path.moveTo(pathrect.left() + width / 2 - 0.4 * width/4.0 - value * 0.6 * width /4.0, pathrect.center().y());
path.lineTo(pathrect.right() - width / 4 - (1.0 - value) * 0.6 * width /4.0 , pathrect.center().y());
@ -2764,9 +2720,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
painter->setPen(sp->m_CheckBoxParameters.checkBoxClickPen);
painter->setBrush(sp->m_CheckBoxParameters.checkBoxClickBrush);
// qDebug() << "start onscale............";
// painter->setPen(sp->m_CheckBoxParameters.checkBoxDefaultPen);
// painter->setBrush(Qt::yellow);//sp->m_CheckBoxParameters.checkBoxHoverPen);
if(painter->pen().width() == 1 && sp->m_CheckBoxParameters.radius != 0)
painter->translate(0.5, 0.5);
painter->drawRoundedRect(rect.adjusted(margin, margin, -margin, -margin), sp->m_CheckBoxParameters.radius, sp->m_CheckBoxParameters.radius);
@ -3096,7 +3049,6 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
}
int currentIndex = vi->index.row();
int allNum = listView->model()->rowCount();
// qDebug() << "index....." << currentIndex << allNum;
bool begin = false;
bool end = false;
@ -3107,15 +3059,12 @@ void UKUIConfigStyle::drawPrimitive(QStyle::PrimitiveElement element, const QSty
onlyOne = true;
}
else{
// qDebug() << "all index11111...." << listView->model()->rowCount();
QList<QModelIndex> selectList = listView->selectionModel()->selectedIndexes();
QList<int> selectIndexList;
foreach (QModelIndex index, selectList) {
int i = index.row();
selectIndexList.append(i);
}
// qDebug() << "selectIndexList...." << selectIndexList;
if(selectIndexList.contains(currentIndex - 1) && selectIndexList.contains(currentIndex +1))
mid = true;
else if(selectIndexList.contains(currentIndex - 1))
@ -5494,7 +5443,6 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp
drawRect.adjust(MenuItem_HMargin, sp->ComboBox_VMargin, -MenuItem_HMargin, -1 * sp->ComboBox_VMargin);
}
//qDebug() << "focus........." << focus << menuItem->text;
if (enable && (selected | sunken)) {
painter->save();
painter->setRenderHint(QPainter::Antialiasing);
@ -6456,9 +6404,9 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty
int sliderstart = lineLength + sliderPositionFromValue(bar->minimum, bar->maximum,
bar->sliderPosition,maxlen - sliderlen, bar->upsideDown) + distance / 2;
// qDebug() << "sliderstart0000......" << sliderstart << lineLength << bar->sliderPosition;
aScrollBarDebug << "sliderstart0000......" << sliderstart << lineLength << bar->sliderPosition;
if (animator && hasAnimation) {
// qDebug() << "bar value..." << bar->sliderValue << bar->sliderPosition;
aScrollBarDebug << "bar value..." << bar->sliderValue << bar->sliderPosition;
if(animator->isRunning("move_position") ||
(animator->getExtraProperty("start_position").toInt() !=
animator->getExtraProperty("end_position").toInt() &&
@ -6471,7 +6419,7 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty
int startValue = animator->getExtraProperty("start_position").toInt();
int endValue = animator->getExtraProperty("end_position").toInt();
int v = startValue + (endValue - startValue) * 1.0 * animator->value("move_position").toReal();
// qDebug() << "v...................." << v << startValue << endValue;
aScrollBarDebug << "v...................." << v << startValue << endValue;
if (v >= qMin(startValue, endValue) && v <= qMax(startValue, endValue)) {
sbar->setValue(v);
auto startPos = sliderPositionFromValue(bar->minimum, bar->maximum, startValue,
@ -6479,9 +6427,9 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty
auto endPos = sliderPositionFromValue(bar->minimum, bar->maximum,
endValue, maxlen - sliderlen, bar->upsideDown) + distance / 2;
// qDebug() << "startpos....:" << startPos << "endpos...:" << endPos;
aScrollBarDebug << "startpos....:" << startPos << "endpos...:" << endPos;
sliderstart = lineLength + startPos + (endPos - startPos) * 1.0 * animator->value("move_position").toReal();
// qDebug() << "sliderstart11111......" << sliderstart;
aScrollBarDebug << "sliderstart11111......" << sliderstart;
}
}
@ -6532,7 +6480,7 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty
case SC_ScrollBarSlider:
{
if(!animator->isRunning("move_position") && animator->currentAnimatorTime("move_position") != 0){
// qDebug() << "stop animator time.........";
aScrollBarDebug << "stop animator time.........";
animator->setAnimatorCurrentTime("move_position", 0);
animator->setExtraProperty("end_position", 0);
animator->setExtraProperty("start_position", 0);
@ -6543,7 +6491,7 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty
else
r = QRect(0, sliderstart, rect.width(), sliderlen);
QWidget *w = const_cast<QWidget *>(widget);
// qDebug() << "SC_ScrollBarSlider......" << w << r;
aScrollBarDebug << "SC_ScrollBarSlider......" << w << r;
w->setProperty("ScrollBarSliderRect", r);
return r;
}
@ -6556,7 +6504,7 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty
else
r = QRect(rect.x(), rect.y() + lineLength, rect.width(), rect.height() - 2 * lineLength);
QWidget *w = const_cast<QWidget *>(widget);
// qDebug() << "SC_ScrollBarGroove......" << w << r;
aScrollBarDebug << "SC_ScrollBarGroove......" << w << r;
w->setProperty("ScrollBarGrooveRect", r);
return r;
}
@ -6593,7 +6541,7 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty
int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderValue,
proxy()->pixelMetric(PM_SliderSpaceAvailable, option, widget), slider->upsideDown);
// qDebug() << "sliderPos000........" << sliderPos;
aScrollBarDebug << "sliderPos000........" << sliderPos;
bool hasAnimation = widget && ((widget->property("animation").isValid() && widget->property("animation").toBool()) ||
(!widget->property("animation").isValid()));
if (slider && animator && hasAnimation){
@ -6602,20 +6550,20 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty
animator->getExtraProperty("end_position").toInt() &&
slider->sliderValue != animator->getExtraProperty("end_position").toInt())) {
auto sliderBar = qobject_cast<const QAbstractSlider *>(widget);
// qDebug() << "value......." << subControl << slider->sliderValue << animator->getExtraProperty("start_position").toInt();
// qDebug() << "isrunning............." << animator->isRunning("move_position");
// qDebug() << "CC_Slider.....:" << animator->isRunning("move_position") << animator->value("move_position").toReal();
// qDebug() << "value:.........." << animator->value("move_position").toReal();
aScrollBarDebug << "value......." << subControl << slider->sliderValue << animator->getExtraProperty("start_position").toInt();
aScrollBarDebug << "isrunning............." << animator->isRunning("move_position");
aScrollBarDebug << "CC_Slider.....:" << animator->isRunning("move_position") << animator->value("move_position").toReal();
aScrollBarDebug << "value:.........." << animator->value("move_position").toReal();
QAbstractSlider *sbar = const_cast<QAbstractSlider *>(sliderBar);
if (sbar) {
int startValue = animator->getExtraProperty("start_position").toInt();
int endValue = animator->getExtraProperty("end_position").toInt();
// qDebug() << "startvalue:" << startValue << "endvalue:" << endValue
// << animator->getExtraProperty("start_position").toInt()
// << animator->getExtraProperty("end_position").toInt();
aScrollBarDebug << "startvalue:" << startValue << "endvalue:" << endValue
<< animator->getExtraProperty("start_position").toInt()
<< animator->getExtraProperty("end_position").toInt();
int v = startValue + (endValue - startValue) * 1.0 * animator->value("move_position").toReal();
// qDebug() << "vvvvvvvvvvv" << v;
aScrollBarDebug << "vvvvvvvvvvv" << v;
if(v >= qMin(startValue, endValue) && v <= qMax(startValue, endValue)){
sbar->setValue(startValue + (endValue - startValue) * 1.0 * animator->value("move_position").toReal());
@ -6624,9 +6572,9 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty
auto endPos = sliderPositionFromValue(slider->minimum, slider->maximum, endValue,
proxy()->pixelMetric(PM_SliderSpaceAvailable, option, widget), slider->upsideDown);
sliderPos = startPos + (endPos - startPos) * 1.0 * animator->value("move_position").toReal();
// qDebug() << "sliderPos1111........" << sliderPos;
aScrollBarDebug << "sliderPos1111........" << sliderPos;
}
// qDebug() << "sbar value:" << sbar->value();
aScrollBarDebug << "sbar value:" << sbar->value();
}
}
}
@ -6637,7 +6585,7 @@ QRect UKUIConfigStyle::subControlRect(QStyle::ComplexControl control, const QSty
animator->setAnimatorCurrentTime("move_position", 0);
animator->setExtraProperty("end_position", 0);
animator->setExtraProperty("start_position", 0);
// qDebug() << "setAnimatorCurrentTime0000000000000000" << animator->getExtraProperty("start_position").toInt() << animator->getExtraProperty("end_position").toInt();
aScrollBarDebug << "setAnimatorCurrentTime0000000000000000" << animator->getExtraProperty("start_position").toInt() << animator->getExtraProperty("end_position").toInt();
}
}
@ -7672,8 +7620,6 @@ QSize UKUIConfigStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
const bool horizontal(slider->orientation == Qt::Horizontal);
qDebug()<<"oldSize"<<newSize;
if (horizontal) {
newSize.setHeight(qMax(newSize.height() + 2 * sp->Slider_Margin, sp->Slider_DefaultWidth));
newSize.setWidth(qMax(newSize.width(), sp->Slider_DefaultLength));
@ -7681,9 +7627,6 @@ QSize UKUIConfigStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt
newSize.setWidth(qMax(newSize.width() + 2 * sp->Slider_Margin, sp->Slider_DefaultWidth));
newSize.setHeight(qMax(newSize.height(), sp->Slider_DefaultLength));
}
qDebug()<<"newSize"<<newSize;
return newSize;
}
break;

View File

@ -27,6 +27,7 @@
#include <QStringList>
#include <QStandardPaths>
#include <QMetaEnum>
#include "platformthemedebug.h"
ReadConfig::ReadConfig(const QString &cfg)
{

View File

@ -31,56 +31,6 @@
#include <QPalette>
#include "themeinformation.h"
//#define UKUIStyle_Debug
//#define UKUIStyle_Warning
class Debug
{
public:
template<typename T>
Debug & operator <<(const T&){return *this;}
};
inline Debug debug(){return Debug();}
#ifdef UKUIStyle_Debug
# define cDebug qDebug() << "UKUIStyle input:"
#else
# define cDebug Debug()
#endif
class Warning
{
public:
template<typename T>
Warning & operator <<(const T&){return *this;}
};
inline Warning warning(){return Warning();}
#ifdef UKUIStyle_Warning
# define cWarning qWarning() << "UKUIStyle input:"
#else
# define cWarning Warning()
#endif
class ReadConfig : public QObject
{

View File

@ -153,7 +153,6 @@ QStyle *UKUIStylePlugin::create(const QString &key)
auto widgetThemeName = settings->get("widgetThemeName").toString();
auto styleName = settings->get("styleName").toString();
qDebug() << "widgetThemeName........." << widgetThemeName;
if (widgetThemeName != "") {
if(qAppName() != blackStyleChangeApp) {
if (widgetThemeName == "classical") {
@ -223,7 +222,6 @@ void UKUIStylePlugin::tableModeChanged(bool isTableMode)
auto widgetThemeName = settings->get("widgetThemeName").toString();
auto styleName = settings->get("styleName").toString();
qDebug() << "widgetThemeName123........." << widgetThemeName;
if (widgetThemeName != "") {
if(qAppName() != blackStyleChangeApp) {
if (widgetThemeName == "classical") {