forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.10'
Change-Id: Ic7144b8ae429707cd120719f3445b624c0b83564
This commit is contained in:
@@ -66,6 +66,10 @@
|
|||||||
authentication. If you do not have an SSH key, you can use the ssh-keygen
|
authentication. If you do not have an SSH key, you can use the ssh-keygen
|
||||||
tool to create it in \QC. For more information, see \l {Generating SSH Keys}.
|
tool to create it in \QC. For more information, see \l {Generating SSH Keys}.
|
||||||
|
|
||||||
|
\note \QC does not store passwords, so if you use password authentication,
|
||||||
|
you may need to enter the password on every connection to the device,
|
||||||
|
or, if caching is enabled, at every \QC restart.
|
||||||
|
|
||||||
To configure connections between \QC and an embedded Linux device and to
|
To configure connections between \QC and an embedded Linux device and to
|
||||||
specify build and run settings for the device:
|
specify build and run settings for the device:
|
||||||
|
|
||||||
|
@@ -99,12 +99,14 @@ void TextBrowserHelpViewer::scaleDown()
|
|||||||
|
|
||||||
void TextBrowserHelpViewer::resetScale()
|
void TextBrowserHelpViewer::resetScale()
|
||||||
{
|
{
|
||||||
if (m_textBrowser->zoomCount != 0) {
|
m_textBrowser->withFixedTopPosition([this] {
|
||||||
m_textBrowser->forceFont = true;
|
if (m_textBrowser->zoomCount != 0) {
|
||||||
m_textBrowser->zoomOut(m_textBrowser->zoomCount);
|
m_textBrowser->forceFont = true;
|
||||||
m_textBrowser->forceFont = false;
|
m_textBrowser->zoomOut(m_textBrowser->zoomCount);
|
||||||
}
|
m_textBrowser->forceFont = false;
|
||||||
m_textBrowser->zoomCount = 0;
|
}
|
||||||
|
m_textBrowser->zoomCount = 0;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal TextBrowserHelpViewer::scale() const
|
qreal TextBrowserHelpViewer::scale() const
|
||||||
@@ -114,18 +116,20 @@ qreal TextBrowserHelpViewer::scale() const
|
|||||||
|
|
||||||
void TextBrowserHelpViewer::setScale(qreal scale)
|
void TextBrowserHelpViewer::setScale(qreal scale)
|
||||||
{
|
{
|
||||||
m_textBrowser->forceFont = true;
|
m_textBrowser->withFixedTopPosition([this, &scale] {
|
||||||
if (scale > 10)
|
m_textBrowser->forceFont = true;
|
||||||
scale = 10;
|
if (scale > 10)
|
||||||
else if (scale < -5)
|
scale = 10;
|
||||||
scale = -5;
|
else if (scale < -5)
|
||||||
int diff = int(scale) - m_textBrowser->zoomCount;
|
scale = -5;
|
||||||
if (diff > 0)
|
int diff = int(scale) - m_textBrowser->zoomCount;
|
||||||
m_textBrowser->zoomIn(diff);
|
if (diff > 0)
|
||||||
else if (diff < 0)
|
m_textBrowser->zoomIn(diff);
|
||||||
m_textBrowser->zoomOut(-diff);
|
else if (diff < 0)
|
||||||
m_textBrowser->zoomCount = int(scale);
|
m_textBrowser->zoomOut(-diff);
|
||||||
m_textBrowser->forceFont = false;
|
m_textBrowser->zoomCount = int(scale);
|
||||||
|
m_textBrowser->forceFont = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextBrowserHelpViewer::title() const
|
QString TextBrowserHelpViewer::title() const
|
||||||
@@ -145,13 +149,11 @@ void TextBrowserHelpViewer::setSource(const QUrl &url)
|
|||||||
|
|
||||||
slotLoadStarted();
|
slotLoadStarted();
|
||||||
m_textBrowser->setSource(url);
|
m_textBrowser->setSource(url);
|
||||||
QTimer::singleShot(0, this, [this, url]() {
|
if (!url.fragment().isEmpty())
|
||||||
if (!url.fragment().isEmpty())
|
m_textBrowser->scrollToAnchor(url.fragment());
|
||||||
m_textBrowser->scrollToAnchor(url.fragment());
|
if (QScrollBar *hScrollBar = m_textBrowser->horizontalScrollBar())
|
||||||
if (QScrollBar *hScrollBar = m_textBrowser->horizontalScrollBar())
|
hScrollBar->setValue(0);
|
||||||
hScrollBar->setValue(0);
|
slotLoadFinished();
|
||||||
slotLoadFinished();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBrowserHelpViewer::setHtml(const QString &html)
|
void TextBrowserHelpViewer::setHtml(const QString &html)
|
||||||
@@ -330,24 +332,46 @@ QString TextBrowserHelpWidget::linkAt(const QPoint &pos)
|
|||||||
return anchor;
|
return anchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextBrowserHelpWidget::withFixedTopPosition(const std::function<void()> &action)
|
||||||
|
{
|
||||||
|
const int topTextPosition = cursorForPosition({width() / 2, 0}).position();
|
||||||
|
action();
|
||||||
|
scrollToTextPosition(topTextPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextBrowserHelpWidget::scrollToTextPosition(int position)
|
||||||
|
{
|
||||||
|
QTextCursor tc(document());
|
||||||
|
tc.setPosition(position);
|
||||||
|
const int dy = cursorRect(tc).top();
|
||||||
|
if (verticalScrollBar()) {
|
||||||
|
verticalScrollBar()->setValue(
|
||||||
|
std::min(verticalScrollBar()->value() + dy, verticalScrollBar()->maximum()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TextBrowserHelpWidget::scaleUp()
|
void TextBrowserHelpWidget::scaleUp()
|
||||||
{
|
{
|
||||||
if (zoomCount < 10) {
|
withFixedTopPosition([this] {
|
||||||
zoomCount++;
|
if (zoomCount < 10) {
|
||||||
forceFont = true;
|
zoomCount++;
|
||||||
zoomIn();
|
forceFont = true;
|
||||||
forceFont = false;
|
zoomIn();
|
||||||
}
|
forceFont = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBrowserHelpWidget::scaleDown()
|
void TextBrowserHelpWidget::scaleDown()
|
||||||
{
|
{
|
||||||
if (zoomCount > -5) {
|
withFixedTopPosition([this] {
|
||||||
zoomCount--;
|
if (zoomCount > -5) {
|
||||||
forceFont = true;
|
zoomCount--;
|
||||||
zoomOut();
|
forceFont = true;
|
||||||
forceFont = false;
|
zoomOut();
|
||||||
}
|
forceFont = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextBrowserHelpWidget::contextMenuEvent(QContextMenuEvent *event)
|
void TextBrowserHelpWidget::contextMenuEvent(QContextMenuEvent *event)
|
||||||
@@ -427,6 +451,13 @@ void TextBrowserHelpWidget::mouseReleaseEvent(QMouseEvent *e)
|
|||||||
QTextBrowser::mouseReleaseEvent(e);
|
QTextBrowser::mouseReleaseEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextBrowserHelpWidget::resizeEvent(QResizeEvent *e)
|
||||||
|
{
|
||||||
|
const int topTextPosition = cursorForPosition({width() / 2, 0}).position();
|
||||||
|
QTextBrowser::resizeEvent(e);
|
||||||
|
scrollToTextPosition(topTextPosition);
|
||||||
|
}
|
||||||
|
|
||||||
void TextBrowserHelpWidget::setSource(const QUrl &name)
|
void TextBrowserHelpWidget::setSource(const QUrl &name)
|
||||||
{
|
{
|
||||||
QTextBrowser::setSource(name);
|
QTextBrowser::setSource(name);
|
||||||
|
@@ -94,14 +94,18 @@ public:
|
|||||||
|
|
||||||
void setSource(const QUrl &name) override;
|
void setSource(const QUrl &name) override;
|
||||||
|
|
||||||
|
void withFixedTopPosition(const std::function<void()> &action);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void contextMenuEvent(QContextMenuEvent *event) override;
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
||||||
bool eventFilter(QObject *obj, QEvent *event) override;
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
void mousePressEvent(QMouseEvent *e) override;
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||||
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString linkAt(const QPoint& pos);
|
QString linkAt(const QPoint &pos);
|
||||||
|
void scrollToTextPosition(int position);
|
||||||
|
|
||||||
int zoomCount;
|
int zoomCount;
|
||||||
bool forceFont;
|
bool forceFont;
|
||||||
|
Reference in New Issue
Block a user