Commit 34fce7c9 authored by Kåre Särs's avatar Kåre Särs

Port the GDB plugin to frameworks

parent ef48700e
......@@ -28,9 +28,9 @@ ecm_optional_add_subdirectory (filebrowser)
# xml completion
ecm_optional_add_subdirectory (xmltools)
#if(NOT WIN32)
# add_subdirectory( gdbplugin ) # reading /proc/...
#endif(NOT WIN32)
if(NOT WIN32)
add_subdirectory( gdbplugin ) # should be tested on windows...
endif(NOT WIN32)
#add_subdirectory( textfilter )
......
cmake_minimum_required( VERSION 2.6 )
# building separately or as part of kdesdk?
if(NOT KDE4_FOUND)
find_package(KDE4 REQUIRED)
ADD_DEFINITIONS(-DKDE_DEFAULT_DEBUG_AREA=13040)
endif(NOT KDE4_FOUND)
include_directories(${KDE4_INCLUDES})
include_directories(${KDE4_KIO_INCLUDES})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
......@@ -20,12 +10,15 @@ set(kategdbplugin_PART_SRCS
advanced_settings.cpp
)
kde4_add_ui_files(kategdbplugin_PART_SRCS advanced_settings.ui)
qt5_wrap_ui(kategdbplugin_PART_SRCS advanced_settings.ui)
add_library(kategdbplugin MODULE ${kategdbplugin_PART_SRCS})
kde4_add_plugin( kategdbplugin ${kategdbplugin_PART_SRCS} )
target_link_libraries( kategdbplugin ${KDE4_KDEUI_LIBS} ${KDE4_KDECORE_LIBS} ktexteditor kateinterfaces )
target_link_libraries(kategdbplugin KF5::TextEditor KF5::I18n KF5::IconThemes)
install( FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/kate/plugins/kategdb )
install( TARGETS kategdbplugin DESTINATION ${PLUGIN_INSTALL_DIR} )
install( FILES kategdbplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
kde4_install_icons( ${ICON_INSTALL_DIR} )
########### install files ###############
install(FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/kategdb)
install(TARGETS kategdbplugin DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES kategdbplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
ecm_install_icons (${ICON_INSTALL_DIR})
kservice_desktop_to_json (kategdbplugin.desktop)
......@@ -18,15 +18,16 @@
// Boston, MA 02110-1301, USA.
#include "advanced_settings.h"
#include "advanced_settings.moc"
#include <KFileDialog>
#include <QFileDialog>
AdvancedGDBSettings::AdvancedGDBSettings(QWidget *parent) : KDialog(parent)
AdvancedGDBSettings::AdvancedGDBSettings(QWidget *parent) : QDialog(parent)
{
QWidget *widget = new QWidget(this);
setupUi(widget);
setMainWidget(widget);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(widget);
connect(u_gdbBrowse, SIGNAL(clicked()), this, SLOT(slotBrowseGDB()));
}
......@@ -41,30 +42,30 @@ const QStringList AdvancedGDBSettings::configs() const
tmp << u_gdbCmd->text();
switch(u_localRemote->currentIndex()) {
case 1:
tmp << QString("target remote %1:%2").arg(u_tcpHost->text()).arg(u_tcpPort->text());
tmp << QStringLiteral("target remote %1:%2").arg(u_tcpHost->text()).arg(u_tcpPort->text());
tmp << QString();
break;
case 2:
tmp << QString("target remote %1").arg(u_ttyPort->text());
tmp << QString("set remotebaud %1").arg(u_baudCombo->currentText());
tmp << QStringLiteral("target remote %1").arg(u_ttyPort->text());
tmp << QStringLiteral("set remotebaud %1").arg(u_baudCombo->currentText());
break;
default:
tmp << QString();
tmp << QString();
}
if (!u_soAbsPrefix->text().isEmpty()) {
tmp << QString("set solib-absolute-prefix %1").arg(u_soAbsPrefix->text());
tmp << QStringLiteral("set solib-absolute-prefix %1").arg(u_soAbsPrefix->text());
}
else {
tmp << QString();
}
if (!u_soSearchPath->text().isEmpty()) {
tmp << QString("set solib-search-path %1").arg(u_soSearchPath->text());
tmp << QStringLiteral("set solib-search-path %1").arg(u_soSearchPath->text());
}
else {
tmp << QString();
}
tmp << u_customInit->toPlainText().split('\n');
tmp << u_customInit->toPlainText().split(QLatin1Char('\n'));
return tmp;
}
......@@ -72,14 +73,14 @@ const QStringList AdvancedGDBSettings::configs() const
void AdvancedGDBSettings::setConfigs(const QStringList &cfgs)
{
// clear all info
u_gdbCmd->setText("gdb");
u_gdbCmd->setText(QStringLiteral("gdb"));
u_localRemote->setCurrentIndex(0);
u_soAbsPrefix->clear();
u_soSearchPath->clear();
u_customInit->clear();
u_tcpHost->setText("");
u_tcpPort->setText("");
u_ttyPort->setText("");
u_tcpHost->setText(QString());
u_tcpPort->setText(QString());
u_ttyPort->setText(QString());
u_baudCombo->setCurrentIndex(0);
// GDB
......@@ -95,26 +96,26 @@ void AdvancedGDBSettings::setConfigs(const QStringList &cfgs)
u_localRemote->setCurrentIndex(0);
u_remoteStack->setCurrentIndex(0);
}
else if (cfgs[LocalRemoteIndex].contains(":")) {
else if (cfgs[LocalRemoteIndex].contains(QLatin1Char(':'))) {
u_localRemote->setCurrentIndex(1);
u_remoteStack->setCurrentIndex(1);
start = cfgs[LocalRemoteIndex].lastIndexOf(' ');
end = cfgs[LocalRemoteIndex].indexOf(':');
start = cfgs[LocalRemoteIndex].lastIndexOf(QLatin1Char(' '));
end = cfgs[LocalRemoteIndex].indexOf(QLatin1Char(':'));
u_tcpHost->setText(cfgs[LocalRemoteIndex].mid(start+1, end-start-1));
u_tcpPort->setText(cfgs[LocalRemoteIndex].mid(end+1));
}
else {
u_localRemote->setCurrentIndex(2);
u_remoteStack->setCurrentIndex(2);
start = cfgs[LocalRemoteIndex].lastIndexOf(' ');
start = cfgs[LocalRemoteIndex].lastIndexOf(QLatin1Char(' '));
u_ttyPort->setText(cfgs[LocalRemoteIndex].mid(start+1));
start = cfgs[RemoteBaudIndex].lastIndexOf(' ');
start = cfgs[RemoteBaudIndex].lastIndexOf(QLatin1Char(' '));
setComboText(u_baudCombo, cfgs[RemoteBaudIndex].mid(start+1));
}
// Solib absolute path
if (cfgs.count() <= SoAbsoluteIndex ) return;
if (cfgs.count() <= SoAbsoluteIndex) return;
start = 26; // "set solib-absolute-prefix "
u_soAbsPrefix->setText(cfgs[SoAbsoluteIndex].mid(start));
......@@ -131,9 +132,9 @@ void AdvancedGDBSettings::setConfigs(const QStringList &cfgs)
void AdvancedGDBSettings::slotBrowseGDB()
{
u_gdbCmd->setText(KFileDialog::getOpenFileName(u_gdbCmd->text(), "application/x-executable"));
u_gdbCmd->setText(QFileDialog::getOpenFileName(this, QString(), u_gdbCmd->text(), QStringLiteral("application/x-executable")));
if (u_gdbCmd->text().isEmpty()) {
u_gdbCmd->setText("gdb");
u_gdbCmd->setText(QStringLiteral("gdb"));
}
}
......@@ -151,3 +152,5 @@ void AdvancedGDBSettings::setComboText(KComboBox *combo, const QString &str)
combo->addItem(str);
combo->setCurrentIndex(combo->count()-1);
}
#include "advanced_settings.moc"
......@@ -22,9 +22,9 @@
#include "ui_advanced_settings.h"
#include <QStringList>
#include <KDialog>
#include <QDialog>
class AdvancedGDBSettings : public KDialog, public Ui::AdvancedGDBSettings
class AdvancedGDBSettings : public QDialog, public Ui::AdvancedGDBSettings
{
Q_OBJECT
public:
......
......@@ -13,7 +13,7 @@
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="KLineEdit" name="u_gdbCmd">
<widget class="QLineEdit" name="u_gdbCmd">
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
......@@ -36,7 +36,7 @@
</widget>
</item>
<item row="3" column="1">
<widget class="KLineEdit" name="u_soAbsPrefix">
<widget class="QLineEdit" name="u_soAbsPrefix">
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
......@@ -50,7 +50,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="KLineEdit" name="u_soSearchPath">
<widget class="QLineEdit" name="u_soSearchPath">
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
......@@ -116,7 +116,7 @@
</widget>
</item>
<item>
<widget class="KLineEdit" name="u_tcpHost">
<widget class="QLineEdit" name="u_tcpHost">
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
......@@ -130,7 +130,7 @@
</widget>
</item>
<item>
<widget class="KLineEdit" name="u_tcpPort">
<widget class="QLineEdit" name="u_tcpPort">
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
......@@ -155,7 +155,7 @@
</widget>
</item>
<item>
<widget class="KLineEdit" name="u_ttyPort">
<widget class="QLineEdit" name="u_ttyPort">
<property name="text">
<string comment="KDE::DoNotExtract">/dev/ttyUSB0</string>
</property>
......@@ -221,7 +221,7 @@
<header>kcombobox.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<class>QLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
......
......@@ -22,25 +22,25 @@
// Boston, MA 02110-1301, USA.
#include "configview.h"
#include "configview.moc"
#include <QtGui/QCompleter>
#include <QtGui/QDirModel>
#include <QtGui/QLayout>
#include <QtCore/QTimer>
#include <QCompleter>
#include <QDirModel>
#include <QLayout>
#include <QTimer>
#include <QPushButton>
#include <QFileDialog>
#include <KTextEditor/View>
#include <KTextEditor/Document>
#include <klocalizedstring.h>
#include <kicon.h>
#include <ktexteditor/view.h>
#include <ktexteditor/document.h>
#include <kfiledialog.h>
#include <kmessagebox.h>
ConfigView::ConfigView(QWidget* parent, Kate::MainWindow* mainWin)
ConfigView::ConfigView(QWidget* parent, KTextEditor::MainWindow* mainWin)
: QWidget(parent),
m_mainWindow(mainWin)
{
m_targetCombo = new KComboBox();
m_targetCombo = new QComboBox();
m_targetCombo->setEditable(true);
// don't let Qt insert items when the user edits; new targets are only
// added when the user explicitly says so
......@@ -48,15 +48,15 @@ ConfigView::ConfigView(QWidget* parent, Kate::MainWindow* mainWin)
m_targetCombo->setDuplicatesEnabled(true);
m_addTarget = new QToolButton();
m_addTarget->setIcon(SmallIcon("document-new"));
m_addTarget->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
m_addTarget->setToolTip(i18n("Add new target"));
m_copyTarget = new QToolButton();
m_copyTarget->setIcon(SmallIcon("document-copy"));
m_copyTarget->setIcon(QIcon::fromTheme(QStringLiteral("document-copy")));
m_copyTarget->setToolTip(i18n("Copy target"));
m_deleteTarget = new QToolButton();
m_deleteTarget->setIcon(SmallIcon("edit-delete"));
m_deleteTarget->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
m_deleteTarget->setToolTip(i18n("Delete target"));
m_line = new QFrame(this);
......@@ -65,28 +65,28 @@ ConfigView::ConfigView(QWidget* parent, Kate::MainWindow* mainWin)
m_execLabel = new QLabel(i18n("Executable:"));
m_execLabel->setBuddy(m_targetCombo);
m_executable = new KLineEdit();
m_executable = new QLineEdit();
QCompleter* completer1 = new QCompleter(this);
completer1->setModel(new QDirModel(QStringList(),
QDir::AllDirs|QDir::NoDotAndDotDot,
QDir::Name, this));
m_executable->setCompleter(completer1);
m_executable->setClearButtonShown(true);
// FIXME KF5 m_executable->setClearButtonShown(true);
m_browseExe = new QToolButton(this);
m_browseExe->setIcon(KIcon("application-x-executable"));
m_browseExe->setIcon(QIcon::fromTheme(QStringLiteral("application-x-executable")));
m_workingDirectory = new KLineEdit();
m_workingDirectory = new QLineEdit();
QCompleter* completer2 = new QCompleter(this);
completer2->setModel(new QDirModel(completer2));
m_workingDirectory->setCompleter(completer2);
m_workingDirectory->setClearButtonShown(true);
// FIXME KF5 m_workingDirectory->setClearButtonShown(true);
m_workDirLabel = new QLabel(i18n("Working Directory:"));
m_workDirLabel->setBuddy(m_workingDirectory);
m_browseDir = new QToolButton(this);
m_browseDir->setIcon(KIcon("inode-directory"));
m_browseDir->setIcon(QIcon::fromTheme(QStringLiteral("inode-directory")));
m_arguments = new KLineEdit();
m_arguments->setClearButtonShown(true);
m_arguments = new QLineEdit();
// FIXME KF5 m_arguments->setClearButtonShown(true);
m_argumentsLabel = new QLabel(i18nc("Program argument list", "Arguments:"));
m_argumentsLabel->setBuddy(m_arguments);
......@@ -97,7 +97,7 @@ ConfigView::ConfigView(QWidget* parent, Kate::MainWindow* mainWin)
m_redirectTerminal = new QCheckBox(i18n("Redirect IO"));
m_redirectTerminal->setToolTip(i18n("Redirect the debugged programs IO to a separate tab"));
m_advancedSettings = new KPushButton(i18n("Advanced Settings"));
m_advancedSettings = new QPushButton(i18n("Advanced Settings"));
m_checBoxLayout = 0;
......@@ -130,21 +130,20 @@ ConfigView::~ConfigView()
void ConfigView::registerActions(KActionCollection* actionCollection)
{
m_targetSelectAction = actionCollection->add<KSelectAction>("targets");
m_targetSelectAction = actionCollection->add<KSelectAction>(QStringLiteral("targets"));
m_targetSelectAction->setText(i18n("Targets"));
connect(m_targetSelectAction, SIGNAL(triggered(int)),
this, SLOT(slotTargetSelected(int)));
}
void ConfigView::readConfig(KConfigBase* config, QString const& groupPrefix)
void ConfigView::readConfig(const KConfigGroup& group)
{
m_targetCombo->clear();
KConfigGroup group = config->group(groupPrefix);
int version = group.readEntry("version", 4);
int targetCount = group.readEntry("targetCount", 1);
int lastTarget = group.readEntry("lastTarget", 0);
QString targetKey("target_%1");
int version = group.readEntry(QStringLiteral("version"), 4);
int targetCount = group.readEntry(QStringLiteral("targetCount"), 1);
int lastTarget = group.readEntry(QStringLiteral("lastTarget"), 0);
QString targetKey(QStringLiteral("target_%1"));
QStringList targetConfStrs;
......@@ -172,9 +171,9 @@ void ConfigView::readConfig(KConfigBase* config, QString const& groupPrefix)
if (version < 4) {
// all targets now have only one argument string
int argListsCount = group.readEntry("argsCount", 0);
QString argsKey("args_%1");
QString targetName("%1<%2>");
int argListsCount = group.readEntry(QStringLiteral("argsCount"), 0);
QString argsKey(QStringLiteral("args_%1"));
QString targetName(QStringLiteral("%1<%2>"));
QString argStr;
int count = m_targetCombo->count();
......@@ -210,16 +209,14 @@ void ConfigView::readConfig(KConfigBase* config, QString const& groupPrefix)
m_redirectTerminal->setChecked(group.readEntry("redirectTerminal",false));
}
void ConfigView::writeConfig(KConfigBase* config, QString const& groupPrefix)
void ConfigView::writeConfig(KConfigGroup& group)
{
// make sure the data is up to date before writing
saveCurrentToIndex(m_currentTarget);
KConfigGroup group = config->group(groupPrefix);
group.writeEntry("version", 4);
QString targetKey("target_%1");
QString targetKey(QStringLiteral("target_%1"));
QStringList targetConfStrs;
group.writeEntry("targetCount", m_targetCombo->count());
......@@ -246,7 +243,7 @@ const GDBTargetConf ConfigView::currentTarget() const
cfg.customInit.removeFirst();
}
else {
cfg.gdbCmd = "gdb";
cfg.gdbCmd = QStringLiteral("gdb");
}
// remove empty strings in the customInit
int i = cfg.customInit.size()-1;
......@@ -419,7 +416,7 @@ void ConfigView::slotAdvancedClicked()
while (tmp.count() < CustomStartIndex) tmp << QString();
if (tmp[GDBIndex].isEmpty()) {
tmp[GDBIndex] = "gdb";
tmp[GDBIndex] = QStringLiteral("gdb");
}
// Remove the strings that are not part of the advanced settings
......@@ -437,32 +434,32 @@ void ConfigView::slotAdvancedClicked()
void ConfigView::slotBrowseExec()
{
KUrl exe(m_executable->text());
QString exe = m_executable->text();
if (m_executable->text().isEmpty()) {
// try current document dir
KTextEditor::View* view = m_mainWindow->activeView();
if (view != NULL) {
exe = view->document()->url();
exe = view->document()->url().toLocalFile();
}
}
m_executable->setText(KFileDialog::getOpenFileName(exe, "application/x-executable"));
m_executable->setText(QFileDialog::getOpenFileName((QWidget *)0, QString(), exe, QStringLiteral("application/x-executable")));
}
void ConfigView::slotBrowseDir()
{
KUrl dir(m_workingDirectory->text());
QString dir = m_workingDirectory->text();
if (m_workingDirectory->text().isEmpty()) {
// try current document dir
KTextEditor::View* view = m_mainWindow->activeView();
if (view != NULL) {
dir = view->document()->url();
dir = view->document()->url().toLocalFile();
}
}
m_workingDirectory->setText(KFileDialog::getExistingDirectory (dir));
m_workingDirectory->setText(QFileDialog::getExistingDirectory(this, QString(), dir));
}
void ConfigView::saveCurrentToIndex(int index)
......@@ -470,16 +467,16 @@ void ConfigView::saveCurrentToIndex(int index)
if ((index < 0) || (index >= m_targetCombo->count())) {
return;
}
QStringList tmp = m_targetCombo->itemData(index).toStringList();
// make sure we have enough strings. The custom init strings are set in slotAdvancedClicked().
while (tmp.count() < CustomStartIndex) tmp << QString();
tmp[NameIndex] = m_targetCombo->itemText(index);
tmp[ExecIndex] = m_executable->text();
tmp[WorkDirIndex] = m_workingDirectory->text();
tmp[ArgsIndex] = m_arguments->text();
m_targetCombo->setItemData(index, tmp);
}
......@@ -498,4 +495,5 @@ void ConfigView::loadFromIndex(int index)
m_arguments->setText(tmp[ArgsIndex]);
}
#include "configview.moc"
......@@ -26,21 +26,19 @@
#include "advanced_settings.h"
#include <QtGui/QWidget>
#include <QtGui/QLabel>
#include <QtGui/QToolButton>
#include <QtGui/QComboBox>
#include <QtGui/QCheckBox>
#include <QtGui/QBoxLayout>
#include <QtGui/QResizeEvent>
#include <QtCore/QList>
#include <kate/mainwindow.h>
#include <QWidget>
#include <QLabel>
#include <QLineEdit>
#include <QToolButton>
#include <QComboBox>
#include <QCheckBox>
#include <QBoxLayout>
#include <QResizeEvent>
#include <QList>
#include <KTextEditor/MainWindow>
#include <kconfiggroup.h>
#include <kcombobox.h>
#include <klineedit.h>
#include <kpushbutton.h>
#include <kactioncollection.h>
#include <kselectaction.h>
......@@ -65,14 +63,14 @@ public:
CustomStartIndex
};
ConfigView(QWidget* parent, Kate::MainWindow* mainWin);
ConfigView(QWidget* parent, KTextEditor::MainWindow* mainWin);
~ConfigView();
public:
void registerActions(KActionCollection* actionCollection);
void readConfig(KConfigBase* config, QString const& groupPrefix);
void writeConfig(KConfigBase* config, QString const& groupPrefix);
void readConfig (const KConfigGroup& config);
void writeConfig (KConfigGroup& config);
const GDBTargetConf currentTarget() const;
bool takeFocusAlways() const;
......@@ -99,25 +97,25 @@ private:
void loadFromIndex(int index);
private:
Kate::MainWindow* m_mainWindow;
KComboBox* m_targetCombo;
KTextEditor::MainWindow* m_mainWindow;
QComboBox* m_targetCombo;
int m_currentTarget;
QToolButton* m_addTarget;
QToolButton* m_copyTarget;
QToolButton* m_deleteTarget;
QFrame* m_line;
KLineEdit* m_executable;
QLineEdit* m_executable;
QToolButton* m_browseExe;
KLineEdit* m_workingDirectory;
QLineEdit* m_workingDirectory;
QToolButton* m_browseDir;
KLineEdit* m_arguments;
QLineEdit* m_arguments;
QCheckBox* m_takeFocus;
QCheckBox* m_redirectTerminal;
KPushButton* m_advancedSettings;
QPushButton* m_advancedSettings;
QBoxLayout* m_checBoxLayout;
bool m_useBottomLayout;
......
This diff is collapsed.
......@@ -24,10 +24,10 @@
#ifndef DEBUGVIEW_H
#define DEBUGVIEW_H
#include <QtCore/QObject>
#include <QObject>
#include <kprocess.h>
#include <kurl.h>
#include <QProcess>
#include <QUrl>
#include "configview.h"
......@@ -35,19 +35,19 @@ class DebugView : public QObject
{
Q_OBJECT
public:
DebugView( QObject* parent );
DebugView(QObject* parent);
~DebugView();
void runDebugger(const GDBTargetConf &conf, const QStringList &ioFifos);
bool debuggerRunning() const;
bool debuggerBusy() const;
bool hasBreakpoint( KUrl const& url, int line );
bool hasBreakpoint(QUrl const& url, int line);
void toggleBreakpoint( KUrl const& url, int line );
void movePC( KUrl const& url, int line );
void runToCursor( KUrl const& url, int line );
void toggleBreakpoint(QUrl const& url, int line);
void movePC(QUrl const& url, int line);
void runToCursor(QUrl const& url, int line);
void issueCommand( QString const& cmd );
void issueCommand(QString const& cmd);
public Q_SLOTS:
......@@ -65,23 +65,23 @@ private Q_SLOTS:
void slotError();
void slotReadDebugStdOut();
void slotReadDebugStdErr();
void slotDebugFinished( int exitCode, QProcess::ExitStatus status );
void slotDebugFinished(int exitCode, QProcess::ExitStatus status);
void issueNextCommand();
Q_SIGNALS:
void debugLocationChanged( const KUrl &file, int lineNum );
void breakPointSet( const KUrl &file, int lineNum );
void breakPointCleared( const KUrl &file, int lineNum );
void debugLocationChanged(const QUrl &file, int lineNum);
void breakPointSet(const QUrl &file, int lineNum);
void breakPointCleared(const QUrl &file, int lineNum);