code format

This commit is contained in:
2022-12-14 14:14:33 +03:00
parent 09e5342956
commit cdb02fc9be
278 changed files with 15371 additions and 12176 deletions

View File

@@ -1,7 +1,8 @@
#include "qad_touch_widgets.h"
#include "touchsliderplugin.h"
#include "touchbuttframeplugin.h"
#include "touchbuttonplugin.h"
#include "touchsliderplugin.h"
QADTouchWidgets::QADTouchWidgets(QObject * parent): QObject(parent) {
@@ -11,7 +12,7 @@ QADTouchWidgets::QADTouchWidgets(QObject * parent): QObject(parent) {
}
QList<QDesignerCustomWidgetInterface*> QADTouchWidgets::customWidgets() const {
QList<QDesignerCustomWidgetInterface *> QADTouchWidgets::customWidgets() const {
return m_widgets;
}

View File

@@ -1,23 +1,24 @@
#ifndef QAD_TOUCH_WIDGETS_H
#define QAD_TOUCH_WIDGETS_H
#include <QtDesigner/QtDesigner>
#include <QtCore/qplugin.h>
#include <QtDesigner/QtDesigner>
class QADTouchWidgets: public QObject, public QDesignerCustomWidgetCollectionInterface
{
class QADTouchWidgets
: public QObject
, public QDesignerCustomWidgetCollectionInterface {
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "qad.touch_widgets")
#endif
public:
explicit QADTouchWidgets(QObject *parent = 0);
virtual QList<QDesignerCustomWidgetInterface * > customWidgets() const;
explicit QADTouchWidgets(QObject * parent = 0);
virtual QList<QDesignerCustomWidgetInterface *> customWidgets() const;
private:
QList<QDesignerCustomWidgetInterface * > m_widgets;
QList<QDesignerCustomWidgetInterface *> m_widgets;
};
#endif // QAD_TOUCH_WIDGETS_H

View File

@@ -1,90 +1,76 @@
#include "touchbuttframe.h"
#include "touchbuttframeplugin.h"
#include <QtCore/QtPlugin>
#include "touchbuttframe.h"
#include <QDesignerFormEditorInterface>
#include <QDesignerPropertyEditorInterface>
#include <QtCore/QtPlugin>
TouchButtFramePlugin::TouchButtFramePlugin(QObject *parent)
: QObject(parent)
{
m_initialized = false;
TouchButtFramePlugin::TouchButtFramePlugin(QObject * parent): QObject(parent) {
m_initialized = false;
}
void TouchButtFramePlugin::initialize(QDesignerFormEditorInterface * /*core*/ )
{
if (m_initialized)
return;
void TouchButtFramePlugin::initialize(QDesignerFormEditorInterface * /*core*/) {
if (m_initialized) return;
// Add extension registrations, etc. here
//core->propertyEditor()->property();
m_initialized = true;
// Add extension registrations, etc. here
// core->propertyEditor()->property();
m_initialized = true;
}
bool TouchButtFramePlugin::isInitialized() const
{
return m_initialized;
bool TouchButtFramePlugin::isInitialized() const {
return m_initialized;
}
QWidget *TouchButtFramePlugin::createWidget(QWidget *parent)
{
TouchButtFrame * tbw = new TouchButtFrame(parent);
QStringList l;
l.append("First");
l.append("Second");
tbw->setButtons(l);
return tbw;
QWidget * TouchButtFramePlugin::createWidget(QWidget * parent) {
TouchButtFrame * tbw = new TouchButtFrame(parent);
QStringList l;
l.append("First");
l.append("Second");
tbw->setButtons(l);
return tbw;
}
QString TouchButtFramePlugin::name() const
{
return QLatin1String("TouchButtFrame");
QString TouchButtFramePlugin::name() const {
return QLatin1String("TouchButtFrame");
}
QString TouchButtFramePlugin::group() const
{
return QLatin1String("Touch Widgets");
QString TouchButtFramePlugin::group() const {
return QLatin1String("Touch Widgets");
}
QIcon TouchButtFramePlugin::icon() const
{
return QIcon(":/icons/touchbuttframe.png");
QIcon TouchButtFramePlugin::icon() const {
return QIcon(":/icons/touchbuttframe.png");
}
QString TouchButtFramePlugin::toolTip() const
{
return QLatin1String("");
QString TouchButtFramePlugin::toolTip() const {
return QLatin1String("");
}
QString TouchButtFramePlugin::whatsThis() const
{
return QLatin1String("");
QString TouchButtFramePlugin::whatsThis() const {
return QLatin1String("");
}
bool TouchButtFramePlugin::isContainer() const
{
return false;
bool TouchButtFramePlugin::isContainer() const {
return false;
}
QString TouchButtFramePlugin::domXml() const
{
return QLatin1String("<ui language=\"c++\">\n"
" <widget class=\"TouchButtFrame\" name=\"touchButtFrame\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>100</width>\n"
" <height>100</height>\n"
" </rect>\n"
" </property>\n"
" </widget>\n"
"</ui>\n");
QString TouchButtFramePlugin::domXml() const {
return QLatin1String("<ui language=\"c++\">\n"
" <widget class=\"TouchButtFrame\" name=\"touchButtFrame\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>100</width>\n"
" <height>100</height>\n"
" </rect>\n"
" </property>\n"
" </widget>\n"
"</ui>\n");
}
QString TouchButtFramePlugin::includeFile() const
{
return QLatin1String("touchbuttframe.h");
QString TouchButtFramePlugin::includeFile() const {
return QLatin1String("touchbuttframe.h");
}

View File

@@ -8,28 +8,29 @@
# include <QDesignerCustomWidgetInterface>
#endif
class TouchButtFramePlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
class TouchButtFramePlugin
: public QObject
, public QDesignerCustomWidgetInterface {
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
TouchButtFramePlugin(QObject *parent = 0);
TouchButtFramePlugin(QObject * parent = 0);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget *createWidget(QWidget *parent);
void initialize(QDesignerFormEditorInterface *core);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget * createWidget(QWidget * parent);
void initialize(QDesignerFormEditorInterface * core);
private:
bool m_initialized;
bool m_initialized;
};
#endif

View File

@@ -1,74 +1,60 @@
#include "touchbutton.h"
#include "touchbuttonplugin.h"
#include <QtCore/QtPlugin>
#include "touchbutton.h"
#include <QDesignerFormEditorInterface>
#include <QDesignerPropertyEditorInterface>
#include <QtCore/QtPlugin>
TouchButtonPlugin::TouchButtonPlugin(QObject *parent)
: QObject(parent)
{
m_initialized = false;
TouchButtonPlugin::TouchButtonPlugin(QObject * parent): QObject(parent) {
m_initialized = false;
}
void TouchButtonPlugin::initialize(QDesignerFormEditorInterface * /* core */)
{
if (m_initialized)
return;
void TouchButtonPlugin::initialize(QDesignerFormEditorInterface * /* core */) {
if (m_initialized) return;
// Add extension registrations, etc. here
// Add extension registrations, etc. here
m_initialized = true;
m_initialized = true;
}
bool TouchButtonPlugin::isInitialized() const
{
return m_initialized;
bool TouchButtonPlugin::isInitialized() const {
return m_initialized;
}
QWidget *TouchButtonPlugin::createWidget(QWidget *parent)
{
return new TouchButton(parent);
QWidget * TouchButtonPlugin::createWidget(QWidget * parent) {
return new TouchButton(parent);
}
QString TouchButtonPlugin::name() const
{
return QLatin1String("TouchButton");
QString TouchButtonPlugin::name() const {
return QLatin1String("TouchButton");
}
QString TouchButtonPlugin::group() const
{
return QLatin1String("Touch Widgets");
QString TouchButtonPlugin::group() const {
return QLatin1String("Touch Widgets");
}
QIcon TouchButtonPlugin::icon() const
{
return QIcon(":/icons/touchbutton.png");
QIcon TouchButtonPlugin::icon() const {
return QIcon(":/icons/touchbutton.png");
}
QString TouchButtonPlugin::toolTip() const
{
return QLatin1String("");
QString TouchButtonPlugin::toolTip() const {
return QLatin1String("");
}
QString TouchButtonPlugin::whatsThis() const
{
return QLatin1String("");
QString TouchButtonPlugin::whatsThis() const {
return QLatin1String("");
}
bool TouchButtonPlugin::isContainer() const
{
return false;
bool TouchButtonPlugin::isContainer() const {
return false;
}
QString TouchButtonPlugin::domXml() const
{
return QLatin1String("<widget class=\"TouchButton\" name=\"touchButton\">\n</widget>\n");
QString TouchButtonPlugin::domXml() const {
return QLatin1String("<widget class=\"TouchButton\" name=\"touchButton\">\n</widget>\n");
}
QString TouchButtonPlugin::includeFile() const
{
return QLatin1String("touchbutton.h");
QString TouchButtonPlugin::includeFile() const {
return QLatin1String("touchbutton.h");
}

View File

@@ -8,28 +8,29 @@
# include <QDesignerCustomWidgetInterface>
#endif
class TouchButtonPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
class TouchButtonPlugin
: public QObject
, public QDesignerCustomWidgetInterface {
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
TouchButtonPlugin(QObject *parent = 0);
TouchButtonPlugin(QObject * parent = 0);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget *createWidget(QWidget *parent);
void initialize(QDesignerFormEditorInterface *core);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget * createWidget(QWidget * parent);
void initialize(QDesignerFormEditorInterface * core);
private:
bool m_initialized;
bool m_initialized;
};
#endif // TOUCHBUTTONPLUGIN_H

View File

@@ -1,81 +1,67 @@
#include "touchslider.h"
#include "touchsliderplugin.h"
#include <QtCore/QtPlugin>
#include "touchslider.h"
#include <QDesignerFormEditorInterface>
#include <QDesignerPropertyEditorInterface>
#include <QtCore/QtPlugin>
TouchSliderPlugin::TouchSliderPlugin(QObject *parent)
: QObject(parent)
{
m_initialized = false;
TouchSliderPlugin::TouchSliderPlugin(QObject * parent): QObject(parent) {
m_initialized = false;
}
void TouchSliderPlugin::initialize(QDesignerFormEditorInterface * /* core */)
{
if (m_initialized)
return;
void TouchSliderPlugin::initialize(QDesignerFormEditorInterface * /* core */) {
if (m_initialized) return;
// Add extension registrations, etc. here
// Add extension registrations, etc. here
m_initialized = true;
m_initialized = true;
}
bool TouchSliderPlugin::isInitialized() const
{
return m_initialized;
bool TouchSliderPlugin::isInitialized() const {
return m_initialized;
}
QWidget *TouchSliderPlugin::createWidget(QWidget *parent)
{
TouchSlider * ts = new TouchSlider(parent);
ts->setMinimum(-5.);
ts->setMaximum(5.);
ts->setPrecision(0.2);
ts->setValue(2.2);
ts->setPrefix("Distanse");
ts->setSuffix("meters");
return ts;
QWidget * TouchSliderPlugin::createWidget(QWidget * parent) {
TouchSlider * ts = new TouchSlider(parent);
ts->setMinimum(-5.);
ts->setMaximum(5.);
ts->setPrecision(0.2);
ts->setValue(2.2);
ts->setPrefix("Distanse");
ts->setSuffix("meters");
return ts;
}
QString TouchSliderPlugin::name() const
{
return QLatin1String("TouchSlider");
QString TouchSliderPlugin::name() const {
return QLatin1String("TouchSlider");
}
QString TouchSliderPlugin::group() const
{
return QLatin1String("Touch Widgets");
QString TouchSliderPlugin::group() const {
return QLatin1String("Touch Widgets");
}
QIcon TouchSliderPlugin::icon() const
{
return QIcon(":/icons/touchslider.png");
QIcon TouchSliderPlugin::icon() const {
return QIcon(":/icons/touchslider.png");
}
QString TouchSliderPlugin::toolTip() const
{
return QLatin1String("");
QString TouchSliderPlugin::toolTip() const {
return QLatin1String("");
}
QString TouchSliderPlugin::whatsThis() const
{
return QLatin1String("");
QString TouchSliderPlugin::whatsThis() const {
return QLatin1String("");
}
bool TouchSliderPlugin::isContainer() const
{
return false;
bool TouchSliderPlugin::isContainer() const {
return false;
}
QString TouchSliderPlugin::domXml() const
{
return QLatin1String("<widget class=\"TouchSlider\" name=\"touchSlider\">\n</widget>\n");
QString TouchSliderPlugin::domXml() const {
return QLatin1String("<widget class=\"TouchSlider\" name=\"touchSlider\">\n</widget>\n");
}
QString TouchSliderPlugin::includeFile() const
{
return QLatin1String("touchslider.h");
QString TouchSliderPlugin::includeFile() const {
return QLatin1String("touchslider.h");
}

View File

@@ -8,28 +8,29 @@
# include <QDesignerCustomWidgetInterface>
#endif
class TouchSliderPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
class TouchSliderPlugin
: public QObject
, public QDesignerCustomWidgetInterface {
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
public:
TouchSliderPlugin(QObject *parent = 0);
TouchSliderPlugin(QObject * parent = 0);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget *createWidget(QWidget *parent);
void initialize(QDesignerFormEditorInterface *core);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget * createWidget(QWidget * parent);
void initialize(QDesignerFormEditorInterface * core);
private:
bool m_initialized;
bool m_initialized;
};
#endif

View File

@@ -1,20 +1,20 @@
/*
QAD - Qt ADvanced
QAD - Qt ADvanced
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOUCH_BAR_H
@@ -24,10 +24,10 @@
class touch_bar: public QProgressBar {
Q_OBJECT
public:
touch_bar(QWidget * parent = 0): QProgressBar(parent)
{
//setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
touch_bar(QWidget * parent = 0): QProgressBar(parent) {
// setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
}
signals:
void mouseMoveEvent(QMouseEvent * e);

View File

@@ -20,7 +20,7 @@ void TouchButtFrame::addButton(const QString & caption) {
butt->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
butt->setCheckable(true);
butt->setAutoExclusive(true);
//butt->setAutoFillBackground(true);
// butt->setAutoFillBackground(true);
lay->addWidget(butt);
this->setLayout(lay);
connect(butt, SIGNAL(clickedID(int)), SLOT(butt_click(int)));
@@ -49,8 +49,10 @@ void TouchButtFrame::setButtons(const QStringList & captions) {
deleteButtons();
for (int i = 0; i < captions.size(); ++i)
addButton(QString(captions.at(i)).replace("\\n", "\n"));
if (button(cur) != 0) button(cur)->setChecked(true);
else if (!captions.isEmpty()) button(0)->setChecked(true);
if (button(cur) != 0)
button(cur)->setChecked(true);
else if (!captions.isEmpty())
button(0)->setChecked(true);
resetColors();
}
@@ -79,7 +81,6 @@ QStringList TouchButtFrame::buttons() {
TouchButton * TouchButtFrame::button(int index) {
if (index >= 0 && index < lay->count())
return (qobject_cast<TouchButton * >(lay->itemAt(index)->widget()));
if (index >= 0 && index < lay->count()) return (qobject_cast<TouchButton *>(lay->itemAt(index)->widget()));
return 0;
}

View File

@@ -1,34 +1,34 @@
/*
QAD - Qt ADvanced
QAD - Qt ADvanced
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOUCHBUTTFRAME_H
#define TOUCHBUTTFRAME_H
#include <QFrame>
#include "qad_touch_widgets_export.h"
#include "touchbutton.h"
#include <QBoxLayout>
#include <QDebug>
#include "touchbutton.h"
#include "qad_touch_widgets_export.h"
#include <QFrame>
class QAD_TOUCH_WIDGETS_EXPORT TouchButtFrame: public QFrame
{
class QAD_TOUCH_WIDGETS_EXPORT TouchButtFrame: public QFrame {
Q_OBJECT
Q_PROPERTY(QColor colorYes READ colorYes WRITE setColorYes)
Q_PROPERTY(QColor colorNo READ colorNo WRITE setColorNo)
@@ -39,95 +39,189 @@ class QAD_TOUCH_WIDGETS_EXPORT TouchButtFrame: public QFrame
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
Q_PROPERTY(int clickID READ clickID WRITE setClickID)
Q_PROPERTY(int setID READ setID WRITE setSetID)
public:
TouchButtFrame(QWidget * parent = 0, Qt::Orientation orientation = Qt::Horizontal);
int clickID() const {return id_click;}
int setID() const {return id_set;}
int clickID() const { return id_click; }
int setID() const { return id_set; }
void setButtons(const QStringList & captions);
QStringList buttons();
TouchButton * button(int index);
int buttonsCount() const {return lay->count();}
int buttonsCount() const { return lay->count(); }
int currentButton();
Qt::Orientation orientation() const {if (lay->direction() == 0) return Qt::Horizontal; else return Qt::Vertical;}
QColor colorYes() const {return colg;}
QColor colorNo() const {return colr;}
QColor colorGray() const {return colw;}
QColor colorDown() const {return colp;}
Qt::Orientation orientation() const {
if (lay->direction() == 0)
return Qt::Horizontal;
else
return Qt::Vertical;
}
QColor colorYes() const { return colg; }
QColor colorNo() const { return colr; }
QColor colorGray() const { return colw; }
QColor colorDown() const { return colp; }
void setCurrentButton(int index);
void setColorYes(QColor col) {colg = col; resetColors();}
void setColorNo(QColor col) {colr = col; resetColors();}
void setColorGray(QColor col) {colw = col; resetColors();}
void setColorDown(QColor col) {colp = col; resetColors();}
void setOrientation(Qt::Orientation orientation) {if (orientation == Qt::Horizontal) lay->setDirection(QBoxLayout::LeftToRight); else lay->setDirection(QBoxLayout::TopToBottom);}
void setColorYes(QColor col) {
colg = col;
resetColors();
}
void setColorNo(QColor col) {
colr = col;
resetColors();
}
void setColorGray(QColor col) {
colw = col;
resetColors();
}
void setColorDown(QColor col) {
colp = col;
resetColors();
}
void setOrientation(Qt::Orientation orientation) {
if (orientation == Qt::Horizontal)
lay->setDirection(QBoxLayout::LeftToRight);
else
lay->setDirection(QBoxLayout::TopToBottom);
}
private:
void resetColors();
void deleteButtons();
void addButton(const QString & caption);
int id_click, id_set;
QColor colr, colg, colw, colp;
QBoxLayout * lay;
//int count;
// int count;
private slots:
void butt_click(int index) {emit clicked(index); emit clickedID(id_click, index);}
void butt_toggle(int index, bool checked) {emit toggled(index, checked); emit toggledID(id_click, index, checked);}
void butt_click(int index) {
emit clicked(index);
emit clickedID(id_click, index);
}
void butt_toggle(int index, bool checked) {
emit toggled(index, checked);
emit toggledID(id_click, index, checked);
}
public slots:
void enable() {setEnabled(true);}
void disable() {setAllButtonsGray(); setEnabled(false);}
void setClickID(int id) {id_click = id;}
void setSetID(int id) {id_set = id;}
void setButtonChecked(int index) {if (button(index) != 0) button(index)->setChecked(true);}
void setButtonUnchecked(int index) {if (button(index) != 0) button(index)->setChecked(false);}
void setButtonState(int index, TouchButton::State state) {if (button(index) != 0) button(index)->setState(state);}
void setButtonYes(int index) {if (button(index) != 0) button(index)->setStateYes();}
void setButtonNo(int index) {if (button(index) != 0) button(index)->setStateNo();}
void setButtonGray(int index) {if (button(index) != 0) button(index)->setStateGray();}
void setAllButtonsState(TouchButton::State state) {for (int i = 0; i < buttonsCount(); ++i) button(i)->setState(state);}
void setAllButtonsYes() {for (int i = 0; i < buttonsCount(); ++i) button(i)->setStateYes();}
void setAllButtonsNo() {for (int i = 0; i < buttonsCount(); ++i) button(i)->setStateNo();}
void setAllButtonsGray() {for (int i = 0; i < buttonsCount(); ++i) button(i)->setStateGray();}
void hideButton(int index) {if (button(index) != 0) button(index)->hide();}
void showButton(int index) {if (button(index) != 0) button(index)->show();}
void enableButton(int index) {if (button(index) != 0) button(index)->enable();}
void disableButton(int index) {if (button(index) != 0) button(index)->disable();}
void enable() { setEnabled(true); }
void disable() {
setAllButtonsGray();
setEnabled(false);
}
void enableID(int set_id) {if (set_id == id_set) enable();}
void disableID(int set_id) {if (set_id == id_set) disable();}
void setButtonCheckedID(int set_id, int index) {if (set_id == id_set) setButtonChecked(index);}
void setButtonUncheckedID(int set_id, int index) {if (set_id == id_set) setButtonUnchecked(index);}
void setButtonStateID(int set_id, int index, TouchButton::State state) {if (set_id == id_set) setButtonState(index, state);}
void setButtonYesID(int set_id, int index) {if (set_id == id_set) setButtonYes(index);}
void setButtonNoID(int set_id, int index) {if (set_id == id_set) setButtonNo(index);}
void setButtonGrayID(int set_id, int index) {if (set_id == id_set) setButtonGray(index);}
void setAllButtonsStateID(int set_id, TouchButton::State state) {if (set_id == id_set) setAllButtonsState(state);}
void setAllButtonsYesID(int set_id) {if (set_id == id_set) setAllButtonsYes();}
void setAllButtonsNoID(int set_id) {if (set_id == id_set) setAllButtonsNo();}
void setAllButtonsGrayID(int set_id) {if (set_id == id_set) setAllButtonsGray();}
void hideButtonID(int set_id, int index) {if (set_id == id_set) hideButton(index);}
void showButtonID(int set_id, int index) {if (set_id == id_set) showButton(index);}
void enableButtonID(int set_id, int index) {if (set_id == id_set) enableButton(index);}
void disableButtonID(int set_id, int index) {if (set_id == id_set) disableButton(index);}
void setClickID(int id) { id_click = id; }
void setSetID(int id) { id_set = id; }
void setButtonChecked(int index) {
if (button(index) != 0) button(index)->setChecked(true);
}
void setButtonUnchecked(int index) {
if (button(index) != 0) button(index)->setChecked(false);
}
void setButtonState(int index, TouchButton::State state) {
if (button(index) != 0) button(index)->setState(state);
}
void setButtonYes(int index) {
if (button(index) != 0) button(index)->setStateYes();
}
void setButtonNo(int index) {
if (button(index) != 0) button(index)->setStateNo();
}
void setButtonGray(int index) {
if (button(index) != 0) button(index)->setStateGray();
}
void setAllButtonsState(TouchButton::State state) {
for (int i = 0; i < buttonsCount(); ++i)
button(i)->setState(state);
}
void setAllButtonsYes() {
for (int i = 0; i < buttonsCount(); ++i)
button(i)->setStateYes();
}
void setAllButtonsNo() {
for (int i = 0; i < buttonsCount(); ++i)
button(i)->setStateNo();
}
void setAllButtonsGray() {
for (int i = 0; i < buttonsCount(); ++i)
button(i)->setStateGray();
}
void hideButton(int index) {
if (button(index) != 0) button(index)->hide();
}
void showButton(int index) {
if (button(index) != 0) button(index)->show();
}
void enableButton(int index) {
if (button(index) != 0) button(index)->enable();
}
void disableButton(int index) {
if (button(index) != 0) button(index)->disable();
}
void enableID(int set_id) {
if (set_id == id_set) enable();
}
void disableID(int set_id) {
if (set_id == id_set) disable();
}
void setButtonCheckedID(int set_id, int index) {
if (set_id == id_set) setButtonChecked(index);
}
void setButtonUncheckedID(int set_id, int index) {
if (set_id == id_set) setButtonUnchecked(index);
}
void setButtonStateID(int set_id, int index, TouchButton::State state) {
if (set_id == id_set) setButtonState(index, state);
}
void setButtonYesID(int set_id, int index) {
if (set_id == id_set) setButtonYes(index);
}
void setButtonNoID(int set_id, int index) {
if (set_id == id_set) setButtonNo(index);
}
void setButtonGrayID(int set_id, int index) {
if (set_id == id_set) setButtonGray(index);
}
void setAllButtonsStateID(int set_id, TouchButton::State state) {
if (set_id == id_set) setAllButtonsState(state);
}
void setAllButtonsYesID(int set_id) {
if (set_id == id_set) setAllButtonsYes();
}
void setAllButtonsNoID(int set_id) {
if (set_id == id_set) setAllButtonsNo();
}
void setAllButtonsGrayID(int set_id) {
if (set_id == id_set) setAllButtonsGray();
}
void hideButtonID(int set_id, int index) {
if (set_id == id_set) hideButton(index);
}
void showButtonID(int set_id, int index) {
if (set_id == id_set) showButton(index);
}
void enableButtonID(int set_id, int index) {
if (set_id == id_set) enableButton(index);
}
void disableButtonID(int set_id, int index) {
if (set_id == id_set) disableButton(index);
}
signals:
void clicked(int index);
void toggled(int index, bool checked);
void clickedID(int id, int index);
void toggledID(int id, int index, bool checked);
};
#endif // TOUCHBUTTFRAME_H

View File

@@ -13,8 +13,7 @@ TouchButton::TouchButton(int id__, const QString & text): QToolButton(0) {
}
TouchButton::~TouchButton() {
}
TouchButton::~TouchButton() {}
void TouchButton::init() {
@@ -26,15 +25,15 @@ void TouchButton::init() {
animation.setDuration(350);
delay_blink = 500;
anim = auto_gray = true;
state_ = Gray;
state_ = Gray;
id_click = id_yes = id_no = -1;
timer = 0;
pal = palette();
col_yes = QColor(Qt::green);
col_no = QColor(Qt::red);
col_down = QColor(Qt::yellow);
timer = 0;
pal = palette();
col_yes = QColor(Qt::green);
col_no = QColor(Qt::red);
col_down = QColor(Qt::yellow);
col_gray = col_cur = col_up = pal.button().color();
col_dst = col_gray;
col_dst = col_gray;
}
@@ -81,7 +80,7 @@ void TouchButton::animateColor(const QColor & tc) {
void TouchButton::applyState(State s) {
if (s == state_) return;
State ps = state_;
state_ = s;
state_ = s;
emit stateChanged(state_, ps);
emit stateChangedID(id_click, state_, ps);
}

View File

@@ -1,37 +1,37 @@
/*
QAD - Qt ADvanced
QAD - Qt ADvanced
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOUCHBUTTON_H
#define TOUCHBUTTON_H
#include <QToolButton>
#include "qad_touch_widgets_export.h"
#include <QDebug>
#include <QFrame>
#include <QMouseEvent>
#include <QPropertyAnimation>
#include <QDebug>
#include "qad_touch_widgets_export.h"
#include <QToolButton>
class QAD_TOUCH_WIDGETS_EXPORT TouchButton: public QToolButton
{
class QAD_TOUCH_WIDGETS_EXPORT TouchButton: public QToolButton {
Q_OBJECT
Q_ENUMS(State)
Q_ENUMS(State)
Q_PROPERTY(QColor downColor READ downColor WRITE setDownColor)
Q_PROPERTY(QColor upColor READ upColor WRITE setUpColor)
Q_PROPERTY(QColor grayColor READ grayColor WRITE setGrayColor)
@@ -52,36 +52,43 @@ public:
explicit TouchButton(QWidget * parent = 0);
TouchButton(int id, const QString & text = QString());
~TouchButton();
enum State {Gray, Yes, No};
int clickID() const {return id_click;}
int yesID() const {return id_yes;}
int noID() const {return id_no;}
QColor downColor() const {return col_down;}
QColor upColor() const {return col_up;}
QColor grayColor() const {return col_gray;}
QColor yesColor() const {return col_yes;}
QColor noColor() const {return col_no;}
QColor currentColor() const {return col_cur;}
State state() const {return state_;}
bool autoGray() const {return auto_gray;}
bool animated() const {return anim;}
int animationDuration() const {return animation.duration();}
QEasingCurve::Type animationCurve() const {return animation.easingCurve().type();}
int blinkDelay() const {return delay_blink;}
enum State {
Gray,
Yes,
No
};
int clickID() const { return id_click; }
int yesID() const { return id_yes; }
int noID() const { return id_no; }
QColor downColor() const { return col_down; }
QColor upColor() const { return col_up; }
QColor grayColor() const { return col_gray; }
QColor yesColor() const { return col_yes; }
QColor noColor() const { return col_no; }
QColor currentColor() const { return col_cur; }
State state() const { return state_; }
bool autoGray() const { return auto_gray; }
bool animated() const { return anim; }
int animationDuration() const { return animation.duration(); }
QEasingCurve::Type animationCurve() const { return animation.easingCurve().type(); }
int blinkDelay() const { return delay_blink; }
void blink(const QColor & tc);
private:
void timerEvent(QTimerEvent * e);
void mousePressEvent(QMouseEvent * e);
void mouseReleaseEvent(QMouseEvent * e);
void init();
void animateColor(const QColor & tc);
void applyColor() {pal.setColor(QPalette::Button, col_cur); setPalette(pal);}
void applyColor() {
pal.setColor(QPalette::Button, col_cur);
setPalette(pal);
}
void applyState(State s);
QPalette pal;
@@ -90,74 +97,150 @@ private:
State state_;
int id_click, id_yes, id_no, delay_blink, timer;
bool anim, auto_gray;
private slots:
void _clicked() {emit clickedID(id_click);}
void _toggled(bool on) {if (!on && auto_gray) setStateGray(); emit toggledID(id_click, on);}
void _clicked() { emit clickedID(id_click); }
void _toggled(bool on) {
if (!on && auto_gray) setStateGray();
emit toggledID(id_click, on);
}
public slots:
void enable() {setEnabled(true);}
void disable() {setStateGray(); setEnabled(false);}
void setClickID(int id) {id_click = id;}
void setYesID(int id) {id_yes = id;}
void setNoID(int id) {id_no = id;}
void setDownColor(const QColor & col) {col_down = col;}
void setUpColor(const QColor & col) {col_up = col;}
void setGrayColor(const QColor & col) {col_gray = col;}
void setYesColor(const QColor & col) {col_yes = col;}
void setNoColor(const QColor & col) {col_no = col;}
void enable() { setEnabled(true); }
void disable() {
setStateGray();
setEnabled(false);
}
void setClickID(int id) { id_click = id; }
void setYesID(int id) { id_yes = id; }
void setNoID(int id) { id_no = id; }
void setDownColor(const QColor & col) { col_down = col; }
void setUpColor(const QColor & col) { col_up = col; }
void setGrayColor(const QColor & col) { col_gray = col; }
void setYesColor(const QColor & col) { col_yes = col; }
void setNoColor(const QColor & col) { col_no = col; }
void setState(State s);
void setStateGray() {col_dst = col_gray; applyState(Gray); animateColor(col_dst);}
void setStateYes() {col_dst = col_yes; applyState(Yes); animateColor(col_dst);}
void setStateNo() {col_dst = col_no; applyState(No); animateColor(col_dst);}
void setStateYesOrNo(bool yes) {if (yes) setStateYes(); else setStateNo();}
void setStateYesOrGray(bool yes) {if (yes) setStateYes(); else setStateGray();}
void setStateNoOrYes(bool no) {if (no) setStateNo(); else setStateYes();}
void setStateNoOrGray(bool no) {if (no) setStateNo(); else setStateGray();}
void blinkYes() {blink(col_yes);}
void blinkNo() {blink(col_no);}
void blinkYesOrNo(bool yes) {blink(yes ? col_yes : col_no);}
void blinkNoOrYes(bool no) {blink(no ? col_no : col_yes);}
void enableID(int yes_id) {if (yes_id == id_yes) enable();}
void disableID(int yes_id) {if (yes_id == id_yes) disable();}
void setStateID(int yes_id, State s) {if (yes_id == id_yes) setState(s);}
void setStateGrayID(int yes_id) {if (yes_id == id_yes) setStateGray();}
void setStateYesID(int yes_id) {if (yes_id == id_yes) setStateYes();}
void setStateNoID(int no_id) {if (no_id == id_no) setStateNo();}
void setStateYesOrNoID(int yes_id, bool yes) {if (yes_id == id_yes) setStateYesOrNo(yes);}
void setStateYesOrGrayID(int yes_id, bool yes) {if (yes_id == id_yes) setStateYesOrGray(yes);}
void setStateNoOrYesID(int no_id, bool no) {if (no_id == id_no) setStateNoOrYes(no);}
void setStateNoOrGrayID(int no_id, bool no) {if (no_id == id_no) setStateNoOrGray(no);}
void blinkYesID(int yes_id) {if (yes_id == id_yes) blinkYes();}
void blinkNoID(int no_id) {if (no_id == id_no) blinkNo();}
void blinkYesOrNoID(int yes_id, bool yes) {if (yes_id == id_yes) blinkYesOrNo(yes);}
void blinkNoOrYesID(int no_id, bool no) {if (no_id == id_no) blinkNoOrYes(no);}
void setColor(const QColor & col) {col_dst = col; animateColor(col_dst);}
void setCurrentColor(const QColor & col) {col_cur = col; applyColor();}
void setAutoGray(bool yes) {auto_gray = yes;}
void setAnimated(bool yes) {anim = yes;}
void setAnimationDuration(int dur) {animation.setDuration(dur);}
void setAnimationCurve(QEasingCurve::Type curve) {animation.setEasingCurve(QEasingCurve(curve));}
void setBlinkDelay(int dur) {delay_blink = dur;}
void delayedClick() {QMetaObject::invokeMethod(this, "click", Qt::QueuedConnection);}
void delayedToggle() {QMetaObject::invokeMethod(this, "toggle", Qt::QueuedConnection);}
void delayedClickID(int yes_id) {if (yes_id == id_yes) delayedClick();}
void delayedToggleID(int yes_id) {if (yes_id == id_yes) delayedToggle();}
void setStateGray() {
col_dst = col_gray;
applyState(Gray);
animateColor(col_dst);
}
void setStateYes() {
col_dst = col_yes;
applyState(Yes);
animateColor(col_dst);
}
void setStateNo() {
col_dst = col_no;
applyState(No);
animateColor(col_dst);
}
void setStateYesOrNo(bool yes) {
if (yes)
setStateYes();
else
setStateNo();
}
void setStateYesOrGray(bool yes) {
if (yes)
setStateYes();
else
setStateGray();
}
void setStateNoOrYes(bool no) {
if (no)
setStateNo();
else
setStateYes();
}
void setStateNoOrGray(bool no) {
if (no)
setStateNo();
else
setStateGray();
}
void blinkYes() { blink(col_yes); }
void blinkNo() { blink(col_no); }
void blinkYesOrNo(bool yes) { blink(yes ? col_yes : col_no); }
void blinkNoOrYes(bool no) { blink(no ? col_no : col_yes); }
void enableID(int yes_id) {
if (yes_id == id_yes) enable();
}
void disableID(int yes_id) {
if (yes_id == id_yes) disable();
}
void setStateID(int yes_id, State s) {
if (yes_id == id_yes) setState(s);
}
void setStateGrayID(int yes_id) {
if (yes_id == id_yes) setStateGray();
}
void setStateYesID(int yes_id) {
if (yes_id == id_yes) setStateYes();
}
void setStateNoID(int no_id) {
if (no_id == id_no) setStateNo();
}
void setStateYesOrNoID(int yes_id, bool yes) {
if (yes_id == id_yes) setStateYesOrNo(yes);
}
void setStateYesOrGrayID(int yes_id, bool yes) {
if (yes_id == id_yes) setStateYesOrGray(yes);
}
void setStateNoOrYesID(int no_id, bool no) {
if (no_id == id_no) setStateNoOrYes(no);
}
void setStateNoOrGrayID(int no_id, bool no) {
if (no_id == id_no) setStateNoOrGray(no);
}
void blinkYesID(int yes_id) {
if (yes_id == id_yes) blinkYes();
}
void blinkNoID(int no_id) {
if (no_id == id_no) blinkNo();
}
void blinkYesOrNoID(int yes_id, bool yes) {
if (yes_id == id_yes) blinkYesOrNo(yes);
}
void blinkNoOrYesID(int no_id, bool no) {
if (no_id == id_no) blinkNoOrYes(no);
}
void setColor(const QColor & col) {
col_dst = col;
animateColor(col_dst);
}
void setCurrentColor(const QColor & col) {
col_cur = col;
applyColor();
}
void setAutoGray(bool yes) { auto_gray = yes; }
void setAnimated(bool yes) { anim = yes; }
void setAnimationDuration(int dur) { animation.setDuration(dur); }
void setAnimationCurve(QEasingCurve::Type curve) { animation.setEasingCurve(QEasingCurve(curve)); }
void setBlinkDelay(int dur) { delay_blink = dur; }
void delayedClick() { QMetaObject::invokeMethod(this, "click", Qt::QueuedConnection); }
void delayedToggle() { QMetaObject::invokeMethod(this, "toggle", Qt::QueuedConnection); }
void delayedClickID(int yes_id) {
if (yes_id == id_yes) delayedClick();
}
void delayedToggleID(int yes_id) {
if (yes_id == id_yes) delayedToggle();
}
signals:
void clickedID(int id);
void pressedID(int id);
@@ -165,7 +248,6 @@ signals:
void toggledID(int id, bool on);
void stateChanged(State state, State prev_state);
void stateChangedID(int id, State state, State prev_state);
};
#endif // TOUCHBUTTON_H

View File

@@ -1,16 +1,17 @@
#include "touchslider.h"
#include "ui_touchslider.h"
TouchSlider::TouchSlider(QWidget * parent): QGroupBox(parent), ui(new Ui::TouchSlider) {
ui->setupUi(this);
ui->barNeg->setMinimum(0);
prec = 1;
prec = 1;
id_click = id_set = -1;
hasZero = true;
m_readOnly = false;
m_showMinMax = true;
m_showIncDec = true;
hasZero = true;
m_readOnly = false;
m_showMinMax = true;
m_showIncDec = true;
}
@@ -68,7 +69,8 @@ void TouchSlider::setValue(double val) {
double TouchSlider::value() const {
if (ui->barNeg->value() <= ui->barNeg->minimum())
return (double)(ui->barPos->value()) * prec;
else return -(double)(ui->barNeg->value()) * prec;
else
return -(double)(ui->barNeg->value()) * prec;
}
@@ -117,7 +119,7 @@ void TouchSlider::setPrecision(double precision) {
double min = minimum();
double max = maximum();
double val = value();
prec = precision;
prec = precision;
setMinimum(min);
setMaximum(max);
setValue(val);
@@ -144,9 +146,9 @@ void TouchSlider::on_barPos_mouseMoveEvent(QMouseEvent * e) {
if (m_readOnly) return;
int tx =
#if QT_VERSION_MAJOR <= 5
e->x();
e->x();
#else
e->position().toPoint().x();
e->position().toPoint().x();
#endif
if (tx > ui->barPos->width()) tx = ui->barPos->width();
if (tx < 0) {
@@ -160,7 +162,8 @@ void TouchSlider::on_barPos_mouseMoveEvent(QMouseEvent * e) {
}
tx = 0;
}
ui->barPos->setValue(ui->barPos->minimum() + qRound((double)(tx * (ui->barPos->maximum() - ui->barPos->minimum())) / (double)(ui->barPos->width())));
ui->barPos->setValue(ui->barPos->minimum() +
qRound((double)(tx * (ui->barPos->maximum() - ui->barPos->minimum())) / (double)(ui->barPos->width())));
ui->barNeg->setValue(ui->barNeg->minimum());
}
@@ -169,9 +172,9 @@ void TouchSlider::on_barNeg_mouseMoveEvent(QMouseEvent * e) {
if (m_readOnly) return;
int tx =
#if QT_VERSION_MAJOR <= 5
e->x();
e->x();
#else
e->position().toPoint().x();
e->position().toPoint().x();
#endif
if (tx < 0) tx = 0;
if (tx > ui->barNeg->width()) {
@@ -192,11 +195,12 @@ void TouchSlider::on_barPos_mousePressEvent(QMouseEvent * e) {
if (m_readOnly) return;
int tx =
#if QT_VERSION_MAJOR <= 5
e->x();
e->x();
#else
e->position().toPoint().x();
e->position().toPoint().x();
#endif
ui->barPos->setValue(ui->barPos->minimum() + qRound((double)(tx * (ui->barPos->maximum() - ui->barPos->minimum())) / (double)(ui->barPos->width())));
ui->barPos->setValue(ui->barPos->minimum() +
qRound((double)(tx * (ui->barPos->maximum() - ui->barPos->minimum())) / (double)(ui->barPos->width())));
ui->barNeg->setValue(ui->barNeg->minimum());
}
@@ -205,9 +209,9 @@ void TouchSlider::on_barNeg_mousePressEvent(QMouseEvent * e) {
if (m_readOnly) return;
int tx =
#if QT_VERSION_MAJOR <= 5
e->x();
e->x();
#else
e->position().toPoint().x();
e->position().toPoint().x();
#endif
ui->barNeg->setValue(ui->barNeg->maximum() - qRound((double)(tx * ui->barNeg->maximum()) / (double)(ui->barNeg->width())));
ui->barPos->setValue(ui->barPos->minimum());
@@ -226,19 +230,17 @@ void TouchSlider::on_barPos_valueChanged(int) {
void TouchSlider::setReadOnly(bool arg) {
QBoxLayout * bl = qobject_cast<QBoxLayout *>(layout());
m_readOnly = arg;
m_readOnly = arg;
if (arg) {
ui->pbDec->hide();
ui->pbInc->hide();
if (hasZero)
ui->pbZero->hide();
if (hasZero) ui->pbZero->hide();
bl->setStretchFactor(ui->pbMin, 2);
bl->setStretchFactor(ui->pbMax, 2);
} else {
ui->pbDec->show();
ui->pbInc->show();
if (hasZero)
ui->pbZero->show();
if (hasZero) ui->pbZero->show();
bl->setStretchFactor(ui->pbMin, 1);
bl->setStretchFactor(ui->pbMax, 1);
}
@@ -247,7 +249,7 @@ void TouchSlider::setReadOnly(bool arg) {
void TouchSlider::setShowMinMax(bool arg) {
QBoxLayout * bl = qobject_cast<QBoxLayout *>(layout());
m_showMinMax = arg;
m_showMinMax = arg;
if (arg) {
ui->pbMin->show();
ui->pbMax->show();
@@ -266,19 +268,17 @@ void TouchSlider::setShowMinMax(bool arg) {
void TouchSlider::setShowIncDec(bool arg) {
QBoxLayout * bl = qobject_cast<QBoxLayout *>(layout());
m_showIncDec = arg;
m_showIncDec = arg;
if (arg) {
ui->pbDec->show();
ui->pbInc->show();
if (hasZero)
ui->pbZero->show();
if (hasZero) ui->pbZero->show();
bl->setStretchFactor(ui->pbMin, 2);
bl->setStretchFactor(ui->pbMax, 2);
} else {
ui->pbDec->hide();
ui->pbInc->hide();
if (hasZero)
ui->pbZero->hide();
if (hasZero) ui->pbZero->hide();
bl->setStretchFactor(ui->pbMin, 1);
bl->setStretchFactor(ui->pbMax, 1);
}

View File

@@ -1,37 +1,37 @@
/*
QAD - Qt ADvanced
QAD - Qt ADvanced
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOUCHSLIDER_H
#define TOUCHSLIDER_H
#include "qad_touch_widgets_export.h"
#include <QGroupBox>
#include <QMouseEvent>
#include "qad_touch_widgets_export.h"
namespace Ui {
class TouchSlider;
class TouchSlider;
}
class QAD_TOUCH_WIDGETS_EXPORT TouchSlider: public QGroupBox
{
class QAD_TOUCH_WIDGETS_EXPORT TouchSlider: public QGroupBox {
Q_OBJECT
Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly)
Q_PROPERTY(bool showMinMax READ showMinMax WRITE setShowMinMax)
@@ -46,26 +46,26 @@ class QAD_TOUCH_WIDGETS_EXPORT TouchSlider: public QGroupBox
Q_PROPERTY(int setID READ setID WRITE setSetID)
public:
explicit TouchSlider(QWidget *parent = 0);
explicit TouchSlider(QWidget * parent = 0);
~TouchSlider();
int clickID() const {return id_click;}
int setID() const {return id_set;}
int clickID() const { return id_click; }
int setID() const { return id_set; }
double minimum() const;
double maximum() const;
double value() const;
double precision() const;
QString prefix() const {return pref;}
QString suffix() const {return suff;}
bool readOnly() const {return m_readOnly;}
bool showMinMax() const {return m_showMinMax;}
bool showIncDec() const {return m_showIncDec;}
QString prefix() const { return pref; }
QString suffix() const { return suff; }
bool readOnly() const { return m_readOnly; }
bool showMinMax() const { return m_showMinMax; }
bool showIncDec() const { return m_showIncDec; }
private:
void updateCaption();
Ui::TouchSlider *ui;
Ui::TouchSlider * ui;
bool hasZero;
bool m_readOnly;
bool m_showMinMax;
@@ -75,46 +75,60 @@ private:
QString pref, suff;
public slots:
void enable() {setEnabled(true);}
void disable() {setEnabled(false);}
void setClickID(int id) {id_click = id;}
void setSetID(int id) {id_set = id;}
void setSuffix(const QString & text) {suff = text; updateCaption();}
void setPrefix(const QString & text) {pref = text; updateCaption();}
void enable() { setEnabled(true); }
void disable() { setEnabled(false); }
void setClickID(int id) { id_click = id; }
void setSetID(int id) { id_set = id; }
void setSuffix(const QString & text) {
suff = text;
updateCaption();
}
void setPrefix(const QString & text) {
pref = text;
updateCaption();
}
void setPrecision(double precision);
void setPrecision(int precision) {setPrecision((double)precision);}
void setPrecision(int precision) { setPrecision((double)precision); }
void setMinimum(double min);
void setMinimum(int min) {setMinimum((double)min);}
void setMinimum(int min) { setMinimum((double)min); }
void setMaximum(double max);
void setMaximum(int max) {setMaximum((double)max);}
void setMaximum(int max) { setMaximum((double)max); }
void setReadOnly(bool yes);
void setShowMinMax(bool yes);
void setShowIncDec(bool yes);
void setValue(double val);
void setValue(int val) {setValue((double)val);}
void enableID(int set_id) {if (set_id == id_set) enable();}
void disableID(int set_id) {if (set_id == id_set) disable();}
void setValueID(int set_id, double val) {if (set_id == id_set) setValue(val);}
void setValueID(int set_id, int val) {if (set_id == id_set) setValue(val);}
void clickMin() {on_pbMin_clicked();}
void clickMax() {on_pbMax_clicked();}
void clickInc() {on_pbInc_clicked();}
void clickDec() {on_pbDec_clicked();}
void clickZero() {on_pbZero_clicked();}
void setValue(int val) { setValue((double)val); }
void enableID(int set_id) {
if (set_id == id_set) enable();
}
void disableID(int set_id) {
if (set_id == id_set) disable();
}
void setValueID(int set_id, double val) {
if (set_id == id_set) setValue(val);
}
void setValueID(int set_id, int val) {
if (set_id == id_set) setValue(val);
}
void clickMin() { on_pbMin_clicked(); }
void clickMax() { on_pbMax_clicked(); }
void clickInc() { on_pbInc_clicked(); }
void clickDec() { on_pbDec_clicked(); }
void clickZero() { on_pbZero_clicked(); }
private slots:
void on_barPos_valueChanged(int value);
void on_barNeg_valueChanged(int value);
void on_barNeg_mousePressEvent(QMouseEvent*);
void on_barPos_mousePressEvent(QMouseEvent*);
void on_barNeg_mouseMoveEvent(QMouseEvent*);
void on_barPos_mouseMoveEvent(QMouseEvent*);
void on_barNeg_mousePressEvent(QMouseEvent *);
void on_barPos_mousePressEvent(QMouseEvent *);
void on_barNeg_mouseMoveEvent(QMouseEvent *);
void on_barPos_mouseMoveEvent(QMouseEvent *);
void on_pbZero_clicked();
void on_pbDec_clicked();
void on_pbInc_clicked();