mirror of
https://gitee.com/drabel/LibQQt.git
synced 2025-01-04 10:18:44 +08:00
astyle format code
This commit is contained in:
parent
fd8bc21674
commit
1f7b5eda90
@ -1,6 +1,6 @@
|
||||
#include "qqtanimation.h"
|
||||
|
||||
QQTAnimation::QQTAnimation(QObject *parent) : QParallelAnimationGroup(parent)
|
||||
QQTAnimation::QQTAnimation(QObject* parent) : QParallelAnimationGroup(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class QQTSHARED_EXPORT QQTAnimation : public QParallelAnimationGroup
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQTAnimation(QObject *parent = nullptr);
|
||||
explicit QQTAnimation(QObject* parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -1,83 +1,83 @@
|
||||
#include "qqtcore.h"
|
||||
|
||||
|
||||
QByteArray &operator<<(QByteArray &l, const quint8 r)
|
||||
QByteArray& operator<<(QByteArray& l, const quint8 r)
|
||||
{
|
||||
return l.append(r);
|
||||
}
|
||||
|
||||
|
||||
QByteArray &operator<<(QByteArray &l, const quint16 r)
|
||||
QByteArray& operator<<(QByteArray& l, const quint16 r)
|
||||
{
|
||||
return l<<quint8(r>>8)<<quint8(r);
|
||||
return l << quint8(r >> 8) << quint8(r);
|
||||
}
|
||||
|
||||
|
||||
QByteArray &operator<<(QByteArray &l, const quint32 r)
|
||||
QByteArray& operator<<(QByteArray& l, const quint32 r)
|
||||
{
|
||||
return l<<quint16(r>>16)<<quint16(r);
|
||||
return l << quint16(r >> 16) << quint16(r);
|
||||
}
|
||||
|
||||
|
||||
QByteArray &operator<<(QByteArray &l, const QByteArray &r)
|
||||
QByteArray& operator<<(QByteArray& l, const QByteArray& r)
|
||||
{
|
||||
return l.append(r);
|
||||
}
|
||||
|
||||
|
||||
QByteArray &operator>>(QByteArray &l, quint8 &r)
|
||||
QByteArray& operator>>(QByteArray& l, quint8& r)
|
||||
{
|
||||
r = l.left(sizeof(quint8))[0];
|
||||
return l.remove(0, sizeof(quint8));
|
||||
}
|
||||
|
||||
|
||||
QByteArray &operator>>(QByteArray &l, quint16 &r)
|
||||
QByteArray& operator>>(QByteArray& l, quint16& r)
|
||||
{
|
||||
quint8 r0 = 0, r1 = 0;
|
||||
l >> r0 >> r1;
|
||||
r = ( r0 << 8 ) | r1;
|
||||
r = (r0 << 8) | r1;
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
QByteArray &operator>>(QByteArray &l, quint32 &r)
|
||||
QByteArray& operator>>(QByteArray& l, quint32& r)
|
||||
{
|
||||
quint8 r0 = 0, r1 = 0, r2 = 0, r3 = 0;
|
||||
l >> r0 >> r1 >> r2 >> r3;
|
||||
r = ( r0 << 24 ) | ( r1 << 16 ) | ( r2 << 8 ) | r3;
|
||||
r = (r0 << 24) | (r1 << 16) | (r2 << 8) | r3;
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
QByteArray &operator>>(QByteArray &l, QByteArray &r)
|
||||
QByteArray& operator>>(QByteArray& l, QByteArray& r)
|
||||
{
|
||||
r = l.left(r.size());
|
||||
return l.remove(0, r.size());
|
||||
}
|
||||
|
||||
QByteArray &operator<<(QByteArray &l, const qint8 r)
|
||||
QByteArray& operator<<(QByteArray& l, const qint8 r)
|
||||
{
|
||||
quint8 ubyte = quint8(r);
|
||||
l << ubyte;
|
||||
return l;
|
||||
}
|
||||
|
||||
QByteArray &operator<<(QByteArray &l, const qint16 r)
|
||||
QByteArray& operator<<(QByteArray& l, const qint16 r)
|
||||
{
|
||||
quint16 ubyte = quint16(r);
|
||||
l << ubyte;
|
||||
return l;
|
||||
}
|
||||
|
||||
QByteArray &operator<<(QByteArray &l, const qint32 r)
|
||||
QByteArray& operator<<(QByteArray& l, const qint32 r)
|
||||
{
|
||||
quint32 ubyte = quint32(r);
|
||||
l << ubyte;
|
||||
return l;
|
||||
}
|
||||
|
||||
QByteArray &operator>>(QByteArray &l, qint8 r)
|
||||
QByteArray& operator>>(QByteArray& l, qint8 r)
|
||||
{
|
||||
quint8 ubyte = 0;
|
||||
l >> ubyte;
|
||||
@ -85,7 +85,7 @@ QByteArray &operator>>(QByteArray &l, qint8 r)
|
||||
return l;
|
||||
}
|
||||
|
||||
QByteArray &operator>>(QByteArray &l, qint16 r)
|
||||
QByteArray& operator>>(QByteArray& l, qint16 r)
|
||||
{
|
||||
quint16 ubyte = 0;
|
||||
l >> ubyte;
|
||||
@ -93,7 +93,7 @@ QByteArray &operator>>(QByteArray &l, qint16 r)
|
||||
return l;
|
||||
}
|
||||
|
||||
QByteArray &operator>>(QByteArray &l, qint32 r)
|
||||
QByteArray& operator>>(QByteArray& l, qint32 r)
|
||||
{
|
||||
quint32 ubyte = 0;
|
||||
l >> ubyte;
|
||||
@ -105,7 +105,8 @@ void QQTSleep(int millsecond)
|
||||
{
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
while(timer.elapsed() < millsecond)
|
||||
|
||||
while (timer.elapsed() < millsecond)
|
||||
{
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
@ -139,32 +139,31 @@ public:
|
||||
explicit QQTBlock(QObject* parent = 0): QObject(parent), m_lock(0) {}
|
||||
|
||||
//0x7FFFFFFF
|
||||
bool lock(int millsecond = 0x7FFFFFFF)
|
||||
{
|
||||
bool lock(int millsecond = 0x7FFFFFFF) {
|
||||
//m_lock++;
|
||||
m_lock = 1;
|
||||
|
||||
timer.restart();
|
||||
while (timer.elapsed() < millsecond)
|
||||
{
|
||||
|
||||
while (timer.elapsed() < millsecond) {
|
||||
if (m_lock <= 0)
|
||||
break;
|
||||
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
if (timer.elapsed() >= millsecond)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
void unlock() {
|
||||
//m_lock--;
|
||||
m_lock = 0;
|
||||
}
|
||||
|
||||
bool isLocked()
|
||||
{
|
||||
bool isLocked() {
|
||||
if (m_lock <= 0)
|
||||
return false;
|
||||
|
||||
|
@ -23,14 +23,15 @@ public:
|
||||
* @param parent
|
||||
* @return
|
||||
*/
|
||||
static QObject* createObject(const QByteArray& className, QObject* parent = NULL)
|
||||
{
|
||||
static QObject* createObject(const QByteArray& className, QObject* parent = NULL) {
|
||||
/*
|
||||
* 搜索生成此类对象的函数
|
||||
*/
|
||||
Constructor constructor = constructors().value(className);
|
||||
|
||||
if (constructor == NULL)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* 生成对象,调用constructorHelper<className>(parent)
|
||||
*/
|
||||
@ -40,22 +41,20 @@ public:
|
||||
* @brief registerObject 将对象注册进工厂
|
||||
* @param w
|
||||
*/
|
||||
static void registerObject(const QObject* const& w)
|
||||
{
|
||||
static void registerObject(const QObject* const& w) {
|
||||
containers().push_back(w);
|
||||
}
|
||||
/**
|
||||
* @brief unregisterObject 取消对象在工厂中注册
|
||||
* @param w
|
||||
*/
|
||||
static void unregisterObject(const QObject*& w)
|
||||
{
|
||||
static void unregisterObject(const QObject*& w) {
|
||||
QListIterator<const QObject*> itor(containers());
|
||||
while (itor.hasNext())
|
||||
{
|
||||
|
||||
while (itor.hasNext()) {
|
||||
const QObject* ww = itor.next();
|
||||
if (ww == w)
|
||||
{
|
||||
|
||||
if (ww == w) {
|
||||
containers().removeOne(w);
|
||||
break;
|
||||
}
|
||||
@ -66,17 +65,17 @@ public:
|
||||
* @param objName
|
||||
* @return
|
||||
*/
|
||||
static const QObject* registedObject(const QString objName)
|
||||
{
|
||||
static const QObject* registedObject(const QString objName) {
|
||||
QListIterator<const QObject*> itor(containers());
|
||||
while (itor.hasNext())
|
||||
{
|
||||
|
||||
while (itor.hasNext()) {
|
||||
const QObject* ww = itor.next();
|
||||
if (ww->objectName() == objName)
|
||||
{
|
||||
|
||||
if (ww->objectName() == objName) {
|
||||
return ww;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -84,13 +83,11 @@ private:
|
||||
typedef QObject* (*Constructor)(QObject* parent);
|
||||
|
||||
template<typename T>
|
||||
static QObject* constructorHelper(QObject* parent)
|
||||
{
|
||||
static QObject* constructorHelper(QObject* parent) {
|
||||
return new T(parent);
|
||||
}
|
||||
|
||||
static QHash<QByteArray, Constructor>& constructors()
|
||||
{
|
||||
static QHash<QByteArray, Constructor>& constructors() {
|
||||
/*
|
||||
* 保存生成类对象的具体(非模板)函数
|
||||
*/
|
||||
@ -99,8 +96,7 @@ private:
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static void registerClass()
|
||||
{
|
||||
static void registerClass() {
|
||||
/*
|
||||
* 将生成此类对象的具体(非模板)函数注册进Hash
|
||||
*/
|
||||
@ -108,8 +104,7 @@ private:
|
||||
}
|
||||
|
||||
private:
|
||||
static QList<const QObject*>& containers()
|
||||
{
|
||||
static QList<const QObject*>& containers() {
|
||||
static QList<const QObject*> instance;
|
||||
return instance;
|
||||
}
|
||||
|
@ -25,35 +25,39 @@
|
||||
|
||||
#include "qcpdocumentobject.h"
|
||||
|
||||
QCPDocumentObject::QCPDocumentObject(QObject *parent) :
|
||||
QCPDocumentObject::QCPDocumentObject(QObject* parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QSizeF QCPDocumentObject::intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format)
|
||||
QSizeF QCPDocumentObject::intrinsicSize(QTextDocument* doc, int posInDocument, const QTextFormat& format)
|
||||
{
|
||||
Q_UNUSED(doc)
|
||||
Q_UNUSED(posInDocument)
|
||||
QPicture pic = qvariant_cast<QPicture>(format.property(PicturePropertyId));
|
||||
|
||||
if (pic.isNull())
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "Plot object is empty";
|
||||
return QSizeF(10, 10);
|
||||
} else
|
||||
}
|
||||
else
|
||||
return QSizeF(pic.boundingRect().size());
|
||||
}
|
||||
|
||||
void QCPDocumentObject::drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format)
|
||||
void QCPDocumentObject::drawObject(QPainter* painter, const QRectF& rect, QTextDocument* doc, int posInDocument,
|
||||
const QTextFormat& format)
|
||||
{
|
||||
Q_UNUSED(doc)
|
||||
Q_UNUSED(posInDocument)
|
||||
QPicture pic = qvariant_cast<QPicture>(format.property(PicturePropertyId));
|
||||
|
||||
if (pic.isNull())
|
||||
return;
|
||||
|
||||
QSize finalSize = pic.boundingRect().size();
|
||||
finalSize.scale(rect.size().toSize(), Qt::KeepAspectRatio);
|
||||
double scaleFactor = finalSize.width()/(double)pic.boundingRect().size().width();
|
||||
double scaleFactor = finalSize.width() / (double)pic.boundingRect().size().width();
|
||||
painter->save();
|
||||
painter->scale(scaleFactor, scaleFactor);
|
||||
painter->setClipRect(rect);
|
||||
@ -61,7 +65,7 @@ void QCPDocumentObject::drawObject(QPainter *painter, const QRectF &rect, QTextD
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QTextCharFormat QCPDocumentObject::generatePlotFormat(QCustomPlot *plot, int width, int height)
|
||||
QTextCharFormat QCPDocumentObject::generatePlotFormat(QCustomPlot* plot, int width, int height)
|
||||
{
|
||||
QPicture picture;
|
||||
QCPPainter qcpPainter;
|
||||
|
@ -42,11 +42,12 @@ public:
|
||||
enum { PlotTextFormat = QTextFormat::UserObject + 3902 }; // if your application already uses the id (QTextFormat::UserObject + 3902), just change the id here
|
||||
enum { PicturePropertyId = 1 };
|
||||
|
||||
explicit QCPDocumentObject(QObject *parent = 0);
|
||||
QSizeF intrinsicSize(QTextDocument *doc, int posInDocument, const QTextFormat &format);
|
||||
void drawObject(QPainter *painter, const QRectF &rect, QTextDocument *doc, int posInDocument, const QTextFormat &format);
|
||||
explicit QCPDocumentObject(QObject* parent = 0);
|
||||
QSizeF intrinsicSize(QTextDocument* doc, int posInDocument, const QTextFormat& format);
|
||||
void drawObject(QPainter* painter, const QRectF& rect, QTextDocument* doc, int posInDocument,
|
||||
const QTextFormat& format);
|
||||
|
||||
static QTextCharFormat generatePlotFormat(QCustomPlot *plot, int width=0, int height=0);
|
||||
static QTextCharFormat generatePlotFormat(QCustomPlot* plot, int width = 0, int height = 0);
|
||||
|
||||
};
|
||||
Q_DECLARE_METATYPE(QPicture)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -97,8 +97,7 @@ class QCPBars;
|
||||
/*!
|
||||
The QCP Namespace contains general enums and QFlags used throughout the QCustomPlot library
|
||||
*/
|
||||
namespace QCP
|
||||
{
|
||||
namespace QCP {
|
||||
/*!
|
||||
Defines the sides of a rectangular entity to which margins can be applied.
|
||||
|
||||
@ -202,10 +201,15 @@ inline void setMarginValue(QMargins& margins, QCP::MarginSide side, int value)
|
||||
switch (side)
|
||||
{
|
||||
case QCP::msLeft: margins.setLeft(value); break;
|
||||
|
||||
case QCP::msRight: margins.setRight(value); break;
|
||||
|
||||
case QCP::msTop: margins.setTop(value); break;
|
||||
|
||||
case QCP::msBottom: margins.setBottom(value); break;
|
||||
|
||||
case QCP::msAll: margins = QMargins(value, value, value, value); break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -222,11 +226,16 @@ inline int getMarginValue(const QMargins& margins, QCP::MarginSide side)
|
||||
switch (side)
|
||||
{
|
||||
case QCP::msLeft: return margins.left();
|
||||
|
||||
case QCP::msRight: return margins.right();
|
||||
|
||||
case QCP::msTop: return margins.top();
|
||||
|
||||
case QCP::msBottom: return margins.bottom();
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -753,7 +762,8 @@ protected:
|
||||
void sizeConstraintsChanged() const;
|
||||
void adoptElement(QCPLayoutElement* el);
|
||||
void releaseElement(QCPLayoutElement* el);
|
||||
QVector<int> getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes, QVector<double> stretchFactors, int totalSize) const;
|
||||
QVector<int> getSectionSizes(QVector<int> maxSizes, QVector<int> minSizes, QVector<double> stretchFactors,
|
||||
int totalSize) const;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QCPLayout)
|
||||
@ -1384,7 +1394,8 @@ protected:
|
||||
|
||||
virtual QByteArray generateLabelParameterHash() const;
|
||||
|
||||
virtual void placeTickLabel(QCPPainter* painter, double position, int distanceToAxis, const QString& text, QSize* tickLabelsSize);
|
||||
virtual void placeTickLabel(QCPPainter* painter, double position, int distanceToAxis, const QString& text,
|
||||
QSize* tickLabelsSize);
|
||||
virtual void drawTickLabel(QCPPainter* painter, double x, double y, const TickLabelData& labelData) const;
|
||||
virtual TickLabelData getTickLabelData(const QFont& font, const QString& text) const;
|
||||
virtual QPointF getTickLabelDrawOffset(const TickLabelData& labelData) const;
|
||||
@ -1814,7 +1825,8 @@ public:
|
||||
QList<QCPLegend*> selectedLegends() const;
|
||||
Q_SLOT void deselectAll();
|
||||
|
||||
bool savePdf(const QString& fileName, bool noCosmeticPen = false, int width = 0, int height = 0, const QString& pdfCreator = QString(), const QString& pdfTitle = QString());
|
||||
bool savePdf(const QString& fileName, bool noCosmeticPen = false, int width = 0, int height = 0,
|
||||
const QString& pdfCreator = QString(), const QString& pdfTitle = QString());
|
||||
bool savePng(const QString& fileName, int width = 0, int height = 0, double scale = 1.0, int quality = -1);
|
||||
bool saveJpg(const QString& fileName, int width = 0, int height = 0, double scale = 1.0, int quality = -1);
|
||||
bool saveBmp(const QString& fileName, int width = 0, int height = 0, double scale = 1.0);
|
||||
@ -1955,7 +1967,8 @@ public:
|
||||
void setPeriodic(bool enabled);
|
||||
|
||||
// non-property methods:
|
||||
void colorize(const double* data, const QCPRange& range, QRgb* scanLine, int n, int dataIndexFactor = 1, bool logarithmic = false);
|
||||
void colorize(const double* data, const QCPRange& range, QRgb* scanLine, int n, int dataIndexFactor = 1,
|
||||
bool logarithmic = false);
|
||||
QRgb color(double position, const QCPRange& range, bool logarithmic = false);
|
||||
void loadPreset(GradientPreset preset);
|
||||
void clearColorStops();
|
||||
@ -2550,11 +2563,15 @@ public:
|
||||
void setData(QCPDataMap* data, bool copy = false);
|
||||
void setData(const QVector<double>& key, const QVector<double>& value);
|
||||
void setDataKeyError(const QVector<double>& key, const QVector<double>& value, const QVector<double>& keyError);
|
||||
void setDataKeyError(const QVector<double>& key, const QVector<double>& value, const QVector<double>& keyErrorMinus, const QVector<double>& keyErrorPlus);
|
||||
void setDataKeyError(const QVector<double>& key, const QVector<double>& value, const QVector<double>& keyErrorMinus,
|
||||
const QVector<double>& keyErrorPlus);
|
||||
void setDataValueError(const QVector<double>& key, const QVector<double>& value, const QVector<double>& valueError);
|
||||
void setDataValueError(const QVector<double>& key, const QVector<double>& value, const QVector<double>& valueErrorMinus, const QVector<double>& valueErrorPlus);
|
||||
void setDataBothError(const QVector<double>& key, const QVector<double>& value, const QVector<double>& keyError, const QVector<double>& valueError);
|
||||
void setDataBothError(const QVector<double>& key, const QVector<double>& value, const QVector<double>& keyErrorMinus, const QVector<double>& keyErrorPlus, const QVector<double>& valueErrorMinus, const QVector<double>& valueErrorPlus);
|
||||
void setDataValueError(const QVector<double>& key, const QVector<double>& value, const QVector<double>& valueErrorMinus,
|
||||
const QVector<double>& valueErrorPlus);
|
||||
void setDataBothError(const QVector<double>& key, const QVector<double>& value, const QVector<double>& keyError,
|
||||
const QVector<double>& valueError);
|
||||
void setDataBothError(const QVector<double>& key, const QVector<double>& value, const QVector<double>& keyErrorMinus,
|
||||
const QVector<double>& keyErrorPlus, const QVector<double>& valueErrorMinus, const QVector<double>& valueErrorPlus);
|
||||
void setLineStyle(LineStyle ls);
|
||||
void setScatterStyle(const QCPScatterStyle& style);
|
||||
void setErrorType(ErrorType errorType);
|
||||
@ -2601,8 +2618,10 @@ protected:
|
||||
virtual void drawLegendIcon(QCPPainter* painter, const QRectF& rect) const;
|
||||
virtual QCPRange getKeyRange(bool& foundRange, SignDomain inSignDomain = sdBoth) const;
|
||||
virtual QCPRange getValueRange(bool& foundRange, SignDomain inSignDomain = sdBoth) const;
|
||||
virtual QCPRange getKeyRange(bool& foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface
|
||||
virtual QCPRange getValueRange(bool& foundRange, SignDomain inSignDomain, bool includeErrors) const; // overloads base class interface
|
||||
virtual QCPRange getKeyRange(bool& foundRange, SignDomain inSignDomain,
|
||||
bool includeErrors) const; // overloads base class interface
|
||||
virtual QCPRange getValueRange(bool& foundRange, SignDomain inSignDomain,
|
||||
bool includeErrors) const; // overloads base class interface
|
||||
|
||||
// introduced virtual methods:
|
||||
virtual void drawFill(QCPPainter* painter, QVector<QPointF>* lineData) const;
|
||||
@ -2621,7 +2640,8 @@ protected:
|
||||
void getImpulsePlotData(QVector<QPointF>* linePixelData, QVector<QCPData>* scatterData) const;
|
||||
void drawError(QCPPainter* painter, double x, double y, const QCPData& data) const;
|
||||
void getVisibleDataBounds(QCPDataMap::const_iterator& lower, QCPDataMap::const_iterator& upper) const;
|
||||
int countDataInBounds(const QCPDataMap::const_iterator& lower, const QCPDataMap::const_iterator& upper, int maxCount) const;
|
||||
int countDataInBounds(const QCPDataMap::const_iterator& lower, const QCPDataMap::const_iterator& upper,
|
||||
int maxCount) const;
|
||||
void addFillBasePoints(QVector<QPointF>* lineData) const;
|
||||
void removeFillBasePoints(QVector<QPointF>* lineData) const;
|
||||
QPointF lowerFillBasePoint(double lowerKey) const;
|
||||
@ -2728,11 +2748,15 @@ protected:
|
||||
// non-virtual methods:
|
||||
void getCurveData(QVector<QPointF>* lineData) const;
|
||||
int getRegion(double x, double y, double rectLeft, double rectTop, double rectRight, double rectBottom) const;
|
||||
QPointF getOptimizedPoint(int prevRegion, double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom) const;
|
||||
QVector<QPointF> getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom) const;
|
||||
QPointF getOptimizedPoint(int prevRegion, double prevKey, double prevValue, double key, double value, double rectLeft,
|
||||
double rectTop, double rectRight, double rectBottom) const;
|
||||
QVector<QPointF> getOptimizedCornerPoints(int prevRegion, int currentRegion, double prevKey, double prevValue,
|
||||
double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom) const;
|
||||
bool mayTraverse(int prevRegion, int currentRegion) const;
|
||||
bool getTraverse(double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop, double rectRight, double rectBottom, QPointF& crossA, QPointF& crossB) const;
|
||||
void getTraverseCornerPoints(int prevRegion, int currentRegion, double rectLeft, double rectTop, double rectRight, double rectBottom, QVector<QPointF>& beforeTraverse, QVector<QPointF>& afterTraverse) const;
|
||||
bool getTraverse(double prevKey, double prevValue, double key, double value, double rectLeft, double rectTop,
|
||||
double rectRight, double rectBottom, QPointF& crossA, QPointF& crossB) const;
|
||||
void getTraverseCornerPoints(int prevRegion, int currentRegion, double rectLeft, double rectTop, double rectRight,
|
||||
double rectBottom, QVector<QPointF>& beforeTraverse, QVector<QPointF>& afterTraverse) const;
|
||||
double pointDistance(const QPointF& pixelPoint) const;
|
||||
|
||||
friend class QCustomPlot;
|
||||
@ -3085,7 +3109,8 @@ public:
|
||||
|
||||
// non-property methods:
|
||||
void rescaleDataRange(bool recalculateDataBounds = false);
|
||||
Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode = Qt::SmoothTransformation, const QSize& thumbSize = QSize(32, 18));
|
||||
Q_SLOT void updateLegendIcon(Qt::TransformationMode transformMode = Qt::SmoothTransformation,
|
||||
const QSize& thumbSize = QSize(32, 18));
|
||||
|
||||
// reimplemented virtual methods:
|
||||
virtual void clearData();
|
||||
@ -3188,7 +3213,8 @@ public:
|
||||
|
||||
// setters:
|
||||
void setData(QCPFinancialDataMap* data, bool copy = false);
|
||||
void setData(const QVector<double>& key, const QVector<double>& open, const QVector<double>& high, const QVector<double>& low, const QVector<double>& close);
|
||||
void setData(const QVector<double>& key, const QVector<double>& open, const QVector<double>& high,
|
||||
const QVector<double>& low, const QVector<double>& close);
|
||||
void setChartStyle(ChartStyle style);
|
||||
void setWidth(double width);
|
||||
void setTwoColored(bool twoColored);
|
||||
@ -3201,7 +3227,8 @@ public:
|
||||
void addData(const QCPFinancialDataMap& dataMap);
|
||||
void addData(const QCPFinancialData& data);
|
||||
void addData(double key, double open, double high, double low, double close);
|
||||
void addData(const QVector<double>& key, const QVector<double>& open, const QVector<double>& high, const QVector<double>& low, const QVector<double>& close);
|
||||
void addData(const QVector<double>& key, const QVector<double>& open, const QVector<double>& high,
|
||||
const QVector<double>& low, const QVector<double>& close);
|
||||
void removeDataBefore(double key);
|
||||
void removeDataAfter(double key);
|
||||
void removeData(double fromKey, double toKey);
|
||||
@ -3212,7 +3239,8 @@ public:
|
||||
virtual double selectTest(const QPointF& pos, bool onlySelectable, QVariant* details = 0) const;
|
||||
|
||||
// static methods:
|
||||
static QCPFinancialDataMap timeSeriesToOhlc(const QVector<double>& time, const QVector<double>& value, double timeBinSize, double timeBinOffset = 0);
|
||||
static QCPFinancialDataMap timeSeriesToOhlc(const QVector<double>& time, const QVector<double>& value,
|
||||
double timeBinSize, double timeBinOffset = 0);
|
||||
|
||||
protected:
|
||||
// property members:
|
||||
@ -3230,10 +3258,14 @@ protected:
|
||||
virtual QCPRange getValueRange(bool& foundRange, SignDomain inSignDomain = sdBoth) const;
|
||||
|
||||
// non-virtual methods:
|
||||
void drawOhlcPlot(QCPPainter* painter, const QCPFinancialDataMap::const_iterator& begin, const QCPFinancialDataMap::const_iterator& end);
|
||||
void drawCandlestickPlot(QCPPainter* painter, const QCPFinancialDataMap::const_iterator& begin, const QCPFinancialDataMap::const_iterator& end);
|
||||
double ohlcSelectTest(const QPointF& pos, const QCPFinancialDataMap::const_iterator& begin, const QCPFinancialDataMap::const_iterator& end) const;
|
||||
double candlestickSelectTest(const QPointF& pos, const QCPFinancialDataMap::const_iterator& begin, const QCPFinancialDataMap::const_iterator& end) const;
|
||||
void drawOhlcPlot(QCPPainter* painter, const QCPFinancialDataMap::const_iterator& begin,
|
||||
const QCPFinancialDataMap::const_iterator& end);
|
||||
void drawCandlestickPlot(QCPPainter* painter, const QCPFinancialDataMap::const_iterator& begin,
|
||||
const QCPFinancialDataMap::const_iterator& end);
|
||||
double ohlcSelectTest(const QPointF& pos, const QCPFinancialDataMap::const_iterator& begin,
|
||||
const QCPFinancialDataMap::const_iterator& end) const;
|
||||
double candlestickSelectTest(const QPointF& pos, const QCPFinancialDataMap::const_iterator& begin,
|
||||
const QCPFinancialDataMap::const_iterator& end) const;
|
||||
void getVisibleDataBounds(QCPFinancialDataMap::const_iterator& lower, QCPFinancialDataMap::const_iterator& upper) const;
|
||||
|
||||
friend class QCustomPlot;
|
||||
@ -3599,7 +3631,8 @@ public:
|
||||
|
||||
// setters;
|
||||
void setPixmap(const QPixmap& pixmap);
|
||||
void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio, Qt::TransformationMode transformationMode = Qt::SmoothTransformation);
|
||||
void setScaled(bool scaled, Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio,
|
||||
Qt::TransformationMode transformationMode = Qt::SmoothTransformation);
|
||||
void setPen(const QPen& pen);
|
||||
void setSelectedPen(const QPen& pen);
|
||||
|
||||
|
103
src/dmmu/dmmu.c
103
src/dmmu/dmmu.c
@ -78,13 +78,17 @@ int dmmu_init()
|
||||
// MY_DBG("DMMU_GET_BASE_PHYS=0x%x, DMMU_MAP_USER_MEM=0x%x, DMMU_UNMAP_USER_MEM=0x%x",
|
||||
// DMMU_GET_BASE_PHYS, DMMU_MAP_USER_MEM, DMMU_UNMAP_USER_MEM);
|
||||
|
||||
if (dmmu_fd < 0) {
|
||||
if (dmmu_fd < 0)
|
||||
{
|
||||
dmmu_fd = open(DMMU_DEV_NAME, O_RDWR);
|
||||
if (dmmu_fd < 0) {
|
||||
|
||||
if (dmmu_fd < 0)
|
||||
{
|
||||
printf("DMMU: can't open device: %s\n", DMMU_DEV_NAME);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// android_atomic_inc(&g_dmmu_open_count);
|
||||
g_dmmu_open_count++;
|
||||
|
||||
@ -98,7 +102,8 @@ int dmmu_deinit()
|
||||
{
|
||||
ENTER();
|
||||
|
||||
if (dmmu_fd < 0) {
|
||||
if (dmmu_fd < 0)
|
||||
{
|
||||
printf("dmmu_fd < 0\n");
|
||||
return -1;
|
||||
}
|
||||
@ -106,7 +111,8 @@ int dmmu_deinit()
|
||||
// android_atomic_dec(&g_dmmu_open_count);
|
||||
g_dmmu_open_count--;
|
||||
|
||||
if (g_dmmu_open_count == 0) {
|
||||
if (g_dmmu_open_count == 0)
|
||||
{
|
||||
printf("g_dmmu_open_count is zero!\n");
|
||||
close(dmmu_fd); /* close fd */
|
||||
dmmu_fd = -1;
|
||||
@ -120,35 +126,44 @@ int dmmu_set_table_flag(void)
|
||||
int ret = 0;
|
||||
int flag = VIDEO_TABLE_FLAGE;
|
||||
|
||||
if (dmmu_fd < 0) {
|
||||
if (dmmu_fd < 0)
|
||||
{
|
||||
printf("dmmu_fd < 0\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = ioctl(dmmu_fd, DMMU_SET_TABLE_FLAG, &flag);
|
||||
if (ret < 0) {
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("DMMU_SET_TABLE_FLAG failed!!!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dmmu_get_page_table_base_phys(unsigned int *phys_addr)
|
||||
int dmmu_get_page_table_base_phys(unsigned int* phys_addr)
|
||||
{
|
||||
int ret = 0;
|
||||
ENTER();
|
||||
if (phys_addr == NULL) {
|
||||
|
||||
if (phys_addr == NULL)
|
||||
{
|
||||
printf("phys_addr is NULL!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dmmu_fd < 0) {
|
||||
if (dmmu_fd < 0)
|
||||
{
|
||||
printf("dmmu_fd < 0\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = ioctl(dmmu_fd, DMMU_GET_PAGE_TABLE_BASE_PHYS, phys_addr);
|
||||
if (ret < 0) {
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("dmmu_get_page_table_base_phys_addr ioctl(DMMU_GET_BASE_PHYS) failed, ret=%d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
@ -158,12 +173,13 @@ int dmmu_get_page_table_base_phys(unsigned int *phys_addr)
|
||||
}
|
||||
|
||||
/* NOTE: page_start and page_end maybe used both by two buffer. */
|
||||
int dmmu_map_user_mem(void * vaddr, int size)
|
||||
int dmmu_map_user_mem(void* vaddr, int size)
|
||||
{
|
||||
ENTER();
|
||||
//int i;
|
||||
|
||||
if (dmmu_fd < 0) {
|
||||
if (dmmu_fd < 0)
|
||||
{
|
||||
printf("dmmu_fd < 0\n");
|
||||
return -1;
|
||||
}
|
||||
@ -182,7 +198,9 @@ int dmmu_map_user_mem(void * vaddr, int size)
|
||||
|
||||
int ret = 0;
|
||||
ret = ioctl(dmmu_fd, DMMU_MAP_USER_MEM, &info);
|
||||
if (ret < 0) {
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("dmmu_map_user_memory ioctl(DMMU_MAP_USER_MEM) failed, ret=%d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
@ -190,22 +208,28 @@ int dmmu_map_user_mem(void * vaddr, int size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dmmu_unmap_user_mem(void * vaddr, int size)
|
||||
int dmmu_unmap_user_mem(void* vaddr, int size)
|
||||
{
|
||||
ENTER();
|
||||
|
||||
if (dmmu_fd < 0) {
|
||||
if (dmmu_fd < 0)
|
||||
{
|
||||
printf("dmmu_fd < 0\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct dmmu_mem_info info;
|
||||
|
||||
info.vaddr = vaddr;
|
||||
|
||||
info.size = size;
|
||||
|
||||
int ret = 0;
|
||||
|
||||
ret = ioctl(dmmu_fd, DMMU_UNMAP_USER_MEM, &info);
|
||||
if (ret < 0) {
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("dmmu_unmap_user_memory ioctl(DMMU_UNMAP_USER_MEM) failed, ret=%d\n", ret);
|
||||
return -1;
|
||||
}
|
||||
@ -214,21 +238,25 @@ int dmmu_unmap_user_mem(void * vaddr, int size)
|
||||
}
|
||||
|
||||
/* NOTE: page_start and page_end maybe used both by two buffer. */
|
||||
int dmmu_get_memory_physical_address(struct dmmu_mem_info * mem)
|
||||
int dmmu_get_memory_physical_address(struct dmmu_mem_info* mem)
|
||||
{
|
||||
ENTER();
|
||||
//int i;
|
||||
|
||||
if (dmmu_fd < 0) {
|
||||
if (dmmu_fd < 0)
|
||||
{
|
||||
printf("dmmu_fd < 0\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( mem == NULL ) {
|
||||
if (mem == NULL)
|
||||
{
|
||||
printf("mem == NULL\n");
|
||||
return -1;
|
||||
}
|
||||
if ( mem->pages_phys_addr_table != NULL ) {
|
||||
|
||||
if (mem->pages_phys_addr_table != NULL)
|
||||
{
|
||||
printf("mem->pages_phys_addr_table != NULL\n");
|
||||
return -1;
|
||||
}
|
||||
@ -238,33 +266,41 @@ int dmmu_get_memory_physical_address(struct dmmu_mem_info * mem)
|
||||
init_page_count(mem);
|
||||
|
||||
/* alloc page table space, pages_table filled by dmmu kernel driver. */
|
||||
if ( 1 ) {
|
||||
void *pages_phys_addr;
|
||||
if (1)
|
||||
{
|
||||
void* pages_phys_addr;
|
||||
int page_table_size = mem->page_count * sizeof(int);
|
||||
pages_phys_addr = (void *)malloc(page_table_size);
|
||||
pages_phys_addr = (void*)malloc(page_table_size);
|
||||
memset((void*)pages_phys_addr, 0, page_table_size);
|
||||
MY_DBG("pages_phys_addr: %p\n", pages_phys_addr);
|
||||
mem->pages_phys_addr_table = pages_phys_addr;
|
||||
}
|
||||
|
||||
if ( mem->pages_phys_addr_table ) {
|
||||
if (mem->pages_phys_addr_table)
|
||||
{
|
||||
int ret = 0;
|
||||
ret = ioctl(dmmu_fd, DMMU_GET_TLB_PHYS, mem);
|
||||
if (ret < 0) {
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("get dmmu tlb phys addr failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
MY_DBG("Map mem phys_addr = 0x%08x\n", mem->paddr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dmmu_release_memory_physical_address(struct dmmu_mem_info* mem)
|
||||
{
|
||||
if ( mem->pages_phys_addr_table ) {
|
||||
if (mem->pages_phys_addr_table)
|
||||
{
|
||||
free(mem->pages_phys_addr_table);
|
||||
mem->pages_phys_addr_table = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -281,15 +317,18 @@ int dmmu_unmap_user_memory(struct dmmu_mem_info* mem)
|
||||
return dmmu_unmap_user_mem(mem->vaddr, mem->size);
|
||||
}
|
||||
|
||||
int dmmu_match_user_mem_tlb(void * vaddr, int size)
|
||||
int dmmu_match_user_mem_tlb(void* vaddr, int size)
|
||||
{
|
||||
if (vaddr==NULL)
|
||||
if (vaddr == NULL)
|
||||
return 1;
|
||||
volatile unsigned char * pc;
|
||||
pc = (unsigned char *)vaddr;
|
||||
int pn = size/PAGE_SIZE;
|
||||
|
||||
volatile unsigned char* pc;
|
||||
pc = (unsigned char*)vaddr;
|
||||
int pn = size / PAGE_SIZE;
|
||||
int pg;
|
||||
for(pg=0; pg<pn; pg++ ) {
|
||||
|
||||
for (pg = 0; pg < pn; pg++)
|
||||
{
|
||||
//volatile unsigned char c = *( volatile unsigned char*)pc;
|
||||
pc += PAGE_SIZE;
|
||||
}
|
||||
|
@ -19,29 +19,30 @@ __BEGIN_DECLS
|
||||
|
||||
#define VIDEO_TABLE_FLAGE 1
|
||||
|
||||
struct dmmu_mem_info {
|
||||
struct dmmu_mem_info
|
||||
{
|
||||
int size;
|
||||
int page_count;
|
||||
|
||||
unsigned int paddr;
|
||||
|
||||
void *vaddr;
|
||||
void *pages_phys_addr_table;
|
||||
void* vaddr;
|
||||
void* pages_phys_addr_table;
|
||||
|
||||
unsigned int start_offset;
|
||||
unsigned int end_offset;
|
||||
};
|
||||
|
||||
static inline void init_page_count(struct dmmu_mem_info *info)
|
||||
static inline void init_page_count(struct dmmu_mem_info* info)
|
||||
{
|
||||
int page_count;
|
||||
#ifdef __EMBEDDED_LINUX__
|
||||
unsigned int start; /* page start */
|
||||
unsigned int end; /* page end */
|
||||
|
||||
start = ((unsigned int)info->vaddr) & (~(DMMU_PAGE_SIZE-1));
|
||||
end = ((unsigned int)info->vaddr + (info->size-1)) & (~(DMMU_PAGE_SIZE-1));
|
||||
page_count = (end - start)/(DMMU_PAGE_SIZE) + 1;
|
||||
start = ((unsigned int)info->vaddr) & (~(DMMU_PAGE_SIZE - 1));
|
||||
end = ((unsigned int)info->vaddr + (info->size - 1)) & (~(DMMU_PAGE_SIZE - 1));
|
||||
page_count = (end - start) / (DMMU_PAGE_SIZE) + 1;
|
||||
|
||||
info->page_count = page_count;
|
||||
info->start_offset = (unsigned int)info->vaddr - start;
|
||||
@ -51,9 +52,9 @@ static inline void init_page_count(struct dmmu_mem_info *info)
|
||||
unsigned long start; /* page start */
|
||||
unsigned long end; /* page end */
|
||||
|
||||
start = ((unsigned long)info->vaddr) & (~(DMMU_PAGE_SIZE-1));
|
||||
end = ((unsigned long)info->vaddr + (info->size-1)) & (~(DMMU_PAGE_SIZE-1));
|
||||
page_count = (end - start)/(DMMU_PAGE_SIZE) + 1;
|
||||
start = ((unsigned long)info->vaddr) & (~(DMMU_PAGE_SIZE - 1));
|
||||
end = ((unsigned long)info->vaddr + (info->size - 1)) & (~(DMMU_PAGE_SIZE - 1));
|
||||
page_count = (end - start) / (DMMU_PAGE_SIZE) + 1;
|
||||
|
||||
info->page_count = page_count;
|
||||
info->start_offset = (unsigned long)info->vaddr - start;
|
||||
@ -64,13 +65,15 @@ static inline void init_page_count(struct dmmu_mem_info *info)
|
||||
return;
|
||||
}
|
||||
|
||||
static inline int dump_mem_info(struct dmmu_mem_info *mem, char * description)
|
||||
static inline int dump_mem_info(struct dmmu_mem_info* mem, char* description)
|
||||
{
|
||||
if (mem == NULL) {
|
||||
if (mem == NULL)
|
||||
{
|
||||
printf("mem is NULL!\n");
|
||||
return -1;
|
||||
}
|
||||
printf("mem: %p, \t%s\n", mem, description?description:"");
|
||||
|
||||
printf("mem: %p, \t%s\n", mem, description ? description : "");
|
||||
printf("\tvaddr= %p\n", mem->vaddr);
|
||||
printf("\tsize= %d (0x%x)\n", mem->size, mem->size);
|
||||
printf("\tpaddr= 0x%08x\n", mem->paddr);
|
||||
@ -82,24 +85,25 @@ static inline int dump_mem_info(struct dmmu_mem_info *mem, char * description)
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum REQUIRE_ALLOC_PAGE_TABLE {
|
||||
enum REQUIRE_ALLOC_PAGE_TABLE
|
||||
{
|
||||
NO_REQUIRED = 0,
|
||||
REQUIRED = 1,
|
||||
};
|
||||
|
||||
QQTSHARED_EXPORT extern int dmmu_init();
|
||||
QQTSHARED_EXPORT extern int dmmu_set_table_flag(void);
|
||||
QQTSHARED_EXPORT extern int dmmu_init_with_set_page_table(unsigned int * phys_addr, int size);
|
||||
QQTSHARED_EXPORT extern int dmmu_init_with_set_page_table(unsigned int* phys_addr, int size);
|
||||
QQTSHARED_EXPORT extern int dmmu_deinit();
|
||||
QQTSHARED_EXPORT extern int dmmu_get_page_table_base_phys(unsigned int * phys_addr);
|
||||
QQTSHARED_EXPORT extern int dmmu_set_page_table(unsigned int * phys_addr, int size);
|
||||
QQTSHARED_EXPORT extern int dmmu_get_page_table_base_phys(unsigned int* phys_addr);
|
||||
QQTSHARED_EXPORT extern int dmmu_set_page_table(unsigned int* phys_addr, int size);
|
||||
QQTSHARED_EXPORT extern int dmmu_map_user_memory(struct dmmu_mem_info* mem);
|
||||
QQTSHARED_EXPORT extern int dmmu_unmap_user_memory(struct dmmu_mem_info* mem);
|
||||
|
||||
QQTSHARED_EXPORT extern int dmmu_map_user_mem(void * vaddr, int size);
|
||||
QQTSHARED_EXPORT extern int dmmu_unmap_user_mem(void * vaddr, int size);
|
||||
QQTSHARED_EXPORT extern int dmmu_map_user_mem(void* vaddr, int size);
|
||||
QQTSHARED_EXPORT extern int dmmu_unmap_user_mem(void* vaddr, int size);
|
||||
|
||||
QQTSHARED_EXPORT extern int dmmu_match_user_mem_tlb(void * vaddr, int size);
|
||||
QQTSHARED_EXPORT extern int dmmu_match_user_mem_tlb(void* vaddr, int size);
|
||||
|
||||
QQTSHARED_EXPORT extern int dmmu_get_memory_physical_address(struct dmmu_mem_info* mem);
|
||||
QQTSHARED_EXPORT extern int dmmu_release_memory_physical_address(struct dmmu_mem_info* mem);
|
||||
|
@ -39,7 +39,8 @@ extern "C" {
|
||||
* pixel format definitions
|
||||
*/
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
HAL_PIXEL_FORMAT_RGBA_8888 = 1,
|
||||
HAL_PIXEL_FORMAT_RGBX_8888 = 2,
|
||||
HAL_PIXEL_FORMAT_RGB_888 = 3,
|
||||
@ -131,7 +132,8 @@ enum {
|
||||
*
|
||||
*/
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
/* flip source image horizontally (around the vertical axis) */
|
||||
HAL_TRANSFORM_FLIP_H = 0x01,
|
||||
/* flip source image vertically (around the horizontal axis)*/
|
||||
|
@ -6,17 +6,19 @@
|
||||
|
||||
// android/hardware/libhardware/include/hardware/camera.h
|
||||
struct camera_memory;
|
||||
typedef void (*camera_release_memory)(struct camera_memory *mem);
|
||||
typedef void (*camera_release_memory)(struct camera_memory* mem);
|
||||
|
||||
typedef struct camera_memory {
|
||||
void *data;
|
||||
typedef struct camera_memory
|
||||
{
|
||||
void* data;
|
||||
size_t size;
|
||||
void *handle;
|
||||
void* handle;
|
||||
camera_release_memory release;
|
||||
} camera_memory_t;
|
||||
|
||||
// android/hardware/xb4780/libcamera2/include/CameraDeviceCommon.h
|
||||
struct camera_buffer {
|
||||
struct camera_buffer
|
||||
{
|
||||
struct camera_memory* common;
|
||||
struct dmmu_mem_info dmmu_info;
|
||||
CameraYUVMeta yuvMeta[5];
|
||||
|
@ -67,7 +67,8 @@
|
||||
|
||||
// Values for white balance settings.
|
||||
#define WHITE_BALANCEVALUES_NUM 9
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
WHITE_BALANCE_AUTO = 0x1 << 0,
|
||||
WHITE_BALANCE_INCANDESCENT = 0x1 << 1,
|
||||
WHITE_BALANCE_FLUORESCENT = 0x1 << 2,
|
||||
@ -80,7 +81,8 @@ enum {
|
||||
};
|
||||
// Values for effect settings.
|
||||
#define EFFECTVALUES_NUM 12
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
EFFECT_NONE = 0x1 << 0,
|
||||
EFFECT_MONO = 0x1 << 1,
|
||||
EFFECT_NEGATIVE = 0x1 << 2,
|
||||
@ -96,7 +98,8 @@ enum {
|
||||
};
|
||||
// Values for antibanding settings.
|
||||
#define ANTIBANVALUES_NUM 4
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
ANTIBANDING_AUTO = 0x1 << 0,
|
||||
ANTIBANDING_50HZ = 0x1 << 1,
|
||||
ANTIBANDING_60HZ = 0x1 << 2,
|
||||
@ -104,7 +107,8 @@ enum {
|
||||
};
|
||||
// Values for flash mode settings.
|
||||
#define FLASHMODE_NUM 6
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
FLASH_MODE_OFF = 0x1 << 0,
|
||||
FLASH_MODE_AUTO = 0x1 << 1,
|
||||
FLASH_MODE_ON = 0x1 << 2,
|
||||
@ -114,7 +118,8 @@ enum {
|
||||
};
|
||||
// Values for scene mode settings.
|
||||
#define SCENEVALUES_NUM 16
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
SCENE_MODE_AUTO = 0x1 << 0,
|
||||
SCENE_MODE_ACTION = 0x1 << 1,
|
||||
SCENE_MODE_PORTRAIT = 0x1 << 2,
|
||||
@ -134,27 +139,29 @@ enum {
|
||||
};
|
||||
// Values for focus mode settings.
|
||||
#define FOCUSMODE_NUM 7
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
FOCUS_MODE_FIXED = 0x1 << 0,
|
||||
FOCUS_MODE_AUTO = 0x1 << 1,
|
||||
FOCUS_MODE_INFINITY = 0x1 << 2,
|
||||
FOCUS_MODE_MACRO = 0x1 << 3,
|
||||
FOCUS_MODE_CONTINUOUS_VIDEO = 0x1<<4,
|
||||
FOCUS_MODE_CONTINUOUS_PICTURE = 0x1<<5,
|
||||
FOCUS_MODE_EDOF = 0x1<<6,
|
||||
FOCUS_MODE_CONTINUOUS_VIDEO = 0x1 << 4,
|
||||
FOCUS_MODE_CONTINUOUS_PICTURE = 0x1 << 5,
|
||||
FOCUS_MODE_EDOF = 0x1 << 6,
|
||||
};
|
||||
#define PREVIEWFORMAT_NUM 10
|
||||
enum PreviewFormat {
|
||||
PIXEL_FORMAT_YUV422SP = 0x1<<0,
|
||||
PIXEL_FORMAT_YUV420SP = 0x1<<1,
|
||||
PIXEL_FORMAT_YUV422I = 0x1<<2,
|
||||
PIXEL_FORMAT_RGB565 = 0x1<<3,
|
||||
PIXEL_FORMAT_JPEG = 0x1<<4,
|
||||
PIXEL_FORMAT_YUV420P = 0x1<<5,
|
||||
PIXEL_FORMAT_JZ_YUV420T = 0x1<<6,
|
||||
PIXEL_FORMAT_JZ_YUV420P = 0x1<<7,
|
||||
PIXEL_FORMAT_RGBA8888 = 0x1<<8,
|
||||
PIXEL_FORMAT_BAYER_RGGB = 0x1<<9
|
||||
enum PreviewFormat
|
||||
{
|
||||
PIXEL_FORMAT_YUV422SP = 0x1 << 0,
|
||||
PIXEL_FORMAT_YUV420SP = 0x1 << 1,
|
||||
PIXEL_FORMAT_YUV422I = 0x1 << 2,
|
||||
PIXEL_FORMAT_RGB565 = 0x1 << 3,
|
||||
PIXEL_FORMAT_JPEG = 0x1 << 4,
|
||||
PIXEL_FORMAT_YUV420P = 0x1 << 5,
|
||||
PIXEL_FORMAT_JZ_YUV420T = 0x1 << 6,
|
||||
PIXEL_FORMAT_JZ_YUV420P = 0x1 << 7,
|
||||
PIXEL_FORMAT_RGBA8888 = 0x1 << 8,
|
||||
PIXEL_FORMAT_BAYER_RGGB = 0x1 << 9
|
||||
};
|
||||
|
||||
// Values for fps mode settings.
|
||||
@ -199,12 +206,14 @@ enum PreviewFormat {
|
||||
#define SATURATION_M3 0x1<<7
|
||||
#define SATURATION_M4 0x1<<8
|
||||
|
||||
struct frm_size {
|
||||
struct frm_size
|
||||
{
|
||||
unsigned int w;
|
||||
unsigned int h;
|
||||
};
|
||||
|
||||
struct mode_bit_map {
|
||||
struct mode_bit_map
|
||||
{
|
||||
unsigned short balance;
|
||||
unsigned short effect;
|
||||
unsigned short antibanding;
|
||||
@ -225,7 +234,7 @@ typedef struct integer_menu
|
||||
int maximum;
|
||||
int step;
|
||||
char reserved[2];
|
||||
}integer_menu;
|
||||
} integer_menu;
|
||||
|
||||
struct sensor_info
|
||||
{
|
||||
@ -246,7 +255,8 @@ struct sensor_info
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
typedef struct cim_sensor {
|
||||
typedef struct cim_sensor
|
||||
{
|
||||
int vendor;
|
||||
u16 chipid;
|
||||
int id;
|
||||
@ -263,55 +273,56 @@ typedef struct cim_sensor {
|
||||
|
||||
//add by wwzhao for ov5640
|
||||
bool sharpness_supported;
|
||||
struct integer_menu *sharpness;
|
||||
struct integer_menu* sharpness;
|
||||
bool contrast_supported;
|
||||
struct integer_menu *contrast;
|
||||
struct integer_menu* contrast;
|
||||
|
||||
struct frm_size *preview_size;
|
||||
struct frm_size *capture_size;
|
||||
struct frm_size* preview_size;
|
||||
struct frm_size* capture_size;
|
||||
int prev_resolution_nr;
|
||||
int cap_resolution_nr;
|
||||
int cap_wait_frame;
|
||||
|
||||
int (*probe)(struct cim_sensor *data);
|
||||
int (*init)(struct cim_sensor *data);
|
||||
int (*power_on)(struct cim_sensor *data);
|
||||
int (*shutdown)(struct cim_sensor *data);
|
||||
int (*reset)(struct cim_sensor *data);
|
||||
int (*probe)(struct cim_sensor* data);
|
||||
int (*init)(struct cim_sensor* data);
|
||||
int (*power_on)(struct cim_sensor* data);
|
||||
int (*shutdown)(struct cim_sensor* data);
|
||||
int (*reset)(struct cim_sensor* data);
|
||||
|
||||
int (*before_power_on)(struct cim_sensor *data);
|
||||
int (*after_power_on)(struct cim_sensor *data);
|
||||
int (*before_power_on)(struct cim_sensor* data);
|
||||
int (*after_power_on)(struct cim_sensor* data);
|
||||
|
||||
int (*af_init)(struct cim_sensor *data);
|
||||
int (*start_af)(struct cim_sensor *data);
|
||||
int (*stop_af)(struct cim_sensor *data);
|
||||
void (*read_all_regs)(struct cim_sensor *data);
|
||||
int (*af_init)(struct cim_sensor* data);
|
||||
int (*start_af)(struct cim_sensor* data);
|
||||
int (*stop_af)(struct cim_sensor* data);
|
||||
void (*read_all_regs)(struct cim_sensor* data);
|
||||
|
||||
int (*set_preivew_mode)(struct cim_sensor *data);
|
||||
int (*set_capture_mode)(struct cim_sensor *data);
|
||||
int (*set_video_mode)(struct cim_sensor *data);
|
||||
int (*set_preivew_mode)(struct cim_sensor* data);
|
||||
int (*set_capture_mode)(struct cim_sensor* data);
|
||||
int (*set_video_mode)(struct cim_sensor* data);
|
||||
|
||||
int (*set_resolution)(struct cim_sensor *data,int width,int height);
|
||||
int (*set_balance)(struct cim_sensor *data,unsigned short arg);
|
||||
int (*set_effect)(struct cim_sensor *data,unsigned short arg);
|
||||
int (*set_antibanding)(struct cim_sensor *data,unsigned short arg);
|
||||
int (*set_flash_mode)(struct cim_sensor *data,unsigned short arg);
|
||||
int (*set_scene_mode)(struct cim_sensor *data,unsigned short arg);
|
||||
int (*set_focus_mode)(struct cim_sensor *data,unsigned short arg);
|
||||
int (*set_fps)(struct cim_sensor *data,unsigned short arg);
|
||||
int (*set_nightshot)(struct cim_sensor *data,unsigned short arg);
|
||||
int (*set_luma_adaption)(struct cim_sensor *data,unsigned short arg);
|
||||
int (*set_brightness)(struct cim_sensor *data,unsigned short arg);
|
||||
int (*set_contrast)(struct cim_sensor *data, unsigned short arg);
|
||||
int (*set_sharpness)(struct cim_sensor *data, unsigned short arg);
|
||||
int (*set_saturation)(struct cim_sensor *data, unsigned short arg);
|
||||
int (*set_resolution)(struct cim_sensor* data, int width, int height);
|
||||
int (*set_balance)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_effect)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_antibanding)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_flash_mode)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_scene_mode)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_focus_mode)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_fps)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_nightshot)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_luma_adaption)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_brightness)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_contrast)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_sharpness)(struct cim_sensor* data, unsigned short arg);
|
||||
int (*set_saturation)(struct cim_sensor* data, unsigned short arg);
|
||||
|
||||
// int (*fill_buffer)(struct cim_sensor *data,char *buf);
|
||||
|
||||
void *private;
|
||||
}cim_sensor;
|
||||
void* private;
|
||||
} cim_sensor;
|
||||
|
||||
struct jz_cim_platform_data {
|
||||
struct jz_cim_platform_data
|
||||
{
|
||||
void (*power_on)(void);
|
||||
void (*power_off)(void);
|
||||
};
|
||||
@ -319,10 +330,11 @@ struct jz_cim_platform_data {
|
||||
#define CAMERA_FACING_FRONT 1
|
||||
#define CAMERA_FACING_BACK 0
|
||||
|
||||
extern int camera_sensor_register(struct cim_sensor *desc);
|
||||
extern int camera_sensor_register(struct cim_sensor* desc);
|
||||
#endif //end kernel
|
||||
|
||||
typedef struct CameraYUVMeta {
|
||||
typedef struct CameraYUVMeta
|
||||
{
|
||||
int32_t index;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
@ -337,6 +349,6 @@ typedef struct CameraYUVMeta {
|
||||
int32_t vStride;
|
||||
int32_t count;
|
||||
int32_t format;
|
||||
}CameraYUVMeta;
|
||||
} CameraYUVMeta;
|
||||
|
||||
#endif
|
||||
|
@ -67,6 +67,7 @@ void QQtCustomEffectProgressBar::paintEvent(QPaintEvent*)
|
||||
//-width/2 width/2
|
||||
//-height/2 height/2
|
||||
painter.translate(width / 2, height / 2);
|
||||
|
||||
/*更改刻度 设置的是放大的倍数 */
|
||||
/*有利于在绘制的时候,统一绘制数据*/
|
||||
/*矢量放大,不失真*/
|
||||
@ -207,6 +208,7 @@ void QQtCustomEffectProgressBar::drawPolo(QPainter* painter, int radius)
|
||||
|
||||
/*大圆路径*/
|
||||
QPainterPath bigPath;
|
||||
|
||||
if (designStyle == DesignStyle_Circle
|
||||
|| designStyle == DesignStyle_Ellipse)
|
||||
bigPath.addEllipse(-radius, -radius, radius * 2, radius * 2);
|
||||
@ -236,6 +238,7 @@ void QQtCustomEffectProgressBar::drawWave(QPainter* painter, int radius)
|
||||
{
|
||||
/*大路径*/
|
||||
QPainterPath bigPath;
|
||||
|
||||
if (designStyle == DesignStyle_Circle
|
||||
|| designStyle == DesignStyle_Ellipse)
|
||||
bigPath.addEllipse(-radius, -radius, radius * 2, radius * 2);
|
||||
@ -262,12 +265,15 @@ void QQtCustomEffectProgressBar::drawWave(QPainter* painter, int radius)
|
||||
static double offset = 0;
|
||||
/*>=1, wave will lost leisurely */
|
||||
offset += 0.6;
|
||||
|
||||
if (offset > 180)
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
int offset1 = offset;
|
||||
int offset2 = offset;
|
||||
|
||||
if (WaveDirection_Right == waveDirection)
|
||||
{
|
||||
offset1 *= -1;
|
||||
@ -287,20 +293,24 @@ void QQtCustomEffectProgressBar::drawWave(QPainter* painter, int radius)
|
||||
QPainterPath waterPath1;
|
||||
/*移动到左上角起始点*/
|
||||
waterPath1.moveTo(-radius, k);
|
||||
|
||||
for (int x = -radius; x <= radius; x++)
|
||||
{
|
||||
/*第一条波浪Y轴*/
|
||||
double waterY1 = (double)(A * sin(w * x + offset1)) + radius - k;
|
||||
|
||||
/*如果当前值为最小值则Y轴为高度*/
|
||||
if (this->value == minValue)
|
||||
{
|
||||
waterY1 = radius;
|
||||
}
|
||||
|
||||
/*如果当前值为最大值则Y轴为0*/
|
||||
if (this->value == maxValue)
|
||||
{
|
||||
waterY1 = -radius;
|
||||
}
|
||||
|
||||
waterPath1.lineTo(x, waterY1);
|
||||
}
|
||||
|
||||
@ -312,22 +322,27 @@ void QQtCustomEffectProgressBar::drawWave(QPainter* painter, int radius)
|
||||
/*第二条波浪路径集合*/
|
||||
QPainterPath waterPath2;
|
||||
waterPath2.moveTo(-radius, k);
|
||||
|
||||
for (int x = -radius; x <= radius; x++)
|
||||
{
|
||||
/*第二条波浪Y轴*/
|
||||
double waterY2 = (double)(A * sin(w * x + offset2 + 180)) + radius - k;
|
||||
|
||||
/*如果当前值为最小值则Y轴为高度*/
|
||||
if (this->value == minValue)
|
||||
{
|
||||
waterY2 = radius;
|
||||
}
|
||||
|
||||
/*如果当前值为最大值则Y轴为0*/
|
||||
if (this->value == maxValue)
|
||||
{
|
||||
waterY2 = -radius;
|
||||
}
|
||||
|
||||
waterPath2.lineTo(x, waterY2);
|
||||
}
|
||||
|
||||
waterPath2.lineTo(radius, radius);
|
||||
waterPath2.lineTo(-radius, radius);
|
||||
waterPath2.lineTo(-radius, k);
|
||||
@ -386,6 +401,7 @@ void QQtCustomEffectProgressBar::drawText(QPainter* painter, int radius)
|
||||
void QQtCustomEffectProgressBar::drawPercentText(QPainter* painter, int radius)
|
||||
{
|
||||
QString strValue = QString("%1").arg(value - minValue);
|
||||
|
||||
if (showPercent)
|
||||
{
|
||||
strValue = QString("%1%2").arg((double)(value - minValue) / (maxValue - minValue) * 100)
|
||||
@ -735,10 +751,12 @@ void QQtCustomEffectProgressBar::setPercentStyle(QQtCustomEffectProgressBar::Per
|
||||
if (this->percentStyle != percentStyle)
|
||||
{
|
||||
this->percentStyle = percentStyle;
|
||||
|
||||
if (percentStyle == PercentStyle_Wave)
|
||||
timer->start(TIMER_FIELD / waveSpeed);
|
||||
else
|
||||
timer->stop();
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
@ -756,6 +774,7 @@ void QQtCustomEffectProgressBar::setWaveDensity(int value)
|
||||
{
|
||||
if (value < 1)
|
||||
value = 1;
|
||||
|
||||
if (this->waveDensity != value)
|
||||
{
|
||||
this->waveDensity = value;
|
||||
@ -767,6 +786,7 @@ void QQtCustomEffectProgressBar::setWaveHeight(int value)
|
||||
{
|
||||
if (value < 1)
|
||||
value = 1;
|
||||
|
||||
if (this->waveHeight != value)
|
||||
{
|
||||
this->waveHeight = value;
|
||||
@ -787,6 +807,7 @@ void QQtCustomEffectProgressBar::setWaveSpeed(int speed)
|
||||
{
|
||||
if (speed < 1)
|
||||
speed = 1;
|
||||
|
||||
if (this->waveSpeed != speed)
|
||||
{
|
||||
this->waveSpeed = speed;
|
||||
|
@ -144,6 +144,7 @@ inline int QQtCustomPianoKeyBoard::getNoteRangeWidth(int note)
|
||||
|
||||
if (octave[(_note + 1) % 12].isBlack)
|
||||
width -= BWIDTH / 2;
|
||||
|
||||
if (octave[(_note + 23) % 12].isBlack)
|
||||
width -= BWIDTH / 2;
|
||||
|
||||
@ -201,6 +202,7 @@ void QQtCustomPianoKeyBoard::paintEvent(QPaintEvent* /*event*/)
|
||||
for (unsigned int j = 0; j < 12; j++)
|
||||
{
|
||||
int pos = octaveWidth * i + octave[j].pos - scrollOffset;
|
||||
|
||||
if ((pos >= 0 && pos <= viewportWidth) || (pos < 0 && pos + octave[i].width >= 0))
|
||||
{
|
||||
if (octave[j].isBlack)
|
||||
@ -210,6 +212,7 @@ void QQtCustomPianoKeyBoard::paintEvent(QPaintEvent* /*event*/)
|
||||
else
|
||||
{
|
||||
painter.drawRect(pos, rangeSelectorSize, octave[j].width, octave[j].height);
|
||||
|
||||
if (j == 0)
|
||||
painter.drawText(pos + 8, rangeSelectorSize + octave[j].height - 5, QString("%1").arg(i));
|
||||
}
|
||||
@ -243,7 +246,8 @@ void QQtCustomPianoKeyBoard::paintEvent(QPaintEvent* /*event*/)
|
||||
noteToRangeRect(rangeCenter, rCenter);
|
||||
noteToRangeRect(rangeEnd, rEnd);
|
||||
|
||||
painter.fillRect(rStart.right(), rStart.top(), rEnd.left() - rStart.right(), rEnd.bottom() - rStart.top(), Qt::lightGray);
|
||||
painter.fillRect(rStart.right(), rStart.top(), rEnd.left() - rStart.right(), rEnd.bottom() - rStart.top(),
|
||||
Qt::lightGray);
|
||||
|
||||
painter.setPen(Qt::blue);
|
||||
QPainterPath rangeStartPath(rStart.topRight());
|
||||
@ -302,7 +306,8 @@ int QQtCustomPianoKeyBoard::getNoteFromMousePos(const QPoint& p, bool ignoreY)
|
||||
}
|
||||
}
|
||||
|
||||
if (!isWhite && !isBlack(_note) && _pos >= octave[(_note + 1) % 12 ].pos && _pos < octave[(_note + 1) % 12 ].pos + octave[(_note + 1) % 12 ].width)
|
||||
if (!isWhite && !isBlack(_note) && _pos >= octave[(_note + 1) % 12 ].pos
|
||||
&& _pos < octave[(_note + 1) % 12 ].pos + octave[(_note + 1) % 12 ].width)
|
||||
_note++;
|
||||
|
||||
_note += _octave * 12;
|
||||
@ -400,14 +405,17 @@ void QQtCustomPianoKeyBoard::mousePressEvent(QMouseEvent* event)
|
||||
if (currentNote != -1)
|
||||
{
|
||||
pianoKeyDown = true;
|
||||
|
||||
if (m_EmitOutOfRangeNotes || isNoteInRange(currentNote))
|
||||
emit noteOn(currentNote);
|
||||
|
||||
update();
|
||||
}
|
||||
else
|
||||
{
|
||||
currentNote = -1;
|
||||
int* thumb = NULL;
|
||||
|
||||
if (getRangeThumbFromMousePos(event->pos(), &thumb))
|
||||
{
|
||||
selectedRangeThumb = thumb;
|
||||
@ -425,8 +433,10 @@ void QQtCustomPianoKeyBoard::mouseReleaseEvent(QMouseEvent* event)
|
||||
if (pianoKeyDown)
|
||||
{
|
||||
pianoKeyDown = false;
|
||||
|
||||
if (m_EmitOutOfRangeNotes || isNoteInRange(currentNote))
|
||||
emit noteOff(currentNote);
|
||||
|
||||
currentNote = -1;
|
||||
update();
|
||||
}
|
||||
@ -442,6 +452,7 @@ void QQtCustomPianoKeyBoard::mouseMoveEvent(QMouseEvent* event)
|
||||
if (pianoKeyDown)
|
||||
{
|
||||
int _note = getNoteFromMousePos(event->pos());
|
||||
|
||||
if (_note != currentNote)
|
||||
{
|
||||
if (m_EmitOutOfRangeNotes || isNoteInRange(currentNote))
|
||||
|
@ -174,6 +174,7 @@ QString QQtCustomQrEncodeWidget::getQrFilePath() const
|
||||
void QQtCustomQrEncodeWidget::setQrFilePath(const QString& value)
|
||||
{
|
||||
qrFilePath = value;
|
||||
|
||||
if (!qrFilePath.isEmpty())
|
||||
{
|
||||
saveCurViewToFile();
|
||||
@ -186,6 +187,7 @@ void QQtCustomQrEncodeWidget::paintEvent(QPaintEvent* e)
|
||||
QPainter painter(this);
|
||||
QRcode* qrcode = QRcode_encodeString(qrData.toUtf8(), 7, (QRecLevel)qrLevel, (QRencodeMode)qrMode, qrCasesen ? 1 : 0);
|
||||
QRect rect(0, 0, qrSize.width(), qrSize.height());
|
||||
|
||||
if (0 != qrcode)
|
||||
{
|
||||
unsigned char* point = qrcode->data;
|
||||
@ -194,6 +196,7 @@ void QQtCustomQrEncodeWidget::paintEvent(QPaintEvent* e)
|
||||
painter.drawRect(rect);
|
||||
double scale = (rect.width() - 2.0 * qrMargin) / qrcode->width;
|
||||
painter.setBrush(this->qrForeground);
|
||||
|
||||
for (int y = 0; y < qrcode->width; y ++)
|
||||
{
|
||||
for (int x = 0; x < qrcode->width; x ++)
|
||||
@ -203,9 +206,11 @@ void QQtCustomQrEncodeWidget::paintEvent(QPaintEvent* e)
|
||||
QRectF r(qrMargin + x * scale, qrMargin + y * scale, scale, scale);
|
||||
painter.drawRects(&r, 1);
|
||||
}
|
||||
|
||||
point ++;
|
||||
}
|
||||
}
|
||||
|
||||
point = NULL;
|
||||
QRcode_free(qrcode);
|
||||
painter.setBrush(QColor("#00ffffff"));
|
||||
@ -215,6 +220,7 @@ void QQtCustomQrEncodeWidget::paintEvent(QPaintEvent* e)
|
||||
double wrap_y = (rect.width() - icon_height) / 2.0;
|
||||
QRectF wrap(wrap_x - 5, wrap_y - 5, icon_width + 10, icon_height + 10);
|
||||
painter.drawRoundRect(wrap, 50, 50);
|
||||
|
||||
if (qrLogo.isEmpty() || qrLogo == "daodaoliang.github.io")
|
||||
{
|
||||
painter.save();
|
||||
@ -231,6 +237,7 @@ void QQtCustomQrEncodeWidget::paintEvent(QPaintEvent* e)
|
||||
{
|
||||
qrLogo = qrLogo.replace("qrc", "");
|
||||
}
|
||||
|
||||
QPixmap image(qrLogo);
|
||||
QRectF target(wrap_x, wrap_y, icon_width, icon_height);
|
||||
QRectF source(0, 0, image.width(), image.height());
|
||||
@ -245,6 +252,7 @@ void QQtCustomQrEncodeWidget::resizeEvent(QResizeEvent* e)
|
||||
{
|
||||
int w = this->size().width();
|
||||
int h = this->size().height();
|
||||
|
||||
if (w > h)
|
||||
{
|
||||
setQrSize(QSize(h, h));
|
||||
@ -259,16 +267,20 @@ void QQtCustomQrEncodeWidget::resizeEvent(QResizeEvent* e)
|
||||
void QQtCustomQrEncodeWidget::saveCurViewToFile()
|
||||
{
|
||||
QString str = qrFilePath;
|
||||
|
||||
if (!str.endsWith(".png"))
|
||||
{
|
||||
str.append(".png");
|
||||
}
|
||||
|
||||
QFile file(str);
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
|
||||
QRect rect(0, 0, qrSize.width(), qrSize.height());
|
||||
QPixmap pixmap(rect.size());
|
||||
this->render(&pixmap, QPoint(), QRegion(rect));
|
||||
|
@ -53,6 +53,7 @@ void QQtCustomSpeedMeter::setMinValue(int value)
|
||||
Q_EMIT errorSignal(MinValueError);
|
||||
else
|
||||
m_minValue = value;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@ -88,6 +89,7 @@ void QQtCustomSpeedMeter::setPrecision(int precision)
|
||||
Q_EMIT errorSignal(PrecisionError);
|
||||
else
|
||||
m_precision = precision;
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@ -117,6 +119,7 @@ void QQtCustomSpeedMeter::paintEvent(QPaintEvent*)
|
||||
|
||||
if (m_numericIndicatorEnabled)
|
||||
drawNumericValue(&painter); /* 画数字显示 */
|
||||
|
||||
drawIndicator(&painter); /* 画指针 */
|
||||
}
|
||||
|
||||
@ -162,6 +165,7 @@ void QQtCustomSpeedMeter::drawScaleNum(QPainter* painter)
|
||||
y = -82 * sina + h / 4;
|
||||
painter->drawText(x, y, str);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
@ -173,6 +177,7 @@ void QQtCustomSpeedMeter::drawScale(QPainter* painter)
|
||||
double angleStep = (360.0 - m_startAngle - m_endAngle) / steps;
|
||||
painter->setPen(m_foreground);
|
||||
QPen pen = painter->pen();
|
||||
|
||||
for (int i = 0; i <= steps; i++)
|
||||
{
|
||||
if (i % m_scaleMinor == 0)
|
||||
@ -187,8 +192,10 @@ void QQtCustomSpeedMeter::drawScale(QPainter* painter)
|
||||
painter->setPen(pen);
|
||||
painter->drawLine(0, 67, 0, 72);
|
||||
}
|
||||
|
||||
painter->rotate(angleStep);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,9 @@ class QQTSHARED_EXPORT QQtCustomSpeedMeter: public QWidget
|
||||
Q_PROPERTY(bool numericIndicatorEnabled READ isNumericIndicatorEnabled WRITE setNumericIndicatorEnabled)
|
||||
|
||||
public:
|
||||
enum ErrorCode {MaxValueError=1,MinValueError,ThresholdError,TargetError,PrecisionError,ColorError,UnitsEmpty,OutOfRange};
|
||||
enum ErrorCode {MaxValueError = 1, MinValueError, ThresholdError, TargetError, PrecisionError, ColorError, UnitsEmpty, OutOfRange};
|
||||
|
||||
explicit QQtCustomSpeedMeter(QWidget *parent = 0);
|
||||
explicit QQtCustomSpeedMeter(QWidget* parent = 0);
|
||||
double value() const {return m_value;}
|
||||
int minValue() const {return m_minValue;}
|
||||
int maxValue() const {return m_maxValue;}
|
||||
@ -71,16 +71,16 @@ public Q_SLOTS:
|
||||
|
||||
protected:
|
||||
void thresholdManager();
|
||||
void paintEvent(QPaintEvent *);
|
||||
void paintEvent(QPaintEvent*);
|
||||
|
||||
void drawCrown(QPainter *painter);
|
||||
void drawBackground(QPainter *painter);
|
||||
void drawScale(QPainter *painter);
|
||||
void drawScaleNum(QPainter *painter);
|
||||
void drawUnits(QPainter *painter);
|
||||
void drawIndicator(QPainter *painter);
|
||||
void drawThresholdLine(QPainter *painter);
|
||||
void drawNumericValue(QPainter *painter);
|
||||
void drawCrown(QPainter* painter);
|
||||
void drawBackground(QPainter* painter);
|
||||
void drawScale(QPainter* painter);
|
||||
void drawScaleNum(QPainter* painter);
|
||||
void drawUnits(QPainter* painter);
|
||||
void drawIndicator(QPainter* painter);
|
||||
void drawThresholdLine(QPainter* painter);
|
||||
void drawNumericValue(QPainter* painter);
|
||||
|
||||
private:
|
||||
double m_value;
|
||||
@ -89,7 +89,7 @@ private:
|
||||
QString m_units;
|
||||
int m_scaleMajor;
|
||||
int m_scaleMinor;
|
||||
int m_startAngle,m_endAngle;
|
||||
int m_startAngle, m_endAngle;
|
||||
double m_threshold;
|
||||
bool m_thresholdFlag;
|
||||
|
||||
|
@ -89,6 +89,7 @@ QPixmap QQtCustomVerificationCode::generateOneCaptcha()
|
||||
|
||||
// 噪音线
|
||||
QPainter painter(&image);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
QPen penHText(captchaInstance->generateRandomColor(), 2);
|
||||
@ -99,6 +100,7 @@ QPixmap QQtCustomVerificationCode::generateOneCaptcha()
|
||||
captchaInstance->generateRandom(-canvas_h, canvas_h));
|
||||
captchaInstance->sleepNow(5);
|
||||
}
|
||||
|
||||
painter.end();
|
||||
// 验证码
|
||||
int xStart = captchaInstance->generateRandom(canvas_w / captchaCount / 3 * 2, canvas_w / captchaCount);
|
||||
@ -106,6 +108,7 @@ QPixmap QQtCustomVerificationCode::generateOneCaptcha()
|
||||
int fontSize = captchaInstance->generateRandom(canvas_h / 5 * 2, canvas_h / 5 * 3);
|
||||
int rotateVar = 0;
|
||||
QString captchaString;
|
||||
|
||||
for (int i = 0; i < captchaCount; i++)
|
||||
{
|
||||
QPainter painter(&image);
|
||||
@ -131,6 +134,7 @@ QPixmap QQtCustomVerificationCode::generateOneCaptcha()
|
||||
painter.rotate(-rotateVar);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
// 验证码转小写
|
||||
captchaString = captchaString.toLower();
|
||||
// 保存验证码
|
||||
@ -189,6 +193,7 @@ QString QQtCustomVerificationCodePrivate::generateLetter(quint16 paramCount)
|
||||
QByteArray allowedChars = "abcdfhikmnstuvwxyzABCDEFGHJKLMNPRSTUVWXYZ01245689";
|
||||
int randomIndex;
|
||||
QByteArray outputString = "";
|
||||
|
||||
for (uint i = 0; i < paramCount; ++i)
|
||||
{
|
||||
randomIndex = rand() % allowedChars.length();
|
||||
@ -203,6 +208,7 @@ qint16 QQtCustomVerificationCodePrivate::generateRandom(qint16 paramLow, qint16
|
||||
QTime time = QTime::currentTime();
|
||||
qsrand((uint)time.msec());
|
||||
sleepNow(2);
|
||||
|
||||
if (paramLow > 0)
|
||||
{
|
||||
return paramLow + rand() % (paramHigh - paramLow);
|
||||
|
@ -53,6 +53,7 @@ void QQtFlipEffectStackedWidget::rotate(int index)
|
||||
{
|
||||
if (isAnimating)
|
||||
return;
|
||||
|
||||
nextIndex = index;
|
||||
int offsetx = frameRect().width();
|
||||
int offsety = frameRect().height();
|
||||
|
@ -313,14 +313,17 @@ bool QQtFramelessHelperPrivate::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
resize(e->pos());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (event->type() == QEvent::MouseButtonRelease)
|
||||
{
|
||||
QMouseEvent* e = (QMouseEvent*)event;
|
||||
|
||||
if (e->button() == Qt::LeftButton && isMousePressed)
|
||||
{
|
||||
isMousePressed = false;
|
||||
@ -328,11 +331,11 @@ bool QQtFramelessHelperPrivate::eventFilter(QObject* obj, QEvent* event)
|
||||
timer->start();
|
||||
return true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
while (false);
|
||||
} while (false);
|
||||
|
||||
|
||||
|
||||
|
@ -80,8 +80,10 @@ void QQtHorizontalTextEffectTabBar::paintEvent(QPaintEvent* e)
|
||||
continue;
|
||||
|
||||
optTabBase.tabBarRect |= tab.rect;
|
||||
|
||||
if (i == selected)
|
||||
continue;
|
||||
|
||||
setShape(QTabBar::RoundedNorth);
|
||||
p.drawControl(QStyle::CE_TabBarTab, tab);
|
||||
setShape(QTabBar::RoundedWest);
|
||||
|
@ -25,8 +25,7 @@ protected:
|
||||
public slots:
|
||||
|
||||
private:
|
||||
static void initStyleBaseOption(QStyleOptionTabBarBase* optTabBase, QTabBar* tabbar, QSize size)
|
||||
{
|
||||
static void initStyleBaseOption(QStyleOptionTabBarBase* optTabBase, QTabBar* tabbar, QSize size) {
|
||||
// QStyleOptionTab tabOverlap;
|
||||
// tabOverlap.shape = tabbar->shape();
|
||||
// int overlap = tabbar->style()->pixelMetric(QStyle::PM_TabBarBaseOverlap, &tabOverlap, tabbar);
|
||||
|
@ -62,6 +62,7 @@ void QQtLedBannerEffectLabel::paintGrid()
|
||||
{
|
||||
painter.drawLine(1 * i, 1, 1 * i, 13);
|
||||
}
|
||||
|
||||
for (int i = 0; i <= 14; i++)
|
||||
{
|
||||
painter.drawLine(1, 1 * i, length - 1, 1 * i);
|
||||
@ -81,14 +82,17 @@ void QQtLedBannerEffectLabel::timerEvent(QTimerEvent* event)
|
||||
textMsg = rest.append(first);
|
||||
update();
|
||||
}
|
||||
|
||||
if (typeEff == intermittent)
|
||||
{
|
||||
on = !on;
|
||||
|
||||
if (on)
|
||||
{
|
||||
textMsg = textOn;
|
||||
update();
|
||||
}
|
||||
|
||||
if (!on)
|
||||
{
|
||||
textMsg = textOff;
|
||||
@ -96,11 +100,13 @@ void QQtLedBannerEffectLabel::timerEvent(QTimerEvent* event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (timerState == false)
|
||||
{
|
||||
textMsg = textOn;
|
||||
update();
|
||||
}
|
||||
|
||||
QLabel::timerEvent(event);
|
||||
}
|
||||
|
||||
@ -150,6 +156,7 @@ void QQtLedBannerEffectLabel::startEffect(bool start)
|
||||
idTimer = startTimer(timerVal);
|
||||
update();
|
||||
}
|
||||
|
||||
if (timerState == false)
|
||||
{
|
||||
killTimer(idTimer);
|
||||
|
@ -44,6 +44,7 @@ void QQtMarqueeEffectLabel::setAlignment(Qt::Alignment align)
|
||||
QLabel::setAlignment(Qt::AlignLeft
|
||||
| (align & Qt::AlignVertical_Mask));
|
||||
break;
|
||||
|
||||
case BottomToTop:
|
||||
default:
|
||||
QLabel::setAlignment(Qt::AlignTop
|
||||
@ -58,12 +59,15 @@ void QQtMarqueeEffectLabel::reset()
|
||||
killTimer(timerId);
|
||||
timerId = 0;
|
||||
}
|
||||
|
||||
bool bActiveChanged = false;
|
||||
|
||||
if (active)
|
||||
{
|
||||
active = false;
|
||||
bActiveChanged = true;
|
||||
}
|
||||
|
||||
marqueeMargin = 0;
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
update();
|
||||
@ -80,6 +84,7 @@ void QQtMarqueeEffectLabel::setActive(bool active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (active)
|
||||
{
|
||||
start();
|
||||
@ -96,14 +101,17 @@ void QQtMarqueeEffectLabel::setInterval(int msec)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (mInterval != msec)
|
||||
{
|
||||
mInterval = msec;
|
||||
|
||||
if (timerId != 0)
|
||||
{
|
||||
killTimer(timerId);
|
||||
timerId = startTimer(mInterval);
|
||||
}
|
||||
|
||||
Q_EMIT intervalChanged(mInterval);
|
||||
}
|
||||
}
|
||||
@ -111,17 +119,20 @@ void QQtMarqueeEffectLabel::setInterval(int msec)
|
||||
void QQtMarqueeEffectLabel::start()
|
||||
{
|
||||
bool bActiveChanged = false;
|
||||
|
||||
if (!active)
|
||||
{
|
||||
active = true;
|
||||
bActiveChanged = true;
|
||||
}
|
||||
|
||||
if (!mouseIn)
|
||||
{
|
||||
if (timerId == 0)
|
||||
{
|
||||
timerId = startTimer(mInterval);
|
||||
}
|
||||
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
@ -134,11 +145,13 @@ void QQtMarqueeEffectLabel::start()
|
||||
void QQtMarqueeEffectLabel::stop()
|
||||
{
|
||||
bool bActiveChanged = false;
|
||||
|
||||
if (active)
|
||||
{
|
||||
active = false;
|
||||
bActiveChanged = true;
|
||||
}
|
||||
|
||||
if (!mouseIn)
|
||||
{
|
||||
if (timerId != 0)
|
||||
@ -146,11 +159,13 @@ void QQtMarqueeEffectLabel::stop()
|
||||
killTimer(timerId);
|
||||
timerId = 0;
|
||||
}
|
||||
|
||||
switch (mDirection)
|
||||
{
|
||||
case RightToLeft:
|
||||
setContentsMargins(marqueeMargin, 0, 0, 0);
|
||||
break;
|
||||
|
||||
case BottomToTop:
|
||||
default:
|
||||
setContentsMargins(0, marqueeMargin, 0, 0);
|
||||
@ -169,18 +184,22 @@ void QQtMarqueeEffectLabel::setDirection(QQtMarqueeEffectLabel::Direction param_
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mDirection = param_direciton;
|
||||
|
||||
switch (mDirection)
|
||||
{
|
||||
case RightToLeft:
|
||||
setAlignment(Qt::AlignLeft
|
||||
| (alignment() & Qt::AlignVertical_Mask));
|
||||
break;
|
||||
|
||||
case BottomToTop:
|
||||
default:
|
||||
setAlignment(Qt::AlignTop
|
||||
| (alignment() & Qt::AlignHorizontal_Mask));
|
||||
}
|
||||
|
||||
marqueeMargin = 0;
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
update();
|
||||
@ -190,6 +209,7 @@ void QQtMarqueeEffectLabel::setDirection(QQtMarqueeEffectLabel::Direction param_
|
||||
void QQtMarqueeEffectLabel::enterEvent(QEvent* event)
|
||||
{
|
||||
mouseIn = true;
|
||||
|
||||
if (active)
|
||||
{
|
||||
if (timerId != 0)
|
||||
@ -197,30 +217,36 @@ void QQtMarqueeEffectLabel::enterEvent(QEvent* event)
|
||||
killTimer(timerId);
|
||||
timerId = 0;
|
||||
}
|
||||
|
||||
switch (mDirection)
|
||||
{
|
||||
case RightToLeft:
|
||||
setContentsMargins(marqueeMargin, 0, 0, 0);
|
||||
break;
|
||||
|
||||
case BottomToTop:
|
||||
default:
|
||||
setContentsMargins(0, marqueeMargin, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
QLabel::enterEvent(event);
|
||||
}
|
||||
|
||||
void QQtMarqueeEffectLabel::leaveEvent(QEvent* event)
|
||||
{
|
||||
mouseIn = false;
|
||||
|
||||
if (active)
|
||||
{
|
||||
if (timerId == 0)
|
||||
{
|
||||
timerId = startTimer(mInterval);
|
||||
}
|
||||
|
||||
setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
QLabel::leaveEvent(event);
|
||||
}
|
||||
|
||||
@ -228,15 +254,18 @@ void QQtMarqueeEffectLabel::resizeEvent(QResizeEvent* event)
|
||||
{
|
||||
QLabel::resizeEvent(event);
|
||||
int w;
|
||||
|
||||
switch (mDirection)
|
||||
{
|
||||
case RightToLeft:
|
||||
w = event->size().width();
|
||||
break;
|
||||
|
||||
case BottomToTop:
|
||||
default:
|
||||
w = event->size().height();
|
||||
}
|
||||
|
||||
if (marqueeMargin > w)
|
||||
{
|
||||
marqueeMargin = w;
|
||||
@ -247,25 +276,30 @@ void QQtMarqueeEffectLabel::resizeEvent(QResizeEvent* event)
|
||||
void QQtMarqueeEffectLabel::timerEvent(QTimerEvent* event)
|
||||
{
|
||||
QLabel::timerEvent(event);
|
||||
|
||||
if (timerId != 0 && event->timerId() == timerId)
|
||||
{
|
||||
marqueeMargin--;
|
||||
int w, w2;
|
||||
|
||||
switch (mDirection)
|
||||
{
|
||||
case RightToLeft:
|
||||
w = sizeHint().width();
|
||||
w2 = width();
|
||||
break;
|
||||
|
||||
case BottomToTop:
|
||||
default:
|
||||
w = sizeHint().height();
|
||||
w2 = height();
|
||||
}
|
||||
|
||||
if (marqueeMargin < 0 && -marqueeMargin > w)
|
||||
{
|
||||
marqueeMargin = w2;
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
}
|
||||
@ -277,10 +311,12 @@ void QQtMarqueeEffectLabel::paintEvent(QPaintEvent* event)
|
||||
case RightToLeft:
|
||||
setContentsMargins(marqueeMargin, 0, 0, 0);
|
||||
break;
|
||||
|
||||
case BottomToTop:
|
||||
default:
|
||||
setContentsMargins(0, marqueeMargin, 0, 0);
|
||||
}
|
||||
|
||||
QLabel::paintEvent(event);
|
||||
|
||||
if (timerId != 0)
|
||||
|
@ -99,6 +99,7 @@ void QQtPictureEffectTabBar::paintEvent(QPaintEvent* e)
|
||||
void QQtPictureEffectTabBar::drawBackground(QPainter* p)
|
||||
{
|
||||
bool b = drawBase();
|
||||
|
||||
if (b)
|
||||
{
|
||||
for (int index = 0; index < count(); index++)
|
||||
@ -117,6 +118,7 @@ void QQtPictureEffectTabBar::drawPicture(QPainter* p)
|
||||
for (int index = 0; index < count(); index++)
|
||||
{
|
||||
QRect iconRect = tabRect(index);
|
||||
|
||||
if (iconStyle == IconStyle_Left_And_RightText)
|
||||
iconRect = QRect(iconRect.left(), iconRect.top(),
|
||||
iconRect.height(), iconRect.height());
|
||||
@ -144,6 +146,7 @@ void QQtPictureEffectTabBar::drawText(QPainter* p)
|
||||
QRect tabTextRect = tabRect(index);
|
||||
//-rect.height()/20 上移
|
||||
verticalTabs() ? tabTextRect.adjust(0, 0, 0, 0) : tabTextRect.adjust(0, 0, 0, 0);
|
||||
|
||||
if (iconStyle == IconStyle_Cover_And_BottomText)
|
||||
tabTextRect.adjust(0, 0, 0, -2);
|
||||
else if (iconStyle == IconStyle_Cover_And_TopText)
|
||||
@ -160,6 +163,7 @@ void QQtPictureEffectTabBar::drawText(QPainter* p)
|
||||
tabTextRect.width() - tabTextRect.height(), tabTextRect.height());
|
||||
|
||||
int flags = Qt::AlignCenter;
|
||||
|
||||
if (iconStyle == IconStyle_Cover_And_BottomText)
|
||||
flags = Qt::AlignHCenter | Qt::AlignBottom;
|
||||
else if (iconStyle == IconStyle_Cover_And_TopText)
|
||||
@ -175,10 +179,12 @@ void QQtPictureEffectTabBar::drawText(QPainter* p)
|
||||
//if on board text is normal, this is right. otherwise the palette is right
|
||||
p->save();
|
||||
p->setFont(textFont);
|
||||
|
||||
if (index == currentIndex())
|
||||
p->setPen(selectedTextColor);
|
||||
else
|
||||
p->setPen(textColor);
|
||||
|
||||
p->drawText(tabTextRect, flags, tabText(index));
|
||||
p->restore();
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ void QQtPopEffectDialog::showPopDialog(quint32 paramRemainTime)
|
||||
{
|
||||
mremainTime = paramRemainTime * 500;
|
||||
this->move((desktop.availableGeometry().width() - this->width()), desktop.availableGeometry().height());
|
||||
|
||||
if (!this->isVisible())
|
||||
{
|
||||
show();
|
||||
@ -29,7 +30,8 @@ void QQtPopEffectDialog::pausePopDialog()
|
||||
{
|
||||
if (animation != NULL)
|
||||
{
|
||||
this->move((desktop.availableGeometry().width() - this->width()), (desktop.availableGeometry().height() - this->height()));
|
||||
this->move((desktop.availableGeometry().width() - this->width()),
|
||||
(desktop.availableGeometry().height() - this->height()));
|
||||
animation->setPaused(true);
|
||||
mIsPause = true;
|
||||
}
|
||||
@ -56,7 +58,8 @@ void QQtPopEffectDialog::closeAnimation()
|
||||
delete remainTimer;
|
||||
remainTimer = NULL;
|
||||
animation->setStartValue(QPoint(this->x(), this->y()));
|
||||
animation->setEndValue(QPoint((desktop.availableGeometry().width() - this->width()), desktop.availableGeometry().height() + 50));
|
||||
animation->setEndValue(QPoint((desktop.availableGeometry().width() - this->width()),
|
||||
desktop.availableGeometry().height() + 50));
|
||||
animation->start();
|
||||
connect(animation, SIGNAL(finished()), this, SLOT(clearAll()));
|
||||
}
|
||||
@ -69,6 +72,7 @@ void QQtPopEffectDialog::clearAll()
|
||||
disconnect(animation, SIGNAL(finished()), this, SLOT(clearAll()));
|
||||
delete animation;
|
||||
}
|
||||
|
||||
animation = NULL;
|
||||
hide();
|
||||
}
|
||||
@ -81,7 +85,8 @@ void QQtPopEffectDialog::showAnimation()
|
||||
animation->setDuration(mremainTime);
|
||||
animation->setEasingCurve(QEasingCurve::OutElastic);
|
||||
animation->setStartValue(QPoint(this->x(), this->y()));
|
||||
animation->setEndValue(QPoint((desktop.availableGeometry().width() - this->width()), (desktop.availableGeometry().height() - this->height())));
|
||||
animation->setEndValue(QPoint((desktop.availableGeometry().width() - this->width()),
|
||||
(desktop.availableGeometry().height() - this->height())));
|
||||
connect(animation, SIGNAL(valueChanged(QVariant)), this, SLOT(animationValueChanged(QVariant)));
|
||||
animation->start();
|
||||
remainTimer = new QTimer();
|
||||
|
@ -34,6 +34,7 @@ void QQtRippleEffectPushButton::paintEvent(QPaintEvent* event)
|
||||
tempPainter.drawEllipse(rectangle);
|
||||
tempPainter.end();
|
||||
}
|
||||
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
|
@ -77,64 +77,50 @@ private slots:
|
||||
void resetVariables();
|
||||
|
||||
public:
|
||||
double getValue() const
|
||||
{
|
||||
double getValue() const {
|
||||
return value;
|
||||
}
|
||||
double getMinValue() const
|
||||
{
|
||||
double getMinValue() const {
|
||||
return minValue;
|
||||
}
|
||||
double getMaxValue() const
|
||||
{
|
||||
double getMaxValue() const {
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
int getPrecision() const
|
||||
{
|
||||
int getPrecision() const {
|
||||
return precision;
|
||||
}
|
||||
int getLongStep() const
|
||||
{
|
||||
int getLongStep() const {
|
||||
return longStep;
|
||||
}
|
||||
int getShortStep() const
|
||||
{
|
||||
int getShortStep() const {
|
||||
return shortStep;
|
||||
}
|
||||
int getSpace() const
|
||||
{
|
||||
int getSpace() const {
|
||||
return space;
|
||||
}
|
||||
|
||||
QColor getBgColorStart() const
|
||||
{
|
||||
QColor getBgColorStart() const {
|
||||
return bgColorStart;
|
||||
}
|
||||
QColor getBgColorEnd() const
|
||||
{
|
||||
QColor getBgColorEnd() const {
|
||||
return bgColorEnd;
|
||||
}
|
||||
QColor getLineColor() const
|
||||
{
|
||||
QColor getLineColor() const {
|
||||
return lineColor;
|
||||
}
|
||||
|
||||
QColor getSliderColorTop() const
|
||||
{
|
||||
QColor getSliderColorTop() const {
|
||||
return sliderColorTop;
|
||||
}
|
||||
QColor getSliderColorBottom() const
|
||||
{
|
||||
QColor getSliderColorBottom() const {
|
||||
return sliderColorBottom;
|
||||
}
|
||||
|
||||
QColor getTipBgColor() const
|
||||
{
|
||||
QColor getTipBgColor() const {
|
||||
return tipBgColor;
|
||||
}
|
||||
QColor getTipTextColor() const
|
||||
{
|
||||
QColor getTipTextColor() const {
|
||||
return tipTextColor;
|
||||
}
|
||||
public slots:
|
||||
|
@ -80,9 +80,11 @@ void QQtSlideEffectTabBar::drawTabBarIcon(QPainter* painter)
|
||||
void QQtSlideEffectTabBar::drawTabBarText(QPainter* painter)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
for (int i = 0; i < count(); i++)
|
||||
{
|
||||
QPalette pale = palette();
|
||||
|
||||
if (i == currentIndex())
|
||||
painter->setBrush(pale.buttonText());
|
||||
else
|
||||
@ -91,6 +93,7 @@ void QQtSlideEffectTabBar::drawTabBarText(QPainter* painter)
|
||||
QRect textRect = tabRect(i);
|
||||
painter->drawText(textRect, Qt::AlignCenter, tabText(i));
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
@ -158,6 +161,7 @@ void QQtSlideEffectTabBar::updateTabBarRect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
@ -165,6 +169,7 @@ void QQtSlideEffectTabBar::updateTabBarRect()
|
||||
void QQtSlideEffectTabBar::mousePressEvent(QMouseEvent* event)
|
||||
{
|
||||
m_barRect = tabRect(currentIndex());
|
||||
|
||||
for (int i = 0 ; i < count(); i++)
|
||||
{
|
||||
if (tabRect(i).contains(event->pos()) && i != currentIndex())
|
||||
@ -174,6 +179,7 @@ void QQtSlideEffectTabBar::mousePressEvent(QMouseEvent* event)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return QTabBar::mousePressEvent(event);
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,10 @@
|
||||
QQtDialog::QQtDialog(QWidget* parent) :
|
||||
QDialog(parent)
|
||||
{
|
||||
setWindowModality(Qt::WindowModal);//阻挡父亲窗口内其他控件,除非本dialog关闭 show的功能强大起来 可以使用输入法
|
||||
/*
|
||||
* 阻挡父亲窗口内其他控件,除非本dialog关闭 show的功能强大起来 可以使用输入法
|
||||
*/
|
||||
setWindowModality(Qt::WindowModal);
|
||||
|
||||
#if 0
|
||||
setWindowFlags(Qt::FramelessWindowHint | windowFlags());
|
||||
|
@ -4,13 +4,14 @@ QSqlDatabase managerDB;
|
||||
QString gUserName;
|
||||
QString gPassword;
|
||||
|
||||
void qqtFrameMsgHandler(QtMsgType type, const char * msg)
|
||||
void qqtFrameMsgHandler(QtMsgType type, const char* msg)
|
||||
{
|
||||
static QMutex mutex;
|
||||
mutex.lock();
|
||||
|
||||
QString text;
|
||||
switch(type)
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case QtDebugMsg:
|
||||
text = QString("Debug");
|
||||
|
@ -20,7 +20,8 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
Auth_Id = 0,
|
||||
Auth_Name,
|
||||
Auth_Passwd,
|
||||
@ -30,7 +31,8 @@ enum {
|
||||
Auth_Comment,
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
Lib_Id = 0,
|
||||
Lib_Name,
|
||||
Lib_Creater,
|
||||
@ -38,19 +40,22 @@ enum {
|
||||
Lib_Comment,
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
Authority_Id = 0,
|
||||
Authority_Level,
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
Method_Id = 0,
|
||||
Method_Name,
|
||||
Method_Type,
|
||||
Method_Vessel,
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
Stage_Id = 0,
|
||||
Stage_Index,
|
||||
Stage_Vessel,
|
||||
@ -62,20 +67,23 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
Type_Standard = 0,
|
||||
Type_Temprature,
|
||||
Type_Stressure,
|
||||
Type_Extract,
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
Login_Request,
|
||||
Login_Success,
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
Event_ID,
|
||||
Event_Name,
|
||||
Event_Time,
|
||||
@ -83,13 +91,15 @@ enum {
|
||||
Event_Content,
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
Event_TypeId,
|
||||
Event_TypeName,
|
||||
};
|
||||
|
||||
|
||||
typedef enum tagSampleEnum{
|
||||
typedef enum tagSampleEnum
|
||||
{
|
||||
ESampleId,
|
||||
ESampleMingcheng,
|
||||
ESampleBianhao,
|
||||
@ -99,26 +109,29 @@ typedef enum tagSampleEnum{
|
||||
ESampleJieguodanwei,
|
||||
ESampleCeshiren,
|
||||
ESampleCeshishijian,
|
||||
}ESampleColomn;
|
||||
} ESampleColomn;
|
||||
|
||||
enum{
|
||||
enum
|
||||
{
|
||||
Language_English,
|
||||
Language_Chinese,
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
FILE_NAME,
|
||||
FILE_SIZE,
|
||||
FILE_TYPE,
|
||||
FILE_DATE,
|
||||
FILE_ID,
|
||||
FILE_PATH ,
|
||||
FILE_FILEPATH ,
|
||||
FILE_PATH,
|
||||
FILE_FILEPATH,
|
||||
|
||||
FILE_MAX,
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
DIR_NAME,
|
||||
DIR_CODE,
|
||||
DIR_PATH,
|
||||
@ -157,7 +170,7 @@ extern QString gPassword;
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void qqtFrameMsgHandler(QtMsgType type, const char * msg);
|
||||
void qqtFrameMsgHandler(QtMsgType type, const char* msg);
|
||||
|
||||
|
||||
#endif // QQTFRAMEDEFINE_H
|
@ -174,6 +174,7 @@ void QQTInput::InitForm()
|
||||
ui->radioEN->setChecked(true);
|
||||
|
||||
QList<QPushButton*> btn = this->findChildren<QPushButton*>();
|
||||
|
||||
foreach (QPushButton* b, btn)
|
||||
{
|
||||
connect(b, SIGNAL(clicked()), this, SLOT(btn_clicked()));
|
||||
@ -274,6 +275,7 @@ void QQTInput::InitProperty()
|
||||
labCh.append(ui->labCh7);
|
||||
labCh.append(ui->labCh8);
|
||||
labCh.append(ui->labCh9);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
labCh[i]->installEventFilter(this);
|
||||
@ -293,10 +295,12 @@ bool QQTInput::checkPress()
|
||||
bool num_ok = btnPress->property("btnNum").toBool();
|
||||
bool other_ok = btnPress->property("btnOther").toBool();
|
||||
bool letter_ok = btnPress->property("btnLetter").toBool();
|
||||
|
||||
if (num_ok || other_ok || letter_ok)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -321,6 +325,7 @@ void QQTInput::btn_clicked()
|
||||
|
||||
QPushButton* btn = (QPushButton*)sender();
|
||||
QString objectName = btn->objectName();
|
||||
|
||||
//pline() << objectName;
|
||||
/*
|
||||
* 大小写
|
||||
@ -330,15 +335,19 @@ void QQTInput::btn_clicked()
|
||||
if (currentType == "min")
|
||||
{
|
||||
currentType = "max";
|
||||
|
||||
if (!ui->checkShift->isChecked())
|
||||
ui->checkShift->setChecked(true);
|
||||
|
||||
changeType();
|
||||
}
|
||||
else if (currentType == "max")
|
||||
{
|
||||
currentType = "min";
|
||||
|
||||
if (ui->checkShift->isChecked())
|
||||
ui->checkShift->setChecked(false);
|
||||
|
||||
changeType();
|
||||
}
|
||||
else if (currentType == "chinese")
|
||||
@ -362,14 +371,17 @@ void QQTInput::btn_clicked()
|
||||
{
|
||||
currentType = "chinese";
|
||||
ui->checkShift->setPixmap("./skin/default/key_hidden.png", "./skin/default/key_hidden.png");
|
||||
|
||||
if (ui->checkShift->isChecked())
|
||||
ui->checkShift->setChecked(false);
|
||||
|
||||
ui->checkShift->update();
|
||||
changeType();
|
||||
}
|
||||
else if (currentType == "chinese")
|
||||
{
|
||||
}
|
||||
|
||||
//if(ui->radioNum->isChecked())
|
||||
// ui->radioNum->setChecked(false);
|
||||
if (1 == ui->stackedWidget->currentIndex())
|
||||
@ -384,11 +396,14 @@ void QQTInput::btn_clicked()
|
||||
{
|
||||
currentType = "min";
|
||||
ui->checkShift->setPixmap("./skin/default/key_shift.png", "./skin/default/key_shift_press.png");
|
||||
|
||||
if (ui->checkShift->isChecked())
|
||||
ui->checkShift->setChecked(false);
|
||||
|
||||
ui->checkShift->update();
|
||||
changeType();
|
||||
}
|
||||
|
||||
//if(ui->radioNum->isChecked())
|
||||
// ui->radioNum->setChecked(false);
|
||||
if (1 == ui->stackedWidget->currentIndex())
|
||||
@ -403,6 +418,7 @@ void QQTInput::btn_clicked()
|
||||
{
|
||||
QString txt = ui->labPY->text();
|
||||
int len = txt.length();
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
ui->labPY->setText(txt.left(len - 1));
|
||||
@ -438,6 +454,7 @@ void QQTInput::btn_clicked()
|
||||
{
|
||||
currentPY_index = 0;
|
||||
}
|
||||
|
||||
showChinese();
|
||||
}
|
||||
else if (objectName == "btnNext")
|
||||
@ -462,6 +479,7 @@ void QQTInput::btn_clicked()
|
||||
else
|
||||
{
|
||||
QString value = btn->text();
|
||||
|
||||
/*
|
||||
* 如果是&按钮,因为对应&被过滤,所以真实的text为去除前面一个&字符
|
||||
*/
|
||||
@ -469,6 +487,7 @@ void QQTInput::btn_clicked()
|
||||
{
|
||||
value = value.right(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* 当前不是中文模式,则单击按钮对应text为传递参数
|
||||
*/
|
||||
@ -596,12 +615,15 @@ bool QQTInput::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
ShowPanel();
|
||||
}
|
||||
|
||||
btnPress = (QPushButton*)obj;
|
||||
|
||||
if (checkPress())
|
||||
{
|
||||
isPress = true;
|
||||
timerPress->start(500);
|
||||
}
|
||||
|
||||
//pline() << currentEditType;
|
||||
return false;
|
||||
}
|
||||
@ -613,12 +635,14 @@ bool QQTInput::eventFilter(QObject* obj, QEvent* event)
|
||||
else if (event->type() == QEvent::MouseButtonRelease)
|
||||
{
|
||||
btnPress = (QPushButton*)obj;
|
||||
|
||||
if (checkPress())
|
||||
{
|
||||
isPress = false;
|
||||
timerPress->stop();
|
||||
btnPress->update();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (event->type() == QEvent::KeyPress)
|
||||
@ -632,6 +656,7 @@ bool QQTInput::eventFilter(QObject* obj, QEvent* event)
|
||||
}
|
||||
|
||||
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
||||
|
||||
/*
|
||||
* Shift切换输入法模式,esc键关闭输入法面板,空格取第一个汉字,退格键删除
|
||||
* 中文模式下回车键取拼音,中文模式下当没有拼音时可以输入空格
|
||||
@ -705,6 +730,7 @@ bool QQTInput::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
currentType = "min";
|
||||
}
|
||||
|
||||
changeType();
|
||||
return true;
|
||||
}
|
||||
@ -714,7 +740,9 @@ bool QQTInput::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString key;
|
||||
|
||||
if (currentType == "chinese")
|
||||
{
|
||||
key = keyEvent->text();
|
||||
@ -727,7 +755,9 @@ bool QQTInput::eventFilter(QObject* obj, QEvent* event)
|
||||
{
|
||||
key = keyEvent->text().toUpper();
|
||||
}
|
||||
|
||||
QList<QPushButton*> btn = this->findChildren<QPushButton*>();
|
||||
|
||||
foreach (QPushButton* b, btn)
|
||||
{
|
||||
if (b->text() == key)
|
||||
@ -737,14 +767,17 @@ bool QQTInput::eventFilter(QObject* obj, QEvent* event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void QQTInput::focusChanged(QWidget* oldWidget, QWidget* nowWidget)
|
||||
{
|
||||
currentFocusWidget = nowWidget;
|
||||
|
||||
//pline() << currentEditType << "oldWidget:" << oldWidget << " nowWidget:" << nowWidget;
|
||||
if (nowWidget != 0 && !this->isAncestorOf(nowWidget))
|
||||
{
|
||||
@ -760,12 +793,15 @@ void QQTInput::focusChanged(QWidget* oldWidget, QWidget* nowWidget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
isFirst = false;
|
||||
|
||||
if (nowWidget->inherits("QLineEdit"))
|
||||
{
|
||||
QLineEdit* lineedit = (QLineEdit*)nowWidget;
|
||||
|
||||
if (!lineedit->isReadOnly())
|
||||
{
|
||||
currentLineEdit = (QLineEdit*)nowWidget;
|
||||
@ -789,6 +825,7 @@ void QQTInput::focusChanged(QWidget* oldWidget, QWidget* nowWidget)
|
||||
else if (nowWidget->inherits("QComboBox"))
|
||||
{
|
||||
QComboBox* cbox = (QComboBox*)nowWidget;
|
||||
|
||||
/*
|
||||
* 只有当下拉选择框处于编辑模式才可以输入
|
||||
*/
|
||||
@ -827,12 +864,14 @@ void QQTInput::focusChanged(QWidget* oldWidget, QWidget* nowWidget)
|
||||
//pline();
|
||||
return;
|
||||
}
|
||||
|
||||
//pline() << currentEditType;
|
||||
/*
|
||||
* 如果要实现android键盘的效果,再考虑此处,否则不考虑
|
||||
*/
|
||||
changePosition();
|
||||
}
|
||||
|
||||
/*
|
||||
* 这部分代码不可更改 除非添加控件
|
||||
*/
|
||||
@ -873,6 +912,7 @@ void QQTInput::changeType()
|
||||
ui->btnOther18->setText(tr(";"));
|
||||
ui->btnOther21->setText(tr("\""));
|
||||
}
|
||||
|
||||
/*
|
||||
* 每次切换到模式,都要执行清空之前中文模式下的信息
|
||||
*/
|
||||
@ -883,6 +923,7 @@ void QQTInput::changeType()
|
||||
void QQTInput::changeLetter(bool isUpper)
|
||||
{
|
||||
QList<QPushButton*> btn = this->findChildren<QPushButton*>();
|
||||
|
||||
foreach (QPushButton* b, btn)
|
||||
{
|
||||
if (b->property("btnLetter").toBool())
|
||||
@ -906,6 +947,7 @@ void QQTInput::selectChinese()
|
||||
QString currentPY = ui->labPY->text();
|
||||
QString sql = "select [word] from [pinyin] where [pinyin]='" + currentPY + "';";
|
||||
query.exec(sql);
|
||||
|
||||
/*
|
||||
* 逐个将查询到的字词加入汉字队列
|
||||
*/
|
||||
@ -913,6 +955,7 @@ void QQTInput::selectChinese()
|
||||
{
|
||||
QString result = query.value(0).toString();
|
||||
QStringList text = result.split(" ");
|
||||
|
||||
foreach (QString txt, text)
|
||||
{
|
||||
if (txt.length() > 0)
|
||||
@ -922,6 +965,7 @@ void QQTInput::selectChinese()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
showChinese();
|
||||
}
|
||||
|
||||
@ -932,6 +976,7 @@ void QQTInput::showChinese()
|
||||
*/
|
||||
int count = 0;
|
||||
currentPY.clear();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
labCh[i]->setText("");
|
||||
@ -943,12 +988,14 @@ void QQTInput::showChinese()
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
QString txt = QString("%1 ").arg(allPY[currentPY_index]);
|
||||
currentPY.append(allPY[currentPY_index]);
|
||||
labCh[count]->setText(txt);
|
||||
count++;
|
||||
currentPY_index++;
|
||||
}
|
||||
|
||||
qDebug() << "currentPY_index:" << currentPY_index << "currentPY_count:" << currentPY_count;
|
||||
}
|
||||
|
||||
@ -989,6 +1036,7 @@ void QQTInput::deleteValue()
|
||||
* 获取当前QTextEdit光标,如果光标有选中,则移除选中字符,否则删除光标前一个字符
|
||||
*/
|
||||
QTextCursor cursor = currentTextEdit->textCursor();
|
||||
|
||||
if (cursor.hasSelection())
|
||||
{
|
||||
cursor.removeSelectedText();
|
||||
@ -1004,6 +1052,7 @@ void QQTInput::deleteValue()
|
||||
* 获取当前QTextEdit光标,如果光标有选中,则移除选中字符,否则删除光标前一个字符
|
||||
*/
|
||||
QTextCursor cursor = currentPlain->textCursor();
|
||||
|
||||
if (cursor.hasSelection())
|
||||
{
|
||||
cursor.removeSelectedText();
|
||||
@ -1019,6 +1068,7 @@ void QQTInput::deleteValue()
|
||||
* 获取当前QTextEdit光标,如果光标有选中,则移除选中字符,否则删除光标前一个字符
|
||||
*/
|
||||
QTextCursor cursor = currentBrowser->textCursor();
|
||||
|
||||
if (cursor.hasSelection())
|
||||
{
|
||||
cursor.removeSelectedText();
|
||||
@ -1038,6 +1088,7 @@ void QQTInput::deleteValue()
|
||||
void QQTInput::setChinese(int index)
|
||||
{
|
||||
int count = currentPY.count();
|
||||
|
||||
if (count > index)
|
||||
{
|
||||
insertValue(currentPY[index]);
|
||||
@ -1058,6 +1109,7 @@ void QQTInput::clearChinese()
|
||||
{
|
||||
labCh[i]->setText("");
|
||||
}
|
||||
|
||||
allPY.clear();
|
||||
currentPY.clear();
|
||||
currentPY_index = 0;
|
||||
@ -1067,6 +1119,7 @@ void QQTInput::clearChinese()
|
||||
void QQTInput::changeRect()
|
||||
{
|
||||
QRect geo = geometry();
|
||||
|
||||
if (currentType == "min" || currentType == "max")
|
||||
{
|
||||
geo.adjust(0, +frmTopHeight, 0, 0);
|
||||
@ -1075,6 +1128,7 @@ void QQTInput::changeRect()
|
||||
{
|
||||
geo.adjust(0, -frmTopHeight, 0, 0);
|
||||
}
|
||||
|
||||
setFixedHeight(geo.height());
|
||||
setGeometry(geo);
|
||||
}
|
||||
@ -1150,6 +1204,7 @@ void QQTInput::changePosition()
|
||||
{
|
||||
if (currentFocusWidget == NULL)
|
||||
return;
|
||||
|
||||
QRect rect = currentFocusWidget->rect();
|
||||
QPoint pos = QPoint(rect.left(), rect.top() + 27 + 2);
|
||||
QPoint pos2 = QPoint(rect.left(), rect.bottom() + 2);
|
||||
@ -1233,16 +1288,19 @@ void QQTInput::ChangeFont()
|
||||
QFont labFont(this->font().family(), labFontSize);
|
||||
|
||||
QList<QPushButton*> btns = ui->widgetMain->findChildren<QPushButton*>();
|
||||
|
||||
foreach (QPushButton* btn, btns)
|
||||
{
|
||||
btn->setFont(btnFont);
|
||||
}
|
||||
|
||||
QList<QLabel*> labs = ui->widgetTop->findChildren<QLabel*>();
|
||||
|
||||
foreach (QLabel* lab, labs)
|
||||
{
|
||||
lab->setFont(labFont);
|
||||
}
|
||||
|
||||
ui->btnPre->setFont(labFont);
|
||||
ui->btnNext->setFont(labFont);
|
||||
ui->btnClose->setFont(labFont);
|
||||
@ -1254,31 +1312,40 @@ void QQTInput::changeStyle(QString topColor, QString bottomColor, QString border
|
||||
|
||||
qss.append(QString("QWidget#frmInput{background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 %1,stop:1 %2);}")
|
||||
.arg(topColor).arg(bottomColor));
|
||||
qss.append(QString("QWidget#widgetTopPinyin{background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 %1,stop:1 %2);}")
|
||||
qss.append(
|
||||
QString("QWidget#widgetTopPinyin{background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 %1,stop:1 %2);}")
|
||||
.arg(QString("#FFFFFF")).arg(QString("#FFFFFF")));
|
||||
qss.append(QString("QWidget#widgetTopHanzi{background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 %1,stop:1 %2);}")
|
||||
qss.append(
|
||||
QString("QWidget#widgetTopHanzi{background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 %1,stop:1 %2);}")
|
||||
.arg(QString("#F4F4F4")).arg(QString("#F4F4F4")));
|
||||
//normal
|
||||
qss.append(QString("QPushButton{padding:1px;color:%1;background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 %2, stop: 1 %2);border: 0px solid %3;border-radius:6px;}")
|
||||
qss.append(
|
||||
QString("QPushButton{padding:1px;color:%1;background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 %2, stop: 1 %2);border: 0px solid %3;border-radius:6px;}")
|
||||
.arg(textColor).arg("#FFFFFF").arg(borderColor));
|
||||
qss.append(QString("QPushButton::pressed {background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %1, stop: 1.0 %1); border-color: %2; }")
|
||||
qss.append(
|
||||
QString("QPushButton::pressed {background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %1, stop: 1.0 %1); border-color: %2; }")
|
||||
.arg("#FF8400").arg(borderColor));
|
||||
//return
|
||||
qss.append(QString("QPushButton#btnReturn{padding:5px;color:%1;background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 %2, stop: 1 %2);border: 1px solid %3;border-radius:6px;}")
|
||||
qss.append(
|
||||
QString("QPushButton#btnReturn{padding:5px;color:%1;background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 %2, stop: 1 %2);border: 1px solid %3;border-radius:6px;}")
|
||||
.arg("#FFFFFF").arg("#FF8400").arg(borderColor));
|
||||
qss.append(QString("QPushButton#btnReturn::pressed {color:%1; background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %2, stop: 1.0 %2); border-color: %3; }")
|
||||
qss.append(
|
||||
QString("QPushButton#btnReturn::pressed {color:%1; background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %2, stop: 0.5 %2, stop: 1.0 %2); border-color: %3; }")
|
||||
.arg("#000000").arg("#FFFFFF").arg(borderColor));
|
||||
|
||||
//pre next
|
||||
qss.append(QString("QPushButton#btnPre,QPushButton#btnNext{padding:5px;color:%1;background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 %2, stop: 1 %2);border: 1px solid %3;border-radius:6px;}")
|
||||
qss.append(
|
||||
QString("QPushButton#btnPre,QPushButton#btnNext{padding:5px;color:%1;background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 %2, stop: 1 %2);border: 1px solid %3;border-radius:6px;}")
|
||||
.arg("#000000").arg("#F4F4F4").arg("#F4F4F4"));
|
||||
qss.append(QString("QPushButton#btnPre::pressed,QPushButton#btnNext::pressed {background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %1, stop: 1.0 %1); border-color: %2; }")
|
||||
qss.append(
|
||||
QString("QPushButton#btnPre::pressed,QPushButton#btnNext::pressed {background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 0.5 %1, stop: 1.0 %1); border-color: %2; }")
|
||||
.arg("#F4F4F4").arg("#F4F4F4"));
|
||||
|
||||
//qss.append(QString("QPushButton:hover{background:qlineargradient(spread:pad,x1:0,y1:0,x2:0,y2:1,stop:0 %1,stop:1 %2);}")
|
||||
// .arg(topColor).arg(bottomColor));
|
||||
qss.append(QString("QLabel{color:%1;}").arg(textColor));
|
||||
qss.append(QString("QLineEdit{border:1px solid %1;border-radius:5px;padding:2px;background:none;selection-background-color:%2;selection-color:%3;}")
|
||||
qss.append(
|
||||
QString("QLineEdit{border:1px solid %1;border-radius:5px;padding:2px;background:none;selection-background-color:%2;selection-color:%3;}")
|
||||
.arg(borderColor).arg(bottomColor).arg(topColor));
|
||||
this->setStyleSheet(qss.join(""));
|
||||
}
|
||||
|
@ -19,26 +19,26 @@
|
||||
#include <QTextCodec>
|
||||
#include <qqt-local.h>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class frmInput;
|
||||
namespace Ui {
|
||||
class frmInput;
|
||||
}
|
||||
|
||||
class QQTSHARED_EXPORT QQTInput : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
explicit QQTInput(QWidget *parent = 0);
|
||||
explicit QQTInput(QWidget* parent = 0);
|
||||
~QQTInput();
|
||||
|
||||
public:
|
||||
/*
|
||||
* 单例模式,保证一个程序只存在一个输入法实例对象
|
||||
*/
|
||||
static QQTInput *Instance() {
|
||||
static QQTInput* Instance() {
|
||||
if (!_instance) {
|
||||
_instance = new QQTInput;
|
||||
}
|
||||
|
||||
return _instance;
|
||||
}
|
||||
|
||||
@ -51,25 +51,25 @@ protected:
|
||||
/*
|
||||
* 事件过滤器,处理鼠标在汉字标签处单击操作
|
||||
*/
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
/*
|
||||
* 鼠标拖动事件
|
||||
*/
|
||||
void mouseMoveEvent(QMouseEvent *e);
|
||||
void mouseMoveEvent(QMouseEvent* e);
|
||||
/*
|
||||
* 鼠标按下事件
|
||||
*/
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void mousePressEvent(QMouseEvent* e);
|
||||
/*
|
||||
* 鼠标松开事件
|
||||
*/
|
||||
void mouseReleaseEvent(QMouseEvent *);
|
||||
void mouseReleaseEvent(QMouseEvent*);
|
||||
|
||||
private slots:
|
||||
/*
|
||||
* 焦点改变事件槽函数处理
|
||||
*/
|
||||
void focusChanged(QWidget *oldWidget, QWidget *nowWidget);
|
||||
void focusChanged(QWidget* oldWidget, QWidget* nowWidget);
|
||||
/*
|
||||
* 输入法面板按键处理
|
||||
*/
|
||||
@ -85,8 +85,8 @@ private slots:
|
||||
void reClicked();
|
||||
|
||||
private:
|
||||
Ui::frmInput *ui;
|
||||
static QQTInput *_instance; //实例对象
|
||||
Ui::frmInput* ui;
|
||||
static QQTInput* _instance; //实例对象
|
||||
|
||||
int deskWidth; //桌面宽度
|
||||
int deskHeight; //桌面高度
|
||||
@ -102,8 +102,8 @@ private:
|
||||
|
||||
QSqlDatabase m_db; //数据库
|
||||
bool isPress; //是否长按退格键
|
||||
QPushButton *btnPress; //长按按钮
|
||||
QTimer *timerPress; //退格键定时器
|
||||
QPushButton* btnPress; //长按按钮
|
||||
QTimer* timerPress; //退格键定时器
|
||||
bool checkPress(); //校验当前长按的按钮
|
||||
|
||||
bool isFirst; //是否首次加载
|
||||
@ -114,11 +114,11 @@ private:
|
||||
void ShowPanel(); //显示输入法面板
|
||||
|
||||
QWidget* currentFocusWidget;
|
||||
QWidget *currentWidget; //当前焦点的对象
|
||||
QLineEdit *currentLineEdit; //当前焦点的单行文本框
|
||||
QTextEdit *currentTextEdit; //当前焦点的多行文本框
|
||||
QPlainTextEdit *currentPlain; //当前焦点的富文本框
|
||||
QTextBrowser *currentBrowser; //当前焦点的文本浏览框
|
||||
QWidget* currentWidget; //当前焦点的对象
|
||||
QLineEdit* currentLineEdit; //当前焦点的单行文本框
|
||||
QTextEdit* currentTextEdit; //当前焦点的多行文本框
|
||||
QPlainTextEdit* currentPlain; //当前焦点的富文本框
|
||||
QTextBrowser* currentBrowser; //当前焦点的文本浏览框
|
||||
|
||||
QString currentEditType; //当前焦点控件的类型
|
||||
QString currentPosition; //当前输入法面板位置类型
|
||||
@ -132,7 +132,7 @@ private:
|
||||
void changeType(); //改变输入法类型
|
||||
void changeLetter(bool isUpper);//改变字母大小写
|
||||
|
||||
QList<QLabel *>labCh; //汉字标签数组
|
||||
QList<QLabel*>labCh; //汉字标签数组
|
||||
QStringList allPY; //所有拼音链表
|
||||
QStringList currentPY; //当前拼音链表
|
||||
int currentPY_index; //当前拼音索引
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "ui_qqtmsgbox.h"
|
||||
#include "qqtcore.h"
|
||||
|
||||
QQTMsgBox::QQTMsgBox(QWidget *parent) :
|
||||
QQTMsgBox::QQTMsgBox(QWidget* parent) :
|
||||
QQtDialog(parent),
|
||||
ui(new Ui::QQTMsgBox)
|
||||
{
|
||||
@ -17,7 +17,7 @@ QQTMsgBox::QQTMsgBox(QWidget *parent) :
|
||||
|
||||
pline() << qApp->desktop()->size();
|
||||
|
||||
if(qApp->desktop()->size() == QSize(1024, 768))
|
||||
if (qApp->desktop()->size() == QSize(1024, 768))
|
||||
{
|
||||
|
||||
widgetW = 401;
|
||||
@ -25,9 +25,9 @@ QQTMsgBox::QQTMsgBox(QWidget *parent) :
|
||||
btnW = 104;
|
||||
btnH = 40;
|
||||
botoomH = widgetH / 7 * 3;
|
||||
xSpaceYes = (widgetW - btnW - 12)/2;
|
||||
xSpaceYesNo = (widgetW-btnW*2-12)/3;
|
||||
ySpace = (botoomH-btnH)/2;
|
||||
xSpaceYes = (widgetW - btnW - 12) / 2;
|
||||
xSpaceYesNo = (widgetW - btnW * 2 - 12) / 3;
|
||||
ySpace = (botoomH - btnH) / 2;
|
||||
|
||||
pline() << widgetW << widgetH;
|
||||
pline() << btnW << btnH;
|
||||
@ -39,7 +39,7 @@ QQTMsgBox::QQTMsgBox(QWidget *parent) :
|
||||
//size
|
||||
ui->btnNo->setFixedSize(btnW, btnH);
|
||||
ui->btnYes->setFixedSize(btnW, btnH);
|
||||
ui->widgetBottom->setFixedHeight( botoomH );
|
||||
ui->widgetBottom->setFixedHeight(botoomH);
|
||||
|
||||
//text
|
||||
ui->btnNo->setText("");
|
||||
@ -47,26 +47,26 @@ QQTMsgBox::QQTMsgBox(QWidget *parent) :
|
||||
|
||||
//pic
|
||||
ui->btnNo->iconTable().initNormal("./skin/default/bt_back_normal.png",
|
||||
"./skin/default/bt_back_press.png" );
|
||||
"./skin/default/bt_back_press.png");
|
||||
ui->btnNo->iconTable().initOther("./skin/default/bt_back_hover.png",
|
||||
"./skin/default/bt_back_disable.png");
|
||||
|
||||
ui->btnYes->iconTable().initNormal("./skin/default/bt_login_normal.png",
|
||||
"./skin/default/bt_login_press.png" );
|
||||
"./skin/default/bt_login_press.png");
|
||||
ui->btnYes->iconTable().initOther("./skin/default/bt_login_hover.png",
|
||||
"./skin/default/bt_login_disable.png");
|
||||
|
||||
}
|
||||
else if(qApp->desktop()->size() == QSize(800, 480))
|
||||
else if (qApp->desktop()->size() == QSize(800, 480))
|
||||
{
|
||||
widgetW = 300;
|
||||
widgetH = 160;
|
||||
btnW = 80;
|
||||
btnH = 30;
|
||||
botoomH = widgetH / 7 * 3;
|
||||
xSpaceYes = (widgetW - btnW - 12)/2;
|
||||
xSpaceYesNo = (widgetW-btnW*2-12)/3;
|
||||
ySpace = (botoomH-btnH)/2;
|
||||
xSpaceYes = (widgetW - btnW - 12) / 2;
|
||||
xSpaceYesNo = (widgetW - btnW * 2 - 12) / 3;
|
||||
ySpace = (botoomH - btnH) / 2;
|
||||
|
||||
pline() << widgetW << widgetH;
|
||||
pline() << btnW << btnH;
|
||||
@ -78,7 +78,7 @@ QQTMsgBox::QQTMsgBox(QWidget *parent) :
|
||||
//size
|
||||
ui->btnNo->setFixedSize(btnW, btnH);
|
||||
ui->btnYes->setFixedSize(btnW, btnH);
|
||||
ui->widgetBottom->setFixedHeight( botoomH );
|
||||
ui->widgetBottom->setFixedHeight(botoomH);
|
||||
}
|
||||
|
||||
}
|
||||
@ -90,14 +90,14 @@ QQTMsgBox::~QQTMsgBox()
|
||||
|
||||
|
||||
|
||||
int QQTMsgBox::warning(QWidget *parent, QString content )
|
||||
int QQTMsgBox::warning(QWidget* parent, QString content)
|
||||
{
|
||||
QQTMsgBox* msgBox = new QQTMsgBox(parent);
|
||||
|
||||
return msgBox->_warning(content);
|
||||
}
|
||||
|
||||
int QQTMsgBox::question(QWidget *parent, QString content)
|
||||
int QQTMsgBox::question(QWidget* parent, QString content)
|
||||
{
|
||||
QQTMsgBox* msgBox = new QQTMsgBox(parent);
|
||||
return msgBox->_question(content);
|
||||
@ -133,7 +133,7 @@ void QQTMsgBox::showYesAndNo()
|
||||
int x0 = xSpaceYesNo;
|
||||
int y0 = ySpace;
|
||||
ui->btnYes->setGeometry(x0, y0, btnW, btnH);
|
||||
ui->btnNo->setGeometry(x0+btnW+x0, y0, btnW, btnH);
|
||||
ui->btnNo->setGeometry(x0 + btnW + x0, y0, btnW, btnH);
|
||||
}
|
||||
|
||||
void QQTMsgBox::showNull()
|
||||
@ -180,14 +180,16 @@ void QQTMsgBox::information(QString content)
|
||||
QQTSleep(delayShow);
|
||||
}
|
||||
|
||||
void QQTMsgBox::timerEvent(QTimerEvent *e)
|
||||
void QQTMsgBox::timerEvent(QTimerEvent* e)
|
||||
{
|
||||
return;
|
||||
if(m_time > 5)
|
||||
|
||||
if (m_time > 5)
|
||||
{
|
||||
killTimer(e->timerId());
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
|
||||
m_time ++ ;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class QQTSHARED_EXPORT QQTMsgBox : public QQtDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQTMsgBox(QWidget *parent = 0);
|
||||
explicit QQTMsgBox(QWidget* parent = 0);
|
||||
~QQTMsgBox();
|
||||
|
||||
void warning(QString content);
|
||||
@ -38,7 +38,7 @@ protected:
|
||||
int _question(QString content);
|
||||
|
||||
private:
|
||||
Ui::QQTMsgBox *ui;
|
||||
Ui::QQTMsgBox* ui;
|
||||
quint32 m_time;
|
||||
int delayShow;
|
||||
|
||||
@ -58,7 +58,7 @@ private:
|
||||
|
||||
// QObject interface
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *);
|
||||
void timerEvent(QTimerEvent*);
|
||||
};
|
||||
|
||||
#endif // QQTMSGBOX_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "qqtpassworddialog.h"
|
||||
#include "ui_qqtpassworddialog.h"
|
||||
|
||||
QQTPasswordDialog::QQTPasswordDialog(QWidget *parent) :
|
||||
QQTPasswordDialog::QQTPasswordDialog(QWidget* parent) :
|
||||
QQtDialog(parent),
|
||||
ui(new Ui::QQTPasswordDialog)
|
||||
{
|
||||
@ -41,6 +41,6 @@ void QQTPasswordDialog::connectClicked()
|
||||
|
||||
void QQTPasswordDialog::btnEnabled(QString pas)
|
||||
{
|
||||
bool enable = pas.length()<8?false:true;
|
||||
bool enable = pas.length() < 8 ? false : true;
|
||||
ui->pushButton_ssid_connect->setEnabled(enable);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class QQTSHARED_EXPORT QQTPasswordDialog : public QQtDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQTPasswordDialog(QWidget *parent = 0);
|
||||
explicit QQTPasswordDialog(QWidget* parent = 0);
|
||||
~QQTPasswordDialog();
|
||||
|
||||
void setWifiName(QString name);
|
||||
@ -26,7 +26,7 @@ private slots:
|
||||
void btnEnabled(QString);
|
||||
|
||||
private:
|
||||
Ui::QQTPasswordDialog *ui;
|
||||
Ui::QQTPasswordDialog* ui;
|
||||
};
|
||||
|
||||
#endif // QQTPASSWORDDIALOG_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "qqtpreviewwidget.h"
|
||||
#include "ui_qqtpreviewwidget.h"
|
||||
|
||||
QQTPreviewWidget::QQTPreviewWidget(QWidget *parent) :
|
||||
QQTPreviewWidget::QQTPreviewWidget(QWidget* parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::QQTPreviewWidget)
|
||||
{
|
||||
@ -18,9 +18,9 @@ QQTPreviewWidget::QQTPreviewWidget(QWidget *parent) :
|
||||
|
||||
fd = 0;
|
||||
|
||||
memset( & pre_memory, 0, sizeof(struct camera_memory));
|
||||
memset( & pre_buf, 0, sizeof(struct camera_buffer));
|
||||
memset( & pre_size, 0, sizeof(struct frm_size));
|
||||
memset(& pre_memory, 0, sizeof(struct camera_memory));
|
||||
memset(& pre_buf, 0, sizeof(struct camera_buffer));
|
||||
memset(& pre_size, 0, sizeof(struct frm_size));
|
||||
|
||||
tlb_base_phys = 0;
|
||||
format = HAL_PIXEL_FORMAT_YCbCr_422_I;
|
||||
@ -47,9 +47,12 @@ int QQTPreviewWidget::play()
|
||||
dmmu_get_page_table_base_phys(&tlb_base_phys);
|
||||
|
||||
fd = ::open("/dev/cim", O_RDWR); //av
|
||||
if (fd < 0) {
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
qDebug() << "Open device fail\n";
|
||||
}
|
||||
|
||||
ioctl(fd, CIMIO_SELECT_SENSOR, sinfo.sensor_id);
|
||||
|
||||
ioctl(fd, CIMIO_GET_SENSORINFO, &sinfo);
|
||||
@ -58,7 +61,7 @@ int QQTPreviewWidget::play()
|
||||
|
||||
int i = 0;
|
||||
|
||||
if(pre_buf.common && pre_buf.common->data)
|
||||
if (pre_buf.common && pre_buf.common->data)
|
||||
{
|
||||
dmmu_unmap_user_memory(&(pre_buf.dmmu_info));
|
||||
free(pre_buf.common->data);
|
||||
@ -71,6 +74,7 @@ int QQTPreviewWidget::play()
|
||||
pre_buf.common->size = pre_buf.size * pre_buf.nr;
|
||||
pre_buf.common->data = memalign(4096, pre_buf.size * pre_buf.nr);
|
||||
memset(pre_buf.common->data, 0xa5, (pre_buf.size * pre_buf.nr));
|
||||
|
||||
if (pre_buf.common->data == NULL)
|
||||
{
|
||||
printf("==<%s L%d: null pointer!\n", __func__, __LINE__);
|
||||
@ -89,7 +93,8 @@ int QQTPreviewWidget::play()
|
||||
((uint8_t*)(pre_buf.common->data))[pre_buf.common->size - 1] = 0xff;
|
||||
dmmu_map_user_memory(&(pre_buf.dmmu_info));
|
||||
|
||||
for (i= 0; i < pre_buf.nr; ++i) {
|
||||
for (i = 0; i < pre_buf.nr; ++i)
|
||||
{
|
||||
pre_buf.yuvMeta[i].index = i;
|
||||
pre_buf.yuvMeta[i].width = pre_size.w;
|
||||
pre_buf.yuvMeta[i].height = pre_size.h;
|
||||
@ -101,23 +106,29 @@ int QQTPreviewWidget::play()
|
||||
pre_buf.yuvMeta[i].yAddr = (int32_t)pre_buf.common->data + (pre_buf.size) * i;
|
||||
#endif
|
||||
pre_buf.yuvMeta[i].yPhy = pre_buf.paddr + i * (pre_buf.size);
|
||||
if (pre_buf.yuvMeta[i].format == HAL_PIXEL_FORMAT_YCbCr_422_I) { //yuv422 packed
|
||||
|
||||
if (pre_buf.yuvMeta[i].format == HAL_PIXEL_FORMAT_YCbCr_422_I) //yuv422 packed
|
||||
{
|
||||
pre_buf.yuvMeta[i].uAddr = pre_buf.yuvMeta[i].yAddr;
|
||||
pre_buf.yuvMeta[i].vAddr = pre_buf.yuvMeta[i].uAddr;
|
||||
pre_buf.yuvMeta[i].uPhy = pre_buf.yuvMeta[i].yPhy;
|
||||
pre_buf.yuvMeta[i].vPhy = pre_buf.yuvMeta[i].uPhy;
|
||||
pre_buf.yuvMeta[i].yStride = pre_buf.yuvMeta[i].width<<1;
|
||||
pre_buf.yuvMeta[i].yStride = pre_buf.yuvMeta[i].width << 1;
|
||||
pre_buf.yuvMeta[i].uStride = pre_buf.yuvMeta[i].yStride;
|
||||
pre_buf.yuvMeta[i].vStride = pre_buf.yuvMeta[i].yStride;
|
||||
} else if (pre_buf.yuvMeta[i].format == HAL_PIXEL_FORMAT_JZ_YUV_420_P) { //yuv420 planar
|
||||
}
|
||||
else if (pre_buf.yuvMeta[i].format == HAL_PIXEL_FORMAT_JZ_YUV_420_P) //yuv420 planar
|
||||
{
|
||||
pre_buf.yuvMeta[i].uAddr = pre_buf.yuvMeta[i].yAddr + pre_size.w * pre_size.h;
|
||||
pre_buf.yuvMeta[i].vAddr = pre_buf.yuvMeta[i].uAddr + pre_size.w * pre_size.h / 4;
|
||||
pre_buf.yuvMeta[i].uPhy = pre_buf.yuvMeta[i].yPhy + pre_size.w * pre_size.h;
|
||||
pre_buf.yuvMeta[i].vPhy = pre_buf.yuvMeta[i].uPhy + pre_size.w * pre_size.h / 4;
|
||||
pre_buf.yuvMeta[i].yStride = pre_buf.yuvMeta[i].width<<1;
|
||||
pre_buf.yuvMeta[i].yStride = pre_buf.yuvMeta[i].width << 1;
|
||||
pre_buf.yuvMeta[i].uStride = pre_buf.yuvMeta[i].width / 2;
|
||||
pre_buf.yuvMeta[i].vStride = pre_buf.yuvMeta[i].width / 2;
|
||||
} else if (pre_buf.yuvMeta[i].format == HAL_PIXEL_FORMAT_RAW_SENSOR) { //raw bayer
|
||||
}
|
||||
else if (pre_buf.yuvMeta[i].format == HAL_PIXEL_FORMAT_RAW_SENSOR) //raw bayer
|
||||
{
|
||||
pre_buf.yuvMeta[i].uAddr = pre_buf.yuvMeta[i].yAddr + pre_size.w * pre_size.h;
|
||||
pre_buf.yuvMeta[i].vAddr = pre_buf.yuvMeta[i].uAddr;
|
||||
pre_buf.yuvMeta[i].uPhy = pre_buf.yuvMeta[i].yPhy;
|
||||
@ -135,7 +146,7 @@ int QQTPreviewWidget::play()
|
||||
|
||||
ioctl(fd, CIMIO_START_PREVIEW);
|
||||
|
||||
pp = (unsigned char *)malloc(pre_size.w * pre_size.h * 3 * sizeof(char));
|
||||
pp = (unsigned char*)malloc(pre_size.w * pre_size.h * 3 * sizeof(char));
|
||||
frame = new QImage(pp, pre_size.w, pre_size.h, QImage::Format_RGB888);
|
||||
timer->start(100);
|
||||
|
||||
@ -146,8 +157,9 @@ int QQTPreviewWidget::close()
|
||||
{
|
||||
bool ret = false;
|
||||
|
||||
if(fd <= 0)
|
||||
if (fd <= 0)
|
||||
printf("fd < 0\n");
|
||||
|
||||
ret = ioctl(fd, CIMIO_SHUTDOWN);
|
||||
|
||||
::close(fd);
|
||||
@ -156,13 +168,14 @@ int QQTPreviewWidget::close()
|
||||
dmmu_unmap_user_memory(&(pre_buf.dmmu_info));
|
||||
dmmu_deinit();
|
||||
|
||||
memset(pre_buf.yuvMeta, 0, pre_buf.nr * sizeof (CameraYUVMeta));
|
||||
memset(pre_buf.yuvMeta, 0, pre_buf.nr * sizeof(CameraYUVMeta));
|
||||
pre_buf.size = 0;
|
||||
pre_buf.nr = 0;
|
||||
pre_buf.paddr = 0;
|
||||
pre_buf.fd = -1;
|
||||
|
||||
if((pre_buf.common != NULL) && (pre_buf.common->data != NULL)) {
|
||||
if ((pre_buf.common != NULL) && (pre_buf.common->data != NULL))
|
||||
{
|
||||
free(pre_buf.common->data);
|
||||
pre_buf.common->data = NULL;
|
||||
}
|
||||
@ -180,28 +193,31 @@ int QQTPreviewWidget::close()
|
||||
int QQTPreviewWidget::convert_yuv_to_rgb_pixel(int y, int u, int v)
|
||||
{
|
||||
unsigned int pixel32 = 0;
|
||||
unsigned char *pixel = (unsigned char *)&pixel32;
|
||||
unsigned char* pixel = (unsigned char*)&pixel32;
|
||||
int r, g, b;
|
||||
b = y + ((443 * (u - 128)) >> 8);
|
||||
b = (b < 0) ? 0 : ((b > 255 ) ? 255 : b);
|
||||
b = (b < 0) ? 0 : ((b > 255) ? 255 : b);
|
||||
g = y - ((179 * (v - 128) + 86 * (u - 128)) >> 8);
|
||||
g = (g < 0) ? 0 : ((g > 255 ) ? 255 : g);
|
||||
g = (g < 0) ? 0 : ((g > 255) ? 255 : g);
|
||||
r = y + ((351 * (v - 128)) >> 8);
|
||||
r = (r < 0) ? 0 : ((r > 255 ) ? 255 : r);
|
||||
r = (r < 0) ? 0 : ((r > 255) ? 255 : r);
|
||||
pixel[0] = r;
|
||||
pixel[1] = g;
|
||||
pixel[2] = b;
|
||||
return pixel32;
|
||||
}
|
||||
|
||||
int QQTPreviewWidget::convert_yuv_to_rgb_buffer(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height)
|
||||
int QQTPreviewWidget::convert_yuv_to_rgb_buffer(unsigned char* yuv, unsigned char* rgb, unsigned int width,
|
||||
unsigned int height)
|
||||
{
|
||||
unsigned int in, out = 0;
|
||||
unsigned int pixel_16;
|
||||
unsigned char pixel_24[3];
|
||||
unsigned int pixel32;
|
||||
int y0, u, y1, v;
|
||||
for(in = 0; in < width * height * 2; in += 4) {
|
||||
|
||||
for (in = 0; in < width * height * 2; in += 4)
|
||||
{
|
||||
pixel_16 =
|
||||
yuv[in + 3] << 24 |
|
||||
yuv[in + 2] << 16 |
|
||||
@ -226,13 +242,14 @@ int QQTPreviewWidget::convert_yuv_to_rgb_buffer(unsigned char *yuv, unsigned cha
|
||||
rgb[out++] = pixel_24[1];
|
||||
rgb[out++] = pixel_24[2];
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void QQTPreviewWidget::paintEvent(QPaintEvent *)
|
||||
void QQTPreviewWidget::paintEvent(QPaintEvent*)
|
||||
{
|
||||
if(fd <= 0)
|
||||
if (fd <= 0)
|
||||
return;
|
||||
|
||||
QStylePainter painter(this);
|
||||
@ -257,7 +274,7 @@ void QQTPreviewWidget::paintEvent(QPaintEvent *)
|
||||
/*
|
||||
* 缩放OK
|
||||
*/
|
||||
painter.drawImage(dstRect, *frame, srcRect );
|
||||
painter.drawImage(dstRect, *frame, srcRect);
|
||||
//painter.drawPixmap(dstRect,QPixmap::fromImage(*frame,Qt::AutoColor),srcRect);;
|
||||
/*
|
||||
* 裁切OK
|
||||
@ -270,10 +287,11 @@ void QQTPreviewWidget::paintEvent(QPaintEvent *)
|
||||
}
|
||||
|
||||
|
||||
void QQTPreviewWidget::mousePressEvent(QMouseEvent *e)
|
||||
void QQTPreviewWidget::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
static bool bGInit = false;
|
||||
if(!bGInit && !bFullScreen)
|
||||
|
||||
if (!bGInit && !bFullScreen)
|
||||
{
|
||||
flags = windowFlags();
|
||||
flags |= Qt::FramelessWindowHint;
|
||||
@ -282,8 +300,9 @@ void QQTPreviewWidget::mousePressEvent(QMouseEvent *e)
|
||||
}
|
||||
|
||||
#ifdef __EMBEDDED_LINUX__
|
||||
|
||||
//pline() << e->pos() << e->globalPos();
|
||||
if(e->pos().x() < 0 || e->pos().y() < 0 ||
|
||||
if (e->pos().x() < 0 || e->pos().y() < 0 ||
|
||||
e->pos().x() > geome.width() || e->pos().y() > geome.height())
|
||||
{
|
||||
//在mips板上,全屏返回的时候,点击其他位置,会多响应一次,在此处过滤。
|
||||
@ -291,13 +310,14 @@ void QQTPreviewWidget::mousePressEvent(QMouseEvent *e)
|
||||
Q_UNUSED(e);
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
setAttribute(Qt::WA_TranslucentBackground, true);
|
||||
setAttribute(Qt::WA_NoMousePropagation, true);
|
||||
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
||||
|
||||
if(bFullScreen)
|
||||
if (bFullScreen)
|
||||
{
|
||||
flags ^= Qt::Window;
|
||||
flags |= Qt::Widget;
|
||||
|
@ -29,13 +29,13 @@ class QQTSHARED_EXPORT QQTPreviewWidget : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQTPreviewWidget(QWidget *parent = 0);
|
||||
explicit QQTPreviewWidget(QWidget* parent = 0);
|
||||
~QQTPreviewWidget();
|
||||
int play();
|
||||
int close();
|
||||
|
||||
private:
|
||||
Ui::QQTPreviewWidget *ui;
|
||||
Ui::QQTPreviewWidget* ui;
|
||||
|
||||
struct sensor_info sinfo;
|
||||
int pre_bpp;
|
||||
@ -51,10 +51,10 @@ private:
|
||||
struct frm_size pre_size;
|
||||
unsigned int tlb_base_phys;
|
||||
|
||||
uchar *pp;
|
||||
uchar * p;
|
||||
QImage *frame;
|
||||
QTimer *timer;
|
||||
uchar* pp;
|
||||
uchar* p;
|
||||
QImage* frame;
|
||||
QTimer* timer;
|
||||
|
||||
bool bFullScreen;
|
||||
QWidget* m_parent;
|
||||
@ -62,12 +62,12 @@ private:
|
||||
Qt::WindowFlags flags;
|
||||
|
||||
int convert_yuv_to_rgb_pixel(int y, int u, int v);
|
||||
int convert_yuv_to_rgb_buffer(unsigned char *yuv, unsigned char *rgb, unsigned int width, unsigned int height);
|
||||
int convert_yuv_to_rgb_buffer(unsigned char* yuv, unsigned char* rgb, unsigned int width, unsigned int height);
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *);
|
||||
void mousePressEvent(QMouseEvent *e);
|
||||
void paintEvent(QPaintEvent*);
|
||||
void mousePressEvent(QMouseEvent* e);
|
||||
};
|
||||
|
||||
#endif // QPREVIEWUI_H
|
||||
|
@ -5,8 +5,7 @@
|
||||
#include "qqtdialog.h"
|
||||
#include "qqtprogressbar.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
namespace Ui {
|
||||
class QQtProgressDialog;
|
||||
}
|
||||
|
||||
|
@ -6,38 +6,47 @@
|
||||
#include "qqtethenetmanager.h"
|
||||
|
||||
|
||||
void QQTWIFIIDTextDelegate::drawCheck(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, Qt::CheckState state) const
|
||||
void QQTWIFIIDTextDelegate::drawCheck(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect,
|
||||
Qt::CheckState state) const
|
||||
{
|
||||
#if 0
|
||||
|
||||
if (!rect.isValid())
|
||||
return;
|
||||
|
||||
QStyleOptionViewItem opt(option);
|
||||
opt.rect = rect;
|
||||
opt.state = opt.state & ~QStyle::State_HasFocus;
|
||||
switch (state) {
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case Qt::Unchecked:
|
||||
opt.state |= QStyle::State_Off;
|
||||
break;
|
||||
|
||||
case Qt::PartiallyChecked:
|
||||
opt.state |= QStyle::State_NoChange;
|
||||
break;
|
||||
|
||||
case Qt::Checked:
|
||||
opt.state |= QStyle::State_On;
|
||||
break;
|
||||
}
|
||||
|
||||
QApplication::style()->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &opt, painter);
|
||||
#else
|
||||
QItemDelegate::drawCheck(painter, option, rect, state);
|
||||
#endif
|
||||
}
|
||||
|
||||
void QQTWIFIIDTextDelegate::drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const
|
||||
void QQTWIFIIDTextDelegate::drawDisplay(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect,
|
||||
const QString& text) const
|
||||
{
|
||||
if("COMPLETED" == text)
|
||||
if ("COMPLETED" == text)
|
||||
painter->drawImage(rect, QImage("./skin/default/bk_sel.png"));
|
||||
}
|
||||
|
||||
QQTWIFIWidget::QQTWIFIWidget(QWidget *parent) :
|
||||
QQTWIFIWidget::QQTWIFIWidget(QWidget* parent) :
|
||||
QQTTableView(parent),
|
||||
ui(new Ui::QQTWIFIWidget)
|
||||
{
|
||||
@ -68,8 +77,10 @@ QQTWIFIWidget::QQTWIFIWidget(QWidget *parent) :
|
||||
#endif
|
||||
dg = new QQTWIFIIDTextDelegate(this);
|
||||
setItemDelegateForColumn(ESSID_STATUS, dg);
|
||||
for(int i = ESSID_TYPE; i < ESSID_MAX; i++)
|
||||
|
||||
for (int i = ESSID_TYPE; i < ESSID_MAX; i++)
|
||||
setColumnHidden(i, true);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
|
||||
horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed);
|
||||
#else
|
||||
@ -102,14 +113,18 @@ void QQTWIFIWidget::wifiRefreshed()
|
||||
m_model->removeRows(row, m_model->rowCount());
|
||||
QList<TWifi>& list = m_pManager->wifiList();
|
||||
m_model->insertRows(row, list.size());
|
||||
for(QList<TWifi>::Iterator it = list.begin();
|
||||
|
||||
for (QList<TWifi>::Iterator it = list.begin();
|
||||
it != list.end(); it++)
|
||||
{
|
||||
TWifi wifi = *(TWifi*)(&*it);
|
||||
for(int i = ESSID_STATUS; i < ESSID_MAX; i++)
|
||||
|
||||
for (int i = ESSID_STATUS; i < ESSID_MAX; i++)
|
||||
m_model->setData(m_model->index(row, i), wifi[i]);
|
||||
|
||||
row++;
|
||||
}
|
||||
|
||||
m_model->submit();
|
||||
}
|
||||
|
||||
@ -121,12 +136,14 @@ void QQTWIFIWidget::clickWIFI()
|
||||
QString mac = m_model->data(m_model->index(currentIndex().row(), ESSID_BSSID)).toString();
|
||||
|
||||
QQTEthenetManager::Instance()->setRefresh(false);
|
||||
|
||||
do
|
||||
{
|
||||
if("YES" == encryt)
|
||||
if ("YES" == encryt)
|
||||
{
|
||||
m_pass->setWifiName(name);
|
||||
if(QQTPasswordDialog::Rejected == m_pass->exec())
|
||||
|
||||
if (QQTPasswordDialog::Rejected == m_pass->exec())
|
||||
break;
|
||||
}
|
||||
|
||||
@ -134,14 +151,15 @@ void QQTWIFIWidget::clickWIFI()
|
||||
|
||||
pline() << ok;
|
||||
|
||||
if(!ok)
|
||||
if (!ok)
|
||||
{
|
||||
QQTMsgBox::warning(this, tr("Password error"));
|
||||
break;
|
||||
}
|
||||
|
||||
pline() << name << encryt << m_pass->wifiPwd();
|
||||
}while(0);
|
||||
} while (0);
|
||||
|
||||
QQTEthenetManager::Instance()->setRefresh();
|
||||
}
|
||||
|
||||
|
@ -14,18 +14,18 @@ class QQTSHARED_EXPORT QQTWIFIIDTextDelegate : public QItemDelegate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QQTWIFIIDTextDelegate(QObject *parent = 0): QItemDelegate(parent), parent(parent) { }
|
||||
QQTWIFIIDTextDelegate(QObject* parent = 0): QItemDelegate(parent), parent(parent) { }
|
||||
|
||||
private:
|
||||
QObject* parent;
|
||||
|
||||
// QItemDelegate interface
|
||||
protected:
|
||||
void drawCheck(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, Qt::CheckState state) const;
|
||||
void drawCheck(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, Qt::CheckState state) const;
|
||||
|
||||
// QItemDelegate interface
|
||||
protected:
|
||||
void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const;
|
||||
void drawDisplay(QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, const QString& text) const;
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
@ -37,7 +37,7 @@ class QQTWIFIWidget : public QQTTableView
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QQTWIFIWidget(QWidget *parent = 0);
|
||||
explicit QQTWIFIWidget(QWidget* parent = 0);
|
||||
~QQTWIFIWidget();
|
||||
|
||||
private slots:
|
||||
@ -51,7 +51,7 @@ private:
|
||||
QQTWIFIIDTextDelegate* dg;
|
||||
|
||||
private:
|
||||
Ui::QQTWIFIWidget *ui;
|
||||
Ui::QQTWIFIWidget* ui;
|
||||
QStandardItemModel* m_model;
|
||||
QQTPasswordDialog* m_pass;
|
||||
};
|
||||
|
@ -44,7 +44,8 @@ QQTWord::QQTWord(QObject* parent) :
|
||||
#endif
|
||||
|
||||
QRect rect = pr->paperRect();
|
||||
sceneRect = QRectF(0.0, 0.0, logicalDpiX * rect.width() / pr->logicalDpiX(), logicalDpiY * rect.height() / pr->logicalDpiY());
|
||||
sceneRect = QRectF(0.0, 0.0, logicalDpiX * rect.width() / pr->logicalDpiX(),
|
||||
logicalDpiY * rect.height() / pr->logicalDpiY());
|
||||
|
||||
#if 0
|
||||
//1200 9917,14033 printerRect 固定
|
||||
@ -62,18 +63,24 @@ QQTWord::QQTWord(QObject* parent) :
|
||||
#endif
|
||||
|
||||
m_mainFont = QApplication::font();
|
||||
|
||||
if (mainFmt)
|
||||
delete mainFmt;
|
||||
|
||||
mainFmt = new QFontMetrics(m_mainFont);
|
||||
m_titleFont = QApplication::font();
|
||||
m_titleFont.setPointSize(22);
|
||||
|
||||
if (titleFmt)
|
||||
delete titleFmt;
|
||||
|
||||
titleFmt = new QFontMetrics(m_titleFont);
|
||||
m_title2Font = QApplication::font();;
|
||||
m_title2Font.setPointSize(16);
|
||||
|
||||
if (title2Fmt)
|
||||
delete title2Fmt;
|
||||
|
||||
title2Fmt = new QFontMetrics(m_title2Font);
|
||||
|
||||
setMargin();
|
||||
@ -116,8 +123,10 @@ void QQTWord::setFont(QFont font)
|
||||
{
|
||||
//normal font 11
|
||||
m_font = QApplication::font();
|
||||
|
||||
if (fmt)
|
||||
delete fmt;
|
||||
|
||||
fmt = new QFontMetrics(m_font);
|
||||
}
|
||||
|
||||
@ -156,6 +165,7 @@ void QQTWord::addText(const QString& text, QFont font, Qt::Alignment align, QPoi
|
||||
item->moveBy(xpos2 - width, dy + height);
|
||||
else if (align & Qt::AlignHCenter)
|
||||
item->moveBy((pageScene->width() / 2) - (width / 2), dy + height);
|
||||
|
||||
dy += height + spacing;
|
||||
}
|
||||
|
||||
@ -186,6 +196,7 @@ void QQTWord::addTable(const QTableView* table, QPointF pos)
|
||||
{
|
||||
tableRowHeight = table->horizontalHeader()->height();
|
||||
adjustdy(tableRowHeight);
|
||||
|
||||
for (int col = 0; col < model->columnCount(); col++)
|
||||
{
|
||||
int logicalIndex = table->horizontalHeader()->logicalIndex(col);
|
||||
@ -205,11 +216,13 @@ void QQTWord::addTable(const QTableView* table, QPointF pos)
|
||||
item->moveBy(dx, dy);
|
||||
dx += actColSize;
|
||||
}
|
||||
|
||||
dy += tableRowHeight;
|
||||
}
|
||||
|
||||
QHash<int, ESpanFlags> spans = tableSpans(table);
|
||||
QHashIterator<int, ESpanFlags> it(spans);
|
||||
|
||||
while (0 && it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
@ -225,6 +238,7 @@ void QQTWord::addTable(const QTableView* table, QPointF pos)
|
||||
QPen pen(Qt::gray, 0.1);
|
||||
QBrush brush(Qt::gray, Qt::SolidPattern);
|
||||
int row = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (row >= model->rowCount())
|
||||
@ -237,6 +251,7 @@ void QQTWord::addTable(const QTableView* table, QPointF pos)
|
||||
|
||||
tableRowHeight = table->rowHeight(row);
|
||||
adjustdy(tableRowHeight);
|
||||
|
||||
for (int col = 0; col < model->columnCount(); col++)
|
||||
{
|
||||
int logicalIndex = table->horizontalHeader()->logicalIndex(col);
|
||||
@ -257,6 +272,7 @@ void QQTWord::addTable(const QTableView* table, QPointF pos)
|
||||
if (balt)
|
||||
{
|
||||
int modulo = row % 2;
|
||||
|
||||
if (modulo != 0)
|
||||
{
|
||||
//rectangle grey
|
||||
@ -275,10 +291,13 @@ void QQTWord::addTable(const QTableView* table, QPointF pos)
|
||||
|
||||
if (flags.testFlag(ESpanLeft))
|
||||
pageScene->addLine(dx, dy, dx, dy + tableRowHeight, pen);
|
||||
|
||||
if (flags.testFlag(ESpanTop))
|
||||
pageScene->addLine(dx, dy, dx + actColSize, dy, pen);
|
||||
|
||||
if (flags.testFlag(ESpanRight))
|
||||
pageScene->addLine(dx + actColSize, dy, dx + actColSize, dy + tableRowHeight, pen);
|
||||
|
||||
if (flags.testFlag(ESpanBottom))
|
||||
pageScene->addLine(dx, dy + tableRowHeight, dx + actColSize, dy + tableRowHeight, pen);
|
||||
|
||||
@ -293,6 +312,7 @@ void QQTWord::addTable(const QTableView* table, QPointF pos)
|
||||
|
||||
dx += actColSize;
|
||||
}
|
||||
|
||||
row++;
|
||||
dy += tableRowHeight;
|
||||
dx = xpos;
|
||||
@ -310,6 +330,7 @@ void QQTWord::exportPdf(const QString& pdf)
|
||||
QPainter p(pr);
|
||||
|
||||
QQTGraphicsScene* pageScene = 0;
|
||||
|
||||
foreach (pageScene, pageSceneVector)
|
||||
{
|
||||
|
||||
@ -324,6 +345,7 @@ QQTGraphicsScene* QQTWord::getPage(int num)
|
||||
{
|
||||
if (num < 1 || num > pageSceneVector.size())
|
||||
return NULL;
|
||||
|
||||
return pageSceneVector.at(num - 1);
|
||||
}
|
||||
|
||||
@ -337,8 +359,10 @@ void QQTWord::setHeaderFont(QFont font)
|
||||
//header font
|
||||
m_headerFont = QApplication::font();;
|
||||
m_headerFont.setPointSize(9);
|
||||
|
||||
if (headerFmt)
|
||||
delete headerFmt;
|
||||
|
||||
headerFmt = new QFontMetrics(m_headerFont);
|
||||
}
|
||||
|
||||
@ -387,6 +411,7 @@ void QQTWord::initWord()
|
||||
delete pageScene;
|
||||
pageSceneVector.remove(0);
|
||||
}
|
||||
|
||||
headerText = "";
|
||||
footerText = "";
|
||||
createFrame();
|
||||
@ -395,8 +420,10 @@ void QQTWord::initWord()
|
||||
void QQTWord::adjustdy(qreal dy0)
|
||||
{
|
||||
dx = xpos;
|
||||
|
||||
if (dy + dy0 < ypos2)
|
||||
return;
|
||||
|
||||
createFrame();
|
||||
}
|
||||
|
||||
@ -500,6 +527,7 @@ QHash<int, ESpanFlags> QQTWord::tableSpans(const QTableView* table)
|
||||
{
|
||||
|
||||
point = (row + i) * colCount + col + 0;
|
||||
|
||||
/*
|
||||
* 如果此处有Span,但是Spans已经赋值,那么break
|
||||
*/
|
||||
@ -509,6 +537,7 @@ QHash<int, ESpanFlags> QQTWord::tableSpans(const QTableView* table)
|
||||
for (int j = 0; j < colSpan; j++)
|
||||
{
|
||||
point = (row + i) * colCount + col + j;
|
||||
|
||||
/*
|
||||
* 如果此处有Span,但是Spans已经赋值,那么break
|
||||
*/
|
||||
|
@ -23,16 +23,16 @@ class QQTSHARED_EXPORT QQTWord : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQTWord(QObject *parent = 0);
|
||||
explicit QQTWord(QObject* parent = 0);
|
||||
|
||||
void addText(const QString& text, QFont m_font = QFont(),
|
||||
Qt::Alignment align = Qt::AlignHCenter, QPointF point= QPointF(0, 0));
|
||||
Qt::Alignment align = Qt::AlignHCenter, QPointF point = QPointF(0, 0));
|
||||
void addSignoffText(const QString& text, QFont m_font = QFont());
|
||||
void addTable(const QTableView* table, QPointF pos = QPointF(0, 0));
|
||||
|
||||
int pageNum();
|
||||
QQTGraphicsScene* getPage(int num);
|
||||
void exportPdf(const QString &pdf);
|
||||
void exportPdf(const QString& pdf);
|
||||
void print();
|
||||
|
||||
QRectF clientRectF();
|
||||
@ -52,7 +52,7 @@ public:
|
||||
QFont headerFont() { return m_headerFont; }
|
||||
void setHeaderLine(bool show = false);
|
||||
void setFooterLine(bool show = false);
|
||||
void setHeaderText(const QString &text, QFont m_font = QFont(),
|
||||
void setHeaderText(const QString& text, QFont m_font = QFont(),
|
||||
Qt::Alignment align = Qt::AlignHCenter);
|
||||
void setFooterText(const QString& text, QFont m_font = QFont(),
|
||||
Qt::Alignment align = Qt::AlignHCenter);
|
||||
@ -112,7 +112,7 @@ private:
|
||||
*/
|
||||
qreal headerSize;
|
||||
QFont m_headerFont;
|
||||
QFontMetrics *headerFmt;
|
||||
QFontMetrics* headerFmt;
|
||||
QString headerText;
|
||||
|
||||
/*
|
||||
@ -126,25 +126,25 @@ private:
|
||||
* 标题
|
||||
*/
|
||||
QFont m_titleFont;
|
||||
QFontMetrics *titleFmt;
|
||||
QFontMetrics* titleFmt;
|
||||
|
||||
/*
|
||||
* 二号标题
|
||||
*/
|
||||
QFont m_title2Font;
|
||||
QFontMetrics *title2Fmt;
|
||||
QFontMetrics* title2Fmt;
|
||||
|
||||
/*
|
||||
* 正文
|
||||
*/
|
||||
QFont m_mainFont;
|
||||
QFontMetrics *mainFmt;
|
||||
QFontMetrics* mainFmt;
|
||||
|
||||
/*
|
||||
* 使用中
|
||||
*/
|
||||
QFont m_font;
|
||||
QFontMetrics *fmt;
|
||||
QFontMetrics* fmt;
|
||||
|
||||
|
||||
QHash<int, ESpanFlags> tableSpans(const QTableView* table);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "qqtftptreemodel.h"
|
||||
|
||||
QQtFTPTreeModel::QQtFTPTreeModel(QObject *parent) : QObject(parent)
|
||||
QQtFTPTreeModel::QQtFTPTreeModel(QObject* parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class QQTSHARED_EXPORT QQtFTPTreeModel : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtFTPTreeModel(QObject *parent = 0);
|
||||
explicit QQtFTPTreeModel(QObject* parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -29,11 +29,13 @@ bool QQTSqlTreeModel::parseDatabase()
|
||||
{
|
||||
QStringList tables = m_db.tables(QSql::Tables);
|
||||
QStringListIterator itor(tables);
|
||||
|
||||
while (itor.hasNext())
|
||||
{
|
||||
QString table = itor.next();
|
||||
parseTable(table);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -50,11 +52,13 @@ bool QQTSqlTreeModel::parseTable(QString tableName)
|
||||
|
||||
if (columnCount() < mdl->columnCount())
|
||||
setColumnCount(mdl->columnCount());
|
||||
|
||||
for (int i = 0; i < mdl->rowCount(); i++)
|
||||
{
|
||||
QStandardItem* _item = new QStandardItem;
|
||||
_item->setData(mdl->index(i, 0).data(Qt::DisplayRole), Qt::EditRole);
|
||||
itemParent->appendRow(_item);
|
||||
|
||||
for (int j = 1; j < mdl->columnCount(); j++)
|
||||
{
|
||||
QStandardItem* __item = new QStandardItem;
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "qqttablemodel.h"
|
||||
|
||||
QQTTableModel::QQTTableModel(QObject *parent, QSqlDatabase db):
|
||||
QQTTableModel::QQTTableModel(QObject* parent, QSqlDatabase db):
|
||||
QSqlRelationalTableModel(parent, db)
|
||||
{
|
||||
}
|
||||
@ -11,9 +11,9 @@ void QQTTableModel::query(QString filter)
|
||||
select();
|
||||
}
|
||||
|
||||
QVariant QQTTableModel::data(const QModelIndex &index, int role) const
|
||||
QVariant QQTTableModel::data(const QModelIndex& index, int role) const
|
||||
{
|
||||
switch(role)
|
||||
switch (role)
|
||||
{
|
||||
case Qt::TextAlignmentRole:
|
||||
case Qt::DisplayRole:
|
||||
@ -26,12 +26,12 @@ QVariant QQTTableModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
|
||||
|
||||
bool QQTTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
bool QQTTableModel::setData(const QModelIndex& index, const QVariant& value, int role)
|
||||
{
|
||||
return QSqlRelationalTableModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
Qt::ItemFlags QQTTableModel::flags(const QModelIndex &index) const
|
||||
Qt::ItemFlags QQTTableModel::flags(const QModelIndex& index) const
|
||||
{
|
||||
return QSqlRelationalTableModel::flags(index);
|
||||
}
|
||||
|
@ -12,14 +12,14 @@ class QQTSHARED_EXPORT QQTTableModel : public QSqlRelationalTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQTTableModel(QObject *parent = 0, QSqlDatabase db = QSqlDatabase());
|
||||
explicit QQTTableModel(QObject* parent = 0, QSqlDatabase db = QSqlDatabase());
|
||||
|
||||
void query(QString filter);
|
||||
|
||||
public:
|
||||
QVariant data(const QModelIndex &item, int role = Qt::DisplayRole) const;
|
||||
bool setData(const QModelIndex &item, const QVariant &value, int role = Qt::EditRole);
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QVariant data(const QModelIndex& item, int role = Qt::DisplayRole) const;
|
||||
bool setData(const QModelIndex& item, const QVariant& value, int role = Qt::EditRole);
|
||||
Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "qqttreemodel.h"
|
||||
|
||||
QQTTreeModel::QQTTreeModel(QObject *parent) : QStandardItemModel(parent)
|
||||
QQTTreeModel::QQTTreeModel(QObject* parent) : QStandardItemModel(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ class QQTSHARED_EXPORT QQTTreeModel : public QStandardItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQTTreeModel(QObject *parent = 0);
|
||||
explicit QQTTreeModel(QObject* parent = 0);
|
||||
|
||||
/**
|
||||
* @brief query
|
||||
|
@ -11,6 +11,7 @@ QQTXmlTreeModel::QQTXmlTreeModel(QObject* parent) : QQTTreeModel(parent)
|
||||
void QQTXmlTreeModel::setFilePath(QString fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
|
||||
if (!file.open(QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
pline() << "Error: Cannot read file " << qPrintable(fileName)
|
||||
@ -24,6 +25,7 @@ void QQTXmlTreeModel::setFilePath(QString fileName)
|
||||
int errorColumn;
|
||||
|
||||
QDomDocument doc;
|
||||
|
||||
if (!doc.setContent(&file, false, &errorStr, &errorLine,
|
||||
&errorColumn))
|
||||
{
|
||||
@ -64,6 +66,7 @@ void QQTXmlTreeModel::parseChildElement(const QDomElement& element, QStandardIte
|
||||
|
||||
item->setData(element.nodeName(), Qt::EditRole);
|
||||
item->setData(element.text(), Qt::UserRole);
|
||||
|
||||
if (element.isNull() && !element.hasChildNodes())
|
||||
item->setData(itemParent->data(Qt::UserRole), Qt::EditRole);
|
||||
|
||||
@ -86,8 +89,10 @@ void QQTXmlTreeModel::parseChildElement(const QDomElement& element, QStandardIte
|
||||
* @brief element attibute
|
||||
*/
|
||||
QDomNamedNodeMap nodeMap = element.attributes();
|
||||
|
||||
if (nodeMap.count() > columnCount())
|
||||
setColumnCount(nodeMap.count());
|
||||
|
||||
for (int i = 0; i < nodeMap.count(); i++)
|
||||
{
|
||||
QString attName = nodeMap.item(i).nodeName();
|
||||
@ -97,6 +102,7 @@ void QQTXmlTreeModel::parseChildElement(const QDomElement& element, QStandardIte
|
||||
_item->setData(attValue, Qt::EditRole);
|
||||
|
||||
pline() << attName << attValue << itemParent;
|
||||
|
||||
if (itemParent)
|
||||
{
|
||||
itemParent->setChild(item->index().row(), i + 1, _item);
|
||||
@ -115,6 +121,7 @@ void QQTXmlTreeModel::parseChildElement(const QDomElement& element, QStandardIte
|
||||
* child element
|
||||
*/
|
||||
QDomNode child = element.firstChild();
|
||||
|
||||
while (!child.isNull())
|
||||
{
|
||||
parseChildElement(child.toElement(), item);
|
||||
|
@ -9,7 +9,7 @@ class QQTSHARED_EXPORT QQTXmlTreeModel : public QQTTreeModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQTXmlTreeModel(QObject *parent = 0);
|
||||
explicit QQTXmlTreeModel(QObject* parent = 0);
|
||||
|
||||
|
||||
signals:
|
||||
@ -26,7 +26,7 @@ protected:
|
||||
* @brief parseChildElement
|
||||
* @param element
|
||||
*/
|
||||
void parseChildElement(const QDomElement &element, QStandardItem* itemParent = 0);
|
||||
void parseChildElement(const QDomElement& element, QStandardItem* itemParent = 0);
|
||||
|
||||
private:
|
||||
QDomDocument doc;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "qqtmplayer.h"
|
||||
#include "qqtcore.h"
|
||||
|
||||
QQTPlayer::QQTPlayer(QObject *parent) :
|
||||
QQTPlayer::QQTPlayer(QObject* parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
app = new QProcess(this);
|
||||
@ -9,7 +9,7 @@ QQTPlayer::QQTPlayer(QObject *parent) :
|
||||
|
||||
void QQTPlayer::play(QString filename, int wid, int width, int height)
|
||||
{
|
||||
QString mppath="mplayer";
|
||||
QString mppath = "mplayer";
|
||||
QStringList mpargs;
|
||||
mpargs << "-slave";
|
||||
mpargs << "-quiet";
|
||||
@ -24,9 +24,9 @@ void QQTPlayer::play(QString filename, int wid, int width, int height)
|
||||
mpargs << filename;
|
||||
|
||||
app->setProcessChannelMode(QProcess::SeparateChannels);
|
||||
app->start(mppath, mpargs, QIODevice::Truncate|QIODevice::ReadWrite);
|
||||
app->start(mppath, mpargs, QIODevice::Truncate | QIODevice::ReadWrite);
|
||||
|
||||
if(!app->waitForStarted(3000))
|
||||
if (!app->waitForStarted(3000))
|
||||
pline() << "mpp start fail :(";
|
||||
|
||||
pline() << "mpp start success :)";
|
||||
@ -34,14 +34,14 @@ void QQTPlayer::play(QString filename, int wid, int width, int height)
|
||||
|
||||
void QQTPlayer::pause()
|
||||
{
|
||||
char buf[256]= {0};
|
||||
char buf[256] = {0};
|
||||
sprintf(buf, "pause\n");
|
||||
app->write(buf);
|
||||
}
|
||||
|
||||
void QQTPlayer::stop()
|
||||
{
|
||||
char buf[256]= {0};
|
||||
char buf[256] = {0};
|
||||
sprintf(buf, "stop\n");
|
||||
app->write(buf);
|
||||
sprintf(buf, "quit\n");
|
||||
@ -50,7 +50,7 @@ void QQTPlayer::stop()
|
||||
|
||||
double QQTPlayer::timeLength()
|
||||
{
|
||||
char buf[256]= {0};
|
||||
char buf[256] = {0};
|
||||
sprintf(buf, "get_time_length\n");
|
||||
app->write(buf);
|
||||
memset(buf, 0, 256);
|
||||
@ -62,7 +62,7 @@ double QQTPlayer::timeLength()
|
||||
|
||||
double QQTPlayer::timePos()
|
||||
{
|
||||
char buf[256]= {0};
|
||||
char buf[256] = {0};
|
||||
sprintf(buf, "get_time_pos\n");
|
||||
app->write(buf);
|
||||
memset(buf, 0, 256);
|
||||
@ -74,7 +74,7 @@ double QQTPlayer::timePos()
|
||||
|
||||
int QQTPlayer::percent()
|
||||
{
|
||||
char buf[256]= {0};
|
||||
char buf[256] = {0};
|
||||
sprintf(buf, "get_percent\n");
|
||||
app->write(buf);
|
||||
memset(buf, 0, 256);
|
||||
@ -86,21 +86,21 @@ int QQTPlayer::percent()
|
||||
|
||||
void QQTPlayer::seekPos(double second)
|
||||
{
|
||||
char buf[256]= {0};
|
||||
char buf[256] = {0};
|
||||
sprintf(buf, "seek %lf\n", second);
|
||||
app->write(buf);
|
||||
}
|
||||
|
||||
void QQTPlayer::setVolume(int v)
|
||||
{
|
||||
char buf[256]= {0};
|
||||
char buf[256] = {0};
|
||||
sprintf(buf, "volume %d 1\n", v);
|
||||
app->write(buf);
|
||||
}
|
||||
|
||||
void QQTPlayer::mute(bool m)
|
||||
{
|
||||
char buf[256]= {0};
|
||||
char buf[256] = {0};
|
||||
sprintf(buf, "mute %d\n", m);
|
||||
app->write(buf);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class QQTSHARED_EXPORT QQTPlayer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQTPlayer(QObject *parent = 0);
|
||||
explicit QQTPlayer(QObject* parent = 0);
|
||||
|
||||
void play(QString filename, int wid = 0, int width = 20, int height = 20);
|
||||
void pause();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,29 +10,30 @@
|
||||
#include <sys/select.h>
|
||||
#include "qextserialbase.h"
|
||||
|
||||
class Posix_QextSerialPort:public QextSerialBase
|
||||
class Posix_QextSerialPort: public QextSerialBase
|
||||
{
|
||||
private:
|
||||
private:
|
||||
/*!
|
||||
* This method is a part of constructor.
|
||||
*/
|
||||
void init();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
QFile* Posix_File;
|
||||
struct termios Posix_CommConfig;
|
||||
struct timeval Posix_Timeout;
|
||||
struct timeval Posix_Copy_Timeout;
|
||||
|
||||
virtual qint64 readData(char * data, qint64 maxSize);
|
||||
virtual qint64 writeData(const char * data, qint64 maxSize);
|
||||
virtual qint64 readData(char* data, qint64 maxSize);
|
||||
virtual qint64 writeData(const char* data, qint64 maxSize);
|
||||
|
||||
public:
|
||||
public:
|
||||
Posix_QextSerialPort();
|
||||
Posix_QextSerialPort(const Posix_QextSerialPort& s);
|
||||
Posix_QextSerialPort(const QString & name, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
||||
Posix_QextSerialPort(const QString& name, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
||||
Posix_QextSerialPort(const PortSettings& settings, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
||||
Posix_QextSerialPort(const QString & name, const PortSettings& settings, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
||||
Posix_QextSerialPort(const QString& name, const PortSettings& settings,
|
||||
QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
||||
Posix_QextSerialPort& operator=(const Posix_QextSerialPort& s);
|
||||
virtual ~Posix_QextSerialPort();
|
||||
|
||||
@ -54,8 +55,8 @@ class Posix_QextSerialPort:public QextSerialBase
|
||||
|
||||
virtual void translateError(ulong error);
|
||||
|
||||
virtual void setDtr(bool set=true);
|
||||
virtual void setRts(bool set=true);
|
||||
virtual void setDtr(bool set = true);
|
||||
virtual void setRts(bool set = true);
|
||||
virtual ulong lineStatus();
|
||||
|
||||
};
|
||||
|
@ -37,7 +37,7 @@ QextSerialBase::QextSerialBase()
|
||||
\fn QextSerialBase::QextSerialBase(const QString & name)
|
||||
Construct a port and assign it to the device specified by the name parameter.
|
||||
*/
|
||||
QextSerialBase::QextSerialBase(const QString & name)
|
||||
QextSerialBase::QextSerialBase(const QString& name)
|
||||
: QIODevice()
|
||||
{
|
||||
setPortName(name);
|
||||
@ -60,13 +60,13 @@ Common constructor function for setting up default port settings.
|
||||
*/
|
||||
void QextSerialBase::construct()
|
||||
{
|
||||
Settings.BaudRate=BAUD115200;
|
||||
Settings.DataBits=DATA_8;
|
||||
Settings.Parity=PAR_NONE;
|
||||
Settings.StopBits=STOP_1;
|
||||
Settings.FlowControl=FLOW_HARDWARE;
|
||||
Settings.Timeout_Millisec=500;
|
||||
mutex = new QMutex( QMutex::Recursive );
|
||||
Settings.BaudRate = BAUD115200;
|
||||
Settings.DataBits = DATA_8;
|
||||
Settings.Parity = PAR_NONE;
|
||||
Settings.StopBits = STOP_1;
|
||||
Settings.FlowControl = FLOW_HARDWARE;
|
||||
Settings.Timeout_Millisec = 500;
|
||||
mutex = new QMutex(QMutex::Recursive);
|
||||
setOpenMode(QIODevice::NotOpen);
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ void QextSerialBase::setQueryMode(QueryMode mechanism)
|
||||
\fn void QextSerialBase::setPortName(const QString & name)
|
||||
Sets the name of the device associated with the object, e.g. "COM1", or "/dev/ttyS0".
|
||||
*/
|
||||
void QextSerialBase::setPortName(const QString & name)
|
||||
void QextSerialBase::setPortName(const QString& name)
|
||||
{
|
||||
port = name;
|
||||
}
|
||||
@ -161,9 +161,11 @@ Call QextSerialBase::lastError() for error information.
|
||||
*/
|
||||
bool QextSerialBase::atEnd() const
|
||||
{
|
||||
if (size()) {
|
||||
if (size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -173,7 +175,7 @@ This function will read a line of buffered input from the port, stopping when ei
|
||||
have been read, the port has no more data available, or a newline is encountered.
|
||||
The value returned is the length of the string that was read.
|
||||
*/
|
||||
qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
|
||||
qint64 QextSerialBase::readLine(char* data, qint64 maxSize)
|
||||
{
|
||||
qint64 numBytes = bytesAvailable();
|
||||
char* pData = data;
|
||||
@ -182,16 +184,20 @@ qint64 QextSerialBase::readLine(char * data, qint64 maxSize)
|
||||
return -1;
|
||||
|
||||
/*read a byte at a time for MIN(bytesAvail, maxSize - 1) iterations, or until a newline*/
|
||||
while (pData<(data+numBytes) && --maxSize) {
|
||||
while (pData < (data + numBytes) && --maxSize)
|
||||
{
|
||||
readData(pData, 1);
|
||||
if (*pData++ == '\n') {
|
||||
|
||||
if (*pData++ == '\n')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
*pData='\0';
|
||||
|
||||
*pData = '\0';
|
||||
|
||||
/*return size of data read*/
|
||||
return (pData-data);
|
||||
return (pData - data);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -149,28 +149,29 @@ class QextSerialBase : public QIODevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum QueryMode {
|
||||
public:
|
||||
enum QueryMode
|
||||
{
|
||||
Polling,
|
||||
EventDriven
|
||||
};
|
||||
|
||||
protected:
|
||||
protected:
|
||||
QMutex* mutex;
|
||||
QString port;
|
||||
PortSettings Settings;
|
||||
ulong lastErr;
|
||||
QextSerialBase::QueryMode _queryMode;
|
||||
|
||||
virtual qint64 readData(char * data, qint64 maxSize)=0;
|
||||
virtual qint64 writeData(const char * data, qint64 maxSize)=0;
|
||||
virtual qint64 readData(char* data, qint64 maxSize) = 0;
|
||||
virtual qint64 writeData(const char* data, qint64 maxSize) = 0;
|
||||
|
||||
public:
|
||||
public:
|
||||
QextSerialBase();
|
||||
QextSerialBase(const QString & name);
|
||||
QextSerialBase(const QString& name);
|
||||
virtual ~QextSerialBase();
|
||||
virtual void construct();
|
||||
virtual void setPortName(const QString & name);
|
||||
virtual void setPortName(const QString& name);
|
||||
virtual QString portName() const;
|
||||
|
||||
/**!
|
||||
@ -205,38 +206,38 @@ class QextSerialBase : public QIODevice
|
||||
|
||||
// virtual void setBlockingRead(bool block) = 0; ///< @todo implement.
|
||||
|
||||
virtual void setBaudRate(BaudRateType)=0;
|
||||
virtual void setBaudRate(BaudRateType) = 0;
|
||||
virtual BaudRateType baudRate() const;
|
||||
virtual void setDataBits(DataBitsType)=0;
|
||||
virtual void setDataBits(DataBitsType) = 0;
|
||||
virtual DataBitsType dataBits() const;
|
||||
virtual void setParity(ParityType)=0;
|
||||
virtual void setParity(ParityType) = 0;
|
||||
virtual ParityType parity() const;
|
||||
virtual void setStopBits(StopBitsType)=0;
|
||||
virtual void setStopBits(StopBitsType) = 0;
|
||||
virtual StopBitsType stopBits() const;
|
||||
virtual void setFlowControl(FlowType)=0;
|
||||
virtual void setFlowControl(FlowType) = 0;
|
||||
virtual FlowType flowControl() const;
|
||||
virtual void setTimeout(long)=0;
|
||||
virtual void setTimeout(long) = 0;
|
||||
|
||||
virtual bool open(OpenMode mode)=0;
|
||||
virtual bool open(OpenMode mode) = 0;
|
||||
virtual bool isSequential() const;
|
||||
virtual void close()=0;
|
||||
virtual void flush()=0;
|
||||
virtual void close() = 0;
|
||||
virtual void flush() = 0;
|
||||
|
||||
virtual qint64 size() const=0;
|
||||
virtual qint64 bytesAvailable()=0;
|
||||
virtual qint64 size() const = 0;
|
||||
virtual qint64 bytesAvailable() = 0;
|
||||
virtual bool atEnd() const;
|
||||
|
||||
virtual void ungetChar(char c)=0;
|
||||
virtual qint64 readLine(char * data, qint64 maxSize);
|
||||
virtual void ungetChar(char c) = 0;
|
||||
virtual qint64 readLine(char* data, qint64 maxSize);
|
||||
|
||||
virtual ulong lastError() const;
|
||||
virtual void translateError(ulong error)=0;
|
||||
virtual void translateError(ulong error) = 0;
|
||||
|
||||
virtual void setDtr(bool set=true)=0;
|
||||
virtual void setRts(bool set=true)=0;
|
||||
virtual ulong lineStatus()=0;
|
||||
virtual void setDtr(bool set = true) = 0;
|
||||
virtual void setRts(bool set = true) = 0;
|
||||
virtual ulong lineStatus() = 0;
|
||||
|
||||
signals:
|
||||
signals:
|
||||
/**
|
||||
* This signal is emitted whenever port settings are updated.
|
||||
* \param valid \p true if settings are valid, \p false otherwise.
|
||||
|
@ -13,62 +13,70 @@
|
||||
|
||||
|
||||
#ifdef _TTY_WIN_
|
||||
//this is serial port GUID
|
||||
#ifndef GUID_CLASS_COMPORT
|
||||
DEFINE_GUID(GUID_CLASS_COMPORT, 0x86e0d1e0L, 0x8089, 0x11d0, 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73);
|
||||
#endif
|
||||
//this is serial port GUID
|
||||
#ifndef GUID_CLASS_COMPORT
|
||||
DEFINE_GUID(GUID_CLASS_COMPORT, 0x86e0d1e0L, 0x8089, 0x11d0, 0x9c, 0xe4, 0x08, 0x00, 0x3e, 0x30, 0x1f, 0x73);
|
||||
#endif
|
||||
|
||||
/* Gordon Schumacher's macros for TCHAR -> QString conversions and vice versa */
|
||||
#ifdef UNICODE
|
||||
#define QStringToTCHAR(x) (wchar_t*) x.utf16()
|
||||
#define PQStringToTCHAR(x) (wchar_t*) x->utf16()
|
||||
#define TCHARToQString(x) QString::fromUtf16((ushort*)(x))
|
||||
#define TCHARToQStringN(x,y) QString::fromUtf16((ushort*)(x),(y))
|
||||
#else
|
||||
#define QStringToTCHAR(x) x.local8Bit().constData()
|
||||
#define PQStringToTCHAR(x) x->local8Bit().constData()
|
||||
#define TCHARToQString(x) QString::fromLocal8Bit((x))
|
||||
#define TCHARToQStringN(x,y) QString::fromLocal8Bit((x),(y))
|
||||
#endif /*UNICODE*/
|
||||
/* Gordon Schumacher's macros for TCHAR -> QString conversions and vice versa */
|
||||
#ifdef UNICODE
|
||||
#define QStringToTCHAR(x) (wchar_t*) x.utf16()
|
||||
#define PQStringToTCHAR(x) (wchar_t*) x->utf16()
|
||||
#define TCHARToQString(x) QString::fromUtf16((ushort*)(x))
|
||||
#define TCHARToQStringN(x,y) QString::fromUtf16((ushort*)(x),(y))
|
||||
#else
|
||||
#define QStringToTCHAR(x) x.local8Bit().constData()
|
||||
#define PQStringToTCHAR(x) x->local8Bit().constData()
|
||||
#define TCHARToQString(x) QString::fromLocal8Bit((x))
|
||||
#define TCHARToQStringN(x,y) QString::fromLocal8Bit((x),(y))
|
||||
#endif /*UNICODE*/
|
||||
|
||||
|
||||
//static
|
||||
QString QextSerialEnumerator::getRegKeyValue(HKEY key, LPCTSTR property)
|
||||
{
|
||||
//static
|
||||
QString QextSerialEnumerator::getRegKeyValue(HKEY key, LPCTSTR property)
|
||||
{
|
||||
DWORD size = 0;
|
||||
RegQueryValueEx(key, property, NULL, NULL, NULL, & size);
|
||||
BYTE * buff = new BYTE[size];
|
||||
if (RegQueryValueEx(key, property, NULL, NULL, buff, & size) == ERROR_SUCCESS) {
|
||||
BYTE* buff = new BYTE[size];
|
||||
|
||||
if (RegQueryValueEx(key, property, NULL, NULL, buff, & size) == ERROR_SUCCESS)
|
||||
{
|
||||
return TCHARToQStringN(buff, size);
|
||||
delete [] buff;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning("QextSerialEnumerator::getRegKeyValue: can not obtain value from registry");
|
||||
delete [] buff;
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
QString QextSerialEnumerator::getDeviceProperty(HDEVINFO devInfo, PSP_DEVINFO_DATA devData, DWORD property)
|
||||
{
|
||||
//static
|
||||
QString QextSerialEnumerator::getDeviceProperty(HDEVINFO devInfo, PSP_DEVINFO_DATA devData, DWORD property)
|
||||
{
|
||||
DWORD buffSize = 0;
|
||||
SetupDiGetDeviceRegistryProperty(devInfo, devData, property, NULL, NULL, 0, & buffSize);
|
||||
BYTE * buff = new BYTE[buffSize];
|
||||
BYTE* buff = new BYTE[buffSize];
|
||||
|
||||
if (!SetupDiGetDeviceRegistryProperty(devInfo, devData, property, NULL, buff, buffSize, NULL))
|
||||
qCritical("Can not obtain property: %ld from registry", property);
|
||||
|
||||
QString result = TCHARToQString(buff);
|
||||
delete [] buff;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//static
|
||||
void QextSerialEnumerator::setupAPIScan(QList<QextPortInfo> & infoList)
|
||||
{
|
||||
//static
|
||||
void QextSerialEnumerator::setupAPIScan(QList<QextPortInfo>& infoList)
|
||||
{
|
||||
HDEVINFO devInfo = INVALID_HANDLE_VALUE;
|
||||
GUID * guidDev = (GUID *) & GUID_CLASS_COMPORT;
|
||||
GUID* guidDev = (GUID*) & GUID_CLASS_COMPORT;
|
||||
|
||||
devInfo = SetupDiGetClassDevs(guidDev, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
||||
if(devInfo == INVALID_HANDLE_VALUE) {
|
||||
|
||||
if (devInfo == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
qCritical("SetupDiGetClassDevs failed. Error code: %ld", GetLastError());
|
||||
return;
|
||||
}
|
||||
@ -77,26 +85,33 @@
|
||||
bool ok = true;
|
||||
SP_DEVICE_INTERFACE_DATA ifcData;
|
||||
ifcData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
SP_DEVICE_INTERFACE_DETAIL_DATA * detData = NULL;
|
||||
SP_DEVICE_INTERFACE_DETAIL_DATA* detData = NULL;
|
||||
DWORD detDataSize = 0;
|
||||
DWORD oldDetDataSize = 0;
|
||||
|
||||
for (DWORD i = 0; ok; i++) {
|
||||
for (DWORD i = 0; ok; i++)
|
||||
{
|
||||
ok = SetupDiEnumDeviceInterfaces(devInfo, NULL, guidDev, i, &ifcData);
|
||||
if (ok) {
|
||||
|
||||
if (ok)
|
||||
{
|
||||
SP_DEVINFO_DATA devData = {sizeof(SP_DEVINFO_DATA)};
|
||||
//check for required detData size
|
||||
SetupDiGetDeviceInterfaceDetail(devInfo, & ifcData, NULL, 0, & detDataSize, & devData);
|
||||
|
||||
//if larger than old detData size then reallocate the buffer
|
||||
if (detDataSize > oldDetDataSize) {
|
||||
if (detDataSize > oldDetDataSize)
|
||||
{
|
||||
delete [] detData;
|
||||
detData = (SP_DEVICE_INTERFACE_DETAIL_DATA *) new char[detDataSize];
|
||||
detData = (SP_DEVICE_INTERFACE_DETAIL_DATA*) new char[detDataSize];
|
||||
detData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
|
||||
oldDetDataSize = detDataSize;
|
||||
}
|
||||
|
||||
//check the details
|
||||
if (SetupDiGetDeviceInterfaceDetail(devInfo, & ifcData, detData, detDataSize,
|
||||
NULL, & devData)) {
|
||||
NULL, & devData))
|
||||
{
|
||||
// Got a device. Get the details.
|
||||
QextPortInfo info;
|
||||
info.friendName = getDeviceProperty(devInfo, & devData, SPDRP_FRIENDLYNAME);
|
||||
@ -109,21 +124,27 @@
|
||||
info.portName = getRegKeyValue(devKey, TEXT("PortName"));
|
||||
RegCloseKey(devKey);
|
||||
infoList.append(info);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical("SetupDiGetDeviceInterfaceDetail failed. Error code: %ld", GetLastError());
|
||||
delete [] detData;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (GetLastError() != ERROR_NO_MORE_ITEMS) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetLastError() != ERROR_NO_MORE_ITEMS)
|
||||
{
|
||||
delete [] detData;
|
||||
qCritical("SetupDiEnumDeviceInterfaces failed. Error code: %ld", GetLastError());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
delete [] detData;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*_TTY_WIN_*/
|
||||
|
||||
@ -133,26 +154,32 @@ QList<QextPortInfo> QextSerialEnumerator::getPorts()
|
||||
{
|
||||
QList<QextPortInfo> ports;
|
||||
|
||||
#ifdef _TTY_WIN_
|
||||
#ifdef _TTY_WIN_
|
||||
OSVERSIONINFO vi;
|
||||
vi.dwOSVersionInfoSize = sizeof(vi);
|
||||
if (!::GetVersionEx(&vi)) {
|
||||
|
||||
if (!::GetVersionEx(&vi))
|
||||
{
|
||||
qCritical("Could not get OS version.");
|
||||
return ports;
|
||||
}
|
||||
|
||||
// Handle windows 9x and NT4 specially
|
||||
if (vi.dwMajorVersion < 5) {
|
||||
if (vi.dwMajorVersion < 5)
|
||||
{
|
||||
qCritical("Enumeration for this version of Windows is not implemented yet");
|
||||
/* if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
/* if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
||||
EnumPortsWNt4(ports);
|
||||
else
|
||||
EnumPortsW9x(ports);*/
|
||||
} else //w2k or later
|
||||
}
|
||||
else //w2k or later
|
||||
setupAPIScan(ports);
|
||||
#endif /*_TTY_WIN_*/
|
||||
#ifdef _TTY_POSIX_
|
||||
|
||||
#endif /*_TTY_WIN_*/
|
||||
#ifdef _TTY_POSIX_
|
||||
qCritical("Enumeration for POSIX systems is not implemented yet.");
|
||||
#endif /*_TTY_POSIX_*/
|
||||
#endif /*_TTY_POSIX_*/
|
||||
|
||||
return ports;
|
||||
}
|
||||
|
@ -12,15 +12,16 @@
|
||||
#include <QList>
|
||||
|
||||
#ifdef _TTY_WIN_
|
||||
#include <windows.h>
|
||||
#include <setupapi.h>
|
||||
#include <windows.h>
|
||||
#include <setupapi.h>
|
||||
#endif /*_TTY_WIN_*/
|
||||
|
||||
|
||||
/*!
|
||||
* Structure containing port information.
|
||||
*/
|
||||
struct QextPortInfo {
|
||||
struct QextPortInfo
|
||||
{
|
||||
QString portName; ///< Port name.
|
||||
QString physName; ///< Physical name.
|
||||
QString friendName; ///< Friendly name.
|
||||
@ -36,8 +37,8 @@ struct QextPortInfo {
|
||||
*/
|
||||
class QextSerialEnumerator
|
||||
{
|
||||
private:
|
||||
#ifdef _TTY_WIN_
|
||||
private:
|
||||
#ifdef _TTY_WIN_
|
||||
/*!
|
||||
* Get value of specified property from the registry.
|
||||
* \param key handle to an open key.
|
||||
@ -61,10 +62,10 @@ class QextSerialEnumerator
|
||||
* Search for serial ports using setupapi.
|
||||
* \param infoList list with result.
|
||||
*/
|
||||
static void setupAPIScan(QList<QextPortInfo> & infoList);
|
||||
#endif /*_TTY_WIN_*/
|
||||
static void setupAPIScan(QList<QextPortInfo>& infoList);
|
||||
#endif /*_TTY_WIN_*/
|
||||
|
||||
public:
|
||||
public:
|
||||
/*!
|
||||
* Get list of ports.
|
||||
* \return list of ports currently available in the system.
|
||||
|
@ -55,7 +55,7 @@ e.g."COM1" or "/dev/ttyS0".
|
||||
|
||||
\see setQueryMode().
|
||||
*/
|
||||
QextSerialPort::QextSerialPort(const QString & name, QueryMode mode)
|
||||
QextSerialPort::QextSerialPort(const QString& name, QueryMode mode)
|
||||
: QextBaseType(name, mode)
|
||||
{
|
||||
}
|
||||
@ -74,7 +74,7 @@ Constructs a port with the name and settings specified.
|
||||
|
||||
\see setQueryMode().
|
||||
*/
|
||||
QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings, QueryMode mode)
|
||||
QextSerialPort::QextSerialPort(const QString& name, PortSettings const& settings, QueryMode mode)
|
||||
: QextBaseType(name, settings, mode)
|
||||
{}
|
||||
|
||||
|
@ -17,13 +17,13 @@ class QextSerialPort: public QextBaseType
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
public:
|
||||
typedef QextSerialBase::QueryMode QueryMode;
|
||||
|
||||
QextSerialPort();
|
||||
QextSerialPort(const QString & name, QueryMode mode = QextSerialPort::Polling);
|
||||
QextSerialPort(const QString& name, QueryMode mode = QextSerialPort::Polling);
|
||||
QextSerialPort(PortSettings const& s, QueryMode mode = QextSerialPort::Polling);
|
||||
QextSerialPort(const QString & name, PortSettings const& s, QueryMode mode = QextSerialPort::Polling);
|
||||
QextSerialPort(const QString& name, PortSettings const& s, QueryMode mode = QextSerialPort::Polling);
|
||||
QextSerialPort(const QextSerialPort& s);
|
||||
QextSerialPort& operator=(const QextSerialPort&);
|
||||
virtual ~QextSerialPort();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -38,13 +38,13 @@ class Win_QextSerialPort: public QextSerialBase
|
||||
Q_OBJECT
|
||||
friend class Win_QextSerialThread;
|
||||
|
||||
private:
|
||||
private:
|
||||
/*!
|
||||
* This method is a part of constructor.
|
||||
*/
|
||||
void init();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
HANDLE Win_Handle;
|
||||
HANDLE threadStartEvent;
|
||||
HANDLE threadTerminateEvent;
|
||||
@ -52,21 +52,22 @@ class Win_QextSerialPort: public QextSerialBase
|
||||
OVERLAPPED overlapWrite;
|
||||
COMMCONFIG Win_CommConfig;
|
||||
COMMTIMEOUTS Win_CommTimeouts;
|
||||
QReadWriteLock * bytesToWriteLock; ///< @todo maybe move to QextSerialBase.
|
||||
QReadWriteLock* bytesToWriteLock; ///< @todo maybe move to QextSerialBase.
|
||||
qint64 _bytesToWrite; ///< @todo maybe move to QextSerialBase (and implement in POSIX).
|
||||
Win_QextSerialThread * overlapThread; ///< @todo maybe move to QextSerialBase (and implement in POSIX).
|
||||
Win_QextSerialThread* overlapThread; ///< @todo maybe move to QextSerialBase (and implement in POSIX).
|
||||
|
||||
void monitorCommEvent();
|
||||
void terminateCommWait();
|
||||
virtual qint64 readData(char *data, qint64 maxSize);
|
||||
virtual qint64 writeData(const char *data, qint64 maxSize);
|
||||
virtual qint64 readData(char* data, qint64 maxSize);
|
||||
virtual qint64 writeData(const char* data, qint64 maxSize);
|
||||
|
||||
public:
|
||||
public:
|
||||
Win_QextSerialPort();
|
||||
Win_QextSerialPort(Win_QextSerialPort const& s);
|
||||
Win_QextSerialPort(const QString & name, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
||||
Win_QextSerialPort(const QString& name, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
||||
Win_QextSerialPort(const PortSettings& settings, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
||||
Win_QextSerialPort(const QString & name, const PortSettings& settings, QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
||||
Win_QextSerialPort(const QString& name, const PortSettings& settings,
|
||||
QextSerialBase::QueryMode mode = QextSerialBase::Polling);
|
||||
Win_QextSerialPort& operator=(const Win_QextSerialPort& s);
|
||||
virtual ~Win_QextSerialPort();
|
||||
virtual bool open(OpenMode mode);
|
||||
@ -79,8 +80,8 @@ class Win_QextSerialPort: public QextSerialBase
|
||||
virtual void setDataBits(DataBitsType);
|
||||
virtual void setStopBits(StopBitsType);
|
||||
virtual void setBaudRate(BaudRateType);
|
||||
virtual void setDtr(bool set=true);
|
||||
virtual void setRts(bool set=true);
|
||||
virtual void setDtr(bool set = true);
|
||||
virtual void setRts(bool set = true);
|
||||
virtual ulong lineStatus(void);
|
||||
virtual qint64 bytesAvailable();
|
||||
virtual void translateError(ulong);
|
||||
@ -112,23 +113,23 @@ class Win_QextSerialPort: public QextSerialBase
|
||||
*/
|
||||
class Win_QextSerialThread: public QThread
|
||||
{
|
||||
Win_QextSerialPort * qesp;
|
||||
Win_QextSerialPort* qesp;
|
||||
bool terminate;
|
||||
|
||||
public:
|
||||
public:
|
||||
/*!
|
||||
* Constructor.
|
||||
*
|
||||
* \param qesp valid serial port object.
|
||||
*/
|
||||
Win_QextSerialThread(Win_QextSerialPort * qesp);
|
||||
Win_QextSerialThread(Win_QextSerialPort* qesp);
|
||||
|
||||
/*!
|
||||
* Stop the thread.
|
||||
*/
|
||||
void stop();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
//overriden
|
||||
virtual void run();
|
||||
|
||||
|
@ -53,6 +53,7 @@ void QQtBluetoothClient::installProtocol(QQtProtocol* stack)
|
||||
void QQtBluetoothClient::uninstallProtocol(QQtProtocol* stack)
|
||||
{
|
||||
Q_UNUSED(stack)
|
||||
|
||||
if (!m_protocol)
|
||||
return;
|
||||
|
||||
@ -117,17 +118,22 @@ int QQtBluetoothClient::sendDisConnectFromHost()
|
||||
void QQtBluetoothClient::socketStateChanged(QBluetoothSocket::SocketState eSocketState)
|
||||
{
|
||||
pline() << eSocketState;
|
||||
|
||||
switch (eSocketState)
|
||||
{
|
||||
case ServiceLookupState:
|
||||
case ConnectingState:
|
||||
break;
|
||||
|
||||
case ConnectedState:
|
||||
break;
|
||||
|
||||
case ClosingState:
|
||||
break;
|
||||
|
||||
case UnconnectedState:
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -144,6 +150,7 @@ void QQtBluetoothClient::socketErrorOccured(QBluetoothSocket::SocketError e)
|
||||
* 在错误状态下重新连接其他热点,直到确定连接类型,写入配置文件
|
||||
*/
|
||||
pline() << e << errorString();
|
||||
|
||||
switch (e)
|
||||
{
|
||||
case HostNotFoundError:
|
||||
|
@ -9,7 +9,8 @@ class QQTSHARED_EXPORT QQtBluetoothClient : public QBluetoothSocket
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtBluetoothClient(QBluetoothServiceInfo::Protocol socketType = QBluetoothServiceInfo::RfcommProtocol, QObject* parent = nullptr);
|
||||
explicit QQtBluetoothClient(QBluetoothServiceInfo::Protocol socketType = QBluetoothServiceInfo::RfcommProtocol,
|
||||
QObject* parent = nullptr);
|
||||
explicit QQtBluetoothClient(QObject* parent = nullptr);
|
||||
|
||||
/**
|
||||
|
@ -3,24 +3,28 @@
|
||||
|
||||
QQtBluetoothManager* QQtBluetoothManager::_instance = NULL;
|
||||
|
||||
QQtBluetoothManager *QQtBluetoothManager::Instance(QObject *parent)
|
||||
QQtBluetoothManager* QQtBluetoothManager::Instance(QObject* parent)
|
||||
{
|
||||
if(_instance)
|
||||
if (_instance)
|
||||
return _instance;
|
||||
|
||||
_instance = new QQtBluetoothManager(parent);
|
||||
return _instance;
|
||||
}
|
||||
|
||||
void QQtBluetoothManager::changeAdapter(QBluetoothAddress &adapterAddress)
|
||||
void QQtBluetoothManager::changeAdapter(QBluetoothAddress& adapterAddress)
|
||||
{
|
||||
if(adapterAddress!=m_adapterAddress)
|
||||
if (adapterAddress != m_adapterAddress)
|
||||
m_adapterAddress = adapterAddress;
|
||||
|
||||
if(deviceDiscoveryAgent) {
|
||||
if (deviceDiscoveryAgent)
|
||||
{
|
||||
deviceDiscoveryAgent->stop();
|
||||
delete deviceDiscoveryAgent;
|
||||
}
|
||||
for(slitor = sl.begin(); slitor!= sl.end(); slitor++) {
|
||||
|
||||
for (slitor = sl.begin(); slitor != sl.end(); slitor++)
|
||||
{
|
||||
QBluetoothServiceDiscoveryAgent* sa = (QBluetoothServiceDiscoveryAgent*)*slitor;
|
||||
sa->stop();
|
||||
sa->clear();
|
||||
@ -50,23 +54,28 @@ void QQtBluetoothManager::powerOff()
|
||||
bool QQtBluetoothManager::isPowerOn()
|
||||
{
|
||||
HostMode mode = hostMode();
|
||||
if(mode == HostPoweredOff)
|
||||
|
||||
if (mode == HostPoweredOff)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QQtBluetoothManager::isDiscoverable()
|
||||
{
|
||||
HostMode mode = hostMode();
|
||||
if(mode == HostDiscoverable)
|
||||
|
||||
if (mode == HostDiscoverable)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QQtBluetoothManager::setAutoScan(bool scan)
|
||||
{
|
||||
bAutoScan = scan;
|
||||
if(scan)
|
||||
|
||||
if (scan)
|
||||
{
|
||||
deviceDiscoveryAgent->start();
|
||||
}
|
||||
@ -79,7 +88,7 @@ void QQtBluetoothManager::setAutoScan(bool scan)
|
||||
|
||||
void QQtBluetoothManager::setDiscoverable(bool able)
|
||||
{
|
||||
if(able)
|
||||
if (able)
|
||||
setHostMode(HostDiscoverable);
|
||||
else
|
||||
setHostMode(HostConnectable);
|
||||
@ -92,20 +101,25 @@ void QQtBluetoothManager::refresh()
|
||||
|
||||
QList<QBluetoothDeviceInfo> QQtBluetoothManager::getDeviceList()
|
||||
{
|
||||
if(deviceDiscoveryAgent)
|
||||
if (deviceDiscoveryAgent)
|
||||
return deviceDiscoveryAgent->discoveredDevices();
|
||||
|
||||
//empty
|
||||
return QList<QBluetoothDeviceInfo>();
|
||||
}
|
||||
|
||||
QList<QBluetoothServiceInfo> QQtBluetoothManager::getServiceList(QBluetoothAddress &address)
|
||||
QList<QBluetoothServiceInfo> QQtBluetoothManager::getServiceList(QBluetoothAddress& address)
|
||||
{
|
||||
for(slitor = sl.begin(); slitor!= sl.end(); slitor++) {
|
||||
for (slitor = sl.begin(); slitor != sl.end(); slitor++)
|
||||
{
|
||||
QBluetoothServiceDiscoveryAgent* sa = (QBluetoothServiceDiscoveryAgent*)*slitor;
|
||||
if (sa->remoteAddress() == address) {
|
||||
|
||||
if (sa->remoteAddress() == address)
|
||||
{
|
||||
return sa->discoveredServices();
|
||||
}
|
||||
}
|
||||
|
||||
//empty
|
||||
return QList<QBluetoothServiceInfo>();
|
||||
}
|
||||
@ -130,7 +144,7 @@ void QQtBluetoothManager::slot_addService(QBluetoothServiceInfo info)
|
||||
pline() << info;
|
||||
}
|
||||
|
||||
QQtBluetoothManager::QQtBluetoothManager(QObject *parent) :
|
||||
QQtBluetoothManager::QQtBluetoothManager(QObject* parent) :
|
||||
QBluetoothLocalDevice(parent),
|
||||
deviceDiscoveryAgent(nullptr),
|
||||
bAutoScan(true)
|
||||
|
@ -20,7 +20,7 @@ class QQTSHARED_EXPORT QQtBluetoothManager : public QBluetoothLocalDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static QQtBluetoothManager *Instance(QObject* parent = 0);
|
||||
static QQtBluetoothManager* Instance(QObject* parent = 0);
|
||||
/**
|
||||
* @brief changeAdapter
|
||||
* @param adapterAddress
|
||||
@ -56,7 +56,7 @@ private slots:
|
||||
void slot_addService(QBluetoothServiceInfo);
|
||||
protected:
|
||||
private:
|
||||
explicit QQtBluetoothManager(QObject *parent = nullptr);
|
||||
explicit QQtBluetoothManager(QObject* parent = nullptr);
|
||||
static QQtBluetoothManager* _instance;
|
||||
|
||||
QBluetoothDeviceDiscoveryAgent* deviceDiscoveryAgent;
|
||||
|
@ -2,7 +2,8 @@
|
||||
#include "qqtnetwork.h"
|
||||
#include "qqtbluetoothclient.h"
|
||||
|
||||
QQtBluetoothServer::QQtBluetoothServer(QBluetoothServiceInfo::Protocol serverType, QObject* parent) : QBluetoothServer(serverType, parent)
|
||||
QQtBluetoothServer::QQtBluetoothServer(QBluetoothServiceInfo::Protocol serverType,
|
||||
QObject* parent) : QBluetoothServer(serverType, parent)
|
||||
{
|
||||
connect(this, SIGNAL(newConnection()),
|
||||
this, SLOT(comingNewConnection()));
|
||||
@ -37,6 +38,7 @@ void QQtBluetoothServer::installProtocol(QQtProtocol* stack)
|
||||
void QQtBluetoothServer::uninstallProtocol(QQtProtocol* stack)
|
||||
{
|
||||
Q_UNUSED(stack)
|
||||
|
||||
if (!m_protocol)
|
||||
return;
|
||||
|
||||
|
@ -9,7 +9,7 @@ class QQTSHARED_EXPORT QQtBluetoothServer : public QBluetoothServer
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtBluetoothServer(QBluetoothServiceInfo::Protocol serverType, QObject *parent = nullptr);
|
||||
explicit QQtBluetoothServer(QBluetoothServiceInfo::Protocol serverType, QObject* parent = nullptr);
|
||||
~QQtBluetoothServer();
|
||||
|
||||
void installProtocol(QQtProtocol* stack);
|
||||
|
@ -9,7 +9,8 @@
|
||||
QQTClient::QQTClient(QObject* parent) :
|
||||
QTcpSocket(parent)
|
||||
{
|
||||
connect(this, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState)));
|
||||
connect(this, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this,
|
||||
SLOT(socketStateChanged(QAbstractSocket::SocketState)));
|
||||
// connected
|
||||
connect(this, SIGNAL(connected()), this, SLOT(socketConnected()));
|
||||
// disconnected
|
||||
@ -17,7 +18,8 @@ QQTClient::QQTClient(QObject* parent) :
|
||||
// domain
|
||||
connect(this, SIGNAL(hostFound()), this, SLOT(domainHostFound()));
|
||||
// error
|
||||
connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketErrorOccured(QAbstractSocket::SocketError)));
|
||||
connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this,
|
||||
SLOT(socketErrorOccured(QAbstractSocket::SocketError)));
|
||||
|
||||
connect(this, SIGNAL(readyRead()), this, SLOT(readyReadData()));
|
||||
|
||||
@ -129,18 +131,23 @@ void QQTClient::domainHostFound()
|
||||
void QQTClient::socketStateChanged(QAbstractSocket::SocketState eSocketState)
|
||||
{
|
||||
pline() << eSocketState;
|
||||
|
||||
switch (eSocketState)
|
||||
{
|
||||
case QAbstractSocket::HostLookupState:
|
||||
case QAbstractSocket::ConnectingState:
|
||||
break;
|
||||
|
||||
case QAbstractSocket::ConnectedState:
|
||||
break;
|
||||
|
||||
case QAbstractSocket::ClosingState:
|
||||
break;
|
||||
|
||||
case QAbstractSocket::UnconnectedState:
|
||||
eConType++;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -157,10 +164,12 @@ void QQTClient::socketErrorOccured(QAbstractSocket::SocketError e)
|
||||
* 在错误状态下重新连接其他热点,直到确定连接类型,写入配置文件
|
||||
*/
|
||||
pline() << e;
|
||||
|
||||
switch (e)
|
||||
{
|
||||
case QAbstractSocket::RemoteHostClosedError:
|
||||
break;
|
||||
|
||||
case QAbstractSocket::HostNotFoundError:
|
||||
default:
|
||||
emit signalConnectFail();
|
||||
|
@ -5,21 +5,23 @@
|
||||
|
||||
QQTEthenetManager* QQTEthenetManager::_instance = NULL;
|
||||
|
||||
QQTEthenetManager *QQTEthenetManager::Instance(QObject *parent)
|
||||
QQTEthenetManager* QQTEthenetManager::Instance(QObject* parent)
|
||||
{
|
||||
if(_instance)
|
||||
if (_instance)
|
||||
return _instance;
|
||||
|
||||
_instance = new QQTEthenetManager(parent);
|
||||
return _instance;
|
||||
}
|
||||
|
||||
bool QQTEthenetManager::setCurrentWifi(QString bssid_mac, QString password)
|
||||
{
|
||||
for(QList<TWifi>::Iterator it = m_wifiList.begin();
|
||||
for (QList<TWifi>::Iterator it = m_wifiList.begin();
|
||||
it != m_wifiList.end(); it++)
|
||||
{
|
||||
TWifi wifi = *it;
|
||||
if(bssid_mac == wifi[ESSID_BSSID])
|
||||
|
||||
if (bssid_mac == wifi[ESSID_BSSID])
|
||||
{
|
||||
m_status = "";
|
||||
m_curWifi = wifi;
|
||||
@ -30,7 +32,7 @@ bool QQTEthenetManager::setCurrentWifi(QString bssid_mac, QString password)
|
||||
|
||||
restoreWifi();
|
||||
|
||||
if(!restartWifi())
|
||||
if (!restartWifi())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@ -44,11 +46,13 @@ void QQTEthenetManager::ipconfig()
|
||||
|
||||
QString QQTEthenetManager::currentNetName()
|
||||
{
|
||||
if("eth0" == m_netName)
|
||||
if ("eth0" == m_netName)
|
||||
return "Wired Lan";
|
||||
if("wlan0" == m_netName)
|
||||
if("COMPLETED" == m_status)
|
||||
|
||||
if ("wlan0" == m_netName)
|
||||
if ("COMPLETED" == m_status)
|
||||
return m_curWifi[ESSID_NAME];
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
@ -64,23 +68,32 @@ void QQTEthenetManager::readStatus()
|
||||
bzero(result, MAX_LEN);
|
||||
bzero(key, MAX_LEN);
|
||||
bzero(value, MAX_LEN);
|
||||
FILE *pp = popen("wpa_cli -iwlan0 status", "r"); //建立管道
|
||||
FILE* pp = popen("wpa_cli -iwlan0 status", "r"); //建立管道
|
||||
|
||||
if (!pp)
|
||||
return;
|
||||
while( fgets(result, sizeof(result), pp) != NULL)
|
||||
|
||||
while (fgets(result, sizeof(result), pp) != NULL)
|
||||
{
|
||||
sscanf(result, "%[^=]=%s", key, value);
|
||||
|
||||
/*
|
||||
* 如果这里不用QString包含,会对比地址
|
||||
*/
|
||||
if(QString("wpa_state") == QString(key)) {
|
||||
if (QString("wpa_state") == QString(key))
|
||||
{
|
||||
m_curWifi[ESSID_STATUS] = value;
|
||||
} else if(QString("bssid") == QString(key)) {
|
||||
}
|
||||
else if (QString("bssid") == QString(key))
|
||||
{
|
||||
m_curWifi[ESSID_BSSID] = value;
|
||||
} else if(QString("ssid") == QString(key)) {
|
||||
}
|
||||
else if (QString("ssid") == QString(key))
|
||||
{
|
||||
m_curWifi[ESSID_NAME] = value;
|
||||
}
|
||||
}
|
||||
|
||||
pclose(pp);
|
||||
|
||||
return;
|
||||
@ -89,11 +102,14 @@ void QQTEthenetManager::readStatus()
|
||||
void QQTEthenetManager::refreshWifiList()
|
||||
{
|
||||
static int scanid = 0;
|
||||
if(scanid == 12)
|
||||
|
||||
if (scanid == 12)
|
||||
scanid = 0, system("wpa_cli -iwlan0 scan");
|
||||
|
||||
scanid ++;
|
||||
|
||||
FILE *pp = popen("wpa_cli -iwlan0 scan_r", "r"); //建立管道
|
||||
FILE* pp = popen("wpa_cli -iwlan0 scan_r", "r"); //建立管道
|
||||
|
||||
if (!pp)
|
||||
return;
|
||||
|
||||
@ -108,26 +124,30 @@ void QQTEthenetManager::refreshWifiList()
|
||||
|
||||
m_wifiList.clear();
|
||||
|
||||
while( fgets(cmdresult, sizeof(cmdresult), pp) != NULL)
|
||||
while (fgets(cmdresult, sizeof(cmdresult), pp) != NULL)
|
||||
{
|
||||
sscanf(cmdresult, "%s\t%s\t%s\t%s\t%s\n", bssid, frequency, signal, flag, ssid);
|
||||
|
||||
TWifi wifi;
|
||||
wifi[ESSID_NAME] = ssid;
|
||||
if( strstr(flag, "WPA"))
|
||||
|
||||
if (strstr(flag, "WPA"))
|
||||
wifi[ESSID_TYPE] = "WPA";
|
||||
else
|
||||
wifi[ESSID_TYPE] = "WEP";
|
||||
if(strstr(flag, "WPA") || strstr(flag, "WEP"))
|
||||
|
||||
if (strstr(flag, "WPA") || strstr(flag, "WEP"))
|
||||
wifi[ESSID_ENCRYP] = "YES";
|
||||
else
|
||||
wifi[ESSID_ENCRYP] = "NO";
|
||||
|
||||
wifi[ESSID_PASS] = "";
|
||||
wifi[ESSID_BSSID] = bssid;
|
||||
wifi[ESSID_FREQ] = frequency;
|
||||
wifi[ESSID_SIGNAL] = signal;
|
||||
wifi[ESSID_FLAG] = flag;
|
||||
if(wifi[ESSID_BSSID] == m_curWifi[ESSID_BSSID])
|
||||
|
||||
if (wifi[ESSID_BSSID] == m_curWifi[ESSID_BSSID])
|
||||
wifi[ESSID_STATUS] = m_curWifi[ESSID_STATUS];
|
||||
else
|
||||
wifi[ESSID_STATUS] = "";
|
||||
@ -146,7 +166,7 @@ void QQTEthenetManager::refreshWifiStatus()
|
||||
{
|
||||
readStatus();
|
||||
|
||||
if(m_status == m_curWifi[ESSID_STATUS])
|
||||
if (m_status == m_curWifi[ESSID_STATUS])
|
||||
return;
|
||||
|
||||
pline() << m_curWifi[ESSID_BSSID] << m_curWifi[ESSID_NAME] << m_curWifi[ESSID_STATUS];
|
||||
@ -154,17 +174,17 @@ void QQTEthenetManager::refreshWifiStatus()
|
||||
m_status = m_curWifi[ESSID_STATUS];
|
||||
emit sigStatusChanged(m_status);
|
||||
|
||||
if("COMPLETED" == m_status)
|
||||
if ("COMPLETED" == m_status)
|
||||
emit sigConnected();
|
||||
else if("SCANNING" == m_status)
|
||||
else if ("SCANNING" == m_status)
|
||||
emit sigScanning();
|
||||
else if("ASSOCIATING" == m_status)
|
||||
else if ("ASSOCIATING" == m_status)
|
||||
emit sigConnecting();
|
||||
else if("INACTIVE" == m_status)
|
||||
else if ("INACTIVE" == m_status)
|
||||
emit sigDisConnected();
|
||||
else if("4WAY_HANDSHAKE" == m_status)
|
||||
else if ("4WAY_HANDSHAKE" == m_status)
|
||||
emit sigDisConnected();
|
||||
else if("DISCONNECTED" == m_status)
|
||||
else if ("DISCONNECTED" == m_status)
|
||||
emit sigDisConnected();
|
||||
}
|
||||
|
||||
@ -175,21 +195,22 @@ void QQTEthenetManager::checkLanConnection()
|
||||
bzero(cmdbuf, MAX_PATH);
|
||||
bzero(cmdresult, MAX_PATH);
|
||||
sprintf(cmdbuf, "cat /sys/class/net/eth0/carrier");
|
||||
FILE *pp = popen(cmdbuf, "r"); //建立管道
|
||||
FILE* pp = popen(cmdbuf, "r"); //建立管道
|
||||
fgets(cmdresult, sizeof(cmdresult), pp); //""
|
||||
pclose(pp);
|
||||
|
||||
QString netName = m_netName;
|
||||
|
||||
if(strstr(cmdresult, "0"))
|
||||
if (strstr(cmdresult, "0"))
|
||||
m_netName = "wlan0";
|
||||
else
|
||||
m_netName = "eth0";
|
||||
|
||||
if(netName != m_netName)
|
||||
if (netName != m_netName)
|
||||
{
|
||||
config();
|
||||
if("wlan0" == m_netName)
|
||||
|
||||
if ("wlan0" == m_netName)
|
||||
emit sigLanDisConnected();
|
||||
else
|
||||
emit sigLanConnected();
|
||||
@ -204,51 +225,61 @@ void QQTEthenetManager::DhcpPassed(QString netname)
|
||||
struct ifreq ifr;
|
||||
struct sockaddr_in sin;
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
if (sockfd == -1)
|
||||
{
|
||||
perror("socket");
|
||||
return;
|
||||
}
|
||||
|
||||
strncpy(ifr.ifr_name, netname.toLatin1().data(), IFNAMSIZ);
|
||||
ifr.ifr_name[IFNAMSIZ - 1] = 0;
|
||||
|
||||
//ip
|
||||
if(ioctl(sockfd, SIOCGIFADDR, &ifr) <0)
|
||||
if (ioctl(sockfd, SIOCGIFADDR, &ifr) < 0)
|
||||
perror("ioctl");
|
||||
|
||||
memcpy(&sin, &ifr.ifr_addr, sizeof(sin));
|
||||
QString ip = QString(inet_ntoa(sin.sin_addr));
|
||||
|
||||
//mask
|
||||
if (ioctl(sockfd, SIOCGIFNETMASK, &ifr) < 0)
|
||||
perror("ioctl");
|
||||
|
||||
memcpy(&sin, &ifr.ifr_addr, sizeof(sin));
|
||||
QString mask = QString(inet_ntoa(sin.sin_addr));
|
||||
|
||||
//mac
|
||||
if (ioctl(sockfd, SIOCGIFHWADDR, &ifr) < 0)
|
||||
perror("ioctl");
|
||||
|
||||
memcpy(&sin, &ifr.ifr_addr, sizeof(sin));
|
||||
QString mac = QString(inet_ntoa(sin.sin_addr));
|
||||
close(sockfd);
|
||||
//gw
|
||||
FILE *fp;
|
||||
FILE* fp;
|
||||
char buf[MAX_PATH];
|
||||
char gateway[MAX_PATH];
|
||||
bzero(buf, MAX_PATH);
|
||||
bzero(gateway, MAX_PATH);
|
||||
fp = popen("ip route", "r");
|
||||
while(fgets(buf, sizeof(buf), fp) != NULL)
|
||||
|
||||
while (fgets(buf, sizeof(buf), fp) != NULL)
|
||||
{
|
||||
if(strstr(buf, "default via"))
|
||||
if (strstr(buf, "default via"))
|
||||
{
|
||||
sscanf(buf, "%*s%*s%s", gateway);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pclose(fp);
|
||||
QString gw = gateway;
|
||||
//dns
|
||||
QFile file("/etc/resolv.conf");
|
||||
file.open(QFile::ReadOnly);
|
||||
QByteArray nameserver = file.readLine();
|
||||
nameserver[nameserver.size()-1] = '\0';
|
||||
nameserver[nameserver.size() - 1] = '\0';
|
||||
QList<QByteArray> namelist = nameserver.split(' ');
|
||||
QString dns = namelist.size() > 1 ? namelist[1] : gw;
|
||||
file.close();
|
||||
@ -266,7 +297,7 @@ void QQTEthenetManager::checkNetworkClear()
|
||||
m_clearThread->start();
|
||||
}
|
||||
|
||||
QQTEthenetManager::QQTEthenetManager(QObject *parent) :
|
||||
QQTEthenetManager::QQTEthenetManager(QObject* parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
m_bUseDHCP = false;
|
||||
@ -305,41 +336,47 @@ void QQTEthenetManager::restoreWifi()
|
||||
char cmdbuf[MAX_PATH];
|
||||
char cmdresult[MAX_PATH];
|
||||
|
||||
FILE* fp=fopen("/etc/wpa_supplicant.conf", "wb");
|
||||
FILE* fp = fopen("/etc/wpa_supplicant.conf", "wb");
|
||||
fprintf(fp, "ctrl_interface=/var/run/wpa_supplicant\nctrl_interface_group=0\nap_scan=1\n\n");
|
||||
if("NO" == encryt)
|
||||
|
||||
if ("NO" == encryt)
|
||||
{
|
||||
pline() << "None Encryption";
|
||||
fprintf(fp, "network={\n\tssid=%s\n\tkey_mgmt=NONE\n\tpriority=5\n}\n", name.toLatin1().data());
|
||||
}
|
||||
else if("WEP" == type)
|
||||
else if ("WEP" == type)
|
||||
{
|
||||
pline() << "WEP Encryption";
|
||||
fprintf(fp, "network={\n\tssid=\"%s\"\n\tkey_mgmt=NONE\n\twep_key0=%s\n\twep_tx_keyidx=0\n\tpriority=5\n\tauth_alg=SHARED\n}\n",
|
||||
fprintf(fp,
|
||||
"network={\n\tssid=\"%s\"\n\tkey_mgmt=NONE\n\twep_key0=%s\n\twep_tx_keyidx=0\n\tpriority=5\n\tauth_alg=SHARED\n}\n",
|
||||
name.toLatin1().data(), password.toLatin1().data());
|
||||
}
|
||||
else if("WPA" == type)
|
||||
else if ("WPA" == type)
|
||||
{
|
||||
pline() << "WPA Encryption";
|
||||
bzero(cmdbuf, MAX_PATH);
|
||||
bzero(cmdresult, MAX_PATH);
|
||||
#if 0
|
||||
sprintf(cmdbuf, "wpa_passphrase %s %s | awk 'NR==4{print $1}'", name.toLatin1().data(), wifiPassword.toLatin1().data());
|
||||
FILE *pp = popen(cmdbuf, "r"); //建立管道
|
||||
FILE* pp = popen(cmdbuf, "r"); //建立管道
|
||||
fgets(cmdresult, sizeof(cmdresult), pp) ; //""
|
||||
pclose(pp);
|
||||
fprintf(fp, "network={\n\tssid=\"%s\"\n\tkey_mgmt=WPA-PSK\n\tgroup=TKIP\n\tpairwise=CCMP\n\tproto=WPA\n\t#psk=\"%s\"\n\t%s\tpriority=5\n}\n",
|
||||
fprintf(fp,
|
||||
"network={\n\tssid=\"%s\"\n\tkey_mgmt=WPA-PSK\n\tgroup=TKIP\n\tpairwise=CCMP\n\tproto=WPA\n\t#psk=\"%s\"\n\t%s\tpriority=5\n}\n",
|
||||
name, wifiPassword, cmdresult);
|
||||
#else
|
||||
sprintf(cmdbuf, "wpa_passphrase %s %s", name.toLatin1().data(), password.toLatin1().data());
|
||||
FILE *pp = popen(cmdbuf, "r"); //建立管道
|
||||
while(fgets(cmdresult, sizeof(cmdresult), pp)) //""
|
||||
FILE* pp = popen(cmdbuf, "r"); //建立管道
|
||||
|
||||
while (fgets(cmdresult, sizeof(cmdresult), pp)) //""
|
||||
{
|
||||
fputs(cmdresult, fp);
|
||||
}
|
||||
|
||||
pclose(pp);
|
||||
#endif
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
@ -350,12 +387,13 @@ bool QQTEthenetManager::restartWifi()
|
||||
bzero(cmdbuf, MAX_PATH);
|
||||
bzero(cmdresult, MAX_PATH);
|
||||
sprintf(cmdbuf, "wpa_cli -iwlan0 reconf");
|
||||
FILE *pp = popen(cmdbuf, "r"); //建立管道
|
||||
FILE* pp = popen(cmdbuf, "r"); //建立管道
|
||||
fgets(cmdresult, sizeof(cmdresult), pp); //""
|
||||
pclose(pp);
|
||||
|
||||
if(strstr(cmdresult, "FAIL"))
|
||||
if (strstr(cmdresult, "FAIL"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -415,7 +453,7 @@ void QQTEthenetManager::config()
|
||||
system(cmdbuf);
|
||||
//system("route");
|
||||
|
||||
if(m_bUseDHCP)
|
||||
if (m_bUseDHCP)
|
||||
{
|
||||
m_thread->setnet(m_netName);
|
||||
m_thread->start();
|
||||
@ -438,7 +476,13 @@ void QQTEthenetManager::config()
|
||||
mask.toLatin1().data());
|
||||
system(cmdbuf);
|
||||
QStringList sl = gw.split(".");
|
||||
if(sl.size() < 3) { sl.clear(); sl << "0" << "0" << "0" << "0";}
|
||||
|
||||
if (sl.size() < 3)
|
||||
{
|
||||
sl.clear();
|
||||
sl << "0" << "0" << "0" << "0";
|
||||
}
|
||||
|
||||
QString net = QString("%1.%2.%3.0").arg(sl[0]).arg(sl[1]).arg(sl[2]);
|
||||
#if 0
|
||||
/*
|
||||
@ -473,7 +517,7 @@ void QQTEthenetManager::setAddr(QString ip, QString mask, QString gw, QString dn
|
||||
netSet.sync();
|
||||
}
|
||||
|
||||
void QQTEthenetManager::getAddr(QString &ip, QString &mask, QString &gw, QString &dns)
|
||||
void QQTEthenetManager::getAddr(QString& ip, QString& mask, QString& gw, QString& dns)
|
||||
{
|
||||
QSettings netSet;
|
||||
ip = netSet.value("/Network/IP").toString();
|
||||
@ -501,21 +545,25 @@ void QQTNetworkClearThread::run()
|
||||
bzero(cmdbuf, MAX_PATH);
|
||||
bzero(cmdresult, MAX_PATH);
|
||||
sprintf(cmdbuf, "ping 222.175.114.244 -w 2 -c 1");
|
||||
FILE *pp = popen(cmdbuf, "r"); //建立管道
|
||||
while(fgets(cmdresult, sizeof(cmdresult), pp))
|
||||
FILE* pp = popen(cmdbuf, "r"); //建立管道
|
||||
|
||||
while (fgets(cmdresult, sizeof(cmdresult), pp))
|
||||
{
|
||||
if(strstr(cmdresult, "1 packets transmitted, 1 packets received, 0% packet loss"))
|
||||
if (strstr(cmdresult, "1 packets transmitted, 1 packets received, 0% packet loss"))
|
||||
bclear = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
pclose(pp);
|
||||
|
||||
if(_bclear != bclear)
|
||||
if (_bclear != bclear)
|
||||
{
|
||||
if(bclear)
|
||||
if (bclear)
|
||||
emit cleared();
|
||||
else
|
||||
emit notcleared();
|
||||
|
||||
_bclear = bclear;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ class QQTSHARED_EXPORT QQTDhcpThread : public QThread
|
||||
public:
|
||||
QQTDhcpThread(QObject* parent = 0) : QThread(parent) {
|
||||
}
|
||||
void setnet(QString eth = "eth0") {net=eth;}
|
||||
void setnet(QString eth = "eth0") {net = eth;}
|
||||
signals:
|
||||
void passed(QString);
|
||||
// QThread interface
|
||||
@ -44,10 +44,10 @@ class QQTSHARED_EXPORT QQTEthenetManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static QQTEthenetManager *Instance(QObject* parent = 0);
|
||||
static QQTEthenetManager* Instance(QObject* parent = 0);
|
||||
|
||||
QList<TWifi>& wifiList() { return m_wifiList; }
|
||||
inline TWifi currentWifi(){ return m_curWifi; }
|
||||
inline TWifi currentWifi() { return m_curWifi; }
|
||||
bool setCurrentWifi(QString bssid_mac, QString password = "");
|
||||
void setRefresh(bool ref = true) { ref ? m_workTimer->start(5000) : m_workTimer->stop(); }
|
||||
void setDHCP(bool bUse = false) { m_bUseDHCP = bUse; }
|
||||
@ -113,7 +113,7 @@ private slots:
|
||||
void checkNetworkClear();
|
||||
|
||||
private:
|
||||
explicit QQTEthenetManager(QObject *parent = 0);
|
||||
explicit QQTEthenetManager(QObject* parent = 0);
|
||||
void readStatus();
|
||||
void restoreWifi();
|
||||
bool restartWifi();
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "qqtftpprotocol.h"
|
||||
|
||||
QQtFtpProtocol::QQtFtpProtocol(QObject *parent) : QObject(parent)
|
||||
QQtFtpProtocol::QQtFtpProtocol(QObject* parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class QQTSHARED_EXPORT QQtFtpProtocol : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtFtpProtocol(QObject *parent = 0);
|
||||
explicit QQtFtpProtocol(QObject* parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "qqthttpprotocol.h"
|
||||
|
||||
QQtHttpProtocol::QQtHttpProtocol(QObject *parent) : QObject(parent)
|
||||
QQtHttpProtocol::QQtHttpProtocol(QObject* parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class QQTSHARED_EXPORT QQtHttpProtocol : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtHttpProtocol(QObject *parent = 0);
|
||||
explicit QQtHttpProtocol(QObject* parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -9,23 +9,24 @@ bool tagWifi::isValid()
|
||||
#ifdef __EMBEDDED_LINUX__
|
||||
tagWifi& tagWifi::operator= (tagWifi& w)
|
||||
#else
|
||||
tagWifi &tagWifi::operator=(const tagWifi &w)
|
||||
tagWifi& tagWifi::operator=(const tagWifi& w)
|
||||
#endif
|
||||
{
|
||||
for(int i = ESSID_STATUS; i < ESSID_MAX; i++)
|
||||
for (int i = ESSID_STATUS; i < ESSID_MAX; i++)
|
||||
wifi[i] = w[i];
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
QString &tagWifi::operator[](int index)
|
||||
QString& tagWifi::operator[](int index)
|
||||
{
|
||||
if(index < ESSID_STATUS || index >= ESSID_MAX)
|
||||
if (index < ESSID_STATUS || index >= ESSID_MAX)
|
||||
return wifi[0];
|
||||
|
||||
return wifi[index];
|
||||
}
|
||||
|
||||
const QString &tagWifi::operator[](int index) const
|
||||
const QString& tagWifi::operator[](int index) const
|
||||
{
|
||||
return operator [](index);
|
||||
}
|
||||
|
@ -18,7 +18,8 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
ESSID_STATUS = 0,
|
||||
ESSID_NAME,//SSID
|
||||
ESSID_TYPE,
|
||||
@ -46,13 +47,13 @@ typedef struct QQTSHARED_EXPORT tagWifi
|
||||
#ifdef __EMBEDDED_LINUX__
|
||||
tagWifi& operator= (tagWifi& w);
|
||||
#else
|
||||
tagWifi &operator=(const tagWifi &w);
|
||||
tagWifi& operator=(const tagWifi& w);
|
||||
#endif
|
||||
|
||||
const QString &operator[] (int index) const;
|
||||
const QString& operator[](int index) const;
|
||||
|
||||
QString& operator[] (int index);
|
||||
}TWifi;
|
||||
QString& operator[](int index);
|
||||
} TWifi;
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "qqtprotocol.h"
|
||||
|
||||
QQtProtocol::QQtProtocol(QObject *parent) : QObject(parent)
|
||||
QQtProtocol::QQtProtocol(QObject* parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
@ -12,7 +12,7 @@ QQtProtocol::~QQtProtocol()
|
||||
|
||||
#define pline2() pline() << metaObject()->className()
|
||||
|
||||
void QQtProtocol::translator(const QByteArray &bytes)
|
||||
void QQtProtocol::translator(const QByteArray& bytes)
|
||||
{
|
||||
// queued conn and queued package;
|
||||
// direct conn and direct package;
|
||||
@ -58,13 +58,13 @@ void QQtProtocol::translator(const QByteArray &bytes)
|
||||
dispatcher(netData);
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* 正常分发
|
||||
*/
|
||||
dispatcher(sqbaBlockOnNet);
|
||||
break;
|
||||
}
|
||||
while (1);
|
||||
} while (1);
|
||||
|
||||
sqbaBlockOnNet.clear();
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ void QQTSerialPort::installProtocol(QQtProtocol* stack)
|
||||
void QQTSerialPort::uninstallProtocol(QQtProtocol* stack)
|
||||
{
|
||||
Q_UNUSED(stack)
|
||||
|
||||
if (!m_protocol)
|
||||
return;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "qqtwebprotocol.h"
|
||||
|
||||
QQtWebProtocol::QQtWebProtocol(QObject *parent) : QObject(parent)
|
||||
QQtWebProtocol::QQtWebProtocol(QObject* parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ class QQTSHARED_EXPORT QQtWebProtocol : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtWebProtocol(QObject *parent = 0);
|
||||
explicit QQtWebProtocol(QObject* parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "qqtwebserver.h"
|
||||
|
||||
QQtWebServer::QQtWebServer(QObject *parent) : QObject(parent)
|
||||
QQtWebServer::QQtWebServer(QObject* parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ class QQtWebServer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QQtWebServer(QObject *parent = nullptr);
|
||||
explicit QQtWebServer(QObject* parent = nullptr);
|
||||
|
||||
signals:
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "qqtwebworkserver.h"
|
||||
|
||||
QQtWebworkServer::QQtWebworkServer(QObject *parent) : QObject(parent)
|
||||
QQtWebworkServer::QQtWebworkServer(QObject* parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "qdevicewatcher_p.h"
|
||||
|
||||
QDeviceWatcher::QDeviceWatcher(QObject* parent)
|
||||
:QObject(parent),running(false),d_ptr(new QDeviceWatcherPrivate)
|
||||
: QObject(parent), running(false), d_ptr(new QDeviceWatcherPrivate)
|
||||
{
|
||||
Q_D(QDeviceWatcher);
|
||||
d->setWatcher(this);
|
||||
@ -29,7 +29,8 @@ QDeviceWatcher::QDeviceWatcher(QObject* parent)
|
||||
|
||||
QDeviceWatcher::~QDeviceWatcher()
|
||||
{
|
||||
if (d_ptr) {
|
||||
if (d_ptr)
|
||||
{
|
||||
delete d_ptr;
|
||||
d_ptr = NULL;
|
||||
}
|
||||
@ -38,10 +39,13 @@ QDeviceWatcher::~QDeviceWatcher()
|
||||
bool QDeviceWatcher::start()
|
||||
{
|
||||
Q_D(QDeviceWatcher);
|
||||
if (!d->start()) {
|
||||
|
||||
if (!d->start())
|
||||
{
|
||||
stop();
|
||||
running = false;
|
||||
}
|
||||
|
||||
running = true;
|
||||
return running;
|
||||
}
|
||||
@ -58,33 +62,34 @@ bool QDeviceWatcher::isRunning() const
|
||||
return running;
|
||||
}
|
||||
|
||||
void QDeviceWatcher::appendEventReceiver(QObject *receiver)
|
||||
void QDeviceWatcher::appendEventReceiver(QObject* receiver)
|
||||
{
|
||||
Q_D(QDeviceWatcher);
|
||||
d->event_receivers.append(receiver);
|
||||
}
|
||||
|
||||
void QDeviceWatcherPrivate::emitDeviceAdded(const QString &dev)
|
||||
void QDeviceWatcherPrivate::emitDeviceAdded(const QString& dev)
|
||||
{
|
||||
if (!QMetaObject::invokeMethod(watcher, "deviceAdded", Q_ARG(QString, dev)))
|
||||
qWarning("invoke deviceAdded failed");
|
||||
}
|
||||
|
||||
void QDeviceWatcherPrivate::emitDeviceChanged(const QString &dev)
|
||||
void QDeviceWatcherPrivate::emitDeviceChanged(const QString& dev)
|
||||
{
|
||||
if (!QMetaObject::invokeMethod(watcher, "deviceChanged", Q_ARG(QString, dev)))
|
||||
qWarning("invoke deviceChanged failed");
|
||||
}
|
||||
|
||||
void QDeviceWatcherPrivate::emitDeviceRemoved(const QString &dev)
|
||||
void QDeviceWatcherPrivate::emitDeviceRemoved(const QString& dev)
|
||||
{
|
||||
if (!QMetaObject::invokeMethod(watcher, "deviceRemoved", Q_ARG(QString, dev)))
|
||||
qWarning("invoke deviceRemoved failed");
|
||||
}
|
||||
|
||||
void QDeviceWatcherPrivate::emitDeviceAction(const QString &dev, const QString &action)
|
||||
void QDeviceWatcherPrivate::emitDeviceAction(const QString& dev, const QString& action)
|
||||
{
|
||||
QString a(action.toLower());
|
||||
|
||||
if (a == QLatin1String("add"))
|
||||
emitDeviceAdded(dev);
|
||||
else if (a == QLatin1String("remove"))
|
||||
@ -95,7 +100,7 @@ void QDeviceWatcherPrivate::emitDeviceAction(const QString &dev, const QString &
|
||||
|
||||
|
||||
//const QEvent::Type QDeviceChangeEvent::EventType = static_cast<QEvent::Type>(QEvent::registerEventType());
|
||||
QDeviceChangeEvent::QDeviceChangeEvent(Action action, const QString &device) :
|
||||
QDeviceChangeEvent::QDeviceChangeEvent(Action action, const QString& device) :
|
||||
QEvent(registeredType())
|
||||
{
|
||||
m_action = action;
|
||||
|
@ -76,8 +76,7 @@ public:
|
||||
|
||||
Action action() const {return m_action;}
|
||||
QString device() const {return m_device;}
|
||||
static Type registeredType()
|
||||
{
|
||||
static Type registeredType() {
|
||||
static Type EventType = static_cast<Type>(registerEventType());
|
||||
return EventType;
|
||||
}
|
||||
|
@ -52,7 +52,8 @@
|
||||
|
||||
#define UEVENT_BUFFER_SIZE 2048
|
||||
|
||||
enum udev_monitor_netlink_group {
|
||||
enum udev_monitor_netlink_group
|
||||
{
|
||||
UDEV_MONITOR_NONE,
|
||||
UDEV_MONITOR_KERNEL,
|
||||
UDEV_MONITOR_UDEV
|
||||
@ -69,6 +70,7 @@ bool QDeviceWatcherPrivate::start()
|
||||
{
|
||||
if (!init())
|
||||
return false;
|
||||
|
||||
#if CONFIG_SOCKETNOTIFIER
|
||||
socket_notifier->setEnabled(true);
|
||||
#elif CONFIG_TCPSOCKET
|
||||
@ -81,7 +83,8 @@ bool QDeviceWatcherPrivate::start()
|
||||
|
||||
bool QDeviceWatcherPrivate::stop()
|
||||
{
|
||||
if (netlink_socket!=-1) {
|
||||
if (netlink_socket != -1)
|
||||
{
|
||||
#if CONFIG_SOCKETNOTIFIER
|
||||
socket_notifier->setEnabled(false);
|
||||
#elif CONFIG_TCPSOCKET
|
||||
@ -93,6 +96,7 @@ bool QDeviceWatcherPrivate::stop()
|
||||
close(netlink_socket);
|
||||
netlink_socket = -1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -103,9 +107,9 @@ void QDeviceWatcherPrivate::parseDeviceInfo()
|
||||
QByteArray data;
|
||||
#if CONFIG_SOCKETNOTIFIER
|
||||
//socket_notifier->setEnabled(false); //for win
|
||||
data.resize(UEVENT_BUFFER_SIZE*2);
|
||||
data.resize(UEVENT_BUFFER_SIZE * 2);
|
||||
data.fill(0);
|
||||
size_t len = read(socket_notifier->socket(), data.data(), UEVENT_BUFFER_SIZE*2);
|
||||
size_t len = read(socket_notifier->socket(), data.data(), UEVENT_BUFFER_SIZE * 2);
|
||||
//zDebug("read fro socket %d bytes", len);
|
||||
data.resize(len);
|
||||
//socket_notifier->setEnabled(true); //for win
|
||||
@ -113,13 +117,18 @@ void QDeviceWatcherPrivate::parseDeviceInfo()
|
||||
data = tcp_socket->readAll();
|
||||
#endif
|
||||
data = data.replace(0, '\n').trimmed(); //In the original line each information is seperated by 0
|
||||
|
||||
if (buffer.isOpen())
|
||||
buffer.close();
|
||||
|
||||
buffer.setBuffer(&data);
|
||||
buffer.open(QIODevice::ReadOnly);
|
||||
while(!buffer.atEnd()) { //buffer.canReadLine() always false?
|
||||
|
||||
while (!buffer.atEnd()) //buffer.canReadLine() always false?
|
||||
{
|
||||
parseLine(buffer.readLine().trimmed());
|
||||
}
|
||||
|
||||
buffer.close();
|
||||
|
||||
}
|
||||
@ -129,25 +138,32 @@ void QDeviceWatcherPrivate::parseDeviceInfo()
|
||||
void QDeviceWatcherPrivate::run()
|
||||
{
|
||||
QByteArray data;
|
||||
|
||||
//loop only when event happens. because of recv() block the function?
|
||||
while (1) {
|
||||
while (1)
|
||||
{
|
||||
//char buf[UEVENT_BUFFER_SIZE*2] = {0};
|
||||
//recv(d->netlink_socket, &buf, sizeof(buf), 0);
|
||||
data.resize(UEVENT_BUFFER_SIZE*2);
|
||||
data.resize(UEVENT_BUFFER_SIZE * 2);
|
||||
data.fill(0);
|
||||
size_t len = recv(netlink_socket, data.data(), data.size(), 0);
|
||||
//zDebug("read fro socket %d bytes", len);
|
||||
data.resize(len);
|
||||
data = data.replace(0, '\n').trimmed();
|
||||
|
||||
if (buffer.isOpen())
|
||||
buffer.close();
|
||||
|
||||
buffer.setBuffer(&data);
|
||||
buffer.open(QIODevice::ReadOnly);
|
||||
QByteArray line = buffer.readLine();
|
||||
while(!line.isNull()) {
|
||||
|
||||
while (!line.isNull())
|
||||
{
|
||||
parseLine(line.trimmed());
|
||||
line = buffer.readLine();
|
||||
}
|
||||
|
||||
buffer.close();
|
||||
}
|
||||
}
|
||||
@ -182,8 +198,10 @@ bool QDeviceWatcherPrivate::init()
|
||||
snl.nl_groups = UDEV_MONITOR_KERNEL;
|
||||
|
||||
netlink_socket = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT);
|
||||
|
||||
//netlink_socket = socket(PF_NETLINK, SOCK_DGRAM|SOCK_CLOEXEC, NETLINK_KOBJECT_UEVENT); //SOCK_CLOEXEC may be not available
|
||||
if (netlink_socket == -1) {
|
||||
if (netlink_socket == -1)
|
||||
{
|
||||
qWarning("error getting socket: %s", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
@ -191,12 +209,16 @@ bool QDeviceWatcherPrivate::init()
|
||||
/* set receive buffersize */
|
||||
setsockopt(netlink_socket, SOL_SOCKET, SO_RCVBUFFORCE, &buffersize, sizeof(buffersize));
|
||||
retval = bind(netlink_socket, (struct sockaddr*) &snl, sizeof(struct sockaddr_nl));
|
||||
if (retval < 0) {
|
||||
|
||||
if (retval < 0)
|
||||
{
|
||||
qWarning("bind failed: %s", strerror(errno));
|
||||
close(netlink_socket);
|
||||
netlink_socket = -1;
|
||||
return false;
|
||||
} else if (retval == 0) {
|
||||
}
|
||||
else if (retval == 0)
|
||||
{
|
||||
//from libudev-monitor.c
|
||||
struct sockaddr_nl _snl;
|
||||
socklen_t _addrlen;
|
||||
@ -206,7 +228,8 @@ bool QDeviceWatcherPrivate::init()
|
||||
* it is usually, but not necessarily the pid
|
||||
*/
|
||||
_addrlen = sizeof(struct sockaddr_nl);
|
||||
retval = getsockname(netlink_socket, (struct sockaddr *)&_snl, &_addrlen);
|
||||
retval = getsockname(netlink_socket, (struct sockaddr*)&_snl, &_addrlen);
|
||||
|
||||
if (retval == 0)
|
||||
snl.nl_pid = _snl.nl_pid;
|
||||
}
|
||||
@ -218,16 +241,19 @@ bool QDeviceWatcherPrivate::init()
|
||||
#elif CONFIG_TCPSOCKET
|
||||
//QAbstractSocket *socket = new QAbstractSocket(QAbstractSocket::UnknownSocketType, this); //will not detect "remove", why?
|
||||
tcp_socket = new QTcpSocket(this); //works too
|
||||
if (!tcp_socket->setSocketDescriptor(netlink_socket, QAbstractSocket::ConnectedState)) {
|
||||
|
||||
if (!tcp_socket->setSocketDescriptor(netlink_socket, QAbstractSocket::ConnectedState))
|
||||
{
|
||||
qWarning("Failed to assign native socket to QAbstractSocket: %s", qPrintable(tcp_socket->errorString()));
|
||||
delete tcp_socket;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void QDeviceWatcherPrivate::parseLine(const QByteArray &line)
|
||||
void QDeviceWatcherPrivate::parseLine(const QByteArray& line)
|
||||
{
|
||||
//zDebug("%s", line.constData());
|
||||
|
||||
@ -235,6 +261,7 @@ void QDeviceWatcherPrivate::parseLine(const QByteArray &line)
|
||||
QString dev;
|
||||
|
||||
#ifdef __EMBEDDED_LINUX__
|
||||
|
||||
if (line.contains("/event")) //event
|
||||
{
|
||||
action_str = line.left(line.indexOf('@')).toLower();
|
||||
@ -247,39 +274,51 @@ void QDeviceWatcherPrivate::parseLine(const QByteArray &line)
|
||||
#define USE_REGEXP 0
|
||||
#if USE_REGEXP
|
||||
QRegExp rx("(\\w+)(?:@/.*/block/.*/)(\\w+)\\W*");
|
||||
|
||||
//QRegExp rx("(add|remove|change)@/.*/block/.*/(\\w+)\\W*");
|
||||
if (rx.indexIn(line) == -1)
|
||||
return;
|
||||
|
||||
action_str = rx.cap(1).toLower();
|
||||
dev = "/dev/" + rx.cap(2);
|
||||
#else
|
||||
|
||||
if (!line.contains("/block/")) //hotplug
|
||||
return;
|
||||
|
||||
action_str = line.left(line.indexOf('@')).toLower();
|
||||
dev = "/dev/" + line.right(line.length() - line.lastIndexOf('/') - 1);
|
||||
#endif //USE_REGEXP
|
||||
|
||||
#ifdef __EMBEDDED_LINUX__
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
QDeviceChangeEvent *event = 0;
|
||||
QDeviceChangeEvent* event = 0;
|
||||
|
||||
if (action_str==QLatin1String("add")) {
|
||||
if (action_str == QLatin1String("add"))
|
||||
{
|
||||
emitDeviceAdded(dev);
|
||||
event = new QDeviceChangeEvent(QDeviceChangeEvent::Add, dev);
|
||||
} else if (action_str==QLatin1String("remove")) {
|
||||
}
|
||||
else if (action_str == QLatin1String("remove"))
|
||||
{
|
||||
emitDeviceRemoved(dev);
|
||||
event = new QDeviceChangeEvent(QDeviceChangeEvent::Remove, dev);
|
||||
} else if (action_str==QLatin1String("change")) {
|
||||
}
|
||||
else if (action_str == QLatin1String("change"))
|
||||
{
|
||||
emitDeviceChanged(dev);
|
||||
event = new QDeviceChangeEvent(QDeviceChangeEvent::Change, dev);
|
||||
}
|
||||
|
||||
//zDebug("%s %s", qPrintable(action_str), qPrintable(dev));
|
||||
|
||||
if (event != 0 && !event_receivers.isEmpty()) {
|
||||
foreach(QObject* obj, event_receivers) {
|
||||
if (event != 0 && !event_receivers.isEmpty())
|
||||
{
|
||||
foreach (QObject* obj, event_receivers)
|
||||
{
|
||||
QCoreApplication::postEvent(obj, event, Qt::HighEventPriority);
|
||||
}
|
||||
}
|
||||
|
@ -29,8 +29,10 @@ static QStringList sDevices; //disk list, or mount point list?
|
||||
static void onDiskAppear(DADiskRef disk, void* context)
|
||||
{
|
||||
QString disk_name = DADiskGetBSDName(disk);
|
||||
|
||||
if (sDevices.contains(disk_name))
|
||||
return;
|
||||
|
||||
sDevices.append(disk_name);
|
||||
QDeviceWatcherPrivate* p = static_cast<QDeviceWatcherPrivate*>(context);
|
||||
p->emitDeviceAdded(disk_name);
|
||||
@ -90,11 +92,11 @@ void QDeviceWatcherPrivate::run()
|
||||
|
||||
DASessionScheduleWithRunLoop(mSession, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
|
||||
SInt32 result;
|
||||
|
||||
do
|
||||
{
|
||||
result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, true);
|
||||
}
|
||||
while (!mStop && result);
|
||||
} while (!mStop && result);
|
||||
|
||||
DASessionUnscheduleFromRunLoop(mSession, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class QDeviceWatcherPrivate
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDeviceWatcherPrivate(QObject *parent = 0) :
|
||||
QDeviceWatcherPrivate(QObject* parent = 0) :
|
||||
#if CONFIG_THREAD
|
||||
QThread(parent)
|
||||
#else
|
||||
@ -75,7 +75,7 @@ public:
|
||||
}
|
||||
~QDeviceWatcherPrivate();
|
||||
|
||||
void setWatcher(QDeviceWatcher *w) {watcher=w;}
|
||||
void setWatcher(QDeviceWatcher* w) {watcher = w;}
|
||||
bool start(); //conflict with QThread::start()
|
||||
bool stop();
|
||||
|
||||
@ -91,7 +91,7 @@ private slots:
|
||||
void parseDeviceInfo();
|
||||
|
||||
private:
|
||||
QDeviceWatcher *watcher;
|
||||
QDeviceWatcher* watcher;
|
||||
|
||||
bool init();
|
||||
#if CONFIG_THREAD
|
||||
@ -101,9 +101,9 @@ private:
|
||||
QBuffer buffer;
|
||||
void parseLine(const QByteArray& line);
|
||||
# if CONFIG_TCPSOCKET
|
||||
class QTcpSocket *tcp_socket;
|
||||
class QTcpSocket* tcp_socket;
|
||||
# elif CONFIG_SOCKETNOTIFIER
|
||||
class QSocketNotifier *socket_notifier;
|
||||
class QSocketNotifier* socket_notifier;
|
||||
# endif
|
||||
|
||||
QString bus_name;
|
||||
|
@ -44,7 +44,7 @@
|
||||
#if CONFIG_NOTIFICATION
|
||||
static HDEVNOTIFY hDevNotify = 0;
|
||||
#define HID_CLASSGUID {0x4d1e55b2, 0xf16f, 0x11cf,{ 0x88, 0xcb, 0x00, 0x11, 0x11, 0x00, 0x00, 0x30}}
|
||||
static const GUID WceusbshGUID = { 0x25dbce51, 0x6c8f, 0x4a72, 0x8a,0x6d,0xb5,0x4c,0x2b,0x4f,0xc8,0x35 };
|
||||
static const GUID WceusbshGUID = { 0x25dbce51, 0x6c8f, 0x4a72, 0x8a, 0x6d, 0xb5, 0x4c, 0x2b, 0x4f, 0xc8, 0x35 };
|
||||
static const GUID GUID_DEVINTERFACE_USBSTOR = { 0xA5DCBF10L, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED } };
|
||||
static const GUID InterfaceClassGuid = GUID_DEVINTERFACE_USBSTOR;//(GUID)HID_CLASSGUID; //GUID_DEVINTERFACE_USBSTOR
|
||||
#endif //CONFIG_NOTIFICATION
|
||||
@ -57,20 +57,28 @@ static inline QStringList drivesFromMask(quint32 driveBits) //driveBits ->unitma
|
||||
#if 1 //a disk with multiple partitions removed
|
||||
char driveName[] = "A:/";
|
||||
driveBits &= 0x3ffffff;
|
||||
while (driveBits) {
|
||||
|
||||
while (driveBits)
|
||||
{
|
||||
if (driveBits & 0x1)
|
||||
ret.append(QString::fromLatin1(driveName));
|
||||
|
||||
++driveName[0];
|
||||
driveBits >>= 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
#else
|
||||
char i = 0;
|
||||
for (; i<26; ++i) {
|
||||
|
||||
for (; i < 26; ++i)
|
||||
{
|
||||
if (driveBits & 0x1)
|
||||
break;
|
||||
|
||||
driveBits >>= 1;
|
||||
}
|
||||
|
||||
QChar c(i + 'A');
|
||||
return ret << QString(c) + ":";
|
||||
#endif
|
||||
@ -78,7 +86,7 @@ static inline QStringList drivesFromMask(quint32 driveBits) //driveBits ->unitma
|
||||
|
||||
void static UpdateDevice(PDEV_BROADCAST_DEVICEINTERFACE pDevInf, WPARAM wParam)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
// dbcc_name:
|
||||
// \\?\USB#Vid_04e8&Pid_503b#0002F9A9828E0F06#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
|
||||
// convert to
|
||||
@ -137,7 +145,7 @@ void static UpdateDevice(PDEV_BROADCAST_DEVICEINTERFACE pDevInf, WPARAM wParam)
|
||||
if (pspDevInfoData)
|
||||
HeapFree(GetProcessHeap(), 0, pspDevInfoData);
|
||||
SetupDiDestroyDeviceInfoList(hDevInfo);
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
@ -172,33 +180,49 @@ WM_DEVICECHANGE限制:
|
||||
*/
|
||||
LRESULT CALLBACK dw_internal_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (message == WM_DEVICECHANGE) {
|
||||
DEV_BROADCAST_HDR *lpdb = (DEV_BROADCAST_HDR *)lParam;
|
||||
if (message == WM_DEVICECHANGE)
|
||||
{
|
||||
DEV_BROADCAST_HDR* lpdb = (DEV_BROADCAST_HDR*)lParam;
|
||||
zDebug("Device type address: %#x", lpdb);
|
||||
if (lpdb) {
|
||||
if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME) {
|
||||
|
||||
if (lpdb)
|
||||
{
|
||||
if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME)
|
||||
{
|
||||
zDebug("DBT_DEVTYP_VOLUME");
|
||||
} else if (lpdb->dbch_devicetype == DBT_DEVTYP_PORT) {
|
||||
}
|
||||
else if (lpdb->dbch_devicetype == DBT_DEVTYP_PORT)
|
||||
{
|
||||
zDebug("DBT_DEVTYP_PORT");
|
||||
} else if (lpdb->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
|
||||
}
|
||||
else if (lpdb->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||
{
|
||||
zDebug("DBT_DEVTYP_DEVICEINTERFACE");
|
||||
} else if (lpdb->dbch_devicetype == DBT_DEVTYP_OEM) {
|
||||
}
|
||||
else if (lpdb->dbch_devicetype == DBT_DEVTYP_OEM)
|
||||
{
|
||||
zDebug("DBT_DEVTYP_OEM");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
zDebug("Unknow device type");
|
||||
}
|
||||
}
|
||||
|
||||
switch (wParam) {
|
||||
switch (wParam)
|
||||
{
|
||||
case DBT_DEVNODES_CHANGED:
|
||||
zDebug("DBT_DEVNODES_CHANGED message received, no extended info.");
|
||||
break;
|
||||
|
||||
case DBT_QUERYCHANGECONFIG:
|
||||
zDebug("DBT_QUERYCHANGECONFIG message received, no extended info.");
|
||||
break;
|
||||
|
||||
case DBT_CONFIGCHANGED:
|
||||
zDebug("DBT_CONFIGCHANGED message received, no extended info.");
|
||||
break;
|
||||
|
||||
case DBT_CONFIGCHANGECANCELED:
|
||||
zDebug("DBT_CONFIGCHANGECANCELED message received, no extended info.");
|
||||
break;
|
||||
@ -208,68 +232,100 @@ LRESULT CALLBACK dw_internal_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
||||
case DBT_DEVICEQUERYREMOVEFAILED:
|
||||
case DBT_DEVICEREMOVEPENDING:
|
||||
case DBT_DEVICEREMOVECOMPLETE:
|
||||
if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME) {
|
||||
DEV_BROADCAST_VOLUME *db_volume = (DEV_BROADCAST_VOLUME *)lpdb;
|
||||
if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME)
|
||||
{
|
||||
DEV_BROADCAST_VOLUME* db_volume = (DEV_BROADCAST_VOLUME*)lpdb;
|
||||
QStringList drives = drivesFromMask(db_volume->dbcv_unitmask);
|
||||
#ifdef GWLP_USERDATA
|
||||
QDeviceWatcherPrivate *watcher = (QDeviceWatcherPrivate *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
QDeviceWatcherPrivate* watcher = (QDeviceWatcherPrivate*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
|
||||
#else
|
||||
QDeviceWatcherPrivate *watcher = (QDeviceWatcherPrivate *)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
QDeviceWatcherPrivate* watcher = (QDeviceWatcherPrivate*)GetWindowLong(hwnd, GWL_USERDATA);
|
||||
#endif
|
||||
QList<QDeviceChangeEvent *> events;
|
||||
QList<QDeviceChangeEvent*> events;
|
||||
QString action_str("add");
|
||||
QDeviceChangeEvent::Action action = QDeviceChangeEvent::Add;
|
||||
if (wParam == DBT_DEVICEARRIVAL) {
|
||||
} else if (wParam == DBT_DEVICEQUERYREMOVE) {
|
||||
} else if (wParam == DBT_DEVICEQUERYREMOVEFAILED) {
|
||||
} else if (wParam == DBT_DEVICEREMOVEPENDING) {
|
||||
} else if (wParam == DBT_DEVICEREMOVECOMPLETE) {
|
||||
|
||||
if (wParam == DBT_DEVICEARRIVAL)
|
||||
{
|
||||
}
|
||||
else if (wParam == DBT_DEVICEQUERYREMOVE)
|
||||
{
|
||||
}
|
||||
else if (wParam == DBT_DEVICEQUERYREMOVEFAILED)
|
||||
{
|
||||
}
|
||||
else if (wParam == DBT_DEVICEREMOVEPENDING)
|
||||
{
|
||||
}
|
||||
else if (wParam == DBT_DEVICEREMOVECOMPLETE)
|
||||
{
|
||||
action_str = "remove";
|
||||
action = QDeviceChangeEvent::Remove;
|
||||
}
|
||||
foreach (const QString &drive, drives) {
|
||||
|
||||
foreach (const QString& drive, drives)
|
||||
{
|
||||
if (db_volume->dbcv_flags & DBTF_MEDIA)
|
||||
zDebug("Drive %c: Media has been removed.", drive.at(0).toLatin1());
|
||||
else if (db_volume->dbcv_flags & DBTF_NET)
|
||||
zDebug("Drive %c: Network share has been removed.", drive.at(0).toLatin1());
|
||||
else
|
||||
zDebug("Drive %c: Device has been removed.", drive.at(0).toLatin1());
|
||||
|
||||
watcher->emitDeviceAction(drive, action_str);
|
||||
|
||||
if (!watcher->event_receivers.isEmpty())
|
||||
events.append(new QDeviceChangeEvent(action, drive));
|
||||
}
|
||||
if (!events.isEmpty() && !watcher->event_receivers.isEmpty()) {
|
||||
foreach(QObject* obj, watcher->event_receivers) {
|
||||
foreach(QDeviceChangeEvent* event, events) {
|
||||
|
||||
if (!events.isEmpty() && !watcher->event_receivers.isEmpty())
|
||||
{
|
||||
foreach (QObject* obj, watcher->event_receivers)
|
||||
{
|
||||
foreach (QDeviceChangeEvent* event, events)
|
||||
{
|
||||
QCoreApplication::postEvent(obj, event, Qt::HighEventPriority);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (lpdb->dbch_devicetype == DBT_DEVTYP_PORT) {
|
||||
}
|
||||
else if (lpdb->dbch_devicetype == DBT_DEVTYP_PORT)
|
||||
{
|
||||
zDebug("DBT_DEVTYP_PORT");
|
||||
PDEV_BROADCAST_PORT pDevPort = (PDEV_BROADCAST_PORT)lpdb;
|
||||
} else if (lpdb->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
|
||||
}
|
||||
else if (lpdb->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||
{
|
||||
//RegisterDeviceNotification()
|
||||
zDebug("DBT_DEVTYP_DEVICEINTERFACE");
|
||||
PDEV_BROADCAST_DEVICEINTERFACE pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)lpdb;
|
||||
UpdateDevice(pDevInf, wParam);
|
||||
} else if (lpdb->dbch_devicetype == DBT_DEVTYP_OEM) {
|
||||
}
|
||||
else if (lpdb->dbch_devicetype == DBT_DEVTYP_OEM)
|
||||
{
|
||||
zDebug("DBT_DEVTYP_OEM");
|
||||
DEV_BROADCAST_OEM *pDevOem = (DEV_BROADCAST_OEM*)lpdb;
|
||||
} else if (lpdb->dbch_devicetype == DBT_DEVTYP_HANDLE) {
|
||||
DEV_BROADCAST_OEM* pDevOem = (DEV_BROADCAST_OEM*)lpdb;
|
||||
}
|
||||
else if (lpdb->dbch_devicetype == DBT_DEVTYP_HANDLE)
|
||||
{
|
||||
zDebug("DBT_DEVTYP_HANDLE");
|
||||
PDEV_BROADCAST_HANDLE pDevHnd = (PDEV_BROADCAST_HANDLE)lpdb;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case DBT_DEVICETYPESPECIFIC:
|
||||
zDebug("DBT_DEVICETYPESPECIFIC message received, may contain an extended info.");
|
||||
break;
|
||||
|
||||
case DBT_CUSTOMEVENT:
|
||||
zDebug("DBT_CUSTOMEVENT message received, contains an extended info.");
|
||||
break;
|
||||
|
||||
case DBT_USERDEFINED:
|
||||
zDebug("WM_DEVICECHANGE user defined message received, can not handle.");
|
||||
break;
|
||||
|
||||
default:
|
||||
qWarning("WM_DEVICECHANGE message received, unhandled value %d.", wParam);
|
||||
break;
|
||||
@ -299,7 +355,7 @@ static inline HWND dw_create_internal_window(const void* userData)
|
||||
wc.hCursor = 0;
|
||||
wc.hbrBackground = 0;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = reinterpret_cast<const wchar_t *>(className.utf16());
|
||||
wc.lpszClassName = reinterpret_cast<const wchar_t*>(className.utf16());
|
||||
RegisterClass(&wc);
|
||||
|
||||
HWND hwnd = CreateWindow(wc.lpszClassName, // classname
|
||||
@ -310,10 +366,14 @@ static inline HWND dw_create_internal_window(const void* userData)
|
||||
0, // menu handle
|
||||
hi, // application
|
||||
0); // windows creation data.
|
||||
if (!hwnd) {
|
||||
|
||||
if (!hwnd)
|
||||
{
|
||||
qWarning("QDeviceWatcherPrivate: Failed to create internal window: %d", (int)GetLastError());
|
||||
#if CONFIG_NOTIFICATION
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
DEV_BROADCAST_DEVICEINTERFACE NotificationFilter ;
|
||||
ZeroMemory(&NotificationFilter, sizeof(NotificationFilter)) ;
|
||||
NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
|
||||
@ -322,18 +382,24 @@ static inline HWND dw_create_internal_window(const void* userData)
|
||||
//3rd param with DEVICE_NOTIFY_ALL_INTERFACE_CLASSES and dbcc_classguid will be ignored
|
||||
//http://msdn.microsoft.com/en-us/library/windows/desktop/aa363431(v=vs.85).aspx
|
||||
hDevNotify = RegisterDeviceNotification(hwnd, &NotificationFilter, DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
if (!hDevNotify) {
|
||||
|
||||
if (!hDevNotify)
|
||||
{
|
||||
zDebug("");
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
} else if (userData) {
|
||||
}
|
||||
else if (userData)
|
||||
{
|
||||
#ifdef GWLP_USERDATA
|
||||
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)userData);
|
||||
#else
|
||||
SetWindowLong(hwnd, GWL_USERDATA, (LONG)userData);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif //CONFIG_NOTIFICATION
|
||||
return hwnd;
|
||||
}
|
||||
@ -346,7 +412,7 @@ static inline void dw_destroy_internal_window(HWND hwnd)
|
||||
#if CONFIG_NOTIFICATION
|
||||
UnregisterDeviceNotification(hDevNotify);
|
||||
#endif
|
||||
UnregisterClass(reinterpret_cast<const wchar_t *>(className().utf16()), qWinAppInst());
|
||||
UnregisterClass(reinterpret_cast<const wchar_t*>(className().utf16()), qWinAppInst());
|
||||
}
|
||||
|
||||
|
||||
@ -361,9 +427,11 @@ bool QDeviceWatcherPrivate::start()
|
||||
init();
|
||||
hwnd = dw_create_internal_window(this);
|
||||
|
||||
if (!hwnd) {
|
||||
if (!hwnd)
|
||||
{
|
||||
dw_destroy_internal_window(hwnd);
|
||||
}
|
||||
|
||||
return hwnd;
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,10 @@
|
||||
# define TCHAR2QString(x) QString::fromLocal8Bit((x))
|
||||
#endif //UNICODE
|
||||
|
||||
typedef union {
|
||||
typedef union
|
||||
{
|
||||
DEVDETAIL d;
|
||||
char pad[sizeof(DEVDETAIL)+MAX_DEVCLASS_NAMELEN]; //BYTE pad[sizeof(DEVDETAIL) + (MAX_PATH * sizeof(TCHAR))];
|
||||
char pad[sizeof(DEVDETAIL) + MAX_DEVCLASS_NAMELEN]; //BYTE pad[sizeof(DEVDETAIL) + (MAX_PATH * sizeof(TCHAR))];
|
||||
} Q_DEVDETAIL;
|
||||
|
||||
|
||||
@ -53,6 +54,7 @@ bool QDeviceWatcherPrivate::start()
|
||||
{
|
||||
if (!init())
|
||||
return false;
|
||||
|
||||
this->QThread::start();
|
||||
return true;
|
||||
}
|
||||
@ -62,14 +64,18 @@ bool QDeviceWatcherPrivate::stop()
|
||||
{
|
||||
quit();
|
||||
|
||||
if (!StopDeviceNotifications(mNotificationHandle)) {
|
||||
if (!StopDeviceNotifications(mNotificationHandle))
|
||||
{
|
||||
qWarning("StopDeviceNotifications() error: %d", GetLastError());
|
||||
return false;
|
||||
}
|
||||
if (!CloseMsgQueue(mQueueHandle)) {
|
||||
|
||||
if (!CloseMsgQueue(mQueueHandle))
|
||||
{
|
||||
qWarning("CloseMsgQueue() error: %d", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -90,15 +96,21 @@ bool QDeviceWatcherPrivate::init()
|
||||
//msgopts.dwCreationDisposition = CREATE_NEW;
|
||||
|
||||
mQueueHandle = CreateMsgQueue(NULL, &msgopts);
|
||||
if (mQueueHandle == NULL) {
|
||||
|
||||
if (mQueueHandle == NULL)
|
||||
{
|
||||
qWarning("CreateMsgQueue() error: %d", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
mNotificationHandle = RequestDeviceNotifications(&BLOCK_DRIVER_GUID, mQueueHandle, TRUE);
|
||||
if (mNotificationHandle == NULL) {
|
||||
|
||||
if (mNotificationHandle == NULL)
|
||||
{
|
||||
qWarning("RequestDeviceNotifications() error: %d", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -108,20 +120,31 @@ void QDeviceWatcherPrivate::run()
|
||||
DWORD size;
|
||||
Q_DEVDETAIL detail;
|
||||
SetLastError(0); //?
|
||||
while (true) {
|
||||
if(WaitForSingleObject(mQueueHandle, 3000) == WAIT_OBJECT_0) {
|
||||
while(ReadMsgQueue(mQueueHandle, &detail, sizeof(detail), &size, 1, &flags)) {
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (WaitForSingleObject(mQueueHandle, 3000) == WAIT_OBJECT_0)
|
||||
{
|
||||
while (ReadMsgQueue(mQueueHandle, &detail, sizeof(detail), &size, 1, &flags))
|
||||
{
|
||||
QString dev = TCHAR2QString(detail.d.szName);
|
||||
QDeviceChangeEvent *event = 0;
|
||||
if (detail.d.fAttached) {
|
||||
QDeviceChangeEvent* event = 0;
|
||||
|
||||
if (detail.d.fAttached)
|
||||
{
|
||||
emitDeviceAdded(dev);
|
||||
event = new QDeviceChangeEvent(QDeviceChangeEvent::Add, dev);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
emitDeviceRemoved(dev);
|
||||
event = new QDeviceChangeEvent(QDeviceChangeEvent::Remove, dev);
|
||||
}
|
||||
if (event != 0 && !event_receivers.isEmpty()) {
|
||||
foreach(QObject* obj, event_receivers) {
|
||||
|
||||
if (event != 0 && !event_receivers.isEmpty())
|
||||
{
|
||||
foreach (QObject* obj, event_receivers)
|
||||
{
|
||||
QCoreApplication::postEvent(obj, event, Qt::HighEventPriority);
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ QQTPluginWatcher* QQTPluginWatcher::Instance()
|
||||
{
|
||||
if (_instance)
|
||||
return _instance;
|
||||
|
||||
_instance = new QQTPluginWatcher();
|
||||
return _instance;
|
||||
}
|
||||
@ -49,6 +50,7 @@ void QQTPluginWatcher::slotDeviceAdded(const QString& dev)
|
||||
m_devType = E_KEYBOARD;
|
||||
else if ("/dev/sda1" == dev)
|
||||
m_devType = E_STORAGE;
|
||||
|
||||
m_devStat = E_ADD;
|
||||
timer->start(1000);
|
||||
}
|
||||
@ -68,6 +70,7 @@ void QQTPluginWatcher::slotDeviceChanged(const QString& dev)
|
||||
void QQTPluginWatcher::slotDeviceDriver()
|
||||
{
|
||||
#ifdef __EMBEDDED_LINUX__
|
||||
|
||||
if (E_MOUSE == m_devType)
|
||||
{
|
||||
if (E_ADD == m_devStat)
|
||||
@ -94,6 +97,7 @@ bool QQTPluginWatcher::event(QEvent* e)
|
||||
{
|
||||
QDeviceChangeEvent* event = (QDeviceChangeEvent*)e;
|
||||
QString action("Change");
|
||||
|
||||
if (event->action() == QDeviceChangeEvent::Add)
|
||||
action = "Add";
|
||||
else if (event->action() == QDeviceChangeEvent::Remove)
|
||||
@ -103,5 +107,6 @@ bool QQTPluginWatcher::event(QEvent* e)
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
|
||||
return QObject::event(e);
|
||||
}
|
||||
|
@ -34,9 +34,10 @@ class QQTSHARED_EXPORT QQTPluginWatcher : public QThread
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static QQTPluginWatcher *Instance();
|
||||
static QQTPluginWatcher* Instance();
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
E_NULLDEV,
|
||||
E_MOUSE,
|
||||
E_KEYBOARD,
|
||||
@ -44,7 +45,8 @@ public:
|
||||
E_MAXDEV,
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
E_NULLSTAT,
|
||||
E_ADD,
|
||||
E_RM,
|
||||
@ -67,13 +69,13 @@ public slots:
|
||||
void slotDeviceDriver();
|
||||
|
||||
protected:
|
||||
virtual bool event(QEvent *e);
|
||||
virtual bool event(QEvent* e);
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
QDeviceWatcher *watcher;
|
||||
explicit QQTPluginWatcher(QObject *parent = 0);
|
||||
QDeviceWatcher* watcher;
|
||||
explicit QQTPluginWatcher(QObject* parent = 0);
|
||||
static QQTPluginWatcher* _instance;
|
||||
quint32 m_devType;
|
||||
quint32 m_devStat;
|
||||
|
@ -7,7 +7,7 @@ QQTPrinter::QQTPrinter(QPrinter::PrinterMode mode) :
|
||||
|
||||
}
|
||||
|
||||
void QQTPrinter::setOutputFileName(const QString &name)
|
||||
void QQTPrinter::setOutputFileName(const QString& name)
|
||||
{
|
||||
m_outputname = name;
|
||||
QPrinter::setOutputFileName(m_outputname);
|
||||
@ -19,9 +19,10 @@ void QQTPrinter::print()
|
||||
* 此处不会影响打印质量,不必再调试
|
||||
*/
|
||||
QString cmd;
|
||||
QString pbm="./output.pbm";
|
||||
QString pbm = "./output.pbm";
|
||||
|
||||
cmd = cmd.sprintf("gs -q -dBATCH -dSAFER -dQUIET -dNOPAUSE -sPAPERSIZE=a4 -r600*600 -sDEVICE=pbmraw -sOutputFile=%s %s", pbm.toLatin1().data(), m_outputname.toLatin1().data());
|
||||
cmd = cmd.sprintf("gs -q -dBATCH -dSAFER -dQUIET -dNOPAUSE -sPAPERSIZE=a4 -r600*600 -sDEVICE=pbmraw -sOutputFile=%s %s",
|
||||
pbm.toLatin1().data(), m_outputname.toLatin1().data());
|
||||
system(cmd.toLatin1().data());
|
||||
|
||||
cmd = cmd.sprintf("foo2zjs -z3 -p9 -r600*600 %s > /dev/usb/lp0", pbm.toLatin1().data());
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user