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:
|
private:
|
||||||
Ui::QQtProgressDialog* ui;
|
Ui::QQtProgressDialog* ui;
|
||||||
QQTProgressBar* bar;
|
QQtProgressBar* bar;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QPROGRESSWINDOW_H
|
#endif // QPROGRESSWINDOW_H
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>QQtProgressDialog</class>
|
<class>QQtProgressDialog</class>
|
||||||
<widget class="QQtDialog" name="QQTProgressDialog">
|
<widget class="QQtDialog" name="QQtProgressDialog">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<string>Cancel</string>
|
<string>Cancel</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QQTProgressBar" name="widgetBar" native="true">
|
<widget class="QQtProgressBar" name="widgetBar" native="true">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>20</x>
|
<x>20</x>
|
||||||
@ -63,7 +63,7 @@
|
|||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>QQTProgressBar</class>
|
<class>QQtProgressBar</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>qqtprogressbar.h</header>
|
<header>qqtprogressbar.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
#define QQTWIFIDBWIDGET_H
|
#define QQTWIFIDBWIDGET_H
|
||||||
|
|
||||||
#include <qqtwidget.h>
|
#include <qqtwidget.h>
|
||||||
|
#include <qqt-local.h>
|
||||||
|
|
||||||
class QQtWifiDBWidget : public QQtWidget
|
class QQTSHARED_EXPORT QQtWifiDBWidget : public QQtWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_ENUMS(DB_STAT)
|
Q_ENUMS(DB_STAT)
|
||||||
|
@ -17,12 +17,16 @@ SOURCES += \
|
|||||||
$$PWD/svgwidgets/qqtsvgwidget.cpp \
|
$$PWD/svgwidgets/qqtsvgwidget.cpp \
|
||||||
$$PWD/svgwidgets/qqtsvgpushbutton.cpp \
|
$$PWD/svgwidgets/qqtsvgpushbutton.cpp \
|
||||||
$$PWD/svgwidgets/qqtsvgcheckbox.cpp \
|
$$PWD/svgwidgets/qqtsvgcheckbox.cpp \
|
||||||
$$PWD/svgwidgets/qqtsvgradiobutton.cpp
|
$$PWD/svgwidgets/qqtsvgradiobutton.cpp \
|
||||||
|
$$PWD/svgwidgets/qqtgraphicssvgitem.cpp \
|
||||||
|
$$PWD/svgwidgets/qqtsvglabel.cpp
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/svgwidgets/qqtsvgwidget.h \
|
$$PWD/svgwidgets/qqtsvgwidget.h \
|
||||||
$$PWD/svgwidgets/qqtsvgpushbutton.h \
|
$$PWD/svgwidgets/qqtsvgpushbutton.h \
|
||||||
$$PWD/svgwidgets/qqtsvgcheckbox.h \
|
$$PWD/svgwidgets/qqtsvgcheckbox.h \
|
||||||
$$PWD/svgwidgets/qqtsvgradiobutton.h
|
$$PWD/svgwidgets/qqtsvgradiobutton.h \
|
||||||
|
$$PWD/svgwidgets/qqtgraphicssvgitem.h \
|
||||||
|
$$PWD/svgwidgets/qqtsvglabel.h
|
||||||
|
|
||||||
#root dir
|
#root dir
|
||||||
HEADERS += $$PWD/qqt.h \
|
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 <qqtcheckbox.h>
|
||||||
#include <QSvgRenderer>
|
#include <QSvgRenderer>
|
||||||
#include <qqtwidgets.h>
|
#include <qqtwidgets.h>
|
||||||
|
#include <qqt-local.h>
|
||||||
|
|
||||||
class QQtSvgCheckBox : public QQtCheckBox
|
class QQTSHARED_EXPORT QQtSvgCheckBox : public QQtCheckBox
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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 <qqtpushbutton.h>
|
||||||
#include <QSvgRenderer>
|
#include <QSvgRenderer>
|
||||||
#include <qqtwidgets.h>
|
#include <qqtwidgets.h>
|
||||||
|
#include <qqt-local.h>
|
||||||
|
|
||||||
class QQtSvgPushButton : public QQtPushButton
|
class QQTSHARED_EXPORT QQtSvgPushButton : public QQtPushButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -4,8 +4,9 @@
|
|||||||
#include <qqtradiobutton.h>
|
#include <qqtradiobutton.h>
|
||||||
#include <QSvgRenderer>
|
#include <QSvgRenderer>
|
||||||
#include <qqtwidgets.h>
|
#include <qqtwidgets.h>
|
||||||
|
#include <qqt-local.h>
|
||||||
|
|
||||||
class QQtSvgRadioButton : public QQtRadioButton
|
class QQTSHARED_EXPORT QQtSvgRadioButton : public QQtRadioButton
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
#define QQTSVGWIDGET_H
|
#define QQTSVGWIDGET_H
|
||||||
|
|
||||||
#include <QSvgWidget>
|
#include <QSvgWidget>
|
||||||
|
#include <qqt-local.h>
|
||||||
|
|
||||||
class QQtSvgWidget : public QSvgWidget
|
class QQTSHARED_EXPORT QQtSvgWidget : public QSvgWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "qqtlistview.h"
|
#include "qqtlistview.h"
|
||||||
|
|
||||||
QQtListView::QQtListView(QWidget* parent) :
|
QQtListView::QQtListView ( QWidget* parent ) :
|
||||||
QListView(parent)
|
QListView ( parent )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ class QQTSHARED_EXPORT QQtListView : public QListView
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QQtListView(QWidget* parent = 0);
|
explicit QQtListView ( QWidget* parent = 0 );
|
||||||
virtual ~QQtListView();
|
virtual ~QQtListView ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
@ -5,45 +5,45 @@
|
|||||||
#include "QHBoxLayout"
|
#include "QHBoxLayout"
|
||||||
#include "QSpacerItem"
|
#include "QSpacerItem"
|
||||||
|
|
||||||
QQTProgressBar::QQTProgressBar(QWidget* parent) :
|
QQtProgressBar::QQtProgressBar ( QWidget* parent ) :
|
||||||
QWidget(parent),
|
QWidget ( parent ),
|
||||||
ui(new Ui::QQTProgressBar)
|
ui ( new Ui::QQtProgressBar )
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi ( this );
|
||||||
m_value = m_min = 0;
|
m_value = m_min = 0;
|
||||||
m_max = 100;
|
m_max = 100;
|
||||||
m_back = "./skin/default/bk_progress_background.png";
|
m_back = "./skin/default/bk_progress_background.png";
|
||||||
m_trunk = "./skin/default/bk_progress_trunk.png";
|
m_trunk = "./skin/default/bk_progress_trunk.png";
|
||||||
ui->widthTrunk->setPixmap(m_trunk);
|
ui->widthTrunk->setPixmap ( m_trunk );
|
||||||
ui->widgetBack->setPixmap(m_back);
|
ui->widgetBack->setPixmap ( m_back );
|
||||||
ui->widthTrunk->setType(QQtWidget::QQTTILEDWIDTH);
|
ui->widthTrunk->setType ( QQtWidget::QQTTILEDWIDTH );
|
||||||
ui->widgetBack->setType(QQtWidget::QQTZOOMWIDTH);
|
ui->widgetBack->setType ( QQtWidget::QQTZOOMWIDTH );
|
||||||
}
|
}
|
||||||
|
|
||||||
QQTProgressBar::~QQTProgressBar()
|
QQtProgressBar::~QQtProgressBar()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQTProgressBar::setPixMap(QString back, QString trunk)
|
void QQtProgressBar::setPixMap ( QString back, QString trunk )
|
||||||
{
|
{
|
||||||
m_back = back;
|
m_back = back;
|
||||||
m_trunk = trunk;
|
m_trunk = trunk;
|
||||||
ui->widthTrunk->setPixmap(m_trunk);
|
ui->widthTrunk->setPixmap ( m_trunk );
|
||||||
ui->widgetBack->setPixmap(m_back);
|
ui->widgetBack->setPixmap ( m_back );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQTProgressBar::setValue(int value)
|
void QQtProgressBar::setValue ( int value )
|
||||||
{
|
{
|
||||||
m_value = 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();
|
int h = ui->widgetBack->height();
|
||||||
ui->widthTrunk->setFixedSize(w, h);
|
ui->widthTrunk->setFixedSize ( w, h );
|
||||||
|
|
||||||
//pline() << width() << ui->widgetBack->width() << 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_min = min;
|
||||||
m_max = max;
|
m_max = max;
|
||||||
|
@ -11,24 +11,24 @@
|
|||||||
#include "qqtframe.h"
|
#include "qqtframe.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class QQTProgressBar;
|
class QQtProgressBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QQTSHARED_EXPORT QQTProgressBar : public QWidget
|
class QQTSHARED_EXPORT QQtProgressBar : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QQTProgressBar(QWidget* parent = 0);
|
explicit QQtProgressBar ( QWidget* parent = 0 );
|
||||||
~QQTProgressBar();
|
~QQtProgressBar();
|
||||||
|
|
||||||
void setPixMap(QString back, QString trunk);
|
void setPixMap ( QString back, QString trunk );
|
||||||
public slots:
|
public slots:
|
||||||
void setValue(int value);
|
void setValue ( int value );
|
||||||
void setRange(int min, int max);
|
void setRange ( int min, int max );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::QQTProgressBar* ui;
|
Ui::QQtProgressBar* ui;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_back, m_trunk;
|
QString m_back, m_trunk;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>QQTProgressBar</class>
|
<class>QQtProgressBar</class>
|
||||||
<widget class="QWidget" name="QQTProgressBar">
|
<widget class="QWidget" name="QQtProgressBar">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user