diff --git a/dist/changes-1.2.0 b/dist/changes-1.2.0 index 7229fc1194891857a0564fa5e457629c7ba8b833..6bfe3951628325751d198ce894a69161e8bdfd11 100644 --- a/dist/changes-1.2.0 +++ b/dist/changes-1.2.0 @@ -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) diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index c3933ad109861349d09e8196bd037557f2fbc322..b8ddd1bc134b7f807ff70606805914bd8d9ac136 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -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() diff --git a/src/plugins/coreplugin/progressmanager/progresspie.cpp b/src/plugins/coreplugin/progressmanager/progresspie.cpp index 744ba598650eb5417e3ec095f930f21c77f6e5a4..faeab0047c3c58d1690631e9be0456c405eac924 100644 --- a/src/plugins/coreplugin/progressmanager/progresspie.cpp +++ b/src/plugins/coreplugin/progressmanager/progresspie.cpp @@ -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); diff --git a/src/plugins/coreplugin/settingsdatabase.cpp b/src/plugins/coreplugin/settingsdatabase.cpp index b26cb188f3a66a74895cb09ec596d674cdc0864e..00958a7a67f8b67d5c2fad7717a60eb9bcc7696b 100644 --- a/src/plugins/coreplugin/settingsdatabase.cpp +++ b/src/plugins/coreplugin/settingsdatabase.cpp @@ -31,6 +31,7 @@ #include <QtCore/QMap> #include <QtSql/QSqlDatabase> +#include <QtSql/QSqlError> #include <QtSql/QSqlQuery> #include <QDebug> @@ -101,21 +102,24 @@ 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!"; - - // 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!"; - - // Retrieve all available keys (values are retrieved lazily) - if (query.exec(QLatin1String("SELECT key FROM settings"))) { - while (query.next()) { - d->m_settings.insert(query.value(0).toString(), QVariant()); + 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 (!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"))) { + while (query.next()) { + d->m_settings.insert(query.value(0).toString(), QVariant()); + } } } } @@ -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) diff --git a/src/plugins/coreplugin/stylehelper.cpp b/src/plugins/coreplugin/stylehelper.cpp index 42ca012cf31f78f98e46c5615dd45a3068437e34..4c723449511daf23851c5b8fca62563af5d34267 100644 --- a/src/plugins/coreplugin/stylehelper.cpp +++ b/src/plugins/coreplugin/stylehelper.cpp @@ -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) diff --git a/src/plugins/coreplugin/stylehelper.h b/src/plugins/coreplugin/stylehelper.h index 173f12cbf511d3f5f9cf10ea81d5901c4aa48907..32cc200b84a42744933f3e716fd507cf7a315a21 100644 --- a/src/plugins/coreplugin/stylehelper.h +++ b/src/plugins/coreplugin/stylehelper.h @@ -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); diff --git a/src/plugins/cpptools/cppquickopenfilter.cpp b/src/plugins/cpptools/cppquickopenfilter.cpp index a0f74cbbd08e346bacb9d93f486681841a579739..7721c3398633c1b0c42cbe7e2b71868dec6c68cd 100644 --- a/src/plugins/cpptools/cppquickopenfilter.cpp +++ b/src/plugins/cpptools/cppquickopenfilter.cpp @@ -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); - filterEntry.extraInfo = info.symbolType; + if (! info.symbolType.isEmpty()) + filterEntry.extraInfo = info.symbolType; + else + filterEntry.extraInfo = info.fileName; + if (info.symbolName.startsWith(entry)) betterEntries.append(filterEntry); else diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 5f20d04064e93676302c4fcf727a24eb85a6cf6a..f78bd890ac57b5eed88c96493451c71bd5dd440e 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -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); } } diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 676a351a6f8cb07c67e0edcc6c3510b08d22fad1..3fe0ad0d889dd610d5d1a977a53a409ef6baf42e 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -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) diff --git a/src/plugins/projectexplorer/sessiondialog.cpp b/src/plugins/projectexplorer/sessiondialog.cpp index 1285bf171d30aeeeb9513fcd0c54c111bc45cdba..ec5fadbe13193c23829b1af9bbc375bce917b21b 100644 --- a/src/plugins/projectexplorer/sessiondialog.cpp +++ b/src/plugins/projectexplorer/sessiondialog.cpp @@ -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(); } diff --git a/src/plugins/projectexplorer/sessiondialog.ui b/src/plugins/projectexplorer/sessiondialog.ui index ab2f4b08a0ce448ea360ba9ac892da330fb41095..ad11881aaef34185fc59991642a54eb48803be9c 100644 --- a/src/plugins/projectexplorer/sessiondialog.ui +++ b/src/plugins/projectexplorer/sessiondialog.ui @@ -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> diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index 6f02f4ad0e1775c4c0a020240e30cdd5da22f962..340d7fa94796656bbf2b033a7cf8444b4aba9ac2 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -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; diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index d95147698c471fe0456291722a2a20118ac31617..6b6e6e4f999f32decdc2e01bb237710f73b5f396 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -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 diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp index 914c565552c75e9875f0491a36074710c83e19ea..60d6269bfff9fce508627ce6c58f799a7602a531 100644 --- a/src/plugins/texteditor/basetexteditor.cpp +++ b/src/plugins/texteditor/basetexteditor.cpp @@ -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; - - if (expanded) - opt.state |= QStyle::State_Open; + Q_UNUSED(active); + Q_UNUSED(hovered); - if (active) - opt.state |= QStyle::State_MouseOver | QStyle::State_Enabled | QStyle::State_Selected; + painter->save(); + painter->setPen(Qt::NoPen); - if (hovered) - opt.palette.setBrush(QPalette::Window, pal.highlight()); + int size = rect.size().width(); + int sqsize = 2*(size/2); - QStyle *s = style(); + QColor textColor = pal.buttonText().color(); + QColor brushColor = textColor; - if (ManhattanStyle *ms = qobject_cast<ManhattanStyle*>(s)) - s = ms->systemStyle(); + textColor.setAlpha(100); + brushColor.setAlpha(40); - // 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); + 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()); - 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); diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 9a84718af9ceb8469daa349fb91f4c8dd41a426f..8e8eebe6dd96bbb1e1f653f64b255244f6b4e0e7 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -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 diff --git a/src/shared/help/bookmarkmanager.cpp b/src/shared/help/bookmarkmanager.cpp index 96c8643765732bbb9de25b1bbbe1a0738315ce7b..cf696b9f94c486ecce012fb20f7bb5fcf0820fae 100644 --- a/src/shared/help/bookmarkmanager.cpp +++ b/src/shared/help/bookmarkmanager.cpp @@ -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); } diff --git a/src/shared/help/bookmarkmanager.h b/src/shared/help/bookmarkmanager.h index 00f93f670c88fee6ca3b441bc9633c3db0acc218..008c9d1b7dc9acea50475427e15ae8011e04c7ae 100644 --- a/src/shared/help/bookmarkmanager.h +++ b/src/shared/help/bookmarkmanager.h @@ -129,7 +129,6 @@ private slots: private: void setup(bool showButtons); void expandItems(); - void focusInEvent(QFocusEvent *e); bool eventFilter(QObject *object, QEvent *event); private: diff --git a/src/shared/help/contentwindow.cpp b/src/shared/help/contentwindow.cpp index ca722034333915a02b925ac4c52e2d2ed33f288f..e7dcab7da414b146a3644c1cab8cfa976101a516 100644 --- a/src/shared/help/contentwindow.cpp +++ b/src/shared/help/contentwindow.cpp @@ -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); } diff --git a/src/shared/help/contentwindow.h b/src/shared/help/contentwindow.h index 81eee24e57f5090f01ae1923f974be11e7b4a7bf..ec98ea53212bf045fc59bebce7d4996a819f165e 100644 --- a/src/shared/help/contentwindow.h +++ b/src/shared/help/contentwindow.h @@ -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; diff --git a/src/shared/help/indexwindow.cpp b/src/shared/help/indexwindow.cpp index 8ae9f4e0a9346caf100e3af2059cbc6186c81cf1..208f2357a916ef96724d0b92624d361499f77613 100644 --- a/src/shared/help/indexwindow.cpp +++ b/src/shared/help/indexwindow.cpp @@ -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()); diff --git a/src/shared/help/indexwindow.h b/src/shared/help/indexwindow.h index 21d32fbf0eb103d94fa20f2e532f7158119ca4d3..a283d64c21b3808046290662e5f1c171028fe6e7 100644 --- a/src/shared/help/indexwindow.h +++ b/src/shared/help/indexwindow.h @@ -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;