forked from qt-creator/qt-creator
Merge commit 'origin/1.2'
This commit is contained in:
11
dist/changes-1.2.0
vendored
11
dist/changes-1.2.0
vendored
@@ -22,8 +22,15 @@ Editing
|
||||
* Further improvements to FakeVim mode
|
||||
* Make it possible to disable Ctrl+Click navigation
|
||||
* Added optional XCode-style tab indentation
|
||||
* Ui changes are added immediately to the code model
|
||||
* Fixed possibly missing code completion with mingw toolchain
|
||||
* Added option for turning antialiasing of text editor fonts off
|
||||
* Added searching with regular expressions in text editors
|
||||
|
||||
Building and Running
|
||||
* New options: Auto-Save before Build and Run without building
|
||||
* Environment settings
|
||||
* Fixed bug that prevented use of Qt 4 with version < 4.2
|
||||
|
||||
Debugging
|
||||
* Added Windows Console Debugger support (x86 and AMD64)
|
||||
@@ -32,6 +39,7 @@ Debugging
|
||||
avoid crashes for speedup
|
||||
* Changed method of dumper loading on Windows, enabling it for MinGW 64
|
||||
* Make it possible to disable breakpoints
|
||||
* Make it possible to float the debugger views
|
||||
|
||||
Wizards
|
||||
|
||||
@@ -66,7 +74,8 @@ Other Unixes
|
||||
|
||||
Additional credits go to:
|
||||
* axasia <axasia@gmail.com> (japanese translation)
|
||||
* Christian Hoenig <christian@hoenig.cc> ("Build Project Only" submenu and build project dependencies, various patches)
|
||||
* Christian Hoenig <christian@hoenig.cc> ("Build Project Only" submenu and
|
||||
build project dependencies, various patches)
|
||||
* Enrico Ros <enrico.ros@gmail.com> (italian translation)
|
||||
* Joel Nordell <joel.nordell@chloridepower.com> (XCode-style tab behavior, various patches)
|
||||
* Serge Ratke <dev.serge.ratke@gmx.de> (copy lines up/down by Ctrl+Alt+Up/Down)
|
||||
|
||||
@@ -165,6 +165,10 @@ struct EditorManagerPrivate {
|
||||
|
||||
QList<IEditor *> m_editorHistory;
|
||||
QList<EditLocation *> m_navigationHistory;
|
||||
void clearNavigationHistory() {
|
||||
qDeleteAll(m_navigationHistory);
|
||||
m_navigationHistory.clear();
|
||||
}
|
||||
int currentNavigationHistoryPosition;
|
||||
Internal::OpenEditorsWindow *m_windowPopup;
|
||||
Core::BaseView *m_openEditorsView;
|
||||
@@ -205,8 +209,7 @@ EditorManagerPrivate::EditorManagerPrivate(ICore *core, QWidget *parent) :
|
||||
|
||||
EditorManagerPrivate::~EditorManagerPrivate()
|
||||
{
|
||||
qDeleteAll(m_navigationHistory);
|
||||
m_navigationHistory.clear();
|
||||
clearNavigationHistory();
|
||||
}
|
||||
|
||||
EditorManager *EditorManager::m_instance = 0;
|
||||
@@ -654,7 +657,11 @@ QList<IFile *> EditorManager::filesForEditors(QList<IEditor *> editors) const
|
||||
bool EditorManager::closeAllEditors(bool askAboutModifiedEditors)
|
||||
{
|
||||
m_d->m_editorModel->removeAllRestoredEditors();
|
||||
return closeEditors(openedEditors(), askAboutModifiedEditors);
|
||||
if (closeEditors(openedEditors(), askAboutModifiedEditors)) {
|
||||
m_d->clearNavigationHistory();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditorManager::closeOtherEditors()
|
||||
|
||||
@@ -124,7 +124,7 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
||||
p.setPen(QColor(255, 255, 255, 70));
|
||||
p.drawLine(0, 1, size().width(), 1);
|
||||
|
||||
QRect textRect = rect();
|
||||
QRect textRect = rect().adjusted(0, 0, -1, 0);
|
||||
textRect.setHeight(h+5);
|
||||
|
||||
p.setPen(QColor(30, 30, 30, 80));
|
||||
@@ -149,9 +149,8 @@ void ProgressBar::paintEvent(QPaintEvent *)
|
||||
QRect inner = rect.adjusted(2, 2, -1, -1);
|
||||
inner.adjust(0, 0, qRound((percent - 1) * inner.width()), 0);
|
||||
if (m_error) {
|
||||
// TODO this is not fancy enough
|
||||
QColor red(255, 0, 0, 180);
|
||||
p.setBrush(red);
|
||||
QColor red(255, 60, 0, 210);
|
||||
c = red;
|
||||
// avoid too small red bar
|
||||
if (inner.width() < 10)
|
||||
inner.adjust(0, 0, 10 - inner.width(), 0);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtSql/QSqlDatabase>
|
||||
#include <QtSql/QSqlError>
|
||||
#include <QtSql/QSqlQuery>
|
||||
#include <QDebug>
|
||||
|
||||
@@ -101,16 +102,18 @@ SettingsDatabase::SettingsDatabase(const QString &path,
|
||||
|
||||
d->m_db = QSqlDatabase::addDatabase("QSQLITE", QLatin1String("settings"));
|
||||
d->m_db.setDatabaseName(fileName);
|
||||
if (!d->m_db.open())
|
||||
qWarning() << "Warning: Failed to open settings database!";
|
||||
|
||||
if (!d->m_db.open()) {
|
||||
qWarning().nospace() << "Warning: Failed to open settings database at " << fileName << " ("
|
||||
<< d->m_db.lastError().driverText() << ")";
|
||||
} else {
|
||||
// Create the settings table if it doesn't exist yet
|
||||
QSqlQuery query(d->m_db);
|
||||
query.prepare(QLatin1String("CREATE TABLE IF NOT EXISTS settings ("
|
||||
"key PRIMARY KEY ON CONFLICT REPLACE, "
|
||||
"value)"));
|
||||
if (d->m_db.isOpen() && !query.exec())
|
||||
qWarning() << "Warning: Failed to prepare settings database!";
|
||||
if (!query.exec())
|
||||
qWarning().nospace() << "Warning: Failed to prepare settings database! ("
|
||||
<< query.lastError().driverText() << ")";
|
||||
|
||||
// Retrieve all available keys (values are retrieved lazily)
|
||||
if (query.exec(QLatin1String("SELECT key FROM settings"))) {
|
||||
@@ -119,6 +122,7 @@ SettingsDatabase::SettingsDatabase(const QString &path,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SettingsDatabase::~SettingsDatabase()
|
||||
{
|
||||
@@ -135,6 +139,9 @@ void SettingsDatabase::setValue(const QString &key, const QVariant &value)
|
||||
// Add to cache
|
||||
d->m_settings.insert(effectiveKey, value);
|
||||
|
||||
if (!d->m_db.isOpen())
|
||||
return;
|
||||
|
||||
// Instant apply (TODO: Delay writing out settings)
|
||||
QSqlQuery query(d->m_db);
|
||||
query.prepare(QLatin1String("INSERT INTO settings VALUES (?, ?)"));
|
||||
@@ -154,7 +161,7 @@ QVariant SettingsDatabase::value(const QString &key, const QVariant &defaultValu
|
||||
SettingsMap::const_iterator i = d->m_settings.constFind(effectiveKey);
|
||||
if (i != d->m_settings.constEnd() && i.value().isValid()) {
|
||||
value = i.value();
|
||||
} else {
|
||||
} else if (d->m_db.isOpen()) {
|
||||
// Try to read the value from the database
|
||||
QSqlQuery query(d->m_db);
|
||||
query.prepare(QLatin1String("SELECT value FROM settings WHERE key = ?"));
|
||||
@@ -183,13 +190,6 @@ void SettingsDatabase::remove(const QString &key)
|
||||
{
|
||||
const QString effectiveKey = d->effectiveKey(key);
|
||||
|
||||
// Delete keys from the database
|
||||
QSqlQuery query(d->m_db);
|
||||
query.prepare(QLatin1String("DELETE FROM settings WHERE key = ? OR key LIKE ?"));
|
||||
query.addBindValue(effectiveKey);
|
||||
query.addBindValue(effectiveKey + QLatin1String("/%"));
|
||||
query.exec();
|
||||
|
||||
// Remove keys from the cache
|
||||
foreach (const QString &k, d->m_settings.keys()) {
|
||||
// Either it's an exact match, or it matches up to a /
|
||||
@@ -200,6 +200,16 @@ void SettingsDatabase::remove(const QString &key)
|
||||
d->m_settings.remove(k);
|
||||
}
|
||||
}
|
||||
|
||||
if (!d->m_db.isOpen())
|
||||
return;
|
||||
|
||||
// Delete keys from the database
|
||||
QSqlQuery query(d->m_db);
|
||||
query.prepare(QLatin1String("DELETE FROM settings WHERE key = ? OR key LIKE ?"));
|
||||
query.addBindValue(effectiveKey);
|
||||
query.addBindValue(effectiveKey + QLatin1String("/%"));
|
||||
query.exec();
|
||||
}
|
||||
|
||||
void SettingsDatabase::beginGroup(const QString &prefix)
|
||||
|
||||
@@ -48,6 +48,16 @@ static int range(float x, int min, int max)
|
||||
}
|
||||
*/
|
||||
|
||||
QColor StyleHelper::mergedColors(const QColor &colorA, const QColor &colorB, int factor)
|
||||
{
|
||||
const int maxFactor = 100;
|
||||
QColor tmp = colorA;
|
||||
tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
|
||||
tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
|
||||
tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
qreal StyleHelper::sidebarFontSize()
|
||||
{
|
||||
#if defined(Q_WS_MAC)
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
static QColor shadowColor();
|
||||
static QColor borderColor();
|
||||
static QColor buttonTextColor() { return QColor(0x4c4c4c); }
|
||||
static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50);
|
||||
|
||||
// Sets the base color and makes sure all top level widgets are updated
|
||||
static void setBaseColor(const QColor &color);
|
||||
|
||||
@@ -104,9 +104,14 @@ QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &orig
|
||||
foreach (ModelItemInfo info, items) {
|
||||
if ((hasWildcard && regexp.exactMatch(info.symbolName))
|
||||
|| (!hasWildcard && matcher.indexIn(info.symbolName) != -1)) {
|
||||
|
||||
QVariant id = qVariantFromValue(info);
|
||||
QuickOpen::FilterEntry filterEntry(this, info.symbolName, id, info.icon);
|
||||
if (! info.symbolType.isEmpty())
|
||||
filterEntry.extraInfo = info.symbolType;
|
||||
else
|
||||
filterEntry.extraInfo = info.fileName;
|
||||
|
||||
if (info.symbolName.startsWith(entry))
|
||||
betterEntries.append(filterEntry);
|
||||
else
|
||||
|
||||
@@ -638,6 +638,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
||||
int endLine = lineForPosition(position());
|
||||
setPosition(qMin(anchor(), position()));
|
||||
enterExMode();
|
||||
m_currentMessage.clear();
|
||||
m_commandBuffer = QString(".,+%1!").arg(qAbs(endLine - beginLine));
|
||||
m_commandHistory.append(QString());
|
||||
m_commandHistoryIndex = m_commandHistory.size() - 1;
|
||||
@@ -766,7 +767,6 @@ void FakeVimHandler::Private::updateMiniBuffer()
|
||||
msg = "-- PASSING -- ";
|
||||
} else if (!m_currentMessage.isEmpty()) {
|
||||
msg = m_currentMessage;
|
||||
m_currentMessage.clear();
|
||||
} else if (m_mode == CommandMode && m_visualMode != NoVisualMode) {
|
||||
if (m_visualMode == VisualCharMode) {
|
||||
msg = "-- VISUAL --";
|
||||
@@ -991,6 +991,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
||||
finishMovement();
|
||||
} else if (key == ':') {
|
||||
enterExMode();
|
||||
m_currentMessage.clear();
|
||||
m_commandBuffer.clear();
|
||||
if (m_visualMode != NoVisualMode)
|
||||
m_commandBuffer = "'<,'>";
|
||||
@@ -1005,6 +1006,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
||||
// FIXME: make core find dialog sufficiently flexible to
|
||||
// produce the "default vi" behaviour too. For now, roll our own.
|
||||
enterExMode(); // to get the cursor disabled
|
||||
m_currentMessage.clear();
|
||||
m_mode = (key == '/') ? SearchForwardMode : SearchBackwardMode;
|
||||
m_commandBuffer.clear();
|
||||
m_searchHistory.append(QString());
|
||||
@@ -1033,6 +1035,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
||||
m_submode = FilterSubMode;
|
||||
} else if (key == '!' && m_visualMode != NoVisualMode) {
|
||||
enterExMode();
|
||||
m_currentMessage.clear();
|
||||
m_commandBuffer = "'<,'>!";
|
||||
m_commandHistory.append(QString());
|
||||
m_commandHistoryIndex = m_commandHistory.size() - 1;
|
||||
@@ -1971,6 +1974,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
|
||||
enterCommandMode();
|
||||
updateMiniBuffer();
|
||||
} else {
|
||||
enterCommandMode();
|
||||
showRedMessage(tr("E492: Not an editor command: ") + cmd0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -854,6 +854,13 @@ void ProjectExplorerPlugin::showSessionManager()
|
||||
sessionDialog.exec();
|
||||
|
||||
updateActions();
|
||||
|
||||
Core::ModeManager *modeManager = Core::ModeManager::instance();
|
||||
Core::IMode *welcomeMode = modeManager->mode(Core::Constants::MODE_WELCOME);
|
||||
if (modeManager->currentMode() == welcomeMode)
|
||||
{
|
||||
updateWelcomePage(qobject_cast<Core::Internal::WelcomeMode*>(welcomeMode));
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectExplorerPlugin::setStartupProject(Project *project)
|
||||
|
||||
@@ -139,15 +139,13 @@ void SessionDialog::updateActions()
|
||||
|
||||
if (m_ui.sessionList->currentItem())
|
||||
enableDelete = (m_ui.sessionList->currentItem()->text() != m_sessionManager->activeSession()
|
||||
&& m_ui.sessionList->currentItem()->text() != "default");
|
||||
&& (m_ui.sessionList->currentItem()->text() != QLatin1String("default")));
|
||||
m_ui.btDelete->setEnabled(enableDelete);
|
||||
}
|
||||
|
||||
void SessionDialog::accept()
|
||||
{
|
||||
if (m_ui.sessionList->currentItem()) {
|
||||
m_sessionManager->loadSession(m_ui.sessionList->currentItem()->text());
|
||||
}
|
||||
// do nothing
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,17 +14,10 @@
|
||||
<string>Session Manager</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Choose your session</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QListWidget" name="sessionList"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="0" column="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btCreateNew">
|
||||
@@ -62,14 +55,14 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="whatsASessionLabel">
|
||||
<property name="text">
|
||||
<string><a href="qthelp://com.nokia.qtcreator/doc/creator-quick-tour.html#session-management-in-qt-creator">What is a Session?</a></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
|
||||
@@ -385,8 +385,7 @@ QtVersion::QtVersion(const QString &name, const QString &path)
|
||||
|
||||
QtVersion::~QtVersion()
|
||||
{
|
||||
delete m_toolChain;
|
||||
m_toolChain = 0;
|
||||
|
||||
}
|
||||
|
||||
QString QtVersion::name() const
|
||||
@@ -853,7 +852,7 @@ void QtVersion::updateQMakeCXX() const
|
||||
ProjectExplorer::ToolChain *QtVersion::toolChain() const
|
||||
{
|
||||
updateToolChain();
|
||||
return m_toolChain;
|
||||
return m_toolChain.data();
|
||||
}
|
||||
|
||||
void QtVersion::updateToolChain() const
|
||||
@@ -893,11 +892,10 @@ void QtVersion::updateToolChain() const
|
||||
qDebug()<<"Qt Creator doesn't know about the system includes, nor the systems defines.";
|
||||
}
|
||||
|
||||
if (ProjectExplorer::ToolChain::equals(m_test, m_toolChain)) {
|
||||
if (ProjectExplorer::ToolChain::equals(m_test, m_toolChain.data())) {
|
||||
delete m_test;
|
||||
} else {
|
||||
delete m_toolChain;
|
||||
m_toolChain = m_test;
|
||||
m_toolChain = QSharedPointer<ProjectExplorer::ToolChain>(m_test);
|
||||
}
|
||||
|
||||
m_toolChainUpToDate = true;
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <projectexplorer/environment.h>
|
||||
#include <projectexplorer/toolchain.h>
|
||||
|
||||
#include <QtCore/QSharedPointer>
|
||||
#include <QtCore/QHash>
|
||||
|
||||
namespace Qt4ProjectManager {
|
||||
@@ -154,7 +155,7 @@ private:
|
||||
mutable QString m_qmakeCXX;
|
||||
|
||||
mutable bool m_toolChainUpToDate;
|
||||
mutable ProjectExplorer::ToolChain *m_toolChain;
|
||||
mutable QSharedPointer<ProjectExplorer::ToolChain> m_toolChain;
|
||||
};
|
||||
|
||||
class QtVersionManager : public QObject
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/manhattanstyle.h>
|
||||
#include <coreplugin/stylehelper.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <find/basetextfind.h>
|
||||
#include <texteditor/fontsettings.h>
|
||||
@@ -233,6 +234,12 @@ void BaseTextEditor::print(QPrinter *printer)
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
static int collapseBoxWidth(const QFontMetrics &fm)
|
||||
{
|
||||
const int lineSpacing = fm.lineSpacing();
|
||||
return lineSpacing + lineSpacing%2 + 1;
|
||||
}
|
||||
|
||||
static void printPage(int index, QPainter *painter, const QTextDocument *doc,
|
||||
const QRectF &body, const QRectF &titleBox,
|
||||
const QString &title)
|
||||
@@ -1566,10 +1573,10 @@ QRect BaseTextEditor::collapseBox()
|
||||
return QRect();
|
||||
QRectF br = blockBoundingGeometry(begin).translated(contentOffset());
|
||||
QRectF er = blockBoundingGeometry(end).translated(contentOffset());
|
||||
int collapseBoxWidth = fontMetrics().lineSpacing() + 1;
|
||||
return QRect(d->m_extraArea->width() - collapseBoxWidth,
|
||||
|
||||
return QRect(d->m_extraArea->width() - collapseBoxWidth(fontMetrics()),
|
||||
int(br.top()),
|
||||
collapseBoxWidth,
|
||||
collapseBoxWidth(fontMetrics()),
|
||||
er.bottom() - br.top());
|
||||
}
|
||||
|
||||
@@ -2240,7 +2247,7 @@ int BaseTextEditor::extraAreaWidth(int *markWidthPtr) const
|
||||
space += 4;
|
||||
|
||||
if (d->m_codeFoldingVisible)
|
||||
space += fm.lineSpacing();
|
||||
space += collapseBoxWidth(fm);
|
||||
return space;
|
||||
}
|
||||
|
||||
@@ -2260,13 +2267,11 @@ static void drawRectBox(QPainter *painter, const QRect &rect, bool start, bool e
|
||||
|
||||
QRgb b = pal.base().color().rgb();
|
||||
QRgb h = pal.highlight().color().rgb();
|
||||
QColor c = QColor((qRed(b)*2+qRed(h))/3,
|
||||
(qGreen(b)*2+qGreen(h))/3,
|
||||
(qBlue(b)*2+qBlue(h))/3);
|
||||
QColor c = StyleHelper::mergedColors(b,h, 50);
|
||||
|
||||
QLinearGradient grad(rect.topLeft(), rect.topRight());
|
||||
grad.setColorAt(0, c.lighter(110));
|
||||
grad.setColorAt(1, c.lighter(160));
|
||||
grad.setColorAt(1, c.lighter(130));
|
||||
QColor outline = c;
|
||||
QRect r = rect;
|
||||
|
||||
@@ -2305,8 +2310,7 @@ void BaseTextEditor::extraAreaPaintEvent(QPaintEvent *e)
|
||||
// if (documentLayout->doubleMarkCount)
|
||||
// markWidth += fm.lineSpacing() / 3;
|
||||
|
||||
const int collapseBoxWidth = d->m_codeFoldingVisible ? fmLineSpacing + 1: 0;
|
||||
const int extraAreaWidth = d->m_extraArea->width() - collapseBoxWidth;
|
||||
const int extraAreaWidth = d->m_extraArea->width() - collapseBoxWidth(fm);
|
||||
|
||||
painter.fillRect(e->rect(), pal.color(QPalette::Base));
|
||||
painter.fillRect(e->rect().intersected(QRect(0, 0, extraAreaWidth, INT_MAX)),
|
||||
@@ -2414,15 +2418,18 @@ void BaseTextEditor::extraAreaPaintEvent(QPaintEvent *e)
|
||||
bool hovered = blockNumber >= extraAreaHighlightCollapseBlockNumber
|
||||
&& blockNumber <= extraAreaHighlightCollapseEndBlockNumber;
|
||||
|
||||
int boxWidth = collapseBoxWidth(fm);
|
||||
if (hovered) {
|
||||
QRect box = QRect(extraAreaWidth + 1, top, collapseBoxWidth - 2, collapseBoxWidth);
|
||||
QRect box = QRect(extraAreaWidth + 1, top, boxWidth - 2, fmLineSpacing + 2);
|
||||
drawRectBox(&painter, box, drawStart, drawEnd, pal);
|
||||
}
|
||||
|
||||
if (drawBox) {
|
||||
bool expanded = nextBlock.isVisible();
|
||||
QRect box(extraAreaWidth + collapseBoxWidth/4, top + collapseBoxWidth/4,
|
||||
2 * (collapseBoxWidth/4) + 1, 2 * (collapseBoxWidth/4) + 1);
|
||||
int margin = 2;
|
||||
int size = boxWidth/4;
|
||||
QRect box(extraAreaWidth + size, top + size,
|
||||
2 * (size) + 1, 2 * (size) + 1);
|
||||
drawFoldingMarker(&painter, pal, box, expanded, active, hovered);
|
||||
}
|
||||
}
|
||||
@@ -2473,32 +2480,38 @@ void BaseTextEditor::drawFoldingMarker(QPainter *painter, const QPalette &pal,
|
||||
bool active,
|
||||
bool hovered) const
|
||||
{
|
||||
QStyleOptionViewItemV2 opt;
|
||||
opt.rect = rect;
|
||||
opt.state = QStyle::State_Active | QStyle::State_Item | QStyle::State_Children;
|
||||
Q_UNUSED(active);
|
||||
Q_UNUSED(hovered);
|
||||
|
||||
if (expanded)
|
||||
opt.state |= QStyle::State_Open;
|
||||
painter->save();
|
||||
painter->setPen(Qt::NoPen);
|
||||
|
||||
if (active)
|
||||
opt.state |= QStyle::State_MouseOver | QStyle::State_Enabled | QStyle::State_Selected;
|
||||
int size = rect.size().width();
|
||||
int sqsize = 2*(size/2);
|
||||
|
||||
if (hovered)
|
||||
opt.palette.setBrush(QPalette::Window, pal.highlight());
|
||||
QColor textColor = pal.buttonText().color();
|
||||
QColor brushColor = textColor;
|
||||
|
||||
QStyle *s = style();
|
||||
textColor.setAlpha(100);
|
||||
brushColor.setAlpha(40);
|
||||
|
||||
if (ManhattanStyle *ms = qobject_cast<ManhattanStyle*>(s))
|
||||
s = ms->systemStyle();
|
||||
QPolygon a;
|
||||
if (expanded) {
|
||||
// down arrow
|
||||
a.setPoints(3, 0, sqsize/3, sqsize/2, sqsize - sqsize/3, sqsize, sqsize/3);
|
||||
} else {
|
||||
// right arrow
|
||||
a.setPoints(3, sqsize - sqsize/3, sqsize/2, sqsize/2 - sqsize/3, 0, sqsize/2 - sqsize/3, sqsize);
|
||||
painter->setBrush(brushColor);
|
||||
}
|
||||
painter->translate(0.5, 0.5);
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->translate(rect.topLeft());
|
||||
|
||||
// QGtkStyle needs a small correction to draw the marker in the right place
|
||||
if (qstrcmp(s->metaObject()->className(), "QGtkStyle") == 0)
|
||||
opt.rect.translate(-2, 0);
|
||||
else if (qstrcmp(s->metaObject()->className(), "QMacStyle") == 0)
|
||||
opt.rect.translate(-1, 0);
|
||||
|
||||
s->drawPrimitive(QStyle::PE_IndicatorBranch, &opt, painter, this);
|
||||
painter->setPen(textColor);
|
||||
|
||||
painter->drawPolygon(a);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void BaseTextEditor::slotModificationChanged(bool m)
|
||||
@@ -2712,8 +2725,7 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
|
||||
d->extraAreaHighlightCollapseBlockNumber = -1;
|
||||
d->extraAreaHighlightCollapseColumn = -1;
|
||||
|
||||
int collapseBoxWidth = fontMetrics().lineSpacing() + 1;
|
||||
if (e->pos().x() > extraArea()->width() - collapseBoxWidth) {
|
||||
if (e->pos().x() > extraArea()->width() - collapseBoxWidth(fontMetrics())) {
|
||||
d->extraAreaHighlightCollapseBlockNumber = cursor.blockNumber();
|
||||
if (TextBlockUserData::canCollapse(cursor.block())
|
||||
|| !TextBlockUserData::hasClosingCollapse(cursor.block()))
|
||||
@@ -2739,8 +2751,8 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
|
||||
|
||||
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) {
|
||||
if (e->button() == Qt::LeftButton) {
|
||||
int collapseBoxWidth = fontMetrics().lineSpacing() + 1;
|
||||
if (d->m_codeFoldingVisible && e->pos().x() > extraArea()->width() - collapseBoxWidth) {
|
||||
int boxWidth = collapseBoxWidth(fontMetrics());
|
||||
if (d->m_codeFoldingVisible && e->pos().x() > extraArea()->width() - boxWidth) {
|
||||
if (!cursor.block().next().isVisible()) {
|
||||
toggleBlockVisible(cursor.block());
|
||||
d->moveCursorVisible(false);
|
||||
|
||||
@@ -102,6 +102,7 @@ class VCSBaseDiffEditorEditable : public VCSBaseEditorEditable
|
||||
{
|
||||
public:
|
||||
VCSBaseDiffEditorEditable(VCSBaseEditor *, const VCSBaseEditorParameters *type);
|
||||
~VCSBaseDiffEditorEditable();
|
||||
|
||||
virtual QToolBar *toolBar() { return m_toolBar; }
|
||||
QComboBox *diffFileBrowseComboBox() const { return m_diffFileBrowseComboBox; }
|
||||
@@ -109,14 +110,14 @@ public:
|
||||
bool isTemporary() const { return true; }
|
||||
|
||||
private:
|
||||
QComboBox *m_diffFileBrowseComboBox;
|
||||
QToolBar *m_toolBar;
|
||||
QComboBox *m_diffFileBrowseComboBox;
|
||||
};
|
||||
|
||||
VCSBaseDiffEditorEditable::VCSBaseDiffEditorEditable(VCSBaseEditor *e, const VCSBaseEditorParameters *type) :
|
||||
VCSBaseEditorEditable(e, type),
|
||||
m_diffFileBrowseComboBox(new QComboBox),
|
||||
m_toolBar(new QToolBar)
|
||||
m_toolBar(new QToolBar),
|
||||
m_diffFileBrowseComboBox(new QComboBox(m_toolBar))
|
||||
{
|
||||
m_diffFileBrowseComboBox->setMinimumContentsLength(20);
|
||||
m_diffFileBrowseComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
||||
@@ -127,6 +128,11 @@ VCSBaseDiffEditorEditable::VCSBaseDiffEditorEditable(VCSBaseEditor *e, const VCS
|
||||
m_toolBar->addWidget(m_diffFileBrowseComboBox);
|
||||
}
|
||||
|
||||
VCSBaseDiffEditorEditable::~VCSBaseDiffEditorEditable()
|
||||
{
|
||||
delete m_toolBar;
|
||||
}
|
||||
|
||||
// ----------- VCSBaseEditorPrivate
|
||||
|
||||
struct VCSBaseEditorPrivate
|
||||
|
||||
@@ -429,6 +429,8 @@ void BookmarkWidget::setup(bool showButtons)
|
||||
vlayout->addWidget(label);
|
||||
|
||||
searchField = new QLineEdit(this);
|
||||
setFocusProxy(searchField);
|
||||
searchField->installEventFilter(this);
|
||||
vlayout->addWidget(searchField);
|
||||
connect(searchField, SIGNAL(textChanged(const QString &)), this,
|
||||
SLOT(filterChanged()));
|
||||
@@ -509,19 +511,6 @@ void BookmarkWidget::expandItems()
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarkWidget::focusInEvent(QFocusEvent *e)
|
||||
{
|
||||
if (e->reason() != Qt::MouseFocusReason) {
|
||||
searchField->selectAll();
|
||||
searchField->setFocus();
|
||||
|
||||
QModelIndex index = treeView->indexAt(QPoint(1, 1));
|
||||
if (index.isValid())
|
||||
treeView->setCurrentIndex(index);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
bool BookmarkWidget::eventFilter(QObject *object, QEvent *e)
|
||||
{
|
||||
if ((object == this) || (object == treeView->viewport())) {
|
||||
@@ -576,6 +565,15 @@ bool BookmarkWidget::eventFilter(QObject *object, QEvent *e)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (object == searchField && e->type() == QEvent::FocusIn) {
|
||||
if (static_cast<QFocusEvent *>(e)->reason() != Qt::MouseFocusReason) {
|
||||
searchField->selectAll();
|
||||
searchField->setFocus();
|
||||
|
||||
QModelIndex index = treeView->indexAt(QPoint(1, 1));
|
||||
if (index.isValid())
|
||||
treeView->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
return QWidget::eventFilter(object, e);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,6 @@ private slots:
|
||||
private:
|
||||
void setup(bool showButtons);
|
||||
void expandItems();
|
||||
void focusInEvent(QFocusEvent *e);
|
||||
bool eventFilter(QObject *object, QEvent *event);
|
||||
|
||||
private:
|
||||
|
||||
@@ -43,8 +43,10 @@ ContentWindow::ContentWindow(QHelpEngine *helpEngine)
|
||||
, m_expandDepth(-2)
|
||||
{
|
||||
m_contentWidget = m_helpEngine->contentWidget();
|
||||
m_contentWidget->installEventFilter(this);
|
||||
m_contentWidget->viewport()->installEventFilter(this);
|
||||
m_contentWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
setFocusProxy(m_contentWidget);
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
layout->setMargin(4);
|
||||
@@ -90,18 +92,6 @@ void ContentWindow::expandToDepth(int depth)
|
||||
m_contentWidget->expandToDepth(depth);
|
||||
}
|
||||
|
||||
void ContentWindow::focusInEvent(QFocusEvent *e)
|
||||
{
|
||||
if (e->reason() != Qt::MouseFocusReason)
|
||||
m_contentWidget->setFocus();
|
||||
}
|
||||
|
||||
void ContentWindow::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
if (e->key() == Qt::Key_Escape)
|
||||
emit escapePressed();
|
||||
}
|
||||
|
||||
bool ContentWindow::eventFilter(QObject *o, QEvent *e)
|
||||
{
|
||||
if (m_contentWidget && o == m_contentWidget->viewport()
|
||||
@@ -125,6 +115,9 @@ bool ContentWindow::eventFilter(QObject *o, QEvent *e)
|
||||
itemClicked(index);
|
||||
}
|
||||
}
|
||||
} else if (o == m_contentWidget && e->type() == QEvent::KeyPress) {
|
||||
if (static_cast<QKeyEvent *>(e)->key() == Qt::Key_Escape)
|
||||
emit escapePressed();
|
||||
}
|
||||
return QWidget::eventFilter(o, e);
|
||||
}
|
||||
|
||||
@@ -63,8 +63,6 @@ private slots:
|
||||
void itemClicked(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
void focusInEvent(QFocusEvent *e);
|
||||
void keyPressEvent(QKeyEvent *e);
|
||||
bool eventFilter(QObject *o, QEvent *e);
|
||||
bool isPdfFile(QHelpContentItem *item) const;
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ IndexWindow::IndexWindow(QHelpEngine *helpEngine, QWidget *parent)
|
||||
|
||||
m_searchLineEdit = new QLineEdit();
|
||||
l->setBuddy(m_searchLineEdit);
|
||||
setFocusProxy(m_searchLineEdit);
|
||||
connect(m_searchLineEdit, SIGNAL(textChanged(QString)), this,
|
||||
SLOT(filterIndices(QString)));
|
||||
m_searchLineEdit->installEventFilter(this);
|
||||
@@ -112,6 +113,11 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e)
|
||||
break;
|
||||
default: ; // stop complaining
|
||||
}
|
||||
} else if (obj == m_searchLineEdit
|
||||
&& e->type() == QEvent::FocusIn
|
||||
&& static_cast<QFocusEvent *>(e)->reason() != Qt::MouseFocusReason) {
|
||||
m_searchLineEdit->selectAll();
|
||||
m_searchLineEdit->setFocus();
|
||||
} else if (obj == m_indexWidget && e->type() == QEvent::ContextMenu) {
|
||||
QContextMenuEvent *ctxtEvent = static_cast<QContextMenuEvent*>(e);
|
||||
QModelIndex idx = m_indexWidget->indexAt(ctxtEvent->pos());
|
||||
@@ -147,6 +153,7 @@ bool IndexWindow::eventFilter(QObject *obj, QEvent *e)
|
||||
m_indexWidget->activateCurrentItem();
|
||||
}
|
||||
#endif
|
||||
|
||||
return QWidget::eventFilter(obj, e);
|
||||
}
|
||||
|
||||
@@ -166,14 +173,6 @@ void IndexWindow::setSearchLineEditText(const QString &text)
|
||||
m_searchLineEdit->setText(text);
|
||||
}
|
||||
|
||||
void IndexWindow::focusInEvent(QFocusEvent *e)
|
||||
{
|
||||
if (e->reason() != Qt::MouseFocusReason) {
|
||||
m_searchLineEdit->selectAll();
|
||||
m_searchLineEdit->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
void IndexWindow::open(QHelpIndexWidget* indexWidget, const QModelIndex &index)
|
||||
{
|
||||
QHelpIndexModel *model = qobject_cast<QHelpIndexModel*>(indexWidget->model());
|
||||
|
||||
@@ -69,7 +69,6 @@ private slots:
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject *obj, QEvent *e);
|
||||
void focusInEvent(QFocusEvent *e);
|
||||
void open(QHelpIndexWidget* indexWidget, const QModelIndex &index);
|
||||
|
||||
QLineEdit *m_searchLineEdit;
|
||||
|
||||
Reference in New Issue
Block a user