/************************************************************************
-*
-* Copyright 2012 Jakob Leben (jakob.leben@gmail.com)
-*
-* This file is part of SuperCollider Qt GUI.
-*
-* This program is free software: you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation, either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-************************************************************************/
+ *
+ * Copyright 2012 Jakob Leben (jakob.leben@gmail.com)
+ *
+ * This file is part of SuperCollider Qt GUI.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ ************************************************************************/
#include "QcObjectFactory.h"
#include "QcWidgetFactory.h"
#include <QLabel>
-QC_DECLARE_QWIDGET_FACTORY( QLabel );
+QC_DECLARE_QWIDGET_FACTORY(QLabel);
-static void doLoadFactories ()
-{
- QC_ADD_FACTORY( QcDefaultWidget );
- QC_ADD_FACTORY( QcHLayoutWidget );
- QC_ADD_FACTORY( QcVLayoutWidget );
- QC_ADD_FACTORY( QLabel );
- QC_ADD_FACTORY( QcTextField );
- QC_ADD_FACTORY( QcCheckBox );
- QC_ADD_FACTORY( QcListWidget );
- QC_ADD_FACTORY( QcPopUpMenu );
- QC_ADD_FACTORY( QcButton );
- QC_ADD_FACTORY( QcCustomPainted );
- QC_ADD_FACTORY( QcFileDialog );
- QC_ADD_FACTORY( QcGraph );
- QC_ADD_FACTORY( QcKnob );
- QC_ADD_FACTORY( QcLevelIndicator );
- QC_ADD_FACTORY( QcMultiSlider );
- QC_ADD_FACTORY( QcNumberBox );
- QC_ADD_FACTORY( QcPenPrinter );
- QC_ADD_FACTORY( QcRangeSlider );
- QC_ADD_FACTORY( QcScope );
- QC_ADD_FACTORY( QcScopeShm );
- QC_ADD_FACTORY( QcScrollWidget );
- QC_ADD_FACTORY( QcScrollArea );
- QC_ADD_FACTORY( QcSlider );
- QC_ADD_FACTORY( QcSlider2D );
- QC_ADD_FACTORY( QcWaveform );
- QC_ADD_FACTORY( QcTextEdit );
- QC_ADD_FACTORY( QcTreeWidget );
- QC_ADD_FACTORY( QcMenu );
- QC_ADD_FACTORY( QcToolBar );
- QC_ADD_FACTORY( QcAction );
- QC_ADD_FACTORY( QcWidgetAction );
- QC_ADD_FACTORY( QcCallback );
- QC_ADD_FACTORY( WebView );
- QC_ADD_FACTORY( QcWindow );
- QC_ADD_FACTORY( QcScrollWindow );
- QC_ADD_FACTORY( QcHBoxLayout );
- QC_ADD_FACTORY( QcVBoxLayout );
- QC_ADD_FACTORY( QcGridLayout );
- QC_ADD_FACTORY( QcStackLayout );
- QC_ADD_FACTORY( QtDownload );
+static void doLoadFactories() {
+ QC_ADD_FACTORY(QcDefaultWidget);
+ QC_ADD_FACTORY(QcHLayoutWidget);
+ QC_ADD_FACTORY(QcVLayoutWidget);
+ QC_ADD_FACTORY(QLabel);
+ QC_ADD_FACTORY(QcTextField);
+ QC_ADD_FACTORY(QcCheckBox);
+ QC_ADD_FACTORY(QcListWidget);
+ QC_ADD_FACTORY(QcPopUpMenu);
+ QC_ADD_FACTORY(QcButton);
+ QC_ADD_FACTORY(QcCustomPainted);
+ QC_ADD_FACTORY(QcFileDialog);
+ QC_ADD_FACTORY(QcGraph);
+ QC_ADD_FACTORY(QcKnob);
+ QC_ADD_FACTORY(QcLevelIndicator);
+ QC_ADD_FACTORY(QcMultiSlider);
+ QC_ADD_FACTORY(QcNumberBox);
+ QC_ADD_FACTORY(QcPenPrinter);
+ QC_ADD_FACTORY(QcRangeSlider);
+ QC_ADD_FACTORY(QcScope);
+ QC_ADD_FACTORY(QcScopeShm);
+ QC_ADD_FACTORY(QcScrollWidget);
+ QC_ADD_FACTORY(QcScrollArea);
+ QC_ADD_FACTORY(QcSlider);
+ QC_ADD_FACTORY(QcSlider2D);
+ QC_ADD_FACTORY(QcWaveform);
+ QC_ADD_FACTORY(QcTextEdit);
+ QC_ADD_FACTORY(QcTreeWidget);
+ QC_ADD_FACTORY(QcMenu);
+ QC_ADD_FACTORY(QcToolBar);
+ QC_ADD_FACTORY(QcAction);
+ QC_ADD_FACTORY(QcWidgetAction);
+ QC_ADD_FACTORY(QcCallback);
+ QC_ADD_FACTORY(WebView);
+ QC_ADD_FACTORY(QcWindow);
+ QC_ADD_FACTORY(QcScrollWindow);
+ QC_ADD_FACTORY(QcHBoxLayout);
+ QC_ADD_FACTORY(QcVBoxLayout);
+ QC_ADD_FACTORY(QcGridLayout);
+ QC_ADD_FACTORY(QcStackLayout);
+ QC_ADD_FACTORY(QtDownload);
#ifdef __APPLE__
- QC_ADD_FACTORY( QcQuartzComposerView );
+ QC_ADD_FACTORY(QcQuartzComposerView);
#endif
}
namespace QtCollider {
-void loadFactories()
-{
- doLoadFactories();
-}
+void loadFactories() { doLoadFactories(); }
} // namespace QtCollider
QPalette QtCollider::systemPalette() { return gSystemPalette; }
void QtCollider::init() {
- if( !QApplication::instance() ) {
- qcDebugMsg( 1, "Initializing QtCollider" );
+ if (!QApplication::instance()) {
+ qcDebugMsg(1, "Initializing QtCollider");
- initResources();
+ initResources();
- QtCollider::loadFactories();
+ QtCollider::loadFactories();
- QtCollider::MetaType::initAll();
+ QtCollider::MetaType::initAll();
- QLocale::setDefault( QLocale::c() );
+ QLocale::setDefault(QLocale::c());
#ifdef Q_WS_X11
- XInitThreads();
+ XInitThreads();
#endif
#ifdef Q_OS_MAC
- // TODO: this should not be necessary
- QApplication::setAttribute( Qt::AA_PluginApplication, true );
+ // TODO: this should not be necessary
+ QApplication::setAttribute(Qt::AA_PluginApplication, true);
#endif
- static int qcArgc = 1;
- static char qcArg0[] = "SuperCollider";
- static char *qcArgv[1] = {qcArg0};
+ static int qcArgc = 1;
+ static char qcArg0[] = "SuperCollider";
+ static char* qcArgv[1] = { qcArg0 };
- QcApplication *qcApp = new QcApplication( qcArgc, qcArgv );
+ QcApplication* qcApp = new QcApplication(qcArgc, qcArgv);
- qcApp->setQuitOnLastWindowClosed( false );
+ qcApp->setQuitOnLastWindowClosed(false);
- //qcApp->setStyle( new QtCollider::Style::StyleImpl( new QPlastiqueStyle ) );
+ // qcApp->setStyle( new QtCollider::Style::StyleImpl( new QPlastiqueStyle ) );
- gSystemPalette = qcApp->palette();
+ gSystemPalette = qcApp->palette();
- // Enable javascript localStorage for WebViews
- QWebEngineSettings::globalSettings()->setAttribute( QWebEngineSettings::LocalStorageEnabled, true );
+ // Enable javascript localStorage for WebViews
+ QWebEngineSettings::globalSettings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
- // NOTE: Qt may tamper with the C language locale, affecting POSIX number-string conversions.
- // Revert the locale to default:
- setlocale( LC_NUMERIC, "C" );
- }
+ // NOTE: Qt may tamper with the C language locale, affecting POSIX number-string conversions.
+ // Revert the locale to default:
+ setlocale(LC_NUMERIC, "C");
+ }
}
-int QtCollider::exec( int argc, char** argv ) {
- QtCollider::init();
- Q_ASSERT( qApp );
- return qApp->exec();
+int QtCollider::exec(int argc, char** argv) {
+ QtCollider::init();
+ Q_ASSERT(qApp);
+ return qApp->exec();
}
#include <QPainter>
#ifdef Q_OS_MAC
- #include "../hacks/hacks_mac.hpp"
+# include "../hacks/hacks_mac.hpp"
#endif
using namespace QtCollider;
static bool AlwaysShowScrollbars() {
#if defined(Q_OS_MAC)
- return QtCollider::Mac::AlwaysShowScrollbars();
+ return QtCollider::Mac::AlwaysShowScrollbars();
#elif defined(Q_OS_X11)
- return true;
+ return true;
#elif defined(Q_OS_WIN)
- return true;
+ return true;
#else
- return true;
+ return true;
#endif
};
-void ProxyStyle::drawComplexControl ( ComplexControl ctrl, const QStyleOptionComplex *opt,
- QPainter *p, const QWidget * w) const
-{
- // FIXME: this is a workaround for the WebKit bug #104116 (or a variation on it).
- if( ctrl == QStyle::CC_ScrollBar
- && qobject_cast<const QWebEngineView*>(w) != 0
- && opt->type == QStyleOption::SO_Slider )
- {
- // WebKit tries to hide scrollbars, but mistakenly hides QWebView - NULL-ify styleObject to prevent.
- const QStyleOptionSlider *optSlider = static_cast<const QStyleOptionSlider*>(opt);
- QStyleOptionSlider opt2( *optSlider );
- opt2.styleObject = NULL;
+void ProxyStyle::drawComplexControl(ComplexControl ctrl, const QStyleOptionComplex* opt, QPainter* p,
+ const QWidget* w) const {
+ // FIXME: this is a workaround for the WebKit bug #104116 (or a variation on it).
+ if (ctrl == QStyle::CC_ScrollBar && qobject_cast<const QWebEngineView*>(w) != 0
+ && opt->type == QStyleOption::SO_Slider) {
+ // WebKit tries to hide scrollbars, but mistakenly hides QWebView - NULL-ify styleObject to prevent.
+ const QStyleOptionSlider* optSlider = static_cast<const QStyleOptionSlider*>(opt);
+ QStyleOptionSlider opt2(*optSlider);
+ opt2.styleObject = NULL;
- QProxyStyle::drawComplexControl( ctrl, &opt2, p, w );
- return;
- }
+ QProxyStyle::drawComplexControl(ctrl, &opt2, p, w);
+ return;
+ }
- if (ctrl == QStyle::CC_ScrollBar && AlwaysShowScrollbars()) {
- const QStyleOptionSlider *optSlider = static_cast<const QStyleOptionSlider*>(opt);
- QStyleOptionSlider opt2( *optSlider );
- opt2.state = State_On;
- QProxyStyle::drawComplexControl( ctrl, static_cast<const QStyleOptionComplex*>(&opt2), p, w );
- return;
- }
+ if (ctrl == QStyle::CC_ScrollBar && AlwaysShowScrollbars()) {
+ const QStyleOptionSlider* optSlider = static_cast<const QStyleOptionSlider*>(opt);
+ QStyleOptionSlider opt2(*optSlider);
+ opt2.state = State_On;
+ QProxyStyle::drawComplexControl(ctrl, static_cast<const QStyleOptionComplex*>(&opt2), p, w);
+ return;
+ }
- QProxyStyle::drawComplexControl( ctrl, opt, p, w );
+ QProxyStyle::drawComplexControl(ctrl, opt, p, w);
}
-int ProxyStyle::styleHint ( StyleHint hint, const QStyleOption * option,
- const QWidget * widget, QStyleHintReturn * returnData ) const
-{
- switch( hint ) {
+int ProxyStyle::styleHint(StyleHint hint, const QStyleOption* option, const QWidget* widget,
+ QStyleHintReturn* returnData) const {
+ switch (hint) {
case QStyle::SH_Slider_AbsoluteSetButtons:
- return Qt::LeftButton;
+ return Qt::LeftButton;
case QStyle::SH_Slider_PageSetButtons:
- return Qt::NoButton;
+ return Qt::NoButton;
case QStyle::SH_ScrollBar_Transient:
- return 1;
+ return 1;
default:
- return QProxyStyle::styleHint( hint, option, widget, returnData );
- }
+ return QProxyStyle::styleHint(hint, option, widget, returnData);
+ }
}
class WebPage;
class QcCallback;
-class QcCallbackWeakFunctor
-{
+class QcCallbackWeakFunctor {
public:
- QcCallbackWeakFunctor(QPointer<QcCallback> cb)
- : _cb(cb)
- {}
-
- template <typename RESULT>
- void operator()(RESULT r) const;
+ QcCallbackWeakFunctor(QPointer<QcCallback> cb): _cb(cb) {}
+
+ template <typename RESULT> void operator()(RESULT r) const;
private:
- QPointer<QcCallback> _cb;
+ QPointer<QcCallback> _cb;
};
-class QcCallback : public QObject
-{
- Q_OBJECT
+class QcCallback : public QObject {
+ Q_OBJECT
public:
- QcCallback() {}
-
- template<typename CallbackT>
- void call(const CallbackT& result)
- {
- Q_EMIT(onCalled(result));
- }
-
- QcCallbackWeakFunctor asFunctor()
- {
- return QcCallbackWeakFunctor(QPointer<QcCallback>(this));
- }
-
+ QcCallback() {}
+
+ template <typename CallbackT> void call(const CallbackT& result) { Q_EMIT(onCalled(result)); }
+
+ QcCallbackWeakFunctor asFunctor() { return QcCallbackWeakFunctor(QPointer<QcCallback>(this)); }
+
Q_SIGNALS:
- void onCalled(bool);
- void onCalled(const QString&);
- void onCalled(const QVariant&);
- void onCalled(const QUrl&);
+ void onCalled(bool);
+ void onCalled(const QString&);
+ void onCalled(const QVariant&);
+ void onCalled(const QUrl&);
};
-
-template <typename RESULT>
-void QcCallbackWeakFunctor::operator()(RESULT r) const
- {
- if (_cb) {
- _cb->call(r);
- }
+
+template <typename RESULT> void QcCallbackWeakFunctor::operator()(RESULT r) const {
+ if (_cb) {
+ _cb->call(r);
+ }
}
-
-class WebView : public QWebEngineView
-{
- Q_OBJECT
+class WebView : public QWebEngineView {
+ Q_OBJECT
public:
- Q_INVOKABLE void setFontFamily( int genericFontFamily, const QString & fontFamily );
- Q_INVOKABLE void triggerPageAction( int action, bool checked );
- Q_INVOKABLE QAction* pageAction( QWebEnginePage::WebAction ) const;
-
- // QWebEnginePage forwards
- Q_INVOKABLE void setHtml(const QString& html, const QString& baseUrl);
- Q_INVOKABLE void setContent(const QVector<int>& data, const QString& mimeType, const QString& baseUrl);
- Q_INVOKABLE void toHtml(QcCallback* cb) const;
- Q_INVOKABLE void toPlainText(QcCallback* cb) const;
- Q_INVOKABLE void runJavaScript(const QString& script, QcCallback* cb);
- Q_INVOKABLE void setWebAttribute(int attr, bool on);
- Q_INVOKABLE bool testWebAttribute(int attr);
- Q_INVOKABLE void resetWebAttribute(int attr);
- Q_INVOKABLE void navigate(const QString& url);
+ Q_INVOKABLE void setFontFamily(int genericFontFamily, const QString& fontFamily);
+ Q_INVOKABLE void triggerPageAction(int action, bool checked);
+ Q_INVOKABLE QAction* pageAction(QWebEnginePage::WebAction) const;
+
+ // QWebEnginePage forwards
+ Q_INVOKABLE void setHtml(const QString& html, const QString& baseUrl);
+ Q_INVOKABLE void setContent(const QVector<int>& data, const QString& mimeType, const QString& baseUrl);
+ Q_INVOKABLE void toHtml(QcCallback* cb) const;
+ Q_INVOKABLE void toPlainText(QcCallback* cb) const;
+ Q_INVOKABLE void runJavaScript(const QString& script, QcCallback* cb);
+ Q_INVOKABLE void setWebAttribute(int attr, bool on);
+ Q_INVOKABLE bool testWebAttribute(int attr);
+ Q_INVOKABLE void resetWebAttribute(int attr);
+ Q_INVOKABLE void navigate(const QString& url);
public Q_SLOTS:
- void findText( const QString &searchText, bool reversed, QcCallback* cb);
+ void findText(const QString& searchText, bool reversed, QcCallback* cb);
Q_SIGNALS:
- void linkActivated( const QString &, int, bool );
- void jsConsoleMsg( const QString &, int, const QString & );
- void reloadTriggered( const QString & );
- void interpret( const QString & code );
-
- // QWebEnginePage forwards
- void linkHovered(const QString &url);
- void geometryChangeRequested(const QRect& geom);
- void windowCloseRequested();
- void navigationRequested(const QUrl &, int, bool);
-
- void renderProcessTerminated(int terminationStatus, int exitCode);
-
- void scrollPositionChanged(const QPointF &position);
- void contentsSizeChanged(const QSizeF &size);
- void audioMutedChanged(bool muted);
- void recentlyAudibleChanged(bool recentlyAudible);
-
+ void linkActivated(const QString&, int, bool);
+ void jsConsoleMsg(const QString&, int, const QString&);
+ void reloadTriggered(const QString&);
+ void interpret(const QString& code);
+
+ // QWebEnginePage forwards
+ void linkHovered(const QString& url);
+ void geometryChangeRequested(const QRect& geom);
+ void windowCloseRequested();
+ void navigationRequested(const QUrl&, int, bool);
+
+ void renderProcessTerminated(int terminationStatus, int exitCode);
+
+ void scrollPositionChanged(const QPointF& position);
+ void contentsSizeChanged(const QSizeF& size);
+ void audioMutedChanged(bool muted);
+ void recentlyAudibleChanged(bool recentlyAudible);
+
public:
+ WebView(QWidget* parent = 0);
- WebView( QWidget *parent = 0 );
+ Q_PROPERTY(qreal zoom READ zoomFactor WRITE setZoomFactor);
+ Q_PROPERTY(bool hasSelection READ hasSelection);
+ Q_PROPERTY(QString selectedText READ selectedText);
+ Q_PROPERTY(QString title READ title);
- Q_PROPERTY( qreal zoom READ zoomFactor WRITE setZoomFactor );
- Q_PROPERTY( bool hasSelection READ hasSelection );
- Q_PROPERTY( QString selectedText READ selectedText );
- Q_PROPERTY( QString title READ title );
-
- Q_PROPERTY( bool overrideNavigation READ overrideNavigation WRITE setOverrideNavigation );
+ Q_PROPERTY(bool overrideNavigation READ overrideNavigation WRITE setOverrideNavigation);
bool overrideNavigation() const;
void setOverrideNavigation(bool b);
-
- Q_PROPERTY( QString url READ url WRITE setUrl );
- QString url() const;
- void setUrl( const QString & );
- Q_PROPERTY( bool delegateReload READ delegateReload WRITE setDelegateReload );
+ Q_PROPERTY(QString url READ url WRITE setUrl);
+ QString url() const;
+ void setUrl(const QString&);
+
+ Q_PROPERTY(bool delegateReload READ delegateReload WRITE setDelegateReload);
bool delegateReload() const;
- void setDelegateReload( bool );
+ void setDelegateReload(bool);
- Q_PROPERTY( bool enterInterpretsSelection READ interpretSelection WRITE setInterpretSelection );
- bool interpretSelection() const { return _interpretSelection; }
- void setInterpretSelection( bool b ) { _interpretSelection = b; }
+ Q_PROPERTY(bool enterInterpretsSelection READ interpretSelection WRITE setInterpretSelection);
+ bool interpretSelection() const { return _interpretSelection; }
+ void setInterpretSelection(bool b) { _interpretSelection = b; }
- Q_PROPERTY( bool editable READ editable WRITE setEditable );
+ Q_PROPERTY(bool editable READ editable WRITE setEditable);
bool editable() const { return _editable; }
- void setEditable( bool b ) { _editable = b; updateEditable(true); }
-
- // QWebEnginePage properties
- Q_PROPERTY(QString requestedUrl READ requestedUrl)
- QString requestedUrl() const { return page() ? page()->requestedUrl().toString() : QString(); }
-
- Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
- QColor backgroundColor() const { return page() ? page()->backgroundColor() : QColor(); }
- void setBackgroundColor(QColor c) { if (page()) page()->setBackgroundColor(c); }
-
- Q_PROPERTY(QSizeF contentsSize READ contentsSize)
- QSizeF contentsSize() const { return page() ? page()->contentsSize() : QSizeF(0, 0); }
-
- Q_PROPERTY(QPointF scrollPosition READ scrollPosition)
- QPointF scrollPosition() const { return page() ? page()->scrollPosition() : QPointF(0, 0); }
-
- Q_PROPERTY(bool audioMuted READ isAudioMuted WRITE setAudioMuted)
- bool isAudioMuted() const { return page() ? page()->isAudioMuted() : false; }
- void setAudioMuted(bool m) { if (page()) page()->setAudioMuted(m); }
-
- Q_PROPERTY(bool recentlyAudible READ recentlyAudible)
- bool recentlyAudible() const { return page() ? page()->recentlyAudible() : false; }
-
- inline static QUrl urlFromString( const QString & str )
- { return QUrl::fromUserInput(str); }
+ void setEditable(bool b) {
+ _editable = b;
+ updateEditable(true);
+ }
+
+ // QWebEnginePage properties
+ Q_PROPERTY(QString requestedUrl READ requestedUrl)
+ QString requestedUrl() const { return page() ? page()->requestedUrl().toString() : QString(); }
+
+ Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
+ QColor backgroundColor() const { return page() ? page()->backgroundColor() : QColor(); }
+ void setBackgroundColor(QColor c) {
+ if (page())
+ page()->setBackgroundColor(c);
+ }
+
+ Q_PROPERTY(QSizeF contentsSize READ contentsSize)
+ QSizeF contentsSize() const { return page() ? page()->contentsSize() : QSizeF(0, 0); }
+
+ Q_PROPERTY(QPointF scrollPosition READ scrollPosition)
+ QPointF scrollPosition() const { return page() ? page()->scrollPosition() : QPointF(0, 0); }
+
+ Q_PROPERTY(bool audioMuted READ isAudioMuted WRITE setAudioMuted)
+ bool isAudioMuted() const { return page() ? page()->isAudioMuted() : false; }
+ void setAudioMuted(bool m) {
+ if (page())
+ page()->setAudioMuted(m);
+ }
+
+ Q_PROPERTY(bool recentlyAudible READ recentlyAudible)
+ bool recentlyAudible() const { return page() ? page()->recentlyAudible() : false; }
+
+ inline static QUrl urlFromString(const QString& str) { return QUrl::fromUserInput(str); }
protected:
- virtual void keyPressEvent( QKeyEvent * );
- virtual void contextMenuEvent ( QContextMenuEvent * );
+ virtual void keyPressEvent(QKeyEvent*);
+ virtual void contextMenuEvent(QContextMenuEvent*);
public Q_SLOTS:
- void onPageReload();
- void onRenderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus, int);
- void onLinkClicked(const QUrl &, QWebEnginePage::NavigationType, bool);
- void updateEditable(bool);
+ void onPageReload();
+ void onRenderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus, int);
+ void onLinkClicked(const QUrl&, QWebEnginePage::NavigationType, bool);
+ void updateEditable(bool);
private:
- void connectPage(QtCollider::WebPage* page);
-
- bool _interpretSelection;
- bool _editable;
+ void connectPage(QtCollider::WebPage* page);
+
+ bool _interpretSelection;
+ bool _editable;
};
} // namespace QtCollider
using namespace QtCollider;
-Q_DECLARE_METATYPE( QcCallback* );
+Q_DECLARE_METATYPE(QcCallback*);
namespace QtCollider {
-void WebPage::triggerAction ( WebAction action, bool checked )
-{
- switch ( action ) {
+void WebPage::triggerAction(WebAction action, bool checked) {
+ switch (action) {
case QWebEnginePage::Reload:
- if( _delegateReload ) return;
- break;
+ if (_delegateReload)
+ return;
+ break;
case QWebEnginePage::Copy:
- // ignore text formatting, copy only plain text:
- QApplication::clipboard()->setText( selectedText() );
- return;
+ // ignore text formatting, copy only plain text:
+ QApplication::clipboard()->setText(selectedText());
+ return;
default:
- break;
- }
+ break;
+ }
- QWebEnginePage::triggerAction( action, checked );
+ QWebEnginePage::triggerAction(action, checked);
}
-void WebPage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID)
-{
- Q_EMIT( jsConsoleMsg(message, lineNumber, sourceID) );
+void WebPage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber,
+ const QString& sourceID) {
+ Q_EMIT(jsConsoleMsg(message, lineNumber, sourceID));
}
-bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
-{
- if (type == QWebEnginePage::NavigationTypeLinkClicked) {
- Q_EMIT(navigationRequested(url, type, isMainFrame));
- if (_delegateNavigation) {
- return false;
+bool WebPage::acceptNavigationRequest(const QUrl& url, QWebEnginePage::NavigationType type, bool isMainFrame) {
+ if (type == QWebEnginePage::NavigationTypeLinkClicked) {
+ Q_EMIT(navigationRequested(url, type, isMainFrame));
+ if (_delegateNavigation) {
+ return false;
+ }
}
- }
- return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
+ return QWebEnginePage::acceptNavigationRequest(url, type, isMainFrame);
}
} // namespace QtCollider
-
// setup comm channel
WebSocketClientWrapper clientWrapper(&server);
QWebChannel channel;
- QObject::connect(&clientWrapper, &WebSocketClientWrapper::clientConnected,
- &channel, &QWebChannel::connectTo);
+ QObject::connect(&clientWrapper, &WebSocketClientWrapper::clientConnected, &channel, &QWebChannel::connectTo);
// publish IDE interface
- IDEWebChannelWrapper ideWrapper{win->helpBrowserDocklet()->browser()};
+ IDEWebChannelWrapper ideWrapper { win->helpBrowserDocklet()->browser() };
channel.registerObject("IDE", &ideWrapper);
return app.exec();
}
-bool SingleInstanceGuard::tryConnect(QStringList const & arguments)
-{
+bool SingleInstanceGuard::tryConnect(QStringList const& arguments) {
const int maxNumberOfInstances = 128;
if (!arguments.empty()) {
for (int socketID = 0; socketID != maxNumberOfInstances; ++socketID) {
QString serverName = QStringLiteral("SuperColliderIDE_Singleton_%1").arg(socketID);
- QSharedPointer<QLocalSocket> socket (new QLocalSocket(this));
+ QSharedPointer<QLocalSocket> socket(new QLocalSocket(this));
socket->connectToServer(serverName);
QStringList canonicalArguments;
return result;
}
-bool Main::openDocumentation(const QString & string)
-{
+bool Main::openDocumentation(const QString& string) {
QString symbol = string.trimmed();
if (symbol.isEmpty())
return false;
- HelpBrowserDocklet *helpDock = MainWindow::instance()->helpBrowserDocklet();
+ HelpBrowserDocklet* helpDock = MainWindow::instance()->helpBrowserDocklet();
helpDock->browser()->gotoHelpFor(symbol);
helpDock->focus();
return true;
}
-bool Main::openDocumentationForMethod(const QString & className, const QString & methodName)
-{
- HelpBrowserDocklet *helpDock = MainWindow::instance()->helpBrowserDocklet();
+bool Main::openDocumentationForMethod(const QString& className, const QString& methodName) {
+ HelpBrowserDocklet* helpDock = MainWindow::instance()->helpBrowserDocklet();
helpDock->browser()->gotoHelpForMethod(className, methodName);
helpDock->focus();
return true;
}
-void Main::openDefinition(const QString &string, QWidget * parent)
-{
+void Main::openDefinition(const QString& string, QWidget* parent) {
QString definitionString = string.trimmed();
LookupDialog dialog(parent);
parseClassNode(node->children[i], str);
}
-void AutoCompleter::gotoHelp(QString symbol)
-{
- HelpBrowserDocklet *helpDock = MainWindow::instance()->helpBrowserDocklet();
+void AutoCompleter::gotoHelp(QString symbol) {
+ HelpBrowserDocklet* helpDock = MainWindow::instance()->helpBrowserDocklet();
helpDock->browser()->gotoHelpFor(symbol);
helpDock->focus();
}
#include <QKeyEvent>
#ifdef Q_OS_MAC
-# include <QStyleFactory> // QStyleFactory::create, see below
+# include <QStyleFactory> // QStyleFactory::create, see below
#endif
namespace ScIDE {
-HelpWebPage::HelpWebPage(HelpBrowser* browser)
- : WebPage(browser), mBrowser(browser)
-{
+HelpWebPage::HelpWebPage(HelpBrowser* browser): WebPage(browser), mBrowser(browser) {
setDelegateNavigation(true);
- connect( this, SIGNAL(navigationRequested(const QUrl &, QWebEnginePage::NavigationType, bool)),
- browser, SLOT(onLinkClicked(const QUrl &, QWebEnginePage::NavigationType, bool)) );
+ connect(this, SIGNAL(navigationRequested(const QUrl&, QWebEnginePage::NavigationType, bool)), browser,
+ SLOT(onLinkClicked(const QUrl&, QWebEnginePage::NavigationType, bool)));
}
-HelpBrowser::HelpBrowser( QWidget * parent ):
- QWidget(parent)
-{
+HelpBrowser::HelpBrowser(QWidget* parent): QWidget(parent) {
QRect availableScreenRect = qApp->desktop()->availableGeometry(this);
- mSizeHint = QSize( availableScreenRect.width() * 0.4, availableScreenRect.height() * 0.7 );
+ mSizeHint = QSize(availableScreenRect.width() * 0.4, availableScreenRect.height() * 0.7);
- HelpWebPage *webPage = new HelpWebPage(this);
+ HelpWebPage* webPage = new HelpWebPage(this);
webPage->setDelegateReload(true);
mWebView = new QWebEngineView;
// setPage does not take ownership of webPage; it must be deleted manually later (see below)
- mWebView->setPage( webPage );
- mWebView->settings()->setAttribute( QWebEngineSettings::LocalStorageEnabled, true );
- mWebView->setContextMenuPolicy( Qt::CustomContextMenu );
+ mWebView->setPage(webPage);
+ mWebView->settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
+ mWebView->setContextMenuPolicy(Qt::CustomContextMenu);
// Set the style's standard palette to avoid system's palette incoherencies
// get in the way of rendering web pages
- mWebView->setPalette( style()->standardPalette() );
+ mWebView->setPalette(style()->standardPalette());
#ifdef Q_OS_MAC
// On macOS, checkboxes unwantedly appear in the top left-hand corner.
// See QTBUG-43366, 43070, and 42948. The workaround is to set style to fusion.
- mWebView->setStyle( QStyleFactory::create("Fusion") );
+ mWebView->setStyle(QStyleFactory::create("Fusion"));
#endif
mWebView->installEventFilter(this);
namespace ScIDE {
-GenericLookupDialog::GenericLookupDialog( QWidget * parent ):
- QDialog(parent)
-{
+GenericLookupDialog::GenericLookupDialog(QWidget* parent): QDialog(parent) {
addAction(MainWindow::instance()->action(MainWindow::LookupDocumentationForCursor));
mQueryEdit = new QLineEdit(this);
mHelpBrowserDocklet = new HelpBrowserDocklet(this);
mHelpBrowserDocklet->setObjectName("help-dock");
addDockWidget(Qt::RightDockWidgetArea, mHelpBrowserDocklet->dockWidget());
- //mHelpBrowserDockable->hide();
+ // mHelpBrowserDockable->hide();
mPostDocklet = new PostDocklet(this);
mPostDocklet->setObjectName("post-dock");
addDockWidget(Qt::RightDockWidgetArea, mPostDocklet->dockWidget());
// Layout
- QVBoxLayout *center_box = new QVBoxLayout;
- center_box->setContentsMargins(0,0,0,0);
+ QVBoxLayout* center_box = new QVBoxLayout;
+ center_box->setContentsMargins(0, 0, 0, 0);
center_box->setSpacing(0);
center_box->addWidget(mEditors);
center_box->addWidget(mToolBox);
- QWidget *central = new QWidget;
+ QWidget* central = new QWidget;
central->setLayout(center_box);
setCentralWidget(central);
// Session management
- connect(main->sessionManager(), SIGNAL(saveSessionRequest(Session*)),
- this, SLOT(saveSession(Session*)));
- connect(main->sessionManager(), SIGNAL(switchSessionRequest(Session*)),
- this, SLOT(switchSession(Session*)));
- connect(main->sessionManager(), SIGNAL(currentSessionNameChanged()),
- this, SLOT(updateWindowTitle()));
+ connect(main->sessionManager(), SIGNAL(saveSessionRequest(Session*)), this, SLOT(saveSession(Session*)));
+ connect(main->sessionManager(), SIGNAL(switchSessionRequest(Session*)), this, SLOT(switchSession(Session*)));
+ connect(main->sessionManager(), SIGNAL(currentSessionNameChanged()), this, SLOT(updateWindowTitle()));
// A system for easy evaluation of pre-defined code:
- connect(&mCodeEvalMapper, SIGNAL(mapped(QString)),
- this, SIGNAL(evaluateCode(QString)));
- connect(this, SIGNAL(evaluateCode(QString,bool)),
- main->scProcess(), SLOT(evaluateCode(QString,bool)));
+ connect(&mCodeEvalMapper, SIGNAL(mapped(QString)), this, SIGNAL(evaluateCode(QString)));
+ connect(this, SIGNAL(evaluateCode(QString, bool)), main->scProcess(), SLOT(evaluateCode(QString, bool)));
// Interpreter: post output
- connect(main->scProcess(), SIGNAL( scPost(QString) ),
- mPostDocklet->mPostWindow, SLOT( post(QString) ) );
+ connect(main->scProcess(), SIGNAL(scPost(QString)), mPostDocklet->mPostWindow, SLOT(post(QString)));
// Interpreter: monitor running state
- connect(main->scProcess(), SIGNAL( stateChanged(QProcess::ProcessState) ),
- this, SLOT( onInterpreterStateChanged(QProcess::ProcessState) ) );
+ connect(main->scProcess(), SIGNAL(stateChanged(QProcess::ProcessState)), this,
+ SLOT(onInterpreterStateChanged(QProcess::ProcessState)));
// Interpreter: forward status messages
- connect(main->scProcess(), SIGNAL(statusMessage(const QString&)),
- this, SLOT(showStatusMessage(const QString&)));
+ connect(main->scProcess(), SIGNAL(statusMessage(const QString&)), this, SLOT(showStatusMessage(const QString&)));
// Document list interaction
- connect(mDocumentsDocklet->list(), SIGNAL(clicked(Document*)),
- mEditors, SLOT(setCurrent(Document*)));
- connect(mEditors, SIGNAL(currentDocumentChanged(Document*)),
- mDocumentsDocklet->list(), SLOT(setCurrent(Document*)),
- Qt::QueuedConnection);
- connect(mDocumentsDocklet->list(), SIGNAL(updateTabsOrder(QList<Document*>)),
- mEditors, SLOT(updateTabsOrder(QList<Document*>)));
- connect(mEditors, SIGNAL(updateDockletOrder(int, int)),
- mDocumentsDocklet->list(), SLOT(updateDockletOrder(int, int)),
+ connect(mDocumentsDocklet->list(), SIGNAL(clicked(Document*)), mEditors, SLOT(setCurrent(Document*)));
+ connect(mEditors, SIGNAL(currentDocumentChanged(Document*)), mDocumentsDocklet->list(), SLOT(setCurrent(Document*)),
Qt::QueuedConnection);
+ connect(mDocumentsDocklet->list(), SIGNAL(updateTabsOrder(QList<Document*>)), mEditors,
+ SLOT(updateTabsOrder(QList<Document*>)));
+ connect(mEditors, SIGNAL(updateDockletOrder(int, int)), mDocumentsDocklet->list(),
+ SLOT(updateDockletOrder(int, int)), Qt::QueuedConnection);
// Update actions on document change
- connect(mEditors, SIGNAL(currentDocumentChanged(Document*)),
- this, SLOT(onCurrentDocumentChanged(Document*)));
+ connect(mEditors, SIGNAL(currentDocumentChanged(Document*)), this, SLOT(onCurrentDocumentChanged(Document*)));
// Document management
- DocumentManager *docMng = main->documentManager();
- connect(docMng, SIGNAL(changedExternally(Document*)),
- this, SLOT(onDocumentChangedExternally(Document*)));
- connect(docMng, SIGNAL(recentsChanged()),
- this, SLOT(updateRecentDocsMenu()));
- connect(docMng, SIGNAL(saved(Document*)), this, SLOT(updateWindowTitle()) );
- connect(docMng, SIGNAL(titleChanged(Document*)), this, SLOT(updateWindowTitle()) );
-
- connect(main, SIGNAL(applySettingsRequest(Settings::Manager*)),
- this, SLOT(applySettings(Settings::Manager*)));
- connect(main, SIGNAL(storeSettingsRequest(Settings::Manager*)),
- this, SLOT(storeSettings(Settings::Manager*)));
+ DocumentManager* docMng = main->documentManager();
+ connect(docMng, SIGNAL(changedExternally(Document*)), this, SLOT(onDocumentChangedExternally(Document*)));
+ connect(docMng, SIGNAL(recentsChanged()), this, SLOT(updateRecentDocsMenu()));
+ connect(docMng, SIGNAL(saved(Document*)), this, SLOT(updateWindowTitle()));
+ connect(docMng, SIGNAL(titleChanged(Document*)), this, SLOT(updateWindowTitle()));
+
+ connect(main, SIGNAL(applySettingsRequest(Settings::Manager*)), this, SLOT(applySettings(Settings::Manager*)));
+ connect(main, SIGNAL(storeSettingsRequest(Settings::Manager*)), this, SLOT(storeSettings(Settings::Manager*)));
// ToolBox
connect(mToolBox->closeButton(), SIGNAL(clicked()), this, SLOT(hideToolBox()));
#endif
action->setStatusTip(tr("Show configuration dialog"));
connect(action, SIGNAL(triggered()), this, SLOT(showSettings()));
- settings->addAction( action, "ide-settings-dialog", ideCategory);
+ settings->addAction(action, "ide-settings-dialog", ideCategory);
// Help
mActions[Help] = action = new QAction(tr("Show &Help Browser"), this);
action->setStatusTip(tr("Show and focus the Help Browser"));
connect(action, SIGNAL(triggered()), this, SLOT(openHelp()));
- settings->addAction( action, "help-browser", helpCategory);
+ settings->addAction(action, "help-browser", helpCategory);
- mActions[HelpAboutIDE] = action =
- new QAction(QIcon::fromTheme("system-help"), tr("How to Use SuperCollider IDE"), this);
+ mActions[HelpAboutIDE] = action =
+ new QAction(QIcon::fromTheme("system-help"), tr("How to Use SuperCollider IDE"), this);
action->setStatusTip(tr("Open the SuperCollider IDE guide"));
connect(action, SIGNAL(triggered()), this, SLOT(openHelpAboutIDE()));
- mActions[ReportABug] = action =
- new QAction(QIcon::fromTheme("system-help"), tr("Report a bug..."), this);
+ mActions[ReportABug] = action = new QAction(QIcon::fromTheme("system-help"), tr("Report a bug..."), this);
action->setStatusTip(tr("Report a bug"));
connect(action, SIGNAL(triggered()), this, SLOT(doBugReport()));
-
- mActions[LookupDocumentationForCursor] = action =
- new QAction(tr("Look Up Documentation for Cursor"), this);
+
+ mActions[LookupDocumentationForCursor] = action = new QAction(tr("Look Up Documentation for Cursor"), this);
action->setShortcut(tr("Ctrl+D", "Look Up Documentation for Cursor"));
action->setStatusTip(tr("Look up documentation for text under cursor"));
connect(action, SIGNAL(triggered()), this, SLOT(lookupDocumentationForCursor()));
- settings->addAction( action, "help-lookup-for-cursor", helpCategory);
+ settings->addAction(action, "help-lookup-for-cursor", helpCategory);
- mActions[LookupDocumentation] = action =
- new QAction(tr("Look Up Documentation..."), this);
+ mActions[LookupDocumentation] = action = new QAction(tr("Look Up Documentation..."), this);
action->setShortcut(tr("Ctrl+Shift+D", "Look Up Documentation"));
action->setStatusTip(tr("Enter text to look up in documentation"));
connect(action, SIGNAL(triggered()), this, SLOT(lookupDocumentation()));
- settings->addAction( action, "help-lookup", helpCategory);
+ settings->addAction(action, "help-lookup", helpCategory);
- mActions[ShowAbout] = action = new QAction(
- QIcon::fromTheme("help-about"), tr("&About SuperCollider"), this);
+ mActions[ShowAbout] = action = new QAction(QIcon::fromTheme("help-about"), tr("&About SuperCollider"), this);
connect(action, SIGNAL(triggered()), this, SLOT(showAbout()));
- settings->addAction( action, "ide-about", ideCategory);
+ settings->addAction(action, "ide-about", ideCategory);
- mActions[ShowAboutQT] = action = new QAction(
- QIcon::fromTheme("show-about-qt"), tr("About &Qt"), this);
+ mActions[ShowAboutQT] = action = new QAction(QIcon::fromTheme("show-about-qt"), tr("About &Qt"), this);
connect(action, SIGNAL(triggered()), this, SLOT(showAboutQT()));
- settings->addAction( action, "ide-about-qt", ideCategory);
+ settings->addAction(action, "ide-about-qt", ideCategory);
// Add external actions to settings:
action = mPostDocklet->toggleViewAction();
- action->setIcon( QIcon::fromTheme("utilities-terminal"));
+ action->setIcon(QIcon::fromTheme("utilities-terminal"));
action->setStatusTip(tr("Show/hide Post docklet"));
- settings->addAction( mPostDocklet->toggleViewAction(),
- "ide-docklet-post", ideCategory );
+ settings->addAction(mPostDocklet->toggleViewAction(), "ide-docklet-post", ideCategory);
action = mDocumentsDocklet->toggleViewAction();
- action->setIcon( QIcon::fromTheme("text-x-generic") );
+ action->setIcon(QIcon::fromTheme("text-x-generic"));
action->setStatusTip(tr("Show/hide Documents docklet"));
- settings->addAction( mDocumentsDocklet->toggleViewAction(),
- "ide-docklet-documents", ideCategory );
+ settings->addAction(mDocumentsDocklet->toggleViewAction(), "ide-docklet-documents", ideCategory);
action = mHelpBrowserDocklet->toggleViewAction();
- action->setIcon( QIcon::fromTheme("system-help") );
+ action->setIcon(QIcon::fromTheme("system-help"));
action->setStatusTip(tr("Show/hide Help browser docklet"));
- settings->addAction( mHelpBrowserDocklet->toggleViewAction(),
- "ide-docklet-help", ideCategory );
+ settings->addAction(mHelpBrowserDocklet->toggleViewAction(), "ide-docklet-help", ideCategory);
// In Mac OS, all menu item shortcuts need a modifier, so add the action with
// the "Escape" default shortcut to the main window widget.
// FIXME: This is not perfect, as any other action customized to "Escape" will
// still not work.
- addAction( mActions[CloseToolBox] );
+ addAction(mActions[CloseToolBox]);
// Add actions to docklets, so shortcuts work when docklets detached:
mHelpBrowserDocklet->widget()->addAction(mActions[LookupImplementationForCursor]);
mHelpBrowserDocklet->widget()->addAction(mActions[LookupReferences]);
mHelpBrowserDocklet->widget()->addAction(mActions[LookupReferencesForCursor]);
-
}
-void MainWindow::createMenus()
-{
- QMenuBar *menuBar;
- QMenu *menu;
- QMenu *submenu;
+void MainWindow::createMenus() {
+ QMenuBar* menuBar;
+ QMenu* menu;
+ QMenu* submenu;
// On Mac, create a parent-less menu bar to be shared by all windows:
#ifdef Q_OS_MAC
#endif
menu = new QMenu(tr("&File"), this);
- menu->addAction( mActions[DocNew] );
- menu->addAction( mActions[DocOpen] );
+ menu->addAction(mActions[DocNew]);
+ menu->addAction(mActions[DocOpen]);
mRecentDocsMenu = menu->addMenu(tr("Open Recent", "Open a recent document"));
- connect(mRecentDocsMenu, SIGNAL(triggered(QAction*)),
- this, SLOT(onOpenRecentDocument(QAction*)));
- menu->addAction( mActions[DocOpenStartup] );
- menu->addAction( mActions[DocOpenSupportDir] );
- menu->addAction( mActions[DocSave] );
- menu->addAction( mActions[DocSaveAs] );
- menu->addAction( mActions[DocSaveAsExtension] );
- menu->addAction( mActions[DocSaveAll] );
+ connect(mRecentDocsMenu, SIGNAL(triggered(QAction*)), this, SLOT(onOpenRecentDocument(QAction*)));
+ menu->addAction(mActions[DocOpenStartup]);
+ menu->addAction(mActions[DocOpenSupportDir]);
+ menu->addAction(mActions[DocSave]);
+ menu->addAction(mActions[DocSaveAs]);
+ menu->addAction(mActions[DocSaveAsExtension]);
+ menu->addAction(mActions[DocSaveAll]);
menu->addSeparator();
- menu->addAction( mActions[DocReload] );
+ menu->addAction(mActions[DocReload]);
menu->addSeparator();
- menu->addAction( mEditors->action(MultiEditor::DocClose) );
- menu->addAction( mActions[DocCloseAll] );
+ menu->addAction(mEditors->action(MultiEditor::DocClose));
+ menu->addAction(mActions[DocCloseAll]);
menu->addSeparator();
- menu->addAction( mActions[Quit] );
+ menu->addAction(mActions[Quit]);
menuBar->addMenu(menu);
menu = new QMenu(tr("&Session"), this);
- menu->addAction( mActions[NewSession] );
- menu->addAction( mActions[SaveSessionAs] );
+ menu->addAction(mActions[NewSession]);
+ menu->addAction(mActions[SaveSessionAs]);
submenu = menu->addMenu(tr("&Open Session"));
- connect(submenu, SIGNAL(triggered(QAction*)),
- this, SLOT(onOpenSessionAction(QAction*)));
+ connect(submenu, SIGNAL(triggered(QAction*)), this, SLOT(onOpenSessionAction(QAction*)));
mSessionsMenu = submenu;
updateSessionsMenu();
menu->addSeparator();
- menu->addAction( mActions[ManageSessions] );
- menu->addAction( mActions[OpenSessionSwitchDialog] );
+ menu->addAction(mActions[ManageSessions]);
+ menu->addAction(mActions[OpenSessionSwitchDialog]);
menuBar->addMenu(menu);
menu = new QMenu(tr("&Edit"), this);
- menu->addAction( mEditors->action(MultiEditor::Undo) );
- menu->addAction( mEditors->action(MultiEditor::Redo) );
+ menu->addAction(mEditors->action(MultiEditor::Undo));
+ menu->addAction(mEditors->action(MultiEditor::Redo));
menu->addSeparator();
- menu->addAction( mEditors->action(MultiEditor::Cut) );
- menu->addAction( mEditors->action(MultiEditor::Copy) );
- menu->addAction( mEditors->action(MultiEditor::Paste) );
+ menu->addAction(mEditors->action(MultiEditor::Cut));
+ menu->addAction(mEditors->action(MultiEditor::Copy));
+ menu->addAction(mEditors->action(MultiEditor::Paste));
menu->addSeparator();
- menu->addAction( mActions[Find] );
- menu->addAction( mFindReplaceTool->action(TextFindReplacePanel::FindNext) );
- menu->addAction( mFindReplaceTool->action(TextFindReplacePanel::FindPrevious) );
- menu->addAction( mActions[Replace] );
+ menu->addAction(mActions[Find]);
+ menu->addAction(mFindReplaceTool->action(TextFindReplacePanel::FindNext));
+ menu->addAction(mFindReplaceTool->action(TextFindReplacePanel::FindPrevious));
+ menu->addAction(mActions[Replace]);
menu->addSeparator();
- menu->addAction( mEditors->action(MultiEditor::IndentWithSpaces) );
- menu->addAction( mEditors->action(MultiEditor::IndentLineOrRegion) );
- menu->addAction( mEditors->action(MultiEditor::ToggleComment) );
- menu->addAction( mEditors->action(MultiEditor::ToggleOverwriteMode) );
- menu->addAction( mEditors->action(MultiEditor::SelectRegion) );
- menu->addAction( mEditors->action(MultiEditor::SelectEnclosingBlock) );
+ menu->addAction(mEditors->action(MultiEditor::IndentWithSpaces));
+ menu->addAction(mEditors->action(MultiEditor::IndentLineOrRegion));
+ menu->addAction(mEditors->action(MultiEditor::ToggleComment));
+ menu->addAction(mEditors->action(MultiEditor::ToggleOverwriteMode));
+ menu->addAction(mEditors->action(MultiEditor::SelectRegion));
+ menu->addAction(mEditors->action(MultiEditor::SelectEnclosingBlock));
menu->addSeparator();
- menu->addAction( mActions[ShowSettings] );
+ menu->addAction(mActions[ShowSettings]);
menuBar->addMenu(menu);
menu = new QMenu(tr("&View"), this);
submenu = new QMenu(tr("&Docklets"), this);
- submenu->addAction( mPostDocklet->toggleViewAction() );
- submenu->addAction( mDocumentsDocklet->toggleViewAction() );
- submenu->addAction( mHelpBrowserDocklet->toggleViewAction() );
+ submenu->addAction(mPostDocklet->toggleViewAction());
+ submenu->addAction(mDocumentsDocklet->toggleViewAction());
+ submenu->addAction(mHelpBrowserDocklet->toggleViewAction());
menu->addMenu(submenu);
menu->addSeparator();
submenu = menu->addMenu(tr("&Tool Panels"));
- submenu->addAction( mActions[Find] );
- submenu->addAction( mActions[Replace] );
- submenu->addAction( mActions[ShowCmdLine] );
- submenu->addAction( mActions[CmdLineForCursor] );
- submenu->addAction( mActions[ShowGoToLineTool] );
+ submenu->addAction(mActions[Find]);
+ submenu->addAction(mActions[Replace]);
+ submenu->addAction(mActions[ShowCmdLine]);
+ submenu->addAction(mActions[CmdLineForCursor]);
+ submenu->addAction(mActions[ShowGoToLineTool]);
submenu->addSeparator();
- submenu->addAction( mActions[CloseToolBox] );
+ submenu->addAction(mActions[CloseToolBox]);
menu->addSeparator();
- menu->addAction( mEditors->action(MultiEditor::EnlargeFont) );
- menu->addAction( mEditors->action(MultiEditor::ShrinkFont) );
- menu->addAction( mEditors->action(MultiEditor::ResetFontSize) );
+ menu->addAction(mEditors->action(MultiEditor::EnlargeFont));
+ menu->addAction(mEditors->action(MultiEditor::ShrinkFont));
+ menu->addAction(mEditors->action(MultiEditor::ResetFontSize));
menu->addSeparator();
- menu->addAction( mEditors->action(MultiEditor::ShowWhitespace) );
- menu->addAction( mEditors->action(MultiEditor::ShowLinenumber) );
+ menu->addAction(mEditors->action(MultiEditor::ShowWhitespace));
+ menu->addAction(mEditors->action(MultiEditor::ShowLinenumber));
menu->addSeparator();
menu->addAction(mEditors->action(MultiEditor::ShowAutocompleteHelp));
menu->addSeparator();
- menu->addAction( mEditors->action(MultiEditor::NextDocument) );
- menu->addAction( mEditors->action(MultiEditor::PreviousDocument) );
- menu->addAction( mEditors->action(MultiEditor::SwitchDocument) );
+ menu->addAction(mEditors->action(MultiEditor::NextDocument));
+ menu->addAction(mEditors->action(MultiEditor::PreviousDocument));
+ menu->addAction(mEditors->action(MultiEditor::SwitchDocument));
menu->addSeparator();
- menu->addAction( mEditors->action(MultiEditor::SplitHorizontally) );
- menu->addAction( mEditors->action(MultiEditor::SplitVertically) );
- menu->addAction( mEditors->action(MultiEditor::RemoveCurrentSplit) );
- menu->addAction( mEditors->action(MultiEditor::RemoveAllSplits) );
+ menu->addAction(mEditors->action(MultiEditor::SplitHorizontally));
+ menu->addAction(mEditors->action(MultiEditor::SplitVertically));
+ menu->addAction(mEditors->action(MultiEditor::RemoveCurrentSplit));
+ menu->addAction(mEditors->action(MultiEditor::RemoveAllSplits));
menu->addSeparator();
- menu->addAction( mActions[FocusPostWindow] );
+ menu->addAction(mActions[FocusPostWindow]);
menuBar->addMenu(menu);
menu = new QMenu(tr("&Language"), this);
- menu->addAction( mMain->scProcess()->action(ScProcess::ToggleRunning) );
- menu->addAction( mMain->scProcess()->action(ScProcess::Restart) );
- menu->addAction( mMain->scProcess()->action(ScProcess::RecompileClassLibrary) );
+ menu->addAction(mMain->scProcess()->action(ScProcess::ToggleRunning));
+ menu->addAction(mMain->scProcess()->action(ScProcess::Restart));
+ menu->addAction(mMain->scProcess()->action(ScProcess::RecompileClassLibrary));
menu->addSeparator();
- menu->addAction( mMain->scProcess()->action(ScProcess::ShowQuarks) );
+ menu->addAction(mMain->scProcess()->action(ScProcess::ShowQuarks));
menu->addSeparator();
- menu->addAction( mEditors->action(MultiEditor::EvaluateCurrentDocument) );
- menu->addAction( mEditors->action(MultiEditor::EvaluateRegion) );
- menu->addAction( mEditors->action(MultiEditor::EvaluateLine) );
- menu->addAction( mMain->scProcess()->action(ScIDE::ScProcess::StopMain) );
+ menu->addAction(mEditors->action(MultiEditor::EvaluateCurrentDocument));
+ menu->addAction(mEditors->action(MultiEditor::EvaluateRegion));
+ menu->addAction(mEditors->action(MultiEditor::EvaluateLine));
+ menu->addAction(mMain->scProcess()->action(ScIDE::ScProcess::StopMain));
menu->addSeparator();
- menu->addAction( mActions[LookupImplementationForCursor] );
- menu->addAction( mActions[LookupImplementation] );
- menu->addAction( mActions[LookupReferencesForCursor] );
- menu->addAction( mActions[LookupReferences] );
+ menu->addAction(mActions[LookupImplementationForCursor]);
+ menu->addAction(mActions[LookupImplementation]);
+ menu->addAction(mActions[LookupReferencesForCursor]);
+ menu->addAction(mActions[LookupReferences]);
menuBar->addMenu(menu);
menu = new QMenu(tr("Se&rver"), this);
- menu->addAction( mMain->scServer()->action(ScServer::ToggleRunning) );
- menu->addAction( mMain->scServer()->action(ScServer::Reboot) );
- menu->addAction( mMain->scServer()->action(ScServer::KillAll) );
+ menu->addAction(mMain->scServer()->action(ScServer::ToggleRunning));
+ menu->addAction(mMain->scServer()->action(ScServer::Reboot));
+ menu->addAction(mMain->scServer()->action(ScServer::KillAll));
menu->addSeparator();
- menu->addAction( mMain->scServer()->action(ScServer::ShowMeters) );
- menu->addAction( mMain->scServer()->action(ScServer::ShowScope) );
- menu->addAction( mMain->scServer()->action(ScServer::ShowFreqScope) );
- menu->addAction( mMain->scServer()->action(ScServer::DumpNodeTree) );
- menu->addAction( mMain->scServer()->action(ScServer::DumpNodeTreeWithControls) );
- menu->addAction( mMain->scServer()->action(ScServer::PlotTree) );
- menu->addAction( mMain->scServer()->action(ScServer::DumpOSC) );
- menu->addAction( mMain->scServer()->action(ScServer::Record) );
- menu->addAction( mMain->scServer()->action(ScServer::PauseRecord) );
- menu->addAction( mMain->scServer()->action(ScServer::VolumeUp) );
- menu->addAction( mMain->scServer()->action(ScServer::VolumeDown) );
- menu->addAction( mMain->scServer()->action(ScServer::VolumeRestore) );
- menu->addAction( mMain->scServer()->action(ScServer::Mute) );
+ menu->addAction(mMain->scServer()->action(ScServer::ShowMeters));
+ menu->addAction(mMain->scServer()->action(ScServer::ShowScope));
+ menu->addAction(mMain->scServer()->action(ScServer::ShowFreqScope));
+ menu->addAction(mMain->scServer()->action(ScServer::DumpNodeTree));
+ menu->addAction(mMain->scServer()->action(ScServer::DumpNodeTreeWithControls));
+ menu->addAction(mMain->scServer()->action(ScServer::PlotTree));
+ menu->addAction(mMain->scServer()->action(ScServer::DumpOSC));
+ menu->addAction(mMain->scServer()->action(ScServer::Record));
+ menu->addAction(mMain->scServer()->action(ScServer::PauseRecord));
+ menu->addAction(mMain->scServer()->action(ScServer::VolumeUp));
+ menu->addAction(mMain->scServer()->action(ScServer::VolumeDown));
+ menu->addAction(mMain->scServer()->action(ScServer::VolumeRestore));
+ menu->addAction(mMain->scServer()->action(ScServer::Mute));
menuBar->addMenu(menu);
menu = new QMenu(tr("&Help"), this);
- menu->addAction( mActions[HelpAboutIDE] );
- menu->addAction( mActions[ReportABug] );
+ menu->addAction(mActions[HelpAboutIDE]);
+ menu->addAction(mActions[ReportABug]);
menu->addSeparator();
- menu->addAction( mActions[Help] );
- menu->addAction( mActions[LookupDocumentationForCursor] );
- menu->addAction( mActions[LookupDocumentation] );
+ menu->addAction(mActions[Help]);
+ menu->addAction(mActions[LookupDocumentationForCursor]);
+ menu->addAction(mActions[LookupDocumentation]);
menu->addSeparator();
- menu->addAction( mActions[ShowAbout] );
- menu->addAction( mActions[ShowAboutQT] );
+ menu->addAction(mActions[ShowAbout]);
+ menu->addAction(mActions[ShowAboutQT]);
menuBar->addMenu(menu);
}
-static void saveDetachedState( Docklet *docklet, QVariantMap & data )
-{
- data.insert( docklet->objectName(), docklet->saveDetachedState().toBase64() );
+static void saveDetachedState(Docklet* docklet, QVariantMap& data) {
+ data.insert(docklet->objectName(), docklet->saveDetachedState().toBase64());
}
-template <class T>
-void MainWindow::saveWindowState(T * settings)
-{
+template <class T> void MainWindow::saveWindowState(T* settings) {
QVariantMap detachedData;
- saveDetachedState( mPostDocklet, detachedData );
- saveDetachedState( mDocumentsDocklet, detachedData );
- saveDetachedState( mHelpBrowserDocklet, detachedData );
+ saveDetachedState(mPostDocklet, detachedData);
+ saveDetachedState(mDocumentsDocklet, detachedData);
+ saveDetachedState(mHelpBrowserDocklet, detachedData);
settings->beginGroup("mainWindow");
settings->setValue("geometry", this->saveGeometry().toBase64());
QVariant varDetached = settings->value("detached");
settings->endGroup();
- QByteArray geom = QByteArray::fromBase64( varGeom.value<QByteArray>() );
- QByteArray state = QByteArray::fromBase64( varState.value<QByteArray>() );
+ QByteArray geom = QByteArray::fromBase64(varGeom.value<QByteArray>());
+ QByteArray state = QByteArray::fromBase64(varState.value<QByteArray>());
QVariantMap detachedData = varDetached.value<QVariantMap>();
if (!geom.isEmpty()) {
// Workaround for Qt bug 4397:
setWindowState(Qt::WindowNoState);
restoreGeometry(geom);
- }
- else
- setWindowState( windowState() & ~Qt::WindowFullScreen | Qt::WindowMaximized );
+ } else
+ setWindowState(windowState() & ~Qt::WindowFullScreen | Qt::WindowMaximized);
- restoreDetachedState( mPostDocklet, detachedData );
- restoreDetachedState( mDocumentsDocklet, detachedData );
- restoreDetachedState( mHelpBrowserDocklet, detachedData );
+ restoreDetachedState(mPostDocklet, detachedData);
+ restoreDetachedState(mDocumentsDocklet, detachedData);
+ restoreDetachedState(mHelpBrowserDocklet, detachedData);
qDebug("restoring state");
}
}
-void MainWindow::openSession(const QString &sessionName)
-{
- mMain->sessionManager()->openSession( sessionName );
-}
+void MainWindow::openSession(const QString& sessionName) { mMain->sessionManager()->openSession(sessionName); }
-void MainWindow::lookupImplementationForCursor()
-{
+void MainWindow::lookupImplementationForCursor() {
static const QByteArray signature = QMetaObject::normalizedSignature("openDefinition()");
invokeMethodOnFirstResponder(signature);
}
-void MainWindow::lookupImplementation()
-{
- Main::openDefinition(QString(), QApplication::activeWindow());
-}
+void MainWindow::lookupImplementation() { Main::openDefinition(QString(), QApplication::activeWindow()); }
-void MainWindow::lookupReferencesForCursor()
-{
+void MainWindow::lookupReferencesForCursor() {
static const QByteArray signature = QMetaObject::normalizedSignature("findReferences()");
invokeMethodOnFirstResponder(signature);
}
-void MainWindow::lookupReferences()
-{
- Main::findReferences(QString(), QApplication::activeWindow());
-}
+void MainWindow::lookupReferences() { Main::findReferences(QString(), QApplication::activeWindow()); }
-void MainWindow::showStatusMessage( QString const & string )
-{
- mStatusBar->showMessage(string, 3000);
-}
+void MainWindow::showStatusMessage(QString const& string) { mStatusBar->showMessage(string, 3000); }
-void MainWindow::applySettings( Settings::Manager * settings )
-{
- applyCursorBlinkingSettings( settings );
+void MainWindow::applySettings(Settings::Manager* settings) {
+ applyCursorBlinkingSettings(settings);
mPostDocklet->mPostWindow->applySettings(settings);
mHelpBrowserDocklet->browser()->applySettings(settings);
mCmdLine->applySettings(settings);
}
-void MainWindow::applyCursorBlinkingSettings( Settings::Manager * settings )
-{
+void MainWindow::applyCursorBlinkingSettings(Settings::Manager* settings) {
const bool disableBlinkingCursor = settings->value("IDE/editor/disableBlinkingCursor").toBool();
const int defaultCursorFlashTime = settings->defaultCursorFlashTime();
- QApplication::setCursorFlashTime( disableBlinkingCursor ? 0 : defaultCursorFlashTime );
+ QApplication::setCursorFlashTime(disableBlinkingCursor ? 0 : defaultCursorFlashTime);
}
-void MainWindow::storeSettings( Settings::Manager * settings )
-{
- mPostDocklet->mPostWindow->storeSettings(settings);
-}
+void MainWindow::storeSettings(Settings::Manager* settings) { mPostDocklet->mPostWindow->storeSettings(settings); }
-void MainWindow::updateSessionsMenu()
-{
+void MainWindow::updateSessionsMenu() {
mSessionsMenu->clear();
QStringList sessions = mMain->sessionManager()->availableSessions();
- foreach (const QString & session, sessions)
- mSessionsMenu->addAction( session );
+ foreach (const QString& session, sessions)
+ mSessionsMenu->addAction(session);
}
-void MainWindow::showSwitchSessionDialog()
-{
- SessionSwitchDialog * dialog = new SessionSwitchDialog(this);
+void MainWindow::showSwitchSessionDialog() {
+ SessionSwitchDialog* dialog = new SessionSwitchDialog(this);
int result = dialog->exec();
if (result == QDialog::Accepted)
delete dialog;
}
-void MainWindow::lookupDocumentationForCursor()
-{
+void MainWindow::lookupDocumentationForCursor() {
static const QByteArray signature = QMetaObject::normalizedSignature("openDocumentation()");
bool documentationOpened = false;
- QWidget * widget = QApplication::focusWidget();
+ QWidget* widget = QApplication::focusWidget();
int methodIdx = -1;
- widget = findFirstResponder( widget, signature.constData(), methodIdx );
+ widget = findFirstResponder(widget, signature.constData(), methodIdx);
if (widget && methodIdx != -1) {
- widget->metaObject()->method(methodIdx).invoke(
- widget, Qt::DirectConnection,
- Q_RETURN_ARG(bool, documentationOpened) );
+ widget->metaObject()->method(methodIdx).invoke(widget, Qt::DirectConnection,
+ Q_RETURN_ARG(bool, documentationOpened));
};
if (!documentationOpened)
openHelp();
}
-void MainWindow::openHelp()
-{
+void MainWindow::openHelp() {
if (mHelpBrowserDocklet->browser()->url().isEmpty())
mHelpBrowserDocklet->browser()->goHome();
mHelpBrowserDocklet->focus();
}
-void MainWindow::openHelpAboutIDE()
-{
+void MainWindow::openHelpAboutIDE() {
mHelpBrowserDocklet->browser()->gotoHelpFor("Guides/SCIde");
mHelpBrowserDocklet->focus();
}
-
-void MainWindow::doBugReport()
-{
- Settings::Manager *settings = mMain->settings();
+
+void MainWindow::doBugReport() {
+ Settings::Manager* settings = mMain->settings();
bool useGitHubBugReport = false;
-
+
if (settings->contains("IDE/useGitHubBugReport")) {
-
useGitHubBugReport = settings->value("IDE/useGitHubBugReport").toBool();
-
+
} else {
-
QMessageBox* dialog = new QMessageBox();
dialog->setText("Do you want to submit bugs using <a href=\"https://www.github.com\">GitHub</a>?");
dialog->setInformativeText("This requires a GitHub account.");
void focusCodeEditor();
bool promptSaveDocs();
- HelpBrowserDocklet * helpBrowserDocklet() { return mHelpBrowserDocklet; }
- PostDocklet * postDocklet() { return mPostDocklet; }
+ HelpBrowserDocklet* helpBrowserDocklet() { return mHelpBrowserDocklet; }
+ PostDocklet* postDocklet() { return mPostDocklet; }
- static MainWindow *instance() { return mInstance; }
- Settings::Manager *setting();
+ static MainWindow* instance() { return mInstance; }
+ Settings::Manager* setting();
- static bool close( Document * );
- static bool save( Document *, bool forceChoose = false, bool saveInExtensionFolder = false );
- static bool reload( Document * );
+ static bool close(Document*);
+ static bool save(Document*, bool forceChoose = false, bool saveInExtensionFolder = false);
+ static bool reload(Document*);
void restoreDocuments();
void doBugReport();
void lookupDocumentationForCursor();
void lookupDocumentation();
- void applySettings( Settings::Manager * );
- void storeSettings( Settings::Manager * );
+ void applySettings(Settings::Manager*);
+ void storeSettings(Settings::Manager*);
void showSwitchSessionDialog();
void showAbout();
void showAboutQT();
void cmdLineForCursor();
protected:
- virtual void closeEvent(QCloseEvent *event);
- virtual void dragEnterEvent( QDragEnterEvent * );
- virtual void dropEvent( QDropEvent * );
- virtual bool eventFilter( QObject *, QEvent * );
+ virtual void closeEvent(QCloseEvent* event);
+ virtual void dragEnterEvent(QDragEnterEvent*);
+ virtual void dropEvent(QDropEvent*);
+ virtual bool eventFilter(QObject*, QEvent*);
private:
void createActions();
void createMenus();
- template <class T> void saveWindowState(T * settings);
- template <class T> void restoreWindowState(T * settings);
+ template <class T> void saveWindowState(T* settings);
+ template <class T> void restoreWindowState(T* settings);
void updateSessionsMenu();
- void updateClockWidget( bool isFullScreen );
- void openSession( QString const & sessionName );
- bool checkFileExtension( const QString & fpath );
- void toggleInterpreterActions( bool enabled);
- void applyCursorBlinkingSettings( Settings::Manager * );
+ void updateClockWidget(bool isFullScreen);
+ void openSession(QString const& sessionName);
+ bool checkFileExtension(const QString& fpath);
+ void toggleInterpreterActions(bool enabled);
+ void applyCursorBlinkingSettings(Settings::Manager*);
QString documentOpenPath() const;
- QString documentSavePath( Document * ) const;
+ QString documentSavePath(Document*) const;
- Main *mMain;
+ Main* mMain;
- QAction * mActions[ActionCount];
- QMenu * mRecentDocsMenu;
- QMenu * mSessionsMenu;
+ QAction* mActions[ActionCount];
+ QMenu* mRecentDocsMenu;
+ QMenu* mSessionsMenu;
- MultiEditor *mEditors;
+ MultiEditor* mEditors;
// Tools
- ToolBox *mToolBox;
- CmdLine *mCmdLine;
- GoToLineTool *mGoToLineTool;
- TextFindReplacePanel *mFindReplaceTool;
+ ToolBox* mToolBox;
+ CmdLine* mCmdLine;
+ GoToLineTool* mGoToLineTool;
+ TextFindReplacePanel* mFindReplaceTool;
// Status bar
- QStatusBar *mStatusBar;
- StatusBox *mLangStatus;
- StatusBox *mServerStatus;
- ClockStatusBox *mClockLabel;
+ QStatusBar* mStatusBar;
+ StatusBox* mLangStatus;
+ StatusBox* mServerStatus;
+ ClockStatusBox* mClockLabel;
// Docks
- PostDocklet * mPostDocklet;
- DocumentsDocklet *mDocumentsDocklet;
- HelpBrowserDocklet *mHelpBrowserDocklet;
+ PostDocklet* mPostDocklet;
+ DocumentsDocklet* mDocumentsDocklet;
+ HelpBrowserDocklet* mHelpBrowserDocklet;
QSignalMapper mCodeEvalMapper;
- DocumentsDialog * mDocDialog;
+ DocumentsDialog* mDocDialog;
QString mLastDocumentSavePath;
- static MainWindow *mInstance;
+ static MainWindow* mInstance;
};
-class ClockStatusBox : public StatusLabel
-{
+class ClockStatusBox : public StatusLabel {
public:
- ClockStatusBox (QWidget * parent = 0);
+ ClockStatusBox(QWidget* parent = 0);
~ClockStatusBox();
private:
- void timerEvent(QTimerEvent *);
+ void timerEvent(QTimerEvent*);
void updateTime();
int mTimerId;
};
if (qobject_cast<QDockWidget*>(widget)) {
return;
}
- if ( (qobject_cast<QTabBar*>(widget))
- || (qobject_cast<QToolButton*>(widget)) )
- {
+ if ((qobject_cast<QTabBar*>(widget)) || (qobject_cast<QToolButton*>(widget))) {
widget->setAttribute(Qt::WA_Hover, true);
- }
- else
+ } else
QProxyStyle::polish(widget);
-
}
-void Style::unpolish ( QWidget * widget )
-{
- QProxyStyle::unpolish(widget);
-}
+void Style::unpolish(QWidget* widget) { QProxyStyle::unpolish(widget); }
-void Style::drawComplexControl
-( ComplexControl control, const QStyleOptionComplex * option,
- QPainter * painter, const QWidget * widget ) const
-{
+void Style::drawComplexControl(ComplexControl control, const QStyleOptionComplex* option, QPainter* painter,
+ const QWidget* widget) const {
if (shouldNotHandle(widget)) {
QProxyStyle::drawComplexControl(control, option, painter, widget);
return;
}
- switch(control) {
+ switch (control) {
// FIXME: this is a workaround for the WebKit bug #104116 (or a variation on it).
- case QStyle::CC_ScrollBar:
- {
- if (qobject_cast<const QWebEngineView*>(widget) != 0 && option->type == QStyleOption::SO_Slider)
- {
+ case QStyle::CC_ScrollBar: {
+ if (qobject_cast<const QWebEngineView*>(widget) != 0 && option->type == QStyleOption::SO_Slider) {
// WebKit tries to hide scrollbars, but mistakenly hides QWebView - NULL-ify styleObject to prevent.
- const QStyleOptionSlider *optSlider = static_cast<const QStyleOptionSlider*>(option);
- QStyleOptionSlider opt2( *optSlider );
+ const QStyleOptionSlider* optSlider = static_cast<const QStyleOptionSlider*>(option);
+ QStyleOptionSlider opt2(*optSlider);
opt2.styleObject = NULL;
- QProxyStyle::drawComplexControl( control, &opt2, painter, widget );
+ QProxyStyle::drawComplexControl(control, &opt2, painter, widget);
return;
}
}
- case QStyle::CC_ToolButton:
- {
+ case QStyle::CC_ToolButton: {
// TODO: We only draw either text, or icon, or arrow
- const QToolButton *toolBtn = qobject_cast<const QToolButton*>(widget);
+ const QToolButton* toolBtn = qobject_cast<const QToolButton*>(widget);
if (!toolBtn)
break;
Q_ASSERT(toolBtn);
- const QStyleOptionToolButton *toolOption =
- static_cast<const QStyleOptionToolButton*>(option);
+ const QStyleOptionToolButton* toolOption = static_cast<const QStyleOptionToolButton*>(option);
painter->save();
QRect r = option->rect;
if (option->state & QStyle::State_On) {
- painter->setBrush( option->palette.color(QPalette::Dark) );
- painter->setPen( option->palette.color(QPalette::Shadow) );
- painter->drawRect( r.adjusted(0,0,-1,-1) );
- }
- else {
+ painter->setBrush(option->palette.color(QPalette::Dark));
+ painter->setPen(option->palette.color(QPalette::Shadow));
+ painter->drawRect(r.adjusted(0, 0, -1, -1));
+ } else {
bool highlight = option->state & QStyle::State_MouseOver;
if (highlight) {
QColor fill = option->palette.color(QPalette::Button);
painter->setBrush(fill);
painter->setPen(Qt::NoPen);
- painter->drawRect(r.adjusted(0,0,0,-1));
+ painter->drawRect(r.adjusted(0, 0, 0, -1));
}
if (qobject_cast<QTabBar*>(toolBtn->parent())) {