Commit 65e53a8b authored by Kåre Särs's avatar Kåre Särs

Port the build plugin to frameworks

Forgot to merge changes in master before porting... TBD
parent 52eb91b0
......@@ -34,20 +34,22 @@ ecm_optional_add_subdirectory( close-except-like )
if(NOT WIN32)
add_subdirectory( gdbplugin ) # should be tested on windows...
ecm_optional_add_subdirectory (gdbplugin) # should be tested on windows...
endif(NOT WIN32)
# build plugin
ecm_optional_add_subdirectory (katebuild-plugin)
#add_subdirectory( textfilter )
#add_subdirectory( mailfiles )
#add_subdirectory( tabbarextension )
#add_subdirectory( symbolviewer )
#add_subdirectory( filetemplates )
#add_subdirectory( katebuild-plugin )
#add_subdirectory( kttsd )
......
# building separately or as part of kdesdk?
if(NOT KDE4_FOUND)
find_package(KDE4 REQUIRED)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif(NOT KDE4_FOUND)
include_directories (${KDE4_INCLUDES})
include_directories( ${KDE4_KIO_INCLUDES} )
set(katebuild_SRCS plugin_katebuild.cpp targets.cpp selecttargetdialog.cpp)
kde4_add_ui_files(katebuild_SRCS build.ui)
kde4_add_plugin(katebuildplugin ${katebuild_SRCS})
qt5_wrap_ui(katebuild_SRCS build.ui)
target_link_libraries(katebuildplugin ${KDE4_KDECORE_LIBS} kateinterfaces ktexteditor )
add_library(katebuildplugin MODULE ${katebuild_SRCS})
install(TARGETS katebuildplugin DESTINATION ${PLUGIN_INSTALL_DIR} )
target_link_libraries(katebuildplugin KF5::TextEditor KF5::I18n KF5::IconThemes)
########### install files ###############
install(FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/katebuild)
install(TARGETS katebuildplugin DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES katebuildplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
ecm_install_icons (${ICON_INSTALL_DIR})
kservice_desktop_to_json (katebuildplugin.desktop)
install( FILES ui.rc DESTINATION ${DATA_INSTALL_DIR}/kate/plugins/katebuild )
install( FILES katebuildplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
......@@ -18,7 +18,7 @@
<number>0</number>
</property>
<item>
<widget class="KTabWidget" name="ktabwidget">
<widget class="QTabWidget" name="u_tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
......@@ -152,18 +152,10 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KTabWidget</class>
<extends>QTabWidget</extends>
<header>ktabwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>errTreeWidget</tabstop>
<tabstop>plainTextEdit</tabstop>
<tabstop>ktabwidget</tabstop>
<tabstop>u_tabWidget</tabstop>
</tabstops>
<resources/>
<connections/>
......
[Desktop Entry]
Type=Service
ServiceTypes=Kate/Plugin
ServiceTypes=KTextEditor/Plugin
X-KDE-Library=katebuildplugin
X-Kate-Version=2.9
Name=Build Plugin
Name[ast]=Complementu de construcción
Name[bg]=Приставка за построяване
......
......@@ -2,7 +2,7 @@
#define PLUGIN_KATEBUILD_H
/* plugin_katebuild.h Kate Plugin
**
** Copyright (C) 2008 by Kåre Särs <kare.sars@iki.fi>
** Copyright (C) 2008-2014 by Kåre Särs <kare.sars@iki.fi>
**
** This code is almost a total rewrite of the GPL'ed Make plugin
** by Adriaan de Groot.
......@@ -25,22 +25,19 @@
** MA 02110-1301, USA.
*/
class QRegExp;
#include <QTreeWidgetItem>
#include <QRegExp>
#include <QString>
#include <QStack>
#include <QProcess>
#include <ktexteditor/view.h>
#include <ktexteditor/document.h>
#include <kate/plugin.h>
#include <kate/application.h>
#include <kate/documentmanager.h>
#include <kate/mainwindow.h>
#include <kprocess.h>
#include <kselectaction.h>
#include <KTextEditor/MainWindow>
#include <KTextEditor/Document>
#include <KTextEditor/Plugin>
#include <KTextEditor/View>
#include <KXMLGUIClient>
#include <KTextEditor/SessionConfigInterface>
#include <KTextEditor/MessageInterface>
#include <KConfigGroup>
#include <map>
......@@ -48,9 +45,10 @@ class QRegExp;
#include "targets.h"
/******************************************************************/
class KateBuildView : public Kate::PluginView, public Kate::XMLGUIClient
class KateBuildView : public QObject, public KXMLGUIClient, public KTextEditor::SessionConfigInterface
{
Q_OBJECT
Q_INTERFACES(KTextEditor::SessionConfigInterface)
public:
......@@ -62,13 +60,13 @@ class KateBuildView : public Kate::PluginView, public Kate::XMLGUIClient
QString prevTarget;
std::map<QString, QString> targets;
};
KateBuildView(Kate::MainWindow *mw);
KateBuildView(KTextEditor::Plugin *plugin, KTextEditor::MainWindow *mw);
~KateBuildView();
// overwritten: read and write session config
void readSessionConfig(KConfigBase* config, const QString& groupPrefix);
void writeSessionConfig(KConfigBase* config, const QString& groupPrefix);
// reimplemented: read and write session config
void readSessionConfig(const KConfigGroup& config);
void writeSessionConfig(KConfigGroup& config);
QWidget *toolView() const;
......@@ -111,8 +109,8 @@ class KateBuildView : public Kate::PluginView, public Kate::XMLGUIClient
/**
* keep track if the project plugin is alive and if the project map did change
*/
void slotPluginViewCreated(const QString &name, Kate::PluginView *pluginView);
void slotPluginViewDeleted(const QString &name, Kate::PluginView *pluginView);
void slotPluginViewCreated(const QString &name, QObject *pluginView);
void slotPluginViewDeleted(const QString &name, QObject *pluginView);
void slotProjectMapChanged();
void slotAddProjectTarget();
void slotRemoveProjectTarget();
......@@ -131,41 +129,43 @@ class KateBuildView : public Kate::PluginView, public Kate::XMLGUIClient
void processLine(const QString &);
void addError(const QString &filename, const QString &line,
const QString &column, const QString &message);
bool startProcess(const KUrl &dir, const QString &command);
KUrl docUrl();
bool checkLocal(const KUrl &dir);
bool startProcess(const QString &dir, const QString &command);
QUrl docUrl();
bool checkLocal(const QUrl &dir);
void setTargetRowContents(int row, const TargetSet& tgtSet, const QString& name, const QString& buildCmd);
QString makeTargetNameUnique(const QString& name);
QString makeUniqueTargetSetName() const;
Kate::MainWindow *m_win;
void displayBuildResult(const QString &message, KTextEditor::Message::MessageType level);
KTextEditor::MainWindow *m_win;
QWidget *m_toolView;
Ui::build m_buildUi;
TargetsUi *m_targetsUi;
KProcess *m_proc;
QProcess *m_proc;
QString m_output_lines;
KUrl m_make_dir;
QStack<KUrl> m_make_dir_stack;
QString m_make_dir;
QStack<QString> m_make_dir_stack;
QRegExp m_filenameDetector;
QRegExp m_newDirDetector;
unsigned int m_numErrors;
unsigned int m_numWarnings;
QList<TargetSet> m_targetList;
int m_targetIndex;
KSelectAction* m_targetSelectAction;
// KF5 FIXME KSelectAction* m_targetSelectAction;
QString m_prevItemContent;
/**
* current project plugin view, if any
*/
Kate::PluginView *m_projectPluginView;
QObject *m_projectPluginView;
};
typedef QList<QVariant> VariantList;
/******************************************************************/
class KateBuildPlugin : public Kate::Plugin
class KateBuildPlugin : public KTextEditor::Plugin
{
Q_OBJECT
......@@ -173,8 +173,7 @@ class KateBuildPlugin : public Kate::Plugin
explicit KateBuildPlugin(QObject* parent = 0, const VariantList& = VariantList());
virtual ~KateBuildPlugin() {}
Kate::PluginView *createView(Kate::MainWindow *mainWindow);
QObject *createView(KTextEditor::MainWindow *mainWindow);
};
#endif
......
......@@ -26,9 +26,11 @@
#include <QLineEdit>
#include <QListWidget>
#include <KLocalizedString>
SelectTargetDialog::SelectTargetDialog(QList<KateBuildView::TargetSet>& targetSets, QWidget* parent)
:KDialog(parent)
:QDialog(parent)
,m_currentTargetSet(0)
,m_targetName(0)
,m_targetsList(0)
......@@ -36,7 +38,7 @@ SelectTargetDialog::SelectTargetDialog(QList<KateBuildView::TargetSet>& targetSe
,m_targetSets(targetSets)
,m_targets(0)
{
setButtons( KDialog::Ok | KDialog::Cancel);
//KF5 FIXME setButtons( KDialog::Ok | KDialog::Cancel);
QWidget* container = new QWidget();
......@@ -72,7 +74,9 @@ SelectTargetDialog::SelectTargetDialog(QList<KateBuildView::TargetSet>& targetSe
container->setLayout(mainLayout);
this->setMainWidget(container);
QVBoxLayout *dialogLayout = new QVBoxLayout;
setLayout(dialogLayout);
dialogLayout->addWidget(container);
connect(m_currentTargetSet, SIGNAL(currentIndexChanged(int)), this, SLOT(slotTargetSetSelected(int)));
connect(m_targetName, SIGNAL(textEdited(const QString&)), this, SLOT(slotFilterTargets(const QString&)));
......@@ -97,7 +101,7 @@ void SelectTargetDialog::setTargetSet(const QString& name)
m_targets = NULL;
m_allTargets.clear();
m_targetsList->clear();
m_command->setText("");
m_command->setText(QString());
m_targetName->clear();
for (int i=0; i<m_targetSets.size(); i++) {
......@@ -192,7 +196,7 @@ bool SelectTargetDialog::eventFilter(QObject *obj, QEvent *event)
}
}
}
return KDialog::eventFilter(obj, event);
return QDialog::eventFilter(obj, event);
}
// kate: space-indent on; indent-width 4; replace-tabs on;
......@@ -20,7 +20,7 @@
// Boston, MA 02110-1301, USA.
#include <kdialog.h>
#include <QDialog>
#include "plugin_katebuild.h"
......@@ -35,7 +35,7 @@ class QListWidget;
class QListWidgetItem;
class SelectTargetDialog : public KDialog
class SelectTargetDialog : public QDialog
{
Q_OBJECT
public:
......
//
// Description: Widget for configuring build targets
//
// Copyright (c) 2011 Kåre Särs <kare.sars@iki.fi>
// Copyright (c) 2011-2014 Kåre Särs <kare.sars@iki.fi>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
......@@ -18,9 +18,8 @@
// Boston, MA 02110-1301, USA.
#include "targets.h"
#include "targets.moc"
#include <klocalizedstring.h>
#include <QApplication>
//#include <QApplication>
#include <QHeaderView>
TargetsUi::TargetsUi(QWidget *parent):
......@@ -29,7 +28,7 @@ QWidget(parent)
targetLabel = new QLabel(i18n("Target set"), this);
targetCombo = new KComboBox(this);
targetCombo = new QComboBox(this);
targetCombo->setEditable(true);
targetCombo->setInsertPolicy(QComboBox::InsertAtCurrent);
connect(targetCombo, SIGNAL(editTextChanged(QString)), this, SLOT(editTarget(QString)));
......@@ -37,22 +36,22 @@ QWidget(parent)
newTarget = new QToolButton(this);
newTarget->setToolTip(i18n("Create new set of targets"));
newTarget->setIcon(KIcon("document-new"));
newTarget->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
copyTarget = new QToolButton(this);
copyTarget->setToolTip(i18n("Copy set of targets"));
copyTarget->setIcon(KIcon("edit-copy"));
copyTarget->setIcon(QIcon::fromTheme(QStringLiteral("edit-copy")));
deleteTarget = new QToolButton(this);
deleteTarget->setToolTip(i18n("Delete current set of targets"));
deleteTarget->setIcon(KIcon("edit-delete"));
deleteTarget->setIcon(QIcon::fromTheme(QStringLiteral("edit-delete")));
dirLabel = new QLabel(i18n("Working directory"), this);
buildDir = new KLineEdit(this);
buildDir = new QLineEdit(this);
buildDir->setToolTip(i18n("Leave empty to use the directory of the current document. "));
buildDir->setClearButtonShown(true);
// KF5 FIXME buildDir->setClearButtonShown(true);
browse = new QToolButton(this);
browse->setIcon(KIcon("inode-directory"));
browse->setIcon(QIcon::fromTheme(QStringLiteral("inode-directory")));
// quickCmd->setToolTip(i18n("Use:\n\"%f\" for current file\n\"%d\" for directory of current file\n\"%n\" for current file name without suffix"));
......@@ -65,20 +64,20 @@ QWidget(parent)
targetsList->setSelectionMode(QAbstractItemView::SingleSelection);
targetsList->setSelectionBehavior(QAbstractItemView::SelectItems); //SelectRows);
QStringList headerLabels;
headerLabels << QString("Def") << QString("Clean") << QString("Name") << QString("Command");
headerLabels << QStringLiteral("Def") << QStringLiteral("Clean") << QStringLiteral("Name") << QStringLiteral("Command");
targetsList->setHorizontalHeaderLabels(headerLabels);
targetsList->verticalHeader()->setVisible(false);
addButton = new QToolButton(this);
addButton->setIcon(KIcon("list-add"));
addButton->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
addButton->setToolTip(i18n("Add new target"));
deleteButton = new QToolButton(this);
deleteButton->setIcon(KIcon("list-remove"));
deleteButton->setIcon(QIcon::fromTheme(QStringLiteral("list-remove")));
deleteButton->setToolTip(i18n("Delete selected target"));
buildButton = new QToolButton(this);
buildButton->setIcon(KIcon("dialog-ok"));
buildButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok")));
buildButton->setToolTip(i18n("Build selected target"));
// calculate the approximate height to exceed before going to "Side Layout"
......@@ -171,3 +170,4 @@ void TargetsUi::editTarget(const QString &text)
targetCombo->lineEdit()->setCursorPosition(curPos);
}
#include "targets.moc"
......@@ -2,17 +2,14 @@
#ifndef TARGETS_H
#define TARGETS_H
#include <QtGui/QComboBox>
#include <QtGui/QFrame>
#include <QtGui/QGridLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
#include <QtGui/QToolButton>
#include <QtGui/QTableWidget>
#include <QtGui/QWidget>
#include "klineedit.h"
#include "kpushbutton.h"
#include <kcombobox.h>
#include <QComboBox>
#include <QFrame>
#include <QGridLayout>
#include <QLabel>
#include <QToolButton>
#include <QTableWidget>
#include <QWidget>
#include <QLineEdit>
#define COL_DEFAULT_TARGET 0
......@@ -35,7 +32,7 @@ public:
QToolButton *deleteTarget;
QLabel *dirLabel;
KLineEdit *buildDir;
QLineEdit *buildDir;
QToolButton *browse;
QTableWidget *targetsList;
......
<!DOCTYPE kpartgui>
<gui name="katebuild-plugin" library="katebuildplugin" version="8">
<MenuBar>
<Menu name="Build"><text>&amp;Build</text>
<Menu name="Build Menubar"><text>&amp;Build</text>
<Action name="run_make"/>
<Action name="select_target" />
<Action name="build_previous_target" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment