Browse Source

[launcher] add more places for finger scrolling

Laserlicht 1 year ago
parent
commit
ed6ab19818

+ 3 - 0
launcher/firstLaunch/firstlaunch_moc.cpp

@@ -19,6 +19,7 @@
 #include "../../lib/Languages.h"
 #include "../../lib/Languages.h"
 #include "../../lib/VCMIDirs.h"
 #include "../../lib/VCMIDirs.h"
 #include "../../lib/filesystem/Filesystem.h"
 #include "../../lib/filesystem/Filesystem.h"
+#include "../helper.h"
 #include "../languages.h"
 #include "../languages.h"
 
 
 #ifdef ENABLE_INNOEXTRACT
 #ifdef ENABLE_INNOEXTRACT
@@ -37,6 +38,8 @@ FirstLaunchView::FirstLaunchView(QWidget * parent)
 	ui->lineEditDataSystem->setText(pathToQString(boost::filesystem::absolute(VCMIDirs::get().dataPaths().front())));
 	ui->lineEditDataSystem->setText(pathToQString(boost::filesystem::absolute(VCMIDirs::get().dataPaths().front())));
 	ui->lineEditDataUser->setText(pathToQString(boost::filesystem::absolute(VCMIDirs::get().userDataPath())));
 	ui->lineEditDataUser->setText(pathToQString(boost::filesystem::absolute(VCMIDirs::get().userDataPath())));
 
 
+	Helper::enableScrollBySwiping(ui->listWidgetLanguage);
+
 #ifndef ENABLE_INNOEXTRACT
 #ifndef ENABLE_INNOEXTRACT
 	ui->pushButtonGogInstall->hide();
 	ui->pushButtonGogInstall->hide();
 #endif
 #endif

+ 14 - 1
launcher/helper.cpp

@@ -12,7 +12,20 @@
 
 
 #include "../lib/CConfigHandler.h"
 #include "../lib/CConfigHandler.h"
 
 
-void Helper::loadSettings()
+#include <QObject>
+#include <QScroller>
+
+namespace Helper
+{
+void loadSettings()
 {
 {
 	settings.init("config/settings.json", "vcmi:settings");
 	settings.init("config/settings.json", "vcmi:settings");
 }
 }
+
+void enableScrollBySwiping(QObject * scrollTarget)
+{
+#ifdef VCMI_MOBILE
+	QScroller::grabGesture(scrollTarget, QScroller::LeftMouseButtonGesture);
+#endif
+}
+}

+ 3 - 0
launcher/helper.h

@@ -9,7 +9,10 @@
  */
  */
 #pragma once
 #pragma once
 
 
+class QObject;
+
 namespace Helper
 namespace Helper
 {
 {
 void loadSettings();
 void loadSettings();
+void enableScrollBySwiping(QObject * scrollTarget);
 }
 }

+ 7 - 3
launcher/modManager/cmodlistview_moc.cpp

@@ -151,13 +151,14 @@ CModListView::CModListView(QWidget * parent)
 	{
 	{
 		manager->resetRepositories();
 		manager->resetRepositories();
 	}
 	}
-	
-#ifdef Q_OS_IOS
+
+#ifdef VCMI_MOBILE
 	for(auto * scrollWidget : {
 	for(auto * scrollWidget : {
 		(QAbstractItemView*)ui->allModsView,
 		(QAbstractItemView*)ui->allModsView,
 		(QAbstractItemView*)ui->screenshotsList})
 		(QAbstractItemView*)ui->screenshotsList})
 	{
 	{
-		QScroller::grabGesture(scrollWidget, QScroller::LeftMouseButtonGesture);
+		Helper::enableScrollBySwiping(scrollWidget);
+
 		scrollWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
 		scrollWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
 		scrollWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 		scrollWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 	}
 	}
@@ -405,6 +406,9 @@ void CModListView::selectMod(const QModelIndex & index)
 		ui->modInfoBrowser->setHtml(genModInfoText(mod));
 		ui->modInfoBrowser->setHtml(genModInfoText(mod));
 		ui->changelogBrowser->setHtml(genChangelogText(mod));
 		ui->changelogBrowser->setHtml(genChangelogText(mod));
 
 
+		Helper::enableScrollBySwiping(ui->modInfoBrowser);
+		Helper::enableScrollBySwiping(ui->changelogBrowser);
+
 		bool hasInvalidDeps = !findInvalidDependencies(modName).empty();
 		bool hasInvalidDeps = !findInvalidDependencies(modName).empty();
 		bool hasBlockingMods = !findBlockingMods(modName).empty();
 		bool hasBlockingMods = !findBlockingMods(modName).empty();
 		bool hasDependentMods = !findDependentMods(modName, true).empty();
 		bool hasDependentMods = !findDependentMods(modName, true).empty();

+ 2 - 0
launcher/settingsView/csettingsview_moc.cpp

@@ -14,6 +14,7 @@
 #include "mainwindow_moc.h"
 #include "mainwindow_moc.h"
 
 
 #include "../modManager/cmodlistview_moc.h"
 #include "../modManager/cmodlistview_moc.h"
+#include "../helper.h"
 #include "../jsonutils.h"
 #include "../jsonutils.h"
 #include "../languages.h"
 #include "../languages.h"
 #include "../launcherdirs.h"
 #include "../launcherdirs.h"
@@ -284,6 +285,7 @@ CSettingsView::CSettingsView(QWidget * parent)
 	: QWidget(parent), ui(new Ui::CSettingsView)
 	: QWidget(parent), ui(new Ui::CSettingsView)
 {
 {
 	ui->setupUi(this);
 	ui->setupUi(this);
+	Helper::enableScrollBySwiping(ui->settingsScrollArea);
 
 
 	loadSettings();
 	loadSettings();
 }
 }