67 lines
2.2 KiB
C++
67 lines
2.2 KiB
C++
/*
|
|
* Copyright (C) 2020, Tianjin KYLIN Information Technology Co., Ltd.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 3, 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 General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
#ifndef BASEVERTICALSCROLL_H
|
|
#define BASEVERTICALSCROLL_H
|
|
|
|
#include <QWidget>
|
|
#include "gsettingsubject.h"
|
|
#include "primarymanager.h"
|
|
#include <QPropertyAnimation>
|
|
#include <QPainter>
|
|
class BaseVerticalScroll : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit BaseVerticalScroll(int currentValue,int minRange,int maxRange,QWidget *parent = nullptr);
|
|
|
|
void setWheelSpeed(int wheelSpeed);
|
|
int m_currentValue=0;
|
|
int m_wheelSpeed = 1;
|
|
bool m_isFirstFocus = false;
|
|
int m_minRange=0; //最小值 // minimum value
|
|
int m_maxRange=0; //最大值 // Maximum
|
|
void settingsStyle();
|
|
GsettingSubject * subject;
|
|
PrimaryManager * m_priManager;
|
|
void homing();
|
|
int calculateCurrentValue(int current,int offsetValue);
|
|
void commonCalcValue(int height);
|
|
bool isDragging; //鼠标是否按下 // Muse down
|
|
int m_deviation; //偏移量,记录鼠标按下后移动的垂直距离 // Offset, record the vertical distance after mouse is pressed
|
|
int m_mouseSrcPos;
|
|
int m_numSize;
|
|
QPropertyAnimation *homingAni;
|
|
const int interval; //间隔大小 // Interval size
|
|
const int devide; //分隔数量 // Number of partitions
|
|
void paintNum(QPainter &painter, int num, int deviation);
|
|
QString change_NUM_to_str(int alarmHour);
|
|
|
|
|
|
signals:
|
|
void currentValueChanged(int value);
|
|
void deviationChange(int deviation);
|
|
protected:
|
|
void wheelEvent(QWheelEvent *) override;
|
|
void mouseMoveEvent(QMouseEvent *) override;
|
|
private:
|
|
|
|
|
|
};
|
|
|
|
#endif // BASEVERTICALSCROLL_H
|