├── Icon.png ├── sourcetrail.qrc ├── .gitignore ├── scripts ├── osx-fix.sh ├── before_deploy.sh ├── install.sh ├── before_script.sh └── script.sh ├── Sourcetrail.json.in ├── src ├── sourcetrail_global.h ├── sourcetrailconstants.h ├── sourcetrailpluginsettings.h ├── sourcetrailpluginsettingspage.h ├── sourcetrailplugin.h ├── sourcetrailpluginsettings.cpp ├── sourcetrailpluginsettingspage.cpp ├── sourcetrailpluginsettingspage.ui └── sourcetrailplugin.cpp ├── README.md ├── qtc-sourcetrail.pro ├── .travis.yml └── .appveyor.yml /Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CoatiSoftware/qtc-sourcetrail/HEAD/Icon.png -------------------------------------------------------------------------------- /sourcetrail.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | Icon.png 4 | 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.pro.user 3 | *.pro.user.* 4 | 5 | .moc 6 | .obj 7 | .rcc 8 | .uic 9 | Makefile 10 | output 11 | qt-src 12 | qt-bin 13 | 14 | .qmake.stash 15 | Sourcetrail.json 16 | -------------------------------------------------------------------------------- /scripts/osx-fix.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | PLUGINPATH="${1}" 4 | 5 | otool -l "${PLUGINPATH}" | grep -e "name .*/Qt.*" | cut -d' ' -f 11 | sed "p;s|.*\(Qt.*\.framework\)|@rpath\/Frameworks\/\1|;s|$| \"${PLUGINPATH}\"|" | paste -d' ' - - | xargs -L 1 install_name_tool -change 6 | 7 | -------------------------------------------------------------------------------- /scripts/before_deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 4 | cd $TRAVIS_BUILD_DIR/output && zip -r $TRAVIS_BUILD_DIR/qtc-sourcetrail-osx-$QTC_VER * && cd - 5 | elif [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 6 | cd $TRAVIS_BUILD_DIR/output && zip -r $TRAVIS_BUILD_DIR/qtc-sourcetrail-linux-$QTC_VER * && cd - 7 | fi 8 | -------------------------------------------------------------------------------- /Sourcetrail.json.in: -------------------------------------------------------------------------------- 1 | { 2 | \"Name\" : \"Sourcetrail\", 3 | \"Version\" : \"0.8.3\", 4 | \"CompatVersion\" : \"$$QTCREATOR_COMPAT_VERSION\", 5 | \"Vendor\" : \"Coati Software KG\", 6 | \"Copyright\" : \"Coati Software KG\", 7 | \"License\" : \"The MIT License (MIT)\", 8 | \"Description\" : \"Synchronize QtCreator with Sourcetrail\", 9 | \"Url\" : \"https://sourcetrail.com\", 10 | $$dependencyList 11 | } 12 | -------------------------------------------------------------------------------- /src/sourcetrail_global.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #if defined(QTCREATORSOURCETRAIL_LIBRARY) 6 | # define QTCREATORSOURCETRAILSHARED_EXPORT Q_DECL_EXPORT 7 | #else 8 | # define QTCREATORSOURCETRAILSHARED_EXPORT Q_DECL_IMPORT 9 | #endif 10 | 11 | namespace Sourcetrail 12 | { 13 | 14 | enum SourcetrailPluginOptions 15 | { 16 | hostAddress = 1, 17 | pluginPort = 2, 18 | sourcetrailPort = 3 19 | }; 20 | 21 | } // namespace Sourcetrail 22 | -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 4 | brew update 5 | brew install p7zip 6 | brew install qt 7 | brew link --force qt 8 | elif [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 9 | sudo apt-get update 10 | sudo apt-get install apt=1.2.10 11 | sudo apt-get clean 12 | sudo rm -rf /var/lib/apt/lists 13 | sudo apt-get update 14 | sudo apt-get install -qq qt5-default qttools5-dev-tools p7zip-full 15 | sudo apt-get update -qq 16 | fi -------------------------------------------------------------------------------- /scripts/before_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | QT_LINK_PREFIX="http://download.qt.io/official_releases/qtcreator/$QTC_VER/$QTC_VER.0/installer_source" 4 | QT_SRC_FILE="qtcreator_dev.7z" 5 | QT_BIN_FILE="qtcreator.7z" 6 | 7 | curl -fsSL "$QT_LINK_PREFIX/$QTC_DL/$QT_SRC_FILE" -o qt-dev.7z 8 | 7z x -y qt-dev.7z -o"qt-src" 9 | curl -fsSL "$QT_LINK_PREFIX/$QTC_DL/$QT_BIN_FILE" -o qt-bin.7z 10 | 7z x -y qt-bin.7z -o"qt-bin" 11 | 12 | if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 13 | cd qt-bin && ln -s ./ bin 14 | fi -------------------------------------------------------------------------------- /scripts/script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 4 | qmake qtc-sourcetrail.pro -r "QTC_SOURCE=$TRAVIS_BUILD_DIR/qt-src" "QTC_BUILD=$TRAVIS_BUILD_DIR/qt-bin" "LIBS+=-L$TRAVIS_BUILD_DIR/qt-bin" "OUTPUT_PATH=$TRAVIS_BUILD_DIR/output" 5 | elif [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 6 | qmake qtc-sourcetrail.pro -r "QTC_SOURCE=$TRAVIS_BUILD_DIR/qt-src" "QTC_BUILD=$TRAVIS_BUILD_DIR/qt-bin/lib/qtcreator" "LIBS+=-L$TRAVIS_BUILD_DIR/qt-bin/lib/qtcreator" "OUTPUT_PATH=$TRAVIS_BUILD_DIR/output" 7 | fi 8 | 9 | make -------------------------------------------------------------------------------- /src/sourcetrailconstants.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Sourcetrail { 4 | namespace Constants { 5 | 6 | const char CATEGORY_ID[] = "Z.Sourcetrail"; 7 | const char CATEGORY[] = "Sourcetrail"; 8 | const char CATEGORY_ICON[] = ":/sourcetrail/Icon.png"; 9 | const char MENU_ID[] = "QtCreatorSourcetrail.Menu"; 10 | 11 | const char SEND_ACTION_ID[] = "QtCreatorSourcetrail.SendAction"; 12 | const char RESTART_ACTION_ID[] = "QtCreatorSourcetrail.RestartAction"; 13 | const char STOP_ACTION_ID[] = "QtCreatorSourcetrail.StopAction"; 14 | const char STATUS_ACTION_ID[] = "QtCreatorSourcetrail.StatusAction"; 15 | 16 | const char SERVER_RUNNING[] = "Server Status: Running"; 17 | const char SERVER_STOPPED[] = "Server Status: Stopped"; 18 | 19 | } // namespace Constants 20 | } // namespace Sourcetrail 21 | -------------------------------------------------------------------------------- /src/sourcetrailpluginsettings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class QSettings; 7 | 8 | namespace Sourcetrail { 9 | 10 | class SourcetrailPluginSettings 11 | { 12 | public: 13 | void toSettings(QSettings *s) const; 14 | void fromSettings(QSettings *s); 15 | 16 | bool equals(const SourcetrailPluginSettings &bs) const; 17 | 18 | QString m_hostAddress = "localhost"; 19 | int m_sourcetrailPort = 6666; 20 | int m_pluginPort = 6667; 21 | }; 22 | 23 | inline bool operator==(const SourcetrailPluginSettings &t1, const SourcetrailPluginSettings &t2) { return t1.equals(t2); } 24 | inline bool operator!=(const SourcetrailPluginSettings &t1, const SourcetrailPluginSettings &t2) { return !t1.equals(t2); } 25 | 26 | 27 | } // namespace Sourcetrail 28 | -------------------------------------------------------------------------------- /src/sourcetrailpluginsettingspage.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "sourcetrail_global.h" 4 | #include "sourcetrailpluginsettings.h" 5 | 6 | #include 7 | 8 | #include 9 | 10 | namespace Sourcetrail { 11 | 12 | namespace Ui { class SourcetrailPluginSettingsPage; } 13 | 14 | class SourcetrailPluginSettingsPage : public Core::IOptionsPage 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | SourcetrailPluginSettingsPage(QObject *parent); 20 | ~SourcetrailPluginSettingsPage(); 21 | 22 | // IOptionsPage 23 | QWidget *widget(); 24 | void apply(); 25 | void finish(); 26 | 27 | signals: 28 | void SourcetrailPluginSettingsChanged(const SourcetrailPluginSettings &); 29 | 30 | private: 31 | void settingsFromUi(SourcetrailPluginSettings &sourcetrail) const; 32 | 33 | Ui::SourcetrailPluginSettingsPage *m_page; 34 | QPointer m_widget; 35 | SourcetrailPluginSettings m_settings; 36 | }; 37 | 38 | } // namespace Sourcetrail 39 | -------------------------------------------------------------------------------- /src/sourcetrailplugin.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "sourcetrail_global.h" 4 | #include "sourcetrailpluginsettingspage.h" 5 | 6 | #include 7 | 8 | class QTcpServer; 9 | class StatusBarWidget; 10 | class QAction; 11 | 12 | namespace Core { class Command; } 13 | 14 | namespace Sourcetrail { 15 | 16 | class SourcetrailPlugin : public ExtensionSystem::IPlugin 17 | { 18 | Q_OBJECT 19 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Sourcetrail.json") 20 | 21 | public: 22 | SourcetrailPlugin(); 23 | ~SourcetrailPlugin(); 24 | 25 | bool initialize(const QStringList &arguments, QString *errorString) override; 26 | void extensionsInitialized() override; 27 | bool delayedInitialize() override; 28 | ShutdownFlag aboutToShutdown() override; 29 | 30 | public slots: 31 | void restartServer(); 32 | void stopServer(); 33 | 34 | private: 35 | void handleMessage(QString message); 36 | void triggerAction(); 37 | void sendPing(); 38 | void sendLocation(); 39 | void startListening(); 40 | void stopListening(); 41 | void sendMessage(QString message); 42 | void setCursor(QString file, int line, int column); 43 | 44 | QTcpServer *m_server; 45 | SourcetrailPluginSettingsPage *m_page; 46 | SourcetrailPluginSettings m_settings; 47 | StatusBarWidget *m_statusBar; 48 | Core::Command *m_statusCommand; 49 | }; 50 | 51 | } // namespace Sourcetrail 52 | -------------------------------------------------------------------------------- /src/sourcetrailpluginsettings.cpp: -------------------------------------------------------------------------------- 1 | #include "sourcetrailpluginsettings.h" 2 | 3 | #include 4 | 5 | static const char settingsGroup[] = "Sourcetrail"; 6 | static const char addressKey[] = "Address"; 7 | static const char pluginPortKey[] = "PluginPort"; 8 | static const char sourcetrailPortKey[] = "SourcetrailPort"; 9 | 10 | namespace Sourcetrail { 11 | 12 | void SourcetrailPluginSettings::fromSettings(QSettings *s) 13 | { 14 | // assign defaults 15 | *this = SourcetrailPluginSettings(); 16 | 17 | s->beginGroup(settingsGroup); 18 | m_hostAddress = s->value(addressKey, m_hostAddress).toString(); 19 | m_pluginPort = s->value(pluginPortKey, m_pluginPort).toInt(); 20 | m_sourcetrailPort = s->value(sourcetrailPortKey, m_sourcetrailPort).toInt(); 21 | s->endGroup(); 22 | } 23 | 24 | void SourcetrailPluginSettings::toSettings(QSettings *s) const 25 | { 26 | s->beginGroup(QLatin1String(settingsGroup)); 27 | s->setValue(QLatin1String(addressKey), m_hostAddress); 28 | s->setValue(QLatin1String(pluginPortKey), m_pluginPort); 29 | s->setValue(QLatin1String(sourcetrailPortKey), m_sourcetrailPort); 30 | s->endGroup(); 31 | } 32 | 33 | bool SourcetrailPluginSettings::equals(const SourcetrailPluginSettings &stps) const 34 | { 35 | return m_hostAddress == stps.m_hostAddress 36 | && m_pluginPort == stps.m_pluginPort 37 | && m_sourcetrailPort == stps.m_sourcetrailPort; 38 | } 39 | 40 | } // namespace Sourcetrail 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Linux and Mac Builds: [![Build 3 | Status](https://travis-ci.org/CoatiSoftware/qtc-sourcetrail.svg?branch=master)](https://travis-ci.org/CoatiSoftware/qtc-sourcetrail) 4 | 5 | Windows Builds: [![Build status](https://ci.appveyor.com/api/projects/status/6luot2mj145ha6j0/branch/master?svg=true)](https://ci.appveyor.com/project/st4ll1/qtc-sourcetrail/branch/master) 6 | 7 | # qtc-sourcetrail 8 | 9 | Qt Creator Plugin for communication with [Sourcetrail](https://sourcetrail.com) 10 | 11 | Supported Qt Creator Versions: 12 | * Qt Creator 4.12.x 13 | * Qt Creator 4.11.x 14 | * Qt Creator 4.10.x 15 | * Qt Creator 4.9.x 16 | * Qt Creator 4.8.x 17 | * Qt Creator 4.7.x 18 | * Qt Creator 4.6.x 19 | * Qt Creator 4.5.x 20 | 21 | ## Install 22 | 23 | Download the libary from [Releases](https://github.com/CoatiSoftware/qtc-sourcetrail/releases) and put it into the qtcreator plugins folder. It is in `$PrefixPath/../lib/qtcreator/plugins` (for example `c:\Qt\qtcreator-4.12.0\lib\qtcreator\plugins`). To find out where the Qt Creator installation folder is located please check Help -> System Information... -> PrefixPath 24 | 25 | ## Settings 26 | 27 | ### Sourcetrail Settings 28 | 29 | In the menu Tools -> Options ... -> Sourcetrail 30 | 31 | ### Keyboard 32 | 33 | In the menu Tools -> Options ... -> Environment -> Keyboard and use the filter to find the Sourcetrail Actions 34 | 35 | ## Building the Plugin 36 | 37 | Run the build.sh script (curl and 7z needed to run) or look into it to see what is needed to build the plugin. 38 | 39 | ## Creating a new Release 40 | 41 | Commit your changes, bump the version number and create a new tag. The CI pipelines will create all the builds and upload them to the new release here on GitHub. 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/sourcetrailpluginsettingspage.cpp: -------------------------------------------------------------------------------- 1 | #include "sourcetrailpluginsettingspage.h" 2 | 3 | #include "sourcetrailconstants.h" 4 | #include "ui_sourcetrailpluginsettingspage.h" 5 | 6 | #include 7 | 8 | namespace Sourcetrail { 9 | 10 | SourcetrailPluginSettingsPage::SourcetrailPluginSettingsPage(QObject *parent) : 11 | Core::IOptionsPage(parent), 12 | m_page(0) 13 | { 14 | setId(Constants::CATEGORY_ID); 15 | setDisplayName(tr(Constants::CATEGORY)); 16 | 17 | setCategory(Core::Id(Constants::CATEGORY_ID)); 18 | setDisplayCategory(QLatin1String(Constants::CATEGORY)); 19 | setCategoryIcon(Utils::Icon(Constants::CATEGORY_ICON)); 20 | 21 | QSettings *s = Core::ICore::settings(); 22 | m_settings.fromSettings(s); 23 | } 24 | 25 | SourcetrailPluginSettingsPage::~SourcetrailPluginSettingsPage() 26 | { 27 | delete m_page; 28 | } 29 | 30 | QWidget *SourcetrailPluginSettingsPage::widget() 31 | { 32 | if (!m_widget) { 33 | m_widget = new QWidget; 34 | m_page = new Ui::SourcetrailPluginSettingsPage; 35 | m_page->setupUi(m_widget); 36 | 37 | m_page->hostaddress->setText(m_settings.m_hostAddress); 38 | m_page->pluginport->setText(QString::number(m_settings.m_pluginPort)); 39 | m_page->sourcetrailport->setText(QString::number(m_settings.m_sourcetrailPort)); 40 | } 41 | return m_widget; 42 | } 43 | 44 | void SourcetrailPluginSettingsPage::apply() 45 | { 46 | if (!m_page) // page was never shown 47 | return; 48 | 49 | SourcetrailPluginSettings setting; 50 | settingsFromUi(setting); 51 | 52 | if (m_settings != setting) 53 | { 54 | m_settings = setting; 55 | QSettings *s = Core::ICore::settings(); 56 | m_settings.toSettings(s); 57 | emit SourcetrailPluginSettingsChanged(setting); 58 | } 59 | } 60 | 61 | void SourcetrailPluginSettingsPage::finish() 62 | { 63 | delete m_widget; 64 | if (!m_page) // page was never shown 65 | return; 66 | delete m_page; 67 | m_page = 0; 68 | } 69 | 70 | void SourcetrailPluginSettingsPage::settingsFromUi(SourcetrailPluginSettings &settings) const 71 | { 72 | if (!m_page) 73 | return; 74 | 75 | settings.m_hostAddress = m_page->hostaddress->text(); 76 | settings.m_pluginPort = m_page->pluginport->text().toInt(); 77 | settings.m_sourcetrailPort = m_page->sourcetrailport->text().toInt(); 78 | } 79 | 80 | } // namespace Sourcetrail 81 | -------------------------------------------------------------------------------- /qtc-sourcetrail.pro: -------------------------------------------------------------------------------- 1 | QT += gui network 2 | 3 | CONFIG += include_source_dir 4 | CONFIG += c++11 5 | QMAKE_CXXFLAGS += -std=c++11 6 | 7 | DEFINES += SOURCETRAIL_LIBRARY 8 | 9 | # QtCreatorSourcetrail files 10 | TARGET = Sourcetrail 11 | 12 | SOURCES += \ 13 | src/sourcetrailpluginsettingspage.cpp \ 14 | src/sourcetrailpluginsettings.cpp \ 15 | src/sourcetrailplugin.cpp 16 | 17 | HEADERS += \ 18 | src/sourcetrailpluginsettingspage.h \ 19 | src/sourcetrailpluginsettings.h \ 20 | src/sourcetrailplugin.h \ 21 | src/sourcetrailconstants.h \ 22 | src/sourcetrail_global.h 23 | 24 | # Qt Creator linking 25 | 26 | ## Either set the IDE_SOURCE_TREE when running qmake, 27 | ## or set the QTC_SOURCE environment variable, to override the default setting 28 | isEmpty(IDE_SOURCE_TREE): IDE_SOURCE_TREE = $$QTC_SOURCE 29 | isEmpty(IDE_SOURCE_TREE): IDE_SOURCE_TREE = "/home/st4ll1/dev/qt-creator" 30 | 31 | ## Either set the IDE_BUILD_TREE when running qmake, 32 | ## or set the QTC_BUILD environment variable, to override the default setting 33 | isEmpty(IDE_BUILD_TREE): IDE_BUILD_TREE = $$QTC_BUILD 34 | isEmpty(IDE_BUILD_TREE): IDE_BUILD_TREE = "/home/st4ll1/dev/qt-creator" 35 | 36 | ## uncomment to build plugin into user config directory 37 | ## /plugins/ 38 | ## where is e.g. 39 | ## "%LOCALAPPDATA%\QtProject\qtcreator" on Windows Vista and later 40 | ## "$XDG_DATA_HOME/data/QtProject/qtcreator" or "~/.local/share/data/QtProject/qtcreator" on Linux 41 | ## "~/Library/Application Support/QtProject/Qt Creator" on OS X 42 | # USE_USER_DESTDIR = yes 43 | 44 | ###### If the plugin can be depended upon by other plugins, this code needs to be outsourced to 45 | ###### _dependencies.pri, where is the name of the directory containing the 46 | ###### plugin's sources. 47 | 48 | LIBS += -L$$IDE_PLUGIN_PATH/QtProject \ 49 | -L$$IDE_BUILD_TREE \ 50 | -L$$IDE_BUILD_TREE/plugins/QtProject \ 51 | -L$$IDE_BUILD_TREE/plugins 52 | 53 | QTC_PLUGIN_NAME = Sourcetrail 54 | QTC_LIB_DEPENDS += \ 55 | # nothing here at this time 56 | 57 | QTC_PLUGIN_DEPENDS += \ 58 | coreplugin \ 59 | cppeditor 60 | 61 | QTC_PLUGIN_RECOMMENDS += \ 62 | # optional plugin dependencies. nothing here at this time 63 | 64 | ###### End _dependencies.pri contents ###### 65 | 66 | include($$IDE_SOURCE_TREE/src/qtcreatorplugin.pri) 67 | 68 | FORMS += \ 69 | src/sourcetrailpluginsettingspage.ui 70 | 71 | RESOURCES += sourcetrail.qrc 72 | 73 | DISTFILES += \ 74 | Sourcetrail.json.in 75 | 76 | !isEmpty(OUTPUT_PATH) { 77 | DESTDIR = $$OUTPUT_PATH 78 | message("You set output path to $$DESTDIR") 79 | } 80 | -------------------------------------------------------------------------------- /src/sourcetrailpluginsettingspage.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sourcetrail::SourcetrailPluginSettingsPage 4 | 5 | 6 | 7 | 0 8 | 0 9 | 662 10 | 463 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 10 20 | 20 21 | 631 22 | 261 23 | 24 | 25 | 26 | 27 | 28 | 29 | Sourcetrail Plugin 30 | 31 | 32 | 33 | 34 | 35 | 36 | QLayout::SetMinimumSize 37 | 38 | 39 | 40 | 41 | Qt::Vertical 42 | 43 | 44 | 45 | 20 46 | 40 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Host Address: 55 | 56 | 57 | 58 | 59 | 60 | 61 | Sourcetrail Port: 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | Plugin Port 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | matrix: 4 | include: 5 | - os: linux 6 | compiler: gcc 7 | sudo: required 8 | dist: trusty 9 | env: QTC_VER=4.5 QTC_DL=linux_gcc_64_rhel72 10 | - os: linux 11 | compiler: gcc 12 | sudo: required 13 | dist: trusty 14 | env: QTC_VER=4.6 QTC_DL=linux_gcc_64_rhel72 15 | - os: linux 16 | compiler: gcc 17 | sudo: required 18 | dist: trusty 19 | env: QTC_VER=4.7 QTC_DL=linux_gcc_64_rhel72 20 | - os: linux 21 | compiler: gcc 22 | sudo: required 23 | dist: trusty 24 | env: QTC_VER=4.8 QTC_DL=linux_gcc_64_rhel72 25 | - os: linux 26 | compiler: gcc 27 | sudo: required 28 | dist: trusty 29 | env: QTC_VER=4.9 QTC_DL=linux_gcc_64_rhel72 30 | - os: linux 31 | compiler: gcc 32 | sudo: required 33 | dist: trusty 34 | env: QTC_VER=4.10 QTC_DL=linux_gcc_64_rhel72 35 | - os: linux 36 | compiler: gcc 37 | sudo: required 38 | dist: trusty 39 | env: QTC_VER=4.11 QTC_DL=linux_gcc_64_rhel72 40 | - os: linux 41 | compiler: gcc 42 | sudo: required 43 | dist: trusty 44 | env: QTC_VER=4.12 QTC_DL=linux_gcc_64_rhel72 45 | 46 | - os: osx 47 | compiler: clang 48 | env: QTC_VER=4.5 QTC_DL=mac_x64 49 | - os: osx 50 | compiler: clang 51 | env: QTC_VER=4.6 QTC_DL=mac_x64 52 | - os: osx 53 | compiler: clang 54 | env: QTC_VER=4.7 QTC_DL=mac_x64 55 | - os: osx 56 | compiler: clang 57 | env: QTC_VER=4.8 QTC_DL=mac_x64 58 | - os: osx 59 | compiler: clang 60 | env: QTC_VER=4.9 QTC_DL=mac_x64 61 | - os: osx 62 | compiler: clang 63 | env: QTC_VER=4.10 QTC_DL=mac_x64 64 | - os: osx 65 | compiler: clang 66 | env: QTC_VER=4.11 QTC_DL=mac_x64 67 | - os: osx 68 | compiler: clang 69 | env: QTC_VER=4.12 QTC_DL=mac_x64 70 | 71 | install: 72 | - scripts/install.sh 73 | before_script: 74 | - scripts/before_script.sh 75 | script: 76 | - scripts/script.sh 77 | before_deploy: 78 | # - scripts/before_deploy.sh 79 | - if [[ $TRAVIS_OS_NAME == 'osx' ]]; then "$TRAVIS_BUILD_DIR/scripts/osx-fix.sh" $(find $TRAVIS_BUILD_DIR/output/ -name '*.dylib') ; fi 80 | - 7z a $TRAVIS_BUILD_DIR/qtc-sourcetrail-$TRAVIS_OS_NAME-x64-qtc$QTC_VER.zip $TRAVIS_BUILD_DIR/output/* 81 | - ls $TRAVIS_BUILD_DIR/output 82 | deploy: 83 | provider: releases 84 | api_key: 85 | secure: "RMvCoCzTj44tBCRmuVh9IXXh3IX8hWjzurmfpVB/fZU1NZEn9XBTyV5ngD9ZGw2NCRnN7t4KjHaJZCRWBroIUq0G5aH/nYz6/jnlIL4SRCiTsnl8bYHdLzJOtdXnavCIbgAVgDFoNfCsHF14XfRQakrMxSOp+4LKSYNWIdV3rBMPdL4m2OhVOtuJVzge+1IrveEuHsoAcaAlnV7GiSwpWd0CX/v8wcIQ+s6QYA1HEKOfuElVtLkKrZXWq11hO3zHLHFyXzMnwUoPQjZPkR6yOA/aZoxy4ovlooN/2Aa8EgAFnEckXFqGq4Rta6EHsg/hezNSZDzFMXE7UL9/vnqPlyVBX6cU1w29ro7EWnK+62gr9FQqbCkViIxnrJau4bB4qHK+3pvIwrubCnFXkSs9kt4lcZdR+midz35v3pV+D0ZmcEO1cQN8EDQqohpsvGZ/XiF33br/2/g4R2XlB3bDD17aRipGjsOWCoxevh4XDe5ivymhxilseIO1Af1SHbk8z4vhc6ywyppvvQgWGTYInbMEXf8m9zTvVWDZqFHmET0GABSmY0QbuLmaQZrtK6qjisXva06O2P9+Wj69d4i1JxLwxHNbJv60DLu7xGmGanom9+yJaPfJIk/Rx+trewvk9Z0LR3fOcyxnDyDFdKfbIRxDiKspLB+jZ6A97/W+9i0=" 86 | file: $TRAVIS_BUILD_DIR/qtc-sourcetrail-$TRAVIS_OS_NAME-x64-qtc$QTC_VER.zip 87 | overwrite: true 88 | skip_cleanup: true 89 | on: 90 | tags: true 91 | -------------------------------------------------------------------------------- /.appveyor.yml: -------------------------------------------------------------------------------- 1 | # Appveyor project configuration file 2 | # Build the plugin on Windows environment 3 | 4 | version: 0.8.3.{build} 5 | 6 | # Official QtC binaries are built 7 | # with msvc2015-x86 8 | os: Visual Studio 2015 9 | 10 | environment: 11 | QTDIR: C:\Qt\5.11\msvc2015 12 | VSVER: 14.0 13 | BINTRAY_KEY: 14 | secure: 64COF2Ng3AdKqw6BEQqhlTu8G1j0F43qv6zZ6tg4VLbVCxXBxB2kW42COoqSiBJA 15 | matrix: 16 | - platform: x86 17 | QTC_VER: 4.5 18 | VS_VER: 2015 19 | 20 | - platform: x64 21 | QTC_VER: 4.5 22 | VS_VER: 2015 23 | 24 | - platform: x86 25 | QTC_VER: 4.6 26 | VS_VER: 2015 27 | 28 | - platform: x64 29 | QTC_VER: 4.6 30 | VS_VER: 2015 31 | 32 | - platform: x86 33 | QTC_VER: 4.7 34 | VS_VER: 2015 35 | 36 | - platform: x64 37 | QTC_VER: 4.7 38 | VS_VER: 2015 39 | 40 | - platform: x86 41 | QTC_VER: 4.8 42 | VS_VER: 2015 43 | 44 | - platform: x64 45 | QTC_VER: 4.8 46 | VS_VER: 2015 47 | 48 | - platform: x86 49 | QTC_VER: 4.9 50 | VS_VER: 2017 51 | 52 | - platform: x64 53 | QTC_VER: 4.9 54 | VS_VER: 2017 55 | 56 | - platform: x86 57 | QTC_VER: 4.10 58 | VS_VER: 2017 59 | 60 | - platform: x64 61 | QTC_VER: 4.10 62 | VS_VER: 2017 63 | 64 | - platform: x86 65 | QTC_VER: 4.11 66 | VS_VER: 2017 67 | 68 | - platform: x64 69 | QTC_VER: 4.11 70 | VS_VER: 2017 71 | 72 | - platform: x86 73 | QTC_VER: 4.12 74 | VS_VER: 2017 75 | 76 | - platform: x64 77 | QTC_VER: 4.12 78 | VS_VER: 2017 79 | 80 | configuration: 81 | - Release 82 | 83 | # Download and unpack QtC sources and binaries 84 | install: 85 | - cmd: IF %VS_VER% == 2015 IF %PLATFORM% == x86 SET download_dir=windows_vs%VS_VER%_32 86 | - cmd: IF %VS_VER% == 2015 IF %PLATFORM% == x64 SET download_dir=windows_vs%VS_VER%_64 87 | - cmd: IF %VS_VER% == 2017 SET download_dir=windows_msvc%VS_VER%_%PLATFORM% 88 | - cmd: echo %download_dir% 89 | - cmd: curl -fsSL "http://download.qt.io/official_releases/qtcreator/%QTC_VER%/%QTC_VER%.0/installer_source/%download_dir%/qtcreator_dev.7z" -o %APPVEYOR_BUILD_FOLDER%\qt-dev.7z 90 | - cmd: 7z x -y qt-dev.7z -o"%APPVEYOR_BUILD_FOLDER%\qt-src\" | findstr /b /r /c:"\ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace Core; 19 | 20 | namespace Sourcetrail { 21 | 22 | SourcetrailPlugin::SourcetrailPlugin() 23 | { 24 | m_server = new QTcpServer(this); 25 | 26 | connect(m_server, &QTcpServer::newConnection, [=](){ 27 | QTcpSocket *connection = m_server->nextPendingConnection(); 28 | connect(connection, &QAbstractSocket::disconnected, 29 | connection, &QObject::deleteLater); 30 | 31 | connect(connection, &QAbstractSocket::readyRead, [this, connection](){ 32 | this->handleMessage(QString::fromLatin1(connection->readAll())); 33 | }); 34 | }); 35 | } 36 | 37 | void SourcetrailPlugin::handleMessage(QString message) 38 | { 39 | message = message.remove(message.indexOf(""),5); 40 | QStringList list = message.split(">>"); 41 | 42 | if (list[0] == "ping") 43 | { 44 | sendPing(); 45 | } 46 | if (list[0] == "moveCursor") 47 | { 48 | setCursor(list[1], list[2].toInt(), list[3].toInt()); 49 | } 50 | } 51 | 52 | SourcetrailPlugin::~SourcetrailPlugin() 53 | { 54 | // Unregister objects from the plugin manager's object pool 55 | // Delete members 56 | 57 | stopListening(); 58 | delete m_server; 59 | } 60 | 61 | void SourcetrailPlugin::restartServer() 62 | { 63 | QSettings *s = Core::ICore::settings(); 64 | m_settings.fromSettings(s); 65 | stopListening(); 66 | startListening(); 67 | } 68 | 69 | bool SourcetrailPlugin::initialize(const QStringList &arguments, QString *errorString) 70 | { 71 | // Register objects in the plugin manager's object pool 72 | // Load settings 73 | // Add actions to menus 74 | // Connect to other plugins' signals 75 | // In the initialize function, a plugin can be sure that the plugins it 76 | // depends on have initialized their members. 77 | 78 | Q_UNUSED(arguments) 79 | Q_UNUSED(errorString) 80 | 81 | m_page = new SourcetrailPluginSettingsPage(this); 82 | connect(m_page, &SourcetrailPluginSettingsPage::SourcetrailPluginSettingsChanged, 83 | this, &SourcetrailPlugin::restartServer); 84 | 85 | // (re-)start server 86 | QAction *startAction = new QAction(tr("Start Sourcetrail Listener"), this); 87 | Core::Command *restartCommand = Core::ActionManager::registerAction(startAction, 88 | Constants::RESTART_ACTION_ID, 89 | Core::Context(Core::Constants::C_GLOBAL)); 90 | 91 | connect(startAction, &QAction::triggered, this, &SourcetrailPlugin::restartServer); 92 | 93 | // stop server 94 | QAction *stopAction = new QAction(tr("Stop Sourcetrail Listener"), this); 95 | Core::Command *stopCommand = Core::ActionManager::registerAction(stopAction, 96 | Constants::STOP_ACTION_ID, 97 | Core::Context(Core::Constants::C_GLOBAL)); 98 | 99 | connect(stopAction, &QAction::triggered, this, &SourcetrailPlugin::stopServer); 100 | 101 | // send location 102 | QAction *action = new QAction(QIcon(Constants::CATEGORY_ICON),tr("Send Location to Sourcetrail"), this); 103 | Core::Command *cmd = Core::ActionManager::registerAction(action, 104 | Constants::SEND_ACTION_ID, 105 | Core::Context(Core::Constants::C_GLOBAL)); 106 | cmd->setDefaultKeySequence(QKeySequence(tr("Alt+S,Alt+S"))); 107 | connect(action, &QAction::triggered, this, &SourcetrailPlugin::triggerAction); 108 | 109 | // action to show if the server is running TODO: move to statusbar or ... 110 | QAction *statusAction = new QAction(tr("Server Status:" ), this); 111 | statusAction->setEnabled(false); 112 | m_statusCommand = Core::ActionManager::registerAction(statusAction, 113 | Constants::STATUS_ACTION_ID, 114 | Core::Context(Core::Constants::C_GLOBAL)); 115 | 116 | // sourcetrail menu 117 | Core::ActionContainer *menu = Core::ActionManager::createMenu(Constants::MENU_ID); 118 | menu->menu()->setTitle(tr("Sourcetrail")); 119 | menu->menu()->setIcon(QIcon(Constants::CATEGORY_ICON)); 120 | menu->addAction(cmd); 121 | menu->addAction(restartCommand); 122 | menu->addAction(stopCommand); 123 | menu->addAction(m_statusCommand); 124 | Core::ActionManager::actionContainer(Core::Constants::M_TOOLS)->addMenu(menu); 125 | 126 | 127 | // Editor Context Menu 128 | if (ActionContainer *editorContextMenu = 129 | ActionManager::actionContainer(CppEditor::Constants::M_CONTEXT)) 130 | { 131 | editorContextMenu->addAction(cmd); 132 | } 133 | 134 | return true; 135 | } 136 | 137 | 138 | void SourcetrailPlugin::extensionsInitialized() 139 | { 140 | // Retrieve objects from the plugin manager's object pool 141 | // In the extensionsInitialized function, a plugin can be sure that all 142 | // plugins that depend on it are completely initialized. 143 | } 144 | 145 | bool SourcetrailPlugin::delayedInitialize() 146 | { 147 | restartServer(); 148 | return true; 149 | } 150 | 151 | void SourcetrailPlugin::stopServer() 152 | { 153 | stopListening(); 154 | m_statusCommand->action()->setText(Constants::SERVER_STOPPED); 155 | } 156 | 157 | void SourcetrailPlugin::startListening() 158 | { 159 | if (!m_server->listen(QHostAddress::LocalHost, m_settings.m_sourcetrailPort)) 160 | { 161 | MessageManager::write(QString{"Sourcetrail Plugin TCP Server - Could not listen to port %1"}.arg(m_settings.m_sourcetrailPort)); 162 | } 163 | else 164 | { 165 | m_statusCommand->action()->setText(Constants::SERVER_RUNNING); 166 | } 167 | } 168 | 169 | 170 | void SourcetrailPlugin::stopListening() 171 | { 172 | if (m_server->isListening()) 173 | { 174 | m_server->close(); 175 | } 176 | } 177 | 178 | ExtensionSystem::IPlugin::ShutdownFlag SourcetrailPlugin::aboutToShutdown() 179 | { 180 | // Save settings 181 | // Disconnect from signals that are not needed during shutdown 182 | // Hide UI (if you add UI that is not in the main window directly) 183 | return SynchronousShutdown; 184 | } 185 | 186 | void SourcetrailPlugin::sendMessage(QString message) 187 | { 188 | QTcpSocket *senderSocket = new QTcpSocket(this); 189 | senderSocket->connectToHost(m_settings.m_hostAddress, m_settings.m_pluginPort); 190 | 191 | if (senderSocket->waitForConnected()) 192 | { 193 | senderSocket->write(message.toUtf8()); 194 | senderSocket->flush(); 195 | senderSocket->waitForBytesWritten(); 196 | senderSocket->close(); 197 | } 198 | } 199 | 200 | void SourcetrailPlugin::sendPing() 201 | { 202 | sendMessage("ping>>Qt Creator"); 203 | } 204 | 205 | void SourcetrailPlugin::setCursor(QString file, int line, int column) 206 | { 207 | Core::EditorManager::openEditorAt(file, line, column); 208 | } 209 | 210 | void SourcetrailPlugin::sendLocation() 211 | { 212 | IEditor *editor = Core::EditorManager::currentEditor(); 213 | if (editor) 214 | { 215 | int line = Core::EditorManager::currentEditor()->currentLine(); 216 | int column = Core::EditorManager::currentEditor()->currentColumn(); 217 | QString file = Core::EditorManager::currentDocument()->filePath().toString(); 218 | 219 | QString message = "setActiveToken>>" + file + ">>" + QString::number(line) + 220 | ">>" + QString::number(column) + ""; 221 | 222 | sendMessage(message); 223 | } 224 | else 225 | { 226 | MessageManager::write(QString{"Sourcetrail Plugin TCP Server - Action Triggered but no editor"}); 227 | } 228 | } 229 | 230 | void SourcetrailPlugin::triggerAction() 231 | { 232 | sendPing(); 233 | sendLocation(); 234 | 235 | QStringList list; 236 | Core::ICore::openFiles(list); 237 | } 238 | 239 | } // namespace Sourcetrail 240 | --------------------------------------------------------------------------------