ui: Added scroll speed setting to preferences
This commit is contained in:
@@ -7,34 +7,47 @@
|
||||
<!-- COLOR: int int int int - rgba e.g. 125 125 125 255 -->
|
||||
|
||||
<config>
|
||||
<source>
|
||||
<compiler_flags>
|
||||
<compiler_flag><!-- STRING: compiler flag, including the dash e.g. -v --></compiler_flag>
|
||||
</compiler_flags>
|
||||
|
||||
<header_search_paths>
|
||||
<header_search_path><!-- STRING: header search path for each path a header_search_path element --></header_search_path>
|
||||
</header_search_paths>
|
||||
|
||||
<!-- MAC ONLY -->
|
||||
<framework_search_paths>
|
||||
<framework_search_path><!-- STRING: framework search path --></framework_search_path>
|
||||
</framework_search_paths>
|
||||
</source>
|
||||
|
||||
<application>
|
||||
<font_name><!-- STRING: font name --></font_name>
|
||||
<font_size><!-- INTEGER: font size in pt --></font_size>
|
||||
<color_scheme><!-- STRING: color scheme path --></color_scheme>
|
||||
|
||||
<font_size_max><!-- INTEGER: maximum font size in pt --></font_size_max>
|
||||
<font_size_min><!-- INTEGER: minimum font size in pt --></font_size_min>
|
||||
<font_size_std><!-- INTEGER: standard font size in pt --></font_size_std>
|
||||
<indexer_thread_count><!-- INTEGER: number of threads indexing the source code --></indexer_thread_count>
|
||||
|
||||
<show_external_non_fatal_errors><!-- BOOL: show non-fatal errors in unindexed files --></show_external_non_fatal_errors>
|
||||
|
||||
<window_base_width><!-- INTEGER: initial width of an overlay window --></window_base_width>
|
||||
<window_base_height><!-- INTEGER: initial height of an overlay window --></window_base_height>
|
||||
|
||||
<scroll_speed><!-- DECIMAL: multiplier for default scroll speed in views --></scroll_speed>
|
||||
</application>
|
||||
|
||||
<indexing>
|
||||
<indexer_thread_count><!-- INTEGER: number of threads indexing the source code --></indexer_thread_count>
|
||||
|
||||
<cxx>
|
||||
<compiler_flags>
|
||||
<compiler_flag><!-- STRING: compiler flag, including the dash e.g. -v --></compiler_flag>
|
||||
</compiler_flags>
|
||||
|
||||
<header_search_paths>
|
||||
<header_search_path><!-- STRING: header search path for each path a header_search_path element --></header_search_path>
|
||||
</header_search_paths>
|
||||
|
||||
<!-- MAC ONLY -->
|
||||
<framework_search_paths>
|
||||
<framework_search_path><!-- STRING: framework search path --></framework_search_path>
|
||||
</framework_search_paths>
|
||||
</cxx>
|
||||
|
||||
<java>
|
||||
<java_path><!-- STRING: path java installation on Windows e.g. .../java/JDK/jre/bin --></java_path>
|
||||
<java_maximum_memory><!-- INTEGER: memory in MB used by java indexer --></java_maximum_memory>
|
||||
</java>
|
||||
</indexing>
|
||||
|
||||
<code>
|
||||
<tab_width><!-- INTEGER: number of spaces to represent a tab in code files --></tab_width>
|
||||
|
||||
@@ -48,6 +61,7 @@
|
||||
<recent_projects>
|
||||
<recent_project><!-- STRING: recent project path --></recent_project>
|
||||
</recent_projects>
|
||||
|
||||
<license>
|
||||
<check><!-- STRING: hashed path of the working directory used when entering the license key --></check>
|
||||
<license><!-- STRING: the license key --></license>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "utility/messaging/MessageQueue.h"
|
||||
#include "utility/messaging/type/MessageActivateNodes.h"
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageScrollSpeedChange.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/messaging/type/MessageShowStartScreen.h"
|
||||
#include "utility/scheduling/TaskScheduler.h"
|
||||
@@ -72,6 +73,7 @@ void Application::loadSettings()
|
||||
{
|
||||
std::shared_ptr<ApplicationSettings> settings = ApplicationSettings::getInstance();
|
||||
settings->load(FilePath(UserPaths::getAppSettingsPath()));
|
||||
|
||||
loadStyle(settings->getColorSchemePath());
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,16 @@ int ApplicationSettings::getWindowBaseHeight() const
|
||||
return getValue<int>("application/window_base_height", 500);
|
||||
}
|
||||
|
||||
float ApplicationSettings::getScrollSpeed() const
|
||||
{
|
||||
return getValue<float>("application/scroll_speed", 1.0f);
|
||||
}
|
||||
|
||||
void ApplicationSettings::setScrollSpeed(float scrollSpeed)
|
||||
{
|
||||
setValue<float>("application/scroll_speed", scrollSpeed);
|
||||
}
|
||||
|
||||
int ApplicationSettings::getIndexerThreadCount() const
|
||||
{
|
||||
return getValue<int>("indexing/indexer_thread_count", 4);
|
||||
|
||||
@@ -39,6 +39,10 @@ public:
|
||||
int getWindowBaseWidth() const;
|
||||
int getWindowBaseHeight() const;
|
||||
|
||||
float getScrollSpeed() const;
|
||||
void setScrollSpeed(float scrollSpeed);
|
||||
|
||||
// indexing
|
||||
int getIndexerThreadCount() const;
|
||||
void setIndexerThreadCount(const int count);
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef MESSAGE_SCROLL_SPEED_CHANGE_H
|
||||
#define MESSAGE_SCROLL_SPEED_CHANGE_H
|
||||
|
||||
#include "utility/messaging/Message.h"
|
||||
|
||||
class MessageScrollSpeedChange
|
||||
: public Message<MessageScrollSpeedChange>
|
||||
{
|
||||
public:
|
||||
MessageScrollSpeedChange(float scrollSpeed)
|
||||
: scrollSpeed(scrollSpeed)
|
||||
{
|
||||
}
|
||||
|
||||
static const std::string getStaticType()
|
||||
{
|
||||
return "MessageScrollSpeedChange";
|
||||
}
|
||||
|
||||
virtual void print(std::ostream& os) const
|
||||
{
|
||||
os << scrollSpeed;
|
||||
}
|
||||
|
||||
const float scrollSpeed;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_SCROLL_SPEED_CHANGE_H
|
||||
@@ -60,6 +60,8 @@ add_files(
|
||||
qt/utility/QtDeviceScaledPixmap.h
|
||||
qt/utility/QtHighlighter.cpp
|
||||
qt/utility/QtHighlighter.h
|
||||
qt/utility/QtScrollSpeedChangeListener.cpp
|
||||
qt/utility/QtScrollSpeedChangeListener.h
|
||||
qt/utility/QtThreadedFunctor.h
|
||||
qt/utility/utilityQt.cpp
|
||||
qt/utility/utilityQt.h
|
||||
|
||||
@@ -204,6 +204,9 @@ QtAutocompletionList::QtAutocompletionList(QWidget* parent)
|
||||
setModelSorting(QCompleter::UnsortedModel);
|
||||
setCompletionPrefix("");
|
||||
setMaxVisibleItems(20);
|
||||
|
||||
m_scrollSpeedChangeListenerHorizontal.setScrollBar(list->horizontalScrollBar());
|
||||
m_scrollSpeedChangeListenerVertical.setScrollBar(list->verticalScrollBar());
|
||||
}
|
||||
|
||||
QtAutocompletionList::~QtAutocompletionList()
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <QListView>
|
||||
|
||||
#include "data/search/SearchMatch.h"
|
||||
#include "qt/utility/QtScrollSpeedChangeListener.h"
|
||||
|
||||
class QtAutocompletionModel
|
||||
: public QAbstractTableModel
|
||||
@@ -70,6 +71,9 @@ private slots:
|
||||
private:
|
||||
std::shared_ptr<QtAutocompletionModel> m_model;
|
||||
std::shared_ptr<QtAutocompletionDelegate> m_delegate;
|
||||
|
||||
QtScrollSpeedChangeListener m_scrollSpeedChangeListenerHorizontal;
|
||||
QtScrollSpeedChangeListener m_scrollSpeedChangeListenerVertical;
|
||||
};
|
||||
|
||||
#endif // QT_AUTOCOMPLETION_LIST
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "qt/element/QtCodeArea.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <QApplication>
|
||||
#include <QFont>
|
||||
#include <QHBoxLayout>
|
||||
#include <qmenu.h>
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
#include <QPushButton>
|
||||
#include <QScrollBar>
|
||||
#include <QToolTip>
|
||||
#include <qscrollbar.h>
|
||||
|
||||
#include "utility/messaging/type/MessageActivateLocalSymbols.h"
|
||||
#include "utility/messaging/type/MessageActivateTokenLocations.h"
|
||||
@@ -130,6 +130,7 @@ QtCodeArea::QtCodeArea(
|
||||
|
||||
// MouseWheelOverScrollbarFilter is deleted by parent.
|
||||
horizontalScrollBar()->installEventFilter(new MouseWheelOverScrollbarFilter(this));
|
||||
m_scrollSpeedChangeListener.setScrollBar(horizontalScrollBar());
|
||||
|
||||
createActions();
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <QPlainTextEdit>
|
||||
|
||||
#include "data/location/LocationType.h"
|
||||
#include "qt/utility/QtScrollSpeedChangeListener.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
class QDragMoveEvent;
|
||||
@@ -190,6 +191,8 @@ private:
|
||||
|
||||
std::vector<int> m_lineLengths;
|
||||
int m_endTextEditPosition;
|
||||
|
||||
QtScrollSpeedChangeListener m_scrollSpeedChangeListener;
|
||||
};
|
||||
|
||||
#endif // QT_CODE_AREA_H
|
||||
|
||||
@@ -80,6 +80,8 @@ QtCodeNavigator::QtCodeNavigator(QWidget* parent)
|
||||
m_scrollArea->setWidgetResizable(true);
|
||||
m_scrollArea->setWidget(m_list);
|
||||
|
||||
m_scrollSpeedChangeListener.setScrollBar(m_scrollArea->verticalScrollBar());
|
||||
|
||||
connect(m_scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(scrolled(int)));
|
||||
connect(this, SIGNAL(shouldScrollToSnippet(QtCodeSnippet*, uint)),
|
||||
this, SLOT(scrollToSnippet(QtCodeSnippet*, uint)), Qt::QueuedConnection);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QScrollArea>
|
||||
|
||||
#include "qt/element/QtCodeFileList.h"
|
||||
#include "qt/utility/QtScrollSpeedChangeListener.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageCodeReference.h"
|
||||
@@ -125,6 +126,8 @@ private:
|
||||
QtCodeFile* m_scrollToFile;
|
||||
uint m_scrollToLine;
|
||||
Id m_scrollToLocationId;
|
||||
|
||||
QtScrollSpeedChangeListener m_scrollSpeedChangeListener;
|
||||
};
|
||||
|
||||
#endif // QT_CODE_NAVIGATOR_H
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#include "qt/utility/QtScrollSpeedChangeListener.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <QScrollBar>
|
||||
|
||||
#include "settings/ApplicationSettings.h"
|
||||
|
||||
QtScrollSpeedChangeListener::QtScrollSpeedChangeListener()
|
||||
: m_changeScrollSpeedFunctor(std::bind(&QtScrollSpeedChangeListener::doChangeScrollSpeed, this, std::placeholders::_1))
|
||||
, m_scrollBar(nullptr)
|
||||
, m_singleStep(1)
|
||||
{
|
||||
}
|
||||
|
||||
void QtScrollSpeedChangeListener::setScrollBar(QScrollBar* scrollbar)
|
||||
{
|
||||
m_scrollBar = scrollbar;
|
||||
m_singleStep = scrollbar->singleStep();
|
||||
|
||||
doChangeScrollSpeed(ApplicationSettings::getInstance()->getScrollSpeed());
|
||||
}
|
||||
|
||||
void QtScrollSpeedChangeListener::handleMessage(MessageScrollSpeedChange* message)
|
||||
{
|
||||
m_changeScrollSpeedFunctor(message->scrollSpeed);
|
||||
}
|
||||
|
||||
void QtScrollSpeedChangeListener::doChangeScrollSpeed(float scrollSpeed)
|
||||
{
|
||||
if (m_scrollBar)
|
||||
{
|
||||
m_scrollBar->setSingleStep(std::ceil(m_singleStep * scrollSpeed));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef QT_SCROLL_SPEED_CHANGE_LISTENER
|
||||
#define QT_SCROLL_SPEED_CHANGE_LISTENER
|
||||
|
||||
#include "utility/messaging/MessageListener.h"
|
||||
#include "utility/messaging/type/MessageScrollSpeedChange.h"
|
||||
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
|
||||
class QScrollBar;
|
||||
|
||||
class QtScrollSpeedChangeListener
|
||||
: public MessageListener<MessageScrollSpeedChange>
|
||||
{
|
||||
public:
|
||||
QtScrollSpeedChangeListener();
|
||||
|
||||
void setScrollBar(QScrollBar* scrollbar);
|
||||
|
||||
private:
|
||||
void handleMessage(MessageScrollSpeedChange* message);
|
||||
|
||||
void doChangeScrollSpeed(float scrollSpeed);
|
||||
|
||||
QtThreadedFunctor<float> m_changeScrollSpeedFunctor;
|
||||
|
||||
QScrollBar* m_scrollBar;
|
||||
int m_singleStep;
|
||||
};
|
||||
|
||||
#endif // QT_SCROLL_SPEED_CHANGE_LISTENER
|
||||
@@ -13,12 +13,12 @@
|
||||
#include "component/controller/helper/DummyNode.h"
|
||||
#include "component/controller/helper/GraphPostprocessor.h"
|
||||
#include "component/view/GraphViewStyle.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
#include "utility/messaging/type/MessageDeactivateEdge.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
|
||||
#include "qt/utility/utilityQt.h"
|
||||
|
||||
#include "qt/graphics/QtGraphicsView.h"
|
||||
#include "qt/utility/utilityQt.h"
|
||||
#include "qt/view/QtViewWidgetWrapper.h"
|
||||
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponentClickable.h"
|
||||
#include "qt/view/graphElements/nodeComponents/QtGraphNodeComponentMoveable.h"
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "qt/view/graphElements/QtGraphNodeBundle.h"
|
||||
#include "qt/view/graphElements/QtGraphNodeData.h"
|
||||
#include "qt/view/graphElements/QtGraphNodeExpandToggle.h"
|
||||
#include "settings/ColorScheme.h"
|
||||
|
||||
QtGraphView::QtGraphView(ViewLayout* viewLayout)
|
||||
: GraphView(viewLayout)
|
||||
@@ -72,6 +71,9 @@ void QtGraphView::initView()
|
||||
|
||||
connect(view, SIGNAL(emptySpaceClicked()), this, SLOT(clickedInEmptySpace()));
|
||||
|
||||
m_scrollSpeedChangeListenerHorizontal.setScrollBar(view->horizontalScrollBar());
|
||||
m_scrollSpeedChangeListenerVertical.setScrollBar(view->verticalScrollBar());
|
||||
|
||||
doRefreshView();
|
||||
}
|
||||
|
||||
@@ -305,10 +307,12 @@ void QtGraphView::doRefreshView()
|
||||
doClear();
|
||||
doResize();
|
||||
|
||||
std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath() + "graph_view/graph_view.css");
|
||||
getView()->setStyleSheet(css.c_str());
|
||||
QtGraphicsView* view = getView();
|
||||
|
||||
getView()->setAppZoomFactor(GraphViewStyle::getZoomFactor());
|
||||
std::string css = utility::getStyleSheet(ResourcePaths::getGuiPath() + "graph_view/graph_view.css");
|
||||
view->setStyleSheet(css.c_str());
|
||||
|
||||
view->setAppZoomFactor(GraphViewStyle::getZoomFactor());
|
||||
}
|
||||
|
||||
std::shared_ptr<QtGraphNode> QtGraphView::findNodeRecursive(const std::list<std::shared_ptr<QtGraphNode>>& nodes, Id tokenId)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QPointF>
|
||||
|
||||
#include "component/view/GraphView.h"
|
||||
#include "qt/utility/QtScrollSpeedChangeListener.h"
|
||||
#include "qt/utility/QtThreadedFunctor.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
@@ -110,6 +111,9 @@ private:
|
||||
|
||||
std::shared_ptr<QSequentialAnimationGroup> m_transition;
|
||||
QPointF m_sceneRectOffset;
|
||||
|
||||
QtScrollSpeedChangeListener m_scrollSpeedChangeListenerHorizontal;
|
||||
QtScrollSpeedChangeListener m_scrollSpeedChangeListenerVertical;
|
||||
};
|
||||
|
||||
#endif // QT_GRAPH_VIEW_H
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <QSysInfo>
|
||||
#include <QTimer>
|
||||
|
||||
#include "Application.h"
|
||||
#include "component/view/View.h"
|
||||
#include "component/view/CompositeView.h"
|
||||
#include "qt/utility/QtContextMenu.h"
|
||||
@@ -21,7 +22,6 @@
|
||||
#include "qt/window/QtAbout.h"
|
||||
#include "qt/window/QtLicense.h"
|
||||
#include "settings/ApplicationSettings.h"
|
||||
#include "Application.h"
|
||||
#include "utility/file/FileSystem.h"
|
||||
#include "utility/logging/logging.h"
|
||||
#include "utility/messaging/type/MessageCodeReference.h"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "utility/messaging/type/MessageDispatchWhenLicenseValid.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageRefresh.h"
|
||||
#include "utility/messaging/type/MessageScrollSpeedChange.h"
|
||||
#include "utility/messaging/type/MessageStatus.h"
|
||||
#include "utility/solution/SolutionParserVisualStudio.h"
|
||||
#include "utility/utilityString.h"
|
||||
@@ -37,9 +38,11 @@ QtProjectWizzard::QtProjectWizzard(QWidget* parent)
|
||||
connect(&m_windowStack, SIGNAL(push()), this, SLOT(windowStackChanged()));
|
||||
connect(&m_windowStack, SIGNAL(pop()), this, SLOT(windowStackChanged()));
|
||||
|
||||
// save old application settings so they can be compared later
|
||||
ApplicationSettings* appSettings = ApplicationSettings::getInstance().get();
|
||||
m_appSettings.setHeaderSearchPaths(appSettings->getHeaderSearchPaths());
|
||||
m_appSettings.setFrameworkSearchPaths(appSettings->getFrameworkSearchPaths());
|
||||
m_appSettings.setScrollSpeed(appSettings->getScrollSpeed());
|
||||
|
||||
m_parserManager = std::make_shared<SolutionParserManager>();
|
||||
|
||||
@@ -699,6 +702,11 @@ void QtProjectWizzard::savePreferences()
|
||||
{
|
||||
bool appSettingsChanged = !(m_appSettings == *ApplicationSettings::getInstance().get());
|
||||
|
||||
if (m_appSettings.getScrollSpeed() != ApplicationSettings::getInstance()->getScrollSpeed())
|
||||
{
|
||||
MessageScrollSpeedChange(ApplicationSettings::getInstance()->getScrollSpeed()).dispatch();
|
||||
}
|
||||
|
||||
if (appSettingsChanged)
|
||||
{
|
||||
Project* currentProject = Application::getInstance()->getCurrentProject().get();
|
||||
|
||||
@@ -84,8 +84,21 @@ void QtProjectWizzardContentPreferences::populateForm(QGridLayout* layout, int&
|
||||
layout->addWidget(m_colorSchemes, row, QtProjectWizzardWindow::BACK_COL, Qt::AlignLeft);
|
||||
row++;
|
||||
|
||||
layout->setRowMinimumHeight(row++, 20);
|
||||
// scroll speed
|
||||
m_scrollSpeed = new QLineEdit();
|
||||
m_scrollSpeed->setObjectName("name");
|
||||
m_scrollSpeed->setAttribute(Qt::WA_MacShowFocusRect, 0);
|
||||
|
||||
layout->addWidget(createFormLabel("Scroll Speed"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignRight);
|
||||
layout->addWidget(m_scrollSpeed, row, QtProjectWizzardWindow::BACK_COL);
|
||||
|
||||
addHelpButton(
|
||||
"Multiplier for scroll speed. Set to a value between 0 and 1 to scroll slower, or set to larger than 1 to scroll faster."
|
||||
, layout, row
|
||||
);
|
||||
row++;
|
||||
|
||||
layout->setRowMinimumHeight(row++, 20);
|
||||
|
||||
// indexing
|
||||
layout->addWidget(createFormTitle("INDEXING"), row, QtProjectWizzardWindow::FRONT_COL, Qt::AlignLeft);
|
||||
@@ -142,6 +155,8 @@ void QtProjectWizzardContentPreferences::load()
|
||||
}
|
||||
}
|
||||
|
||||
m_scrollSpeed->setText(QString::number(appSettings->getScrollSpeed(), 'f', 1));
|
||||
|
||||
m_threads->setCurrentIndex(appSettings->getIndexerThreadCount() - 1);
|
||||
m_fatalErrors->setChecked(appSettings->getShowExternalNonFatalErrors());
|
||||
}
|
||||
@@ -158,6 +173,12 @@ void QtProjectWizzardContentPreferences::save()
|
||||
appSettings->setColorSchemePath(m_colorSchemePaths[m_colorSchemes->currentIndex()]);
|
||||
m_oldColorSchemeIndex = -1;
|
||||
|
||||
float scrollSpeed = m_scrollSpeed->text().toFloat();
|
||||
if (scrollSpeed)
|
||||
{
|
||||
appSettings->setScrollSpeed(scrollSpeed);
|
||||
}
|
||||
|
||||
appSettings->setIndexerThreadCount(m_threads->currentIndex() + 1);
|
||||
appSettings->setShowExternalNonFatalErrors(m_fatalErrors->isChecked());
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ private:
|
||||
QComboBox* m_fontSize;
|
||||
QComboBox* m_tabWidth;
|
||||
QComboBox* m_colorSchemes;
|
||||
QLineEdit* m_scrollSpeed;
|
||||
|
||||
QComboBox* m_threads;
|
||||
QCheckBox* m_fatalErrors;
|
||||
|
||||
Reference in New Issue
Block a user