mirror of
https://gitee.com/drabel/LibQQt.git
synced 2025-01-04 10:18:44 +08:00
add svglabel svggraphicssvgitem
This commit is contained in:
parent
a94be27a51
commit
3d68da6d8d
@ -26,7 +26,7 @@ public slots:
|
||||
|
||||
private:
|
||||
Ui::QQtProgressDialog* ui;
|
||||
QQTProgressBar* bar;
|
||||
QQtProgressBar* bar;
|
||||
};
|
||||
|
||||
#endif // QPROGRESSWINDOW_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QQtProgressDialog</class>
|
||||
<widget class="QQtDialog" name="QQTProgressDialog">
|
||||
<widget class="QQtDialog" name="QQtProgressDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -26,7 +26,7 @@
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QQTProgressBar" name="widgetBar" native="true">
|
||||
<widget class="QQtProgressBar" name="widgetBar" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
@ -63,7 +63,7 @@
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>QQTProgressBar</class>
|
||||
<class>QQtProgressBar</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>qqtprogressbar.h</header>
|
||||
<container>1</container>
|
||||
|
@ -2,8 +2,9 @@
|
||||
#define QQTWIFIDBWIDGET_H
|
||||
|
||||
#include <qqtwidget.h>
|
||||
#include <qqt-local.h>
|
||||
|
||||
class QQtWifiDBWidget : public QQtWidget
|
||||
class QQTSHARED_EXPORT QQtWifiDBWidget : public QQtWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(DB_STAT)
|
||||
|
@ -17,12 +17,16 @@ SOURCES += \
|
||||
$$PWD/svgwidgets/qqtsvgwidget.cpp \
|
||||
$$PWD/svgwidgets/qqtsvgpushbutton.cpp \
|
||||
$$PWD/svgwidgets/qqtsvgcheckbox.cpp \
|
||||
$$PWD/svgwidgets/qqtsvgradiobutton.cpp
|
||||
$$PWD/svgwidgets/qqtsvgradiobutton.cpp \
|
||||
$$PWD/svgwidgets/qqtgraphicssvgitem.cpp \
|
||||
$$PWD/svgwidgets/qqtsvglabel.cpp
|
||||
HEADERS += \
|
||||
$$PWD/svgwidgets/qqtsvgwidget.h \
|
||||
$$PWD/svgwidgets/qqtsvgpushbutton.h \
|
||||
$$PWD/svgwidgets/qqtsvgcheckbox.h \
|
||||
$$PWD/svgwidgets/qqtsvgradiobutton.h
|
||||
$$PWD/svgwidgets/qqtsvgradiobutton.h \
|
||||
$$PWD/svgwidgets/qqtgraphicssvgitem.h \
|
||||
$$PWD/svgwidgets/qqtsvglabel.h
|
||||
|
||||
#root dir
|
||||
HEADERS += $$PWD/qqt.h \
|
||||
|
13
src/svgwidgets/qqtgraphicssvgitem.cpp
Normal file
13
src/svgwidgets/qqtgraphicssvgitem.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "qqtgraphicssvgitem.h"
|
||||
|
||||
QQtGraphicsSvgItem::QQtGraphicsSvgItem(QQtGraphicsSvgItem* parent) :
|
||||
QGraphicsSvgItem(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QQtGraphicsSvgItem::QQtGraphicsSvgItem(const QString& fileName, QQtGraphicsSvgItem* parentItem) :
|
||||
QGraphicsSvgItem(fileName, parentItem)
|
||||
{
|
||||
|
||||
}
|
19
src/svgwidgets/qqtgraphicssvgitem.h
Normal file
19
src/svgwidgets/qqtgraphicssvgitem.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef QQTGRAPHICSSVGITEM_H
|
||||
#define QQTGRAPHICSSVGITEM_H
|
||||
|
||||
#include <QGraphicsSvgItem>
|
||||
#include <qqt-local.h>
|
||||
|
||||
class QQTSHARED_EXPORT QQtGraphicsSvgItem : public QGraphicsSvgItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtGraphicsSvgItem(QQtGraphicsSvgItem* parent = nullptr);
|
||||
explicit QQtGraphicsSvgItem(const QString& fileName, QQtGraphicsSvgItem* parentItem = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // QQTGRAPHICSSVGITEM_H
|
@ -4,8 +4,9 @@
|
||||
#include <qqtcheckbox.h>
|
||||
#include <QSvgRenderer>
|
||||
#include <qqtwidgets.h>
|
||||
#include <qqt-local.h>
|
||||
|
||||
class QQtSvgCheckBox : public QQtCheckBox
|
||||
class QQTSHARED_EXPORT QQtSvgCheckBox : public QQtCheckBox
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
33
src/svgwidgets/qqtsvglabel.cpp
Normal file
33
src/svgwidgets/qqtsvglabel.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "qqtsvglabel.h"
|
||||
#include <QStylePainter>
|
||||
#include <QStyleOptionFrame>
|
||||
|
||||
QQtSvgLabel::QQtSvgLabel(QWidget* parent) : QQtLabel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QQtSvgLabel::setSvgFile(QString& filename)
|
||||
{
|
||||
mSvgRender.load(filename);
|
||||
}
|
||||
|
||||
void QQtSvgLabel::setSvgContent(QByteArray& bytes)
|
||||
{
|
||||
mSvgRender.load(bytes);
|
||||
}
|
||||
|
||||
|
||||
void QQtSvgLabel::paintEvent(QPaintEvent* event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
|
||||
QStylePainter p(this);
|
||||
if (mSvgRender.isValid())
|
||||
mSvgRender.render(&p);
|
||||
|
||||
bool enabled = isEnabled();
|
||||
QStyleOptionFrame opt;
|
||||
initStyleOption(&opt);
|
||||
p.drawItemText(rect(), alignment(), opt.palette, enabled, text());
|
||||
}
|
29
src/svgwidgets/qqtsvglabel.h
Normal file
29
src/svgwidgets/qqtsvglabel.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef QQTSVGLABEL_H
|
||||
#define QQTSVGLABEL_H
|
||||
|
||||
#include <qqtlabel.h>
|
||||
#include <QSvgRenderer>
|
||||
#include <qqt-local.h>
|
||||
|
||||
class QQTSHARED_EXPORT QQtSvgLabel : public QQtLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtSvgLabel(QWidget* parent = nullptr);
|
||||
|
||||
void setSvgFile(QString& filename);
|
||||
void setSvgContent(QByteArray& bytes);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent* event) override;
|
||||
|
||||
private:
|
||||
QSvgRenderer mSvgRender;
|
||||
};
|
||||
|
||||
#endif // QQTSVGLABEL_H
|
@ -4,8 +4,9 @@
|
||||
#include <qqtpushbutton.h>
|
||||
#include <QSvgRenderer>
|
||||
#include <qqtwidgets.h>
|
||||
#include <qqt-local.h>
|
||||
|
||||
class QQtSvgPushButton : public QQtPushButton
|
||||
class QQTSHARED_EXPORT QQtSvgPushButton : public QQtPushButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -4,8 +4,9 @@
|
||||
#include <qqtradiobutton.h>
|
||||
#include <QSvgRenderer>
|
||||
#include <qqtwidgets.h>
|
||||
#include <qqt-local.h>
|
||||
|
||||
class QQtSvgRadioButton : public QQtRadioButton
|
||||
class QQTSHARED_EXPORT QQtSvgRadioButton : public QQtRadioButton
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -2,8 +2,9 @@
|
||||
#define QQTSVGWIDGET_H
|
||||
|
||||
#include <QSvgWidget>
|
||||
#include <qqt-local.h>
|
||||
|
||||
class QQtSvgWidget : public QSvgWidget
|
||||
class QQTSHARED_EXPORT QQtSvgWidget : public QSvgWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "qqtlistview.h"
|
||||
|
||||
QQtListView::QQtListView(QWidget* parent) :
|
||||
QListView(parent)
|
||||
QQtListView::QQtListView ( QWidget* parent ) :
|
||||
QListView ( parent )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@ class QQTSHARED_EXPORT QQtListView : public QListView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQtListView(QWidget* parent = 0);
|
||||
virtual ~QQtListView();
|
||||
explicit QQtListView ( QWidget* parent = 0 );
|
||||
virtual ~QQtListView ();
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -5,45 +5,45 @@
|
||||
#include "QHBoxLayout"
|
||||
#include "QSpacerItem"
|
||||
|
||||
QQTProgressBar::QQTProgressBar(QWidget* parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::QQTProgressBar)
|
||||
QQtProgressBar::QQtProgressBar ( QWidget* parent ) :
|
||||
QWidget ( parent ),
|
||||
ui ( new Ui::QQtProgressBar )
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->setupUi ( this );
|
||||
m_value = m_min = 0;
|
||||
m_max = 100;
|
||||
m_back = "./skin/default/bk_progress_background.png";
|
||||
m_trunk = "./skin/default/bk_progress_trunk.png";
|
||||
ui->widthTrunk->setPixmap(m_trunk);
|
||||
ui->widgetBack->setPixmap(m_back);
|
||||
ui->widthTrunk->setType(QQtWidget::QQTTILEDWIDTH);
|
||||
ui->widgetBack->setType(QQtWidget::QQTZOOMWIDTH);
|
||||
ui->widthTrunk->setPixmap ( m_trunk );
|
||||
ui->widgetBack->setPixmap ( m_back );
|
||||
ui->widthTrunk->setType ( QQtWidget::QQTTILEDWIDTH );
|
||||
ui->widgetBack->setType ( QQtWidget::QQTZOOMWIDTH );
|
||||
}
|
||||
|
||||
QQTProgressBar::~QQTProgressBar()
|
||||
QQtProgressBar::~QQtProgressBar()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void QQTProgressBar::setPixMap(QString back, QString trunk)
|
||||
void QQtProgressBar::setPixMap ( QString back, QString trunk )
|
||||
{
|
||||
m_back = back;
|
||||
m_trunk = trunk;
|
||||
ui->widthTrunk->setPixmap(m_trunk);
|
||||
ui->widgetBack->setPixmap(m_back);
|
||||
ui->widthTrunk->setPixmap ( m_trunk );
|
||||
ui->widgetBack->setPixmap ( m_back );
|
||||
}
|
||||
|
||||
void QQTProgressBar::setValue(int value)
|
||||
void QQtProgressBar::setValue ( int value )
|
||||
{
|
||||
m_value = value;
|
||||
int w = ui->widgetBack->width() * (m_value - m_min) / (m_max - m_min);
|
||||
int w = ui->widgetBack->width() * ( m_value - m_min ) / ( m_max - m_min );
|
||||
int h = ui->widgetBack->height();
|
||||
ui->widthTrunk->setFixedSize(w, h);
|
||||
ui->widthTrunk->setFixedSize ( w, h );
|
||||
|
||||
//pline() << width() << ui->widgetBack->width() << w << h;
|
||||
}
|
||||
|
||||
void QQTProgressBar::setRange(int min, int max)
|
||||
void QQtProgressBar::setRange ( int min, int max )
|
||||
{
|
||||
m_min = min;
|
||||
m_max = max;
|
||||
|
@ -11,24 +11,24 @@
|
||||
#include "qqtframe.h"
|
||||
|
||||
namespace Ui {
|
||||
class QQTProgressBar;
|
||||
class QQtProgressBar;
|
||||
}
|
||||
|
||||
class QQTSHARED_EXPORT QQTProgressBar : public QWidget
|
||||
class QQTSHARED_EXPORT QQtProgressBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQTProgressBar(QWidget* parent = 0);
|
||||
~QQTProgressBar();
|
||||
explicit QQtProgressBar ( QWidget* parent = 0 );
|
||||
~QQtProgressBar();
|
||||
|
||||
void setPixMap(QString back, QString trunk);
|
||||
void setPixMap ( QString back, QString trunk );
|
||||
public slots:
|
||||
void setValue(int value);
|
||||
void setRange(int min, int max);
|
||||
void setValue ( int value );
|
||||
void setRange ( int min, int max );
|
||||
|
||||
private:
|
||||
Ui::QQTProgressBar* ui;
|
||||
Ui::QQtProgressBar* ui;
|
||||
|
||||
private:
|
||||
QString m_back, m_trunk;
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QQTProgressBar</class>
|
||||
<widget class="QWidget" name="QQTProgressBar">
|
||||
<class>QQtProgressBar</class>
|
||||
<widget class="QWidget" name="QQtProgressBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
|
Loading…
x
Reference in New Issue
Block a user