refactor: put TouchScreen-related classes together

This commit is contained in:
Wei Wei 2023-06-16 10:48:45 +08:00 committed by wangyan
parent 35d841b921
commit fcb2489e0f
5 changed files with 45 additions and 45 deletions

View File

@ -4,13 +4,6 @@
static const QString MAXTABLET = "MaxTablet";
GestureInfo::GestureInfo(ScreenGestureType gesture, QString descrip, QString actionDescrip, QString playgif)
: description(descrip)
, actionDescription(actionDescrip)
, palyGifPath(playgif)
, gestureType(gesture)
{}
QString SettingsCommon::m_systemCategory = QString();
QString SettingsCommon::m_prjCodeName = QString();
int SettingsCommon::m_productFeat = -1;

View File

@ -2,30 +2,6 @@
#define SETTINGSCOMMON_H
#include <QString>
enum class ScreenGestureType
{
bottomEdgeSwipe,
topEdgeSwipe,
rightEdgeSwipe,
fourFingersSwipeDown,
fourFingersHorizontalSwipe,
unknown
};
class GestureInfo
{
public:
GestureInfo() = default;
GestureInfo(ScreenGestureType gesture, QString descrip, QString actionDescrip, QString playgif);
GestureInfo(const GestureInfo&) = default;
GestureInfo& operator=(const GestureInfo&) = default;
QString description;
QString actionDescription;
QString palyGifPath;
ScreenGestureType gestureType;
};
class SettingsCommon
{
public:

View File

@ -93,22 +93,22 @@ QWidget *TouchscreenSettings::pluginUi()
}
else {
if(SettingsCommon::isMaxTabletSystemCategory()) {
pluginWidget = new TouchScreen({GestureInfo(ScreenGestureType::rightEdgeSwipe,
pluginWidget = new TouchScreen({TouchGestureInfo(TouchGestureType::rightEdgeSwipe,
tr("swipe left from the right edge"),
tr("show sidebar"),
":/gif/resources/右边缘左划显示侧边栏.gif")},
tr("Max Tablet Mode"),
tr("auto switch max tablet mode"));
} else {
const static QList<GestureInfo> defaultGestureTypes =
const static QList<TouchGestureInfo> defaultGestureTypes =
{
GestureInfo(ScreenGestureType::bottomEdgeSwipe, QObject::tr("swipe up from the bottom edge"),
TouchGestureInfo(TouchGestureType::bottomEdgeSwipe, QObject::tr("swipe up from the bottom edge"),
QObject::tr("open the multitasking view"), ":/gif/resources/下边缘上划显示多任务视图.gif"),
GestureInfo(ScreenGestureType::fourFingersHorizontalSwipe, QObject::tr("swipe four fingers horizontally"),
TouchGestureInfo(TouchGestureType::fourFingersHorizontalSwipe, QObject::tr("swipe four fingers horizontally"),
QObject::tr("switch windows"), ":/gif/resources/四指水平滑动显示窗口切换.gif"),
GestureInfo(ScreenGestureType::fourFingersSwipeDown, QObject::tr("swipe four fingers down anywhere"),
TouchGestureInfo(TouchGestureType::fourFingersSwipeDown, QObject::tr("swipe four fingers down anywhere"),
QObject::tr("show global search"), ":/gif/resources/四指向下划动显示搜索.gif"),
GestureInfo(ScreenGestureType::rightEdgeSwipe, QObject::tr("swipe left from the right edge"),
TouchGestureInfo(TouchGestureType::rightEdgeSwipe, QObject::tr("swipe left from the right edge"),
QObject::tr("show sidebar"), ":/gif/resources/右边缘左划显示侧边栏.gif")
};

View File

@ -46,7 +46,7 @@ const QString iconThemeName = "icon-theme-name";
#define KYLIN_USER_GUIDE_SERVICE "com.kylinUserGuide.hotel"
#define KYLIN_USER_GUIDE_INTERFACE "com.guide.hotel"
TouchScreen::TouchScreen(QList<GestureInfo> gestureInfos,
TouchScreen::TouchScreen(QList<TouchGestureInfo> gestureInfos,
QString modeTypeText,
QString autoSwitchText,
QWidget *parent)
@ -94,14 +94,14 @@ void TouchScreen::monitorIconThemeChange()
}
}
GestureWidget* TouchScreen::createGestureWidget(GestureInfo gestureInfo)
GestureWidget* TouchScreen::createGestureWidget(TouchGestureInfo gestureInfo)
{
GestureWidget *gesture = new GestureWidget(ui->gesture_widget);
gesture->setGestureDescription(gestureInfo.description);
gesture->setGestureAction(gestureInfo.actionDescription);
m_gestureArray.append(gesture);
connect(gesture, &GestureWidget::clicked, this, [this, gestureInfo]() {
playGif(gestureInfo.palyGifPath);
playGif(gestureInfo.gifPath);
});
return gesture;
}

View File

@ -30,15 +30,46 @@ namespace kdk {
class KSwitchButton;
}
enum class TouchGestureType
{
bottomEdgeSwipe,
topEdgeSwipe,
rightEdgeSwipe,
fourFingersSwipeDown,
fourFingersHorizontalSwipe,
unknown
};
class TouchGestureInfo
{
public:
TouchGestureInfo() = default;
TouchGestureInfo(TouchGestureType gesture, QString descrip,
QString actionDescrip, QString gifPath)
: gestureType(gesture)
, description(descrip)
, actionDescription(actionDescrip)
, gifPath(gifPath)
{}
TouchGestureInfo(const TouchGestureInfo&) = default;
TouchGestureInfo& operator=(const TouchGestureInfo&) = default;
TouchGestureType gestureType;
QString description;
QString actionDescription;
QString gifPath;
};
class QMovie;
class QGSettings;
class GestureWidget;
class GestureInfo;
class TouchGestureInfo;
class TouchScreen : public QWidget
{
Q_OBJECT
public:
explicit TouchScreen(QList<GestureInfo> gestureInfos, QString modeTypeText,
explicit TouchScreen(QList<TouchGestureInfo> gestureInfos, QString modeTypeText,
QString autoSwitchText,
QWidget* parent = nullptr);
~TouchScreen();
@ -58,7 +89,7 @@ signals:
private slots:
void setAutoSwitchTabletBtn(bool checked);
private:
GestureWidget * createGestureWidget(GestureInfo gestureInfo);
GestureWidget * createGestureWidget(TouchGestureInfo gestureInfo);
QList<GestureWidget*> createGestureWidgets();
void initUI();
void loadGif();
@ -73,11 +104,11 @@ private:
QVector<GestureWidget *> m_gestureArray;
QGSettings *m_iconThemeGSettings;
kdk::KSwitchButton* m_autoSwitchTablet;
QList<TouchGestureInfo> m_gestureInfos;
const QString m_modeTypeText;
const QString m_autoSwitchText;
QList<GestureInfo> m_gestureInfos;
};
#endif // TOUCHSCREEN_H