diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kexi/formeditor/test | |
download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/formeditor/test')
-rw-r--r-- | kexi/formeditor/test/Makefile.am | 46 | ||||
-rw-r--r-- | kexi/formeditor/test/cr16-app-kformdesigner.png | bin | 0 -> 493 bytes | |||
-rw-r--r-- | kexi/formeditor/test/cr22-app-kformdesigner.png | bin | 0 -> 733 bytes | |||
-rw-r--r-- | kexi/formeditor/test/cr32-app-kformdesigner.png | bin | 0 -> 1126 bytes | |||
-rw-r--r-- | kexi/formeditor/test/kfd_mainwindow.cpp | 88 | ||||
-rw-r--r-- | kexi/formeditor/test/kfd_mainwindow.h | 46 | ||||
-rw-r--r-- | kexi/formeditor/test/kfd_mainwindow.rc | 26 | ||||
-rw-r--r-- | kexi/formeditor/test/kfd_part.cpp | 729 | ||||
-rw-r--r-- | kexi/formeditor/test/kfd_part.h | 142 | ||||
-rw-r--r-- | kexi/formeditor/test/kformdesigner.desktop | 61 | ||||
-rw-r--r-- | kexi/formeditor/test/kformdesigner_part.desktop | 52 | ||||
-rw-r--r-- | kexi/formeditor/test/kformdesigner_part.rc | 125 | ||||
-rw-r--r-- | kexi/formeditor/test/kformdesigner_part_shell.rc | 138 | ||||
-rw-r--r-- | kexi/formeditor/test/main.cpp | 81 |
14 files changed, 1534 insertions, 0 deletions
diff --git a/kexi/formeditor/test/Makefile.am b/kexi/formeditor/test/Makefile.am new file mode 100644 index 00000000..f039daeb --- /dev/null +++ b/kexi/formeditor/test/Makefile.am @@ -0,0 +1,46 @@ +## Makefile.am for kformdesigner + +include $(top_srcdir)/kexi/Makefile.global + +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +bin_PROGRAMS = kformdesigner + +# set the include path for X, qt and KDE +INCLUDES = -I$(top_srcdir)/kexi -I$(top_srcdir)/kexi/formeditor \ + -I$(top_srcdir)/kexi/widget -I$(top_srcdir)/kexi/core \ + -I$(top_srcdir)/lib -I$(top_srcdir)/lib/kofficecore $(all_includes) + +kformdesigner_LDFLAGS = $(KDE_RPATH) $(all_libraries) + +kformdesigner_LDADD = $(top_builddir)/kexi/formeditor/libkformdesigner.la + +kformdesigner_SOURCES = main.cpp kfd_mainwindow.cpp + +# client stuff + +METASOURCES = AUTO + +kdelnkdir = $(kde_appsdir)/Development +kdelnk_DATA = kformdesigner.desktop + +rcdir = $(kde_datadir)/kformdesigner +rc_DATA = kfd_mainwindow.rc + + +# KFormDesigner KPart +kde_module_LTLIBRARIES = libkformdesigner_part.la + +libkformdesigner_part_la_SOURCES = kfd_part.cpp +libkformdesigner_part_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) $(VER_INFO) +libkformdesigner_part_la_LIBADD = $(top_builddir)/kexi/formeditor/libkformdesigner.la $(LIB_KFILE) + +# this is where the desktop file will go +partdesktopdir = $(kde_servicesdir) +partdesktop_DATA = kformdesigner_part.desktop + +# this is where the part's XML-GUI resource file goes +partrcdir = $(kde_datadir)/kformdesigner_part +partrc_DATA = kformdesigner_part.rc kformdesigner_part_shell.rc + +KDE_ICON = kformdesigner diff --git a/kexi/formeditor/test/cr16-app-kformdesigner.png b/kexi/formeditor/test/cr16-app-kformdesigner.png Binary files differnew file mode 100644 index 00000000..fee34b1a --- /dev/null +++ b/kexi/formeditor/test/cr16-app-kformdesigner.png diff --git a/kexi/formeditor/test/cr22-app-kformdesigner.png b/kexi/formeditor/test/cr22-app-kformdesigner.png Binary files differnew file mode 100644 index 00000000..50f608cc --- /dev/null +++ b/kexi/formeditor/test/cr22-app-kformdesigner.png diff --git a/kexi/formeditor/test/cr32-app-kformdesigner.png b/kexi/formeditor/test/cr32-app-kformdesigner.png Binary files differnew file mode 100644 index 00000000..e98d13d9 --- /dev/null +++ b/kexi/formeditor/test/cr32-app-kformdesigner.png diff --git a/kexi/formeditor/test/kfd_mainwindow.cpp b/kexi/formeditor/test/kfd_mainwindow.cpp new file mode 100644 index 00000000..e9d52e47 --- /dev/null +++ b/kexi/formeditor/test/kfd_mainwindow.cpp @@ -0,0 +1,88 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ +#include <kaction.h> +#include <kstdaction.h> +#include <kurl.h> +#include <kdebug.h> +#include <klibloader.h> +#include <kmessagebox.h> +#include <klocale.h> +#include <kapplication.h> + +#include "kfd_mainwindow.h" + +KFDMainWindow::KFDMainWindow() + : KParts::MainWindow() +{ + setXMLFile("kfd_mainwindow.rc"); + + setupActions(); + //statusBar()->show(); + + KLibFactory *factory = KLibLoader::self()->factory("libkformdesigner_part"); + if (factory) + { + QStringList list; + list << "shell" << "multipleMode"; + m_part = static_cast<KParts::ReadWritePart *>( factory->create(this, "kformdesigner_part", "KParts::ReadWritePart", list) ); + + if(m_part) + { + setCentralWidget(m_part->widget()); + createGUI(m_part); + } + } + else + { + KMessageBox::error(this, i18n("Could not find the KFormDesigner part. Please check your installation.")); + kapp->quit(); + return; + } + + setAutoSaveSettings(); +} + +void +KFDMainWindow::loadUIFile(const QString &filename) +{ + loadUIFile(KURL::fromPathOrURL(filename)); +} + +void +KFDMainWindow::loadUIFile(const KURL &url) +{ + m_part->openURL(url); +} + +void +KFDMainWindow::setupActions() +{ + KStdAction::quit(kapp, SLOT(quit()), actionCollection()); +} + +bool +KFDMainWindow::queryClose() +{ + if(!m_part) + return true; + + return m_part->closeURL(); +} + +#include "kfd_mainwindow.moc" diff --git a/kexi/formeditor/test/kfd_mainwindow.h b/kexi/formeditor/test/kfd_mainwindow.h new file mode 100644 index 00000000..03892a1e --- /dev/null +++ b/kexi/formeditor/test/kfd_mainwindow.h @@ -0,0 +1,46 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef KFORMDESIGNER_MAINWINDOW_H +#define KFORMDESIGNER_MAINWINDOW_H + +#include <kparts/mainwindow.h> + +class KFDMainWindow : public KParts::MainWindow +{ + Q_OBJECT + + public: + KFDMainWindow(); + ~KFDMainWindow() {;} + + /** @todo change it to bool */ + void loadUIFile(const QString &filename); + /** @todo change it to bool */ + void loadUIFile(const KURL &url); + virtual bool queryClose(); + + private: + void setupActions(); + + private: + KParts::ReadWritePart *m_part; +}; + +#endif diff --git a/kexi/formeditor/test/kfd_mainwindow.rc b/kexi/formeditor/test/kfd_mainwindow.rc new file mode 100644 index 00000000..66f48600 --- /dev/null +++ b/kexi/formeditor/test/kfd_mainwindow.rc @@ -0,0 +1,26 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="kfd_mainwindow" version="1"> +<MenuBar> + <Menu noMerge="1" name="file"><text>&File</text> + <Merge/> + <Separator/> + <Action name="file_quit"/> + </Menu> + <Menu noMerge="1" name="edit"><text>&Edit</text> + <Merge/> + </Menu> + <Menu noMerge="1" name="view"><text>&View</text> + <Merge/> + </Menu> + <Menu noMerge="1" name="tools"><text>&Tools</text> + <Merge/> + </Menu> + <Menu noMerge="1" name="widgets"><text>&Widgets</text> + <Merge/> + </Menu> + <Menu noMerge="1" name="format"><text>&Format</text> + <Merge/> + </Menu> + <Merge/> +</MenuBar> +</kpartgui>
\ No newline at end of file diff --git a/kexi/formeditor/test/kfd_part.cpp b/kexi/formeditor/test/kfd_part.cpp new file mode 100644 index 00000000..48832be8 --- /dev/null +++ b/kexi/formeditor/test/kfd_part.cpp @@ -0,0 +1,729 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#include <qworkspace.h> +#include <qdockarea.h> +#include <qdockwindow.h> +#include <qhbox.h> +#include <qpainter.h> +#include <qevent.h> +#include <qobjectlist.h> + +#include <kdeversion.h> +#include <kaction.h> +#include <kinstance.h> +#include <klocale.h> +#include <kaboutdata.h> +#include <kdebug.h> +#include <kstdaction.h> +#include <kapplication.h> +#include <kiconloader.h> +#include <kfiledialog.h> +#include <klibloader.h> +#include <kmessagebox.h> + +#include "form.h" +#include "formIO.h" +#include "objecttree.h" +#include "container.h" +#include "formmanager.h" +#include "objecttreeview.h" +#include <koproperty/set.h> +#include <koproperty/editor.h> + +#include "kfd_part.h" + +/* +#define ENABLE_ACTION(name, enable) + if(actionCollection()->action( name )) + actionCollection()->action( name )->setEnabled( enable ) +*/ + +class KFDPart_FormManager : public KFormDesigner::FormManager +{ + public: + /*! Constructs FormManager object. + See WidgetLibrary's constructor documentation for information about + \a supportedFactoryGroups parameter. + Using \a options you can control manager's behaviour, see \ref Options. */ + KFDPart_FormManager(KFormDesignerPart *part, int options = 0, const char *name = 0) + : KFormDesigner::FormManager(part, options, name) + , m_part(part) + { + } + + virtual KAction* action( const char* name) + { + return m_part->actionCollection()->action( name ); + } + + virtual void enableAction( const char* name, bool enable ) { + if(m_part->actionCollection()->action( name )) + m_part->actionCollection()->action( name )->setEnabled( enable ); + } + + KFormDesignerPart *m_part; +}; + +KInstance *KFDFactory::m_instance = 0L; + +KFDFactory::KFDFactory() +{} + +KFDFactory::~KFDFactory() +{ + if (m_instance) + { + delete m_instance->aboutData(); + delete m_instance; + } + + m_instance = 0; +} + +KParts::Part* +KFDFactory::createPartObject( QWidget *parentWidget, const char *, QObject *, const char *name, + const char *classname, const QStringList &args) +{ + bool readOnly = (classname == "KParts::ReadOnlyPart"); + KFormDesignerPart *part = new KFormDesignerPart(parentWidget, name, readOnly, args); + return part; +} + +KInstance* +KFDFactory::instance() +{ + if (!m_instance) + m_instance = new KInstance(aboutData()); + return m_instance; +} + +KAboutData* +KFDFactory::aboutData() +{ + KAboutData *about = new KAboutData("kformdesigner_part", I18N_NOOP("Form Designer Part"), "0.3"); + return about; +} + +KFormDesigner::WidgetLibrary* KFormDesignerPart::static_formsLibrary = 0L; + +KFormDesignerPart::KFormDesignerPart(QWidget *parent, const char *name, bool readOnly, const QStringList &args) +: KParts::ReadWritePart(parent, name), m_count(0) +{ + setInstance(KFDFactory::instance()); + instance()->iconLoader()->addAppDir("kexi"); + instance()->iconLoader()->addAppDir("kformdesigner"); + + setReadWrite(!readOnly); + m_uniqueFormMode = true; + m_openingFile = false; + + if(!args.grep("multipleMode").isEmpty()) + setUniqueFormMode(false); + m_inShell = (!args.grep("shell").isEmpty()); + + QHBox *container = new QHBox(parent, "kfd_container_widget"); + + m_workspace = new QWorkspace(container, "kfd_workspace"); + m_workspace->show(); + + QStringList supportedFactoryGroups; +/* @todo add configuration for supported factory groups */ + static_formsLibrary = KFormDesigner::FormManager::createWidgetLibrary( + new KFDPart_FormManager(this, 0, "kfd_manager"), supportedFactoryGroups ); + + if(!readOnly) + { + QDockArea *dockArea = new QDockArea(Vertical, QDockArea::Reverse, container, "kfd_part_dockarea"); + + QDockWindow *dockTree = new QDockWindow(dockArea); + KFormDesigner::ObjectTreeView *view = new KFormDesigner::ObjectTreeView(dockTree); + dockTree->setWidget(view); + dockTree->setCaption(i18n("Objects")); + dockTree->setResizeEnabled(true); + dockTree->setFixedExtentWidth(256); + + QDockWindow *dockEditor = new QDockWindow(dockArea); + m_editor = new KoProperty::Editor(dockEditor); + dockEditor->setWidget(m_editor); + dockEditor->setCaption(i18n("Properties")); + dockEditor->setResizeEnabled(true); + + KFormDesigner::FormManager::self()->setEditor(m_editor); + KFormDesigner::FormManager::self()->setObjectTreeView(view); + + setupActions(); + setModified(false); + + // action stuff +// connect(m_manager, SIGNAL(widgetSelected(KFormDesigner::Form*, bool)), SLOT(slotWidgetSelected(KFormDesigner::Form*, bool))); +// connect(m_manager, SIGNAL(formWidgetSelected(KFormDesigner::Form*)), SLOT(slotFormWidgetSelected(KFormDesigner::Form*))); +// connect(m_manager, SIGNAL(noFormSelected()), SLOT(slotNoFormSelected())); + connect(KFormDesigner::FormManager::self(), SIGNAL(undoEnabled(bool, const QString&)), SLOT(setUndoEnabled(bool, const QString&))); + connect(KFormDesigner::FormManager::self(), SIGNAL(redoEnabled(bool, const QString&)), SLOT(setRedoEnabled(bool, const QString&))); + connect(KFormDesigner::FormManager::self(), SIGNAL(dirty(KFormDesigner::Form*, bool)), this, SLOT(slotFormModified(KFormDesigner::Form*, bool))); + } + + container->show(); + setWidget(container); + connect(m_workspace, SIGNAL(windowActivated(QWidget*)), KFormDesigner::FormManager::self(), SLOT(windowChanged(QWidget*))); + connect(KFormDesigner::FormManager::self(), SIGNAL(propertySetSwitched(KoProperty::Set*, bool, const QCString&)), + this, SLOT(slotPropertySetSwitched(KoProperty::Set*, bool, const QCString&))); + +// slotNoFormSelected(); + KFormDesigner::FormManager::self()->emitNoFormSelected(); +} + +KFormDesignerPart::~KFormDesignerPart() +{ +} + +KFormDesigner::WidgetLibrary* KFormDesignerPart::formsLibrary() +{ + return static_formsLibrary; +} + +void +KFormDesignerPart::setupActions() +{ + KStdAction::open(this, SLOT(open()), actionCollection()); + KStdAction::openNew(this, SLOT(createBlankForm()), actionCollection()); + KStdAction::save(this, SLOT(save()), actionCollection()); + KStdAction::saveAs(this, SLOT(saveAs()), actionCollection()); + KStdAction::cut(KFormDesigner::FormManager::self(), SLOT(cutWidget()), actionCollection()); + KStdAction::copy(KFormDesigner::FormManager::self(), SLOT(copyWidget()), actionCollection()); + KStdAction::paste(KFormDesigner::FormManager::self(), SLOT(pasteWidget()), actionCollection()); + KStdAction::undo(KFormDesigner::FormManager::self(), SLOT(undo()), actionCollection()); + KStdAction::redo(KFormDesigner::FormManager::self(), SLOT(redo()), actionCollection()); + KStdAction::selectAll(KFormDesigner::FormManager::self(), SLOT(selectAll()), actionCollection()); + new KAction(i18n("Clear Widget Contents"), "editclear", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(clearWidgetContent()), actionCollection(), "clear_contents"); + new KAction(i18n("Delete Widget"), "editdelete", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(deleteWidget()), actionCollection(), "edit_delete"); + new KAction(i18n("Preview Form"), "filequickprint", CTRL+Key_T, this, SLOT(slotPreviewForm()), actionCollection(), "preview_form"); + new KAction(i18n("Edit Tab Order"), "tab_order", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(editTabOrder()), actionCollection(), "taborder"); + new KAction(i18n("Edit Pixmap Collection"), "icons", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(editFormPixmapCollection()), actionCollection(), "pixmap_collection"); + new KAction(i18n("Edit Form Connections"), "connections", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(editConnections()), actionCollection(), "form_connections"); + + KActionMenu *layoutMenu = new KActionMenu(i18n("Group Widgets"), "", actionCollection(), "layout_menu"); + layoutMenu->insert(new KAction(i18n("&Horizontally"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutHBox()), actionCollection(), "layout_hbox")); + layoutMenu->insert(new KAction(i18n("&Vertically"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutVBox()), actionCollection(), "layout_vbox")); + layoutMenu->insert(new KAction(i18n("In &Grid"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutGrid()), actionCollection(), "layout_grid")); + layoutMenu->insert(new KAction(i18n("By &Rows"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutHFlow()), actionCollection(), "layout_hflow")); + layoutMenu->insert(new KAction(i18n("By &Columns"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutVFlow()), actionCollection(), "layout_vflow")); + layoutMenu->insert(new KAction(i18n("Horizontally in &Splitter"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutHSplitter()), actionCollection(), "layout_hsplitter")); + layoutMenu->insert(new KAction(i18n("Verti&cally in Splitter"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutVSplitter()), actionCollection(), "layout_vsplitter")); + new KAction(i18n("&Ungroup Widgets"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(breakLayout()), actionCollection(), "break_layout"); + +/* + new KAction(i18n("Lay Out Widgets &Horizontally"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutHBox()), actionCollection(), "layout_hbox"); + new KAction(i18n("Lay Out Widgets &Vertically"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutVBox()), actionCollection(), "layout_vbox"); + new KAction(i18n("Lay Out Widgets in &Grid"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutGrid()), actionCollection(), "layout_grid"); + new KAction(i18n("Lay Out Widgets H&orizontally in Splitter"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutHSplitter()), actionCollection(), "layout_hsplitter"); + new KAction(i18n("Lay Out Widgets Verti&cally in Splitter"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(layoutVSplitter()), actionCollection(), "layout_vsplitter"); + new KAction(i18n("&Break Layout"), QString::null, KShortcut(0), KFormDesigner::FormManager::self(), SLOT(breakLayout()), actionCollection(), "break_layout"); +*/ + new KAction(i18n("Bring Widget to Front"), "raise", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(bringWidgetToFront()), actionCollection(), "format_raise"); + new KAction(i18n("Send Widget to Back"), "lower", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(sendWidgetToBack()), actionCollection(), "format_lower"); + + KActionMenu *alignMenu = new KActionMenu(i18n("Align Widgets' Positions"), "aopos2grid", actionCollection(), "align_menu"); + alignMenu->insert( new KAction(i18n("To Left"), "aoleft", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(alignWidgetsToLeft()), actionCollection(), "align_to_left") ); + alignMenu->insert( new KAction(i18n("To Right"), "aoright", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(alignWidgetsToRight()), actionCollection(), "align_to_right") ); + alignMenu->insert( new KAction(i18n("To Top"), "aotop", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(alignWidgetsToTop()), actionCollection(), "align_to_top") ); + alignMenu->insert( new KAction(i18n("To Bottom"), "aobottom", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(alignWidgetsToBottom()), actionCollection(), "align_to_bottom") ); + alignMenu->insert( new KAction(i18n("To Grid"), "aopos2grid", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(alignWidgetsToGrid()), actionCollection(), "align_to_grid") ); + + KActionMenu *sizeMenu = new KActionMenu(i18n("Adjust Widgets' Sizes"), "aogrid", actionCollection(), "adjust_size_menu"); + sizeMenu->insert( new KAction(i18n("To Fit"), "aofit", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(adjustWidgetSize()), actionCollection(), "adjust_to_fit") ); + sizeMenu->insert( new KAction(i18n("To Grid"), "aogrid", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(adjustSizeToGrid()), actionCollection(), "adjust_size_grid") ); + sizeMenu->insert( new KAction(i18n("To Shortest"), "aoshortest", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(adjustHeightToSmall()), actionCollection(), "adjust_height_small") ); + sizeMenu->insert( new KAction(i18n("To Tallest"), "aotallest", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(adjustHeightToBig()), actionCollection(), "adjust_height_big") ); + sizeMenu->insert( new KAction(i18n("To Narrowest"), "aonarrowest", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(adjustWidthToSmall()), actionCollection(), "adjust_width_small") ); + sizeMenu->insert( new KAction(i18n("To Widest"), "aowidest", KShortcut(0), KFormDesigner::FormManager::self(), SLOT(adjustWidthToBig()), actionCollection(), "adjust_width_big") ); + + if(m_inShell) + setXMLFile("kformdesigner_part_shell.rc"); + else + setXMLFile("kformdesigner_part.rc"); + KFormDesigner::FormManager::self()->createActions(formsLibrary(), actionCollection(), this); +} + +void +KFormDesignerPart::createBlankForm() +{ + if(KFormDesigner::FormManager::self()->activeForm() && m_uniqueFormMode) + { + m_openingFile = true; + closeURL(); + m_openingFile = false; + } + + if(m_uniqueFormMode && KFormDesigner::FormManager::self()->activeForm() + && !KFormDesigner::FormManager::self()->activeForm()->isModified() + && KFormDesigner::FormManager::self()->activeForm()->filename().isNull()) + return; // active form is already a blank one + + QString n = i18n("Form") + QString::number(++m_count); + Form *form = new Form(formsLibrary(), n.latin1(), + false/*!designMode, we need to set it early enough*/); + FormWidgetBase *w = new FormWidgetBase(this, m_workspace, n.latin1()); + + w->setCaption(n); + w->setIcon(SmallIcon("form")); + w->resize(350, 300); + w->show(); + w->setFocus(); + + form->createToplevel(w, w); + KFormDesigner::FormManager::self()->importForm(form); +} + +void +KFormDesignerPart::open() +{ + m_openingFile = true; + KURL url = KFileDialog::getOpenURL("::kformdesigner", i18n("*.ui|Qt Designer UI Files"), m_workspace->topLevelWidget()); + if(!url.isEmpty()) + ReadWritePart::openURL(url); + m_openingFile = false; +} + +bool +KFormDesignerPart::openFile() +{ + Form *form = new Form(formsLibrary()); + FormWidgetBase *w = new FormWidgetBase(this, m_workspace); + form->createToplevel(w, w); + + if(!KFormDesigner::FormIO::loadFormFromFile(form, w, m_file)) + { + delete form; + delete w; + return false; + } + + w->show(); + KFormDesigner::FormManager::self()->importForm(form, !isReadWrite()); + return true; +} + +bool +KFormDesignerPart::saveFile() +{ + KFormDesigner::FormIO::saveFormToFile(KFormDesigner::FormManager::self()->activeForm(), m_file); + return true; +} + +void +KFormDesignerPart::saveAs() +{ + KURL url = KFileDialog::getSaveURL("::kformdesigner", i18n("*.ui|Qt Designer UI Files"), + m_workspace->topLevelWidget()); + if(url.isEmpty()) + return; + else + ReadWritePart::saveAs(url); +} + +bool +KFormDesignerPart::closeForm(Form *form) +{ + int res = KMessageBox::questionYesNoCancel( m_workspace->topLevelWidget(), + i18n( "The form \"%1\" has been modified.\n" + "Do you want to save your changes or discard them?" ).arg( form->objectTree()->name() ), + i18n( "Close Form" ), KStdGuiItem::save(), KStdGuiItem::discard() ); + + if(res == KMessageBox::Yes) + save(); + + return (res != KMessageBox::Cancel); +} + +bool +KFormDesignerPart::closeForms() +{ + QWidgetList list = m_workspace->windowList(QWorkspace::CreationOrder); + for(QWidget *w = list.first(); w; w = list.next()) + if(w->close() == false) + return false; + + return true; +} + +bool +KFormDesignerPart::closeURL() +{ + if(!KFormDesigner::FormManager::self()->activeForm()) + return true; + + if(m_uniqueFormMode || !m_openingFile) { + if (!closeForms()) + return false; + } + + delete (KoProperty::Editor*)m_editor; + return true; +} + +void +KFormDesignerPart::slotFormModified(Form *, bool isDirty) +{ + setModified(isDirty); +} + +void +KFormDesignerPart::slotPreviewForm() +{ + if(!KFormDesigner::FormManager::self()->activeForm()) + return; + + FormWidgetBase *w = new FormWidgetBase(this, m_workspace); + KFormDesigner::FormManager::self()->previewForm(KFormDesigner::FormManager::self()->activeForm(), w); +} + +#if 0 + +void +KFormDesignerPart::slotWidgetSelected(Form *form, bool multiple) +{ + enableFormActions(); + // Enable edit actions + ENABLE_ACTION("edit_copy", true); + ENABLE_ACTION("edit_cut", true); + ENABLE_ACTION("edit_delete", true); + ENABLE_ACTION("clear_contents", true); + + // 'Align Widgets' menu + ENABLE_ACTION("align_menu", multiple); + ENABLE_ACTION("align_to_left", multiple); + ENABLE_ACTION("align_to_right", multiple); + ENABLE_ACTION("align_to_top", multiple); + ENABLE_ACTION("align_to_bottom", multiple); + + ENABLE_ACTION("adjust_size_menu", true); + ENABLE_ACTION("adjust_width_small", multiple); + ENABLE_ACTION("adjust_width_big", multiple); + ENABLE_ACTION("adjust_height_small", multiple); + ENABLE_ACTION("adjust_height_big", multiple); + + ENABLE_ACTION("format_raise", true); + ENABLE_ACTION("format_lower", true); + + // If the widgets selected is a container, we enable layout actions + bool containerSelected = false; + if(!multiple) + { + KFormDesigner::ObjectTreeItem *item = form->objectTree()->lookup( form->selectedWidgets()->first()->name() ); + if(item && item->container()) + containerSelected = true; + } + const bool twoSelected = form->selectedWidgets()->count()==2; + // Layout actions + ENABLE_ACTION("layout_menu", multiple || containerSelected); + ENABLE_ACTION("layout_hbox", multiple || containerSelected); + ENABLE_ACTION("layout_vbox", multiple || containerSelected); + ENABLE_ACTION("layout_grid", multiple || containerSelected); + ENABLE_ACTION("layout_hsplitter", twoSelected); + ENABLE_ACTION("layout_vsplitter", twoSelected); + + KFormDesigner::Container *container = KFormDesigner::FormManager::self()->activeForm()->activeContainer(); + ENABLE_ACTION("break_layout", (container->layoutType() != KFormDesigner::Container::NoLayout)); +} + +void +KFormDesignerPart::slotFormWidgetSelected(Form *form) +{ + disableWidgetActions(); + enableFormActions(); + + const bool twoSelected = form->selectedWidgets()->count()==2; + const bool hasChildren = !form->objectTree()->children()->isEmpty(); + + // Layout actions + ENABLE_ACTION("layout_menu", hasChildren); + ENABLE_ACTION("layout_hbox", hasChildren); + ENABLE_ACTION("layout_vbox", hasChildren); + ENABLE_ACTION("layout_grid", hasChildren); + ENABLE_ACTION("layout_hsplitter", twoSelected); + ENABLE_ACTION("layout_vsplitter", twoSelected); + ENABLE_ACTION("break_layout", (form->toplevelContainer()->layoutType() != KFormDesigner::Container::NoLayout)); +} + +void +KFormDesignerPart::slotNoFormSelected() +{ + disableWidgetActions(); + + // Disable paste action + ENABLE_ACTION("edit_paste", false); + + ENABLE_ACTION("edit_undo", false); + ENABLE_ACTION("edit_redo", false); + + // Disable 'Tools' actions + ENABLE_ACTION("pixmap_collection", false); + ENABLE_ACTION("form_connections", false); + ENABLE_ACTION("taborder", false); + ENABLE_ACTION("change_style", KFormDesigner::FormManager::self()->activeForm()); + + // Disable items in 'File' + ENABLE_ACTION("file_save", false); + ENABLE_ACTION("file_save_as", false); + ENABLE_ACTION("preview_form", false); +} + +void +KFormDesignerPart::enableFormActions() +{ + // Enable 'Tools' actions + ENABLE_ACTION("pixmap_collection", true); + ENABLE_ACTION("form_connections", true); + ENABLE_ACTION("taborder", true); + ENABLE_ACTION("change_style", true); + + // Enable items in 'File' + ENABLE_ACTION("file_save", true); + ENABLE_ACTION("file_save_as", true); + ENABLE_ACTION("preview_form", true); + + ENABLE_ACTION("edit_paste", KFormDesigner::FormManager::self()->isPasteEnabled()); + ENABLE_ACTION("edit_select_all", true); +} + +void +KFormDesignerPart::disableWidgetActions() +{ + // Disable edit actions + ENABLE_ACTION("edit_copy", false); + ENABLE_ACTION("edit_cut", false); + ENABLE_ACTION("edit_delete", false); + ENABLE_ACTION("clear_contents", false); + + // Disable format functions + ENABLE_ACTION("align_menu", false); + ENABLE_ACTION("align_to_left", false); + ENABLE_ACTION("align_to_right", false); + ENABLE_ACTION("align_to_top", false); + ENABLE_ACTION("align_to_bottom", false); + ENABLE_ACTION("adjust_size_menu", false); + ENABLE_ACTION("format_raise", false); + ENABLE_ACTION("format_lower", false); + + ENABLE_ACTION("layout_menu", false); + ENABLE_ACTION("layout_hbox", false); + ENABLE_ACTION("layout_vbox", false); + ENABLE_ACTION("layout_grid", false); + ENABLE_ACTION("layout_hsplitter", false); + ENABLE_ACTION("layout_vsplitter", false); + ENABLE_ACTION("break_layout", false); +} +#endif + +void +KFormDesignerPart::setUndoEnabled(bool enabled, const QString &text) +{ + KAction *undoAction = actionCollection()->action("edit_undo"); + if(undoAction) + { + if(!text.isNull()) + undoAction->setText(text); + } +} + +void +KFormDesignerPart::setRedoEnabled(bool enabled, const QString &text) +{ + KAction *redoAction = actionCollection()->action("edit_redo"); + if(redoAction) + { + if(!text.isNull()) + redoAction->setText(text); + } +} + + +////// FormWidgetBase : helper widget to draw rects on top of widgets + +//repaint all children widgets +static void repaintAll(QWidget *w) +{ + w->repaint(); + QObjectList *list = w->queryList("QWidget"); + QObjectListIt it(*list); + for (QObject *obj; (obj=it.current()); ++it ) { + static_cast<QWidget*>(obj)->repaint(); + } + delete list; +} + +void +FormWidgetBase::drawRects(const QValueList<QRect> &list, int type) +{ + QPainter p; + p.begin(this, true); + bool unclipped = testWFlags( WPaintUnclipped ); + setWFlags( WPaintUnclipped ); + + if (prev_rect.isValid()) { + //redraw prev. selection's rectangle + p.drawPixmap( QPoint(prev_rect.x()-2, prev_rect.y()-2), buffer, QRect(prev_rect.x()-2, prev_rect.y()-2, prev_rect.width()+4, prev_rect.height()+4)); + } + p.setBrush(QBrush::NoBrush); + if(type == 1) // selection rect + p.setPen(QPen(white, 1, Qt::DotLine)); + else if(type == 2) // insert rect + p.setPen(QPen(white, 2)); + p.setRasterOp(XorROP); + + prev_rect = QRect(); + QValueList<QRect>::ConstIterator endIt = list.constEnd(); + for(QValueList<QRect>::ConstIterator it = list.constBegin(); it != endIt; ++it) { + p.drawRect(*it); + prev_rect = prev_rect.unite(*it); + } + + if (!unclipped) + clearWFlags( WPaintUnclipped ); + p.end(); +} + +void +FormWidgetBase::drawRect(const QRect& r, int type) +{ + QValueList<QRect> l; + l.append(r); + drawRects(l, type); +} + +void +FormWidgetBase::initBuffer() +{ + repaintAll(this); + buffer.resize( width(), height() ); + buffer = QPixmap::grabWindow( winId() ); + prev_rect = QRect(); +} + +void +FormWidgetBase::clearForm() +{ + QPainter p; + p.begin(this, true); + bool unclipped = testWFlags( WPaintUnclipped ); + setWFlags( WPaintUnclipped ); + + //redraw entire form surface + p.drawPixmap( QPoint(0,0), buffer, QRect(0,0,buffer.width(), buffer.height()) ); + + if (!unclipped) + clearWFlags( WPaintUnclipped ); + p.end(); + + repaintAll(this); +} + +void +FormWidgetBase::highlightWidgets(QWidget *from, QWidget *to)//, const QPoint &point) +{ + QPoint fromPoint, toPoint; + if(from && from->parentWidget() && (from != this)) + fromPoint = from->parentWidget()->mapTo(this, from->pos()); + if(to && to->parentWidget() && (to != this)) + toPoint = to->parentWidget()->mapTo(this, to->pos()); + + QPainter p; + p.begin(this, true); + bool unclipped = testWFlags( WPaintUnclipped ); + setWFlags( WPaintUnclipped ); + + if (prev_rect.isValid()) { + //redraw prev. selection's rectangle + p.drawPixmap( QPoint(prev_rect.x(), prev_rect.y()), buffer, QRect(prev_rect.x(), prev_rect.y(), prev_rect.width(), prev_rect.height())); + } + + p.setPen( QPen(Qt::red, 2) ); + + if(to) + { + QPixmap pix1 = QPixmap::grabWidget(from); + QPixmap pix2 = QPixmap::grabWidget(to); + + if((from != this) && (to != this)) + p.drawLine( from->parentWidget()->mapTo(this, from->geometry().center()), to->parentWidget()->mapTo(this, to->geometry().center()) ); + + p.drawPixmap(fromPoint.x(), fromPoint.y(), pix1); + p.drawPixmap(toPoint.x(), toPoint.y(), pix2); + + if(to == this) + p.drawRoundRect(2, 2, width()-4, height()-4, 4, 4); + else + p.drawRoundRect(toPoint.x(), toPoint.y(), to->width(), to->height(), 5, 5); + } + + if(from == this) + p.drawRoundRect(2, 2, width()-4, height()-4, 4, 4); + else + p.drawRoundRect(fromPoint.x(), fromPoint.y(), from->width(), from->height(), 5, 5); + + if((to == this) || (from == this)) + prev_rect = QRect(0, 0, buffer.width(), buffer.height()); + else if(to) + { + prev_rect.setX( (fromPoint.x() < toPoint.x()) ? (fromPoint.x() - 5) : (toPoint.x() - 5) ); + prev_rect.setY( (fromPoint.y() < toPoint.y()) ? (fromPoint.y() - 5) : (toPoint.y() - 5) ); + prev_rect.setRight( (fromPoint.x() < toPoint.x()) ? (toPoint.x() + to->width() + 10) : (fromPoint.x() + from->width() + 10) ); + prev_rect.setBottom( (fromPoint.y() < toPoint.y()) ? (toPoint.y() + to->height() + 10) : (fromPoint.y() + from->height() + 10) ) ; + } + else + prev_rect = QRect(fromPoint.x()- 5, fromPoint.y() -5, from->width() + 10, from->height() + 10); + + if (!unclipped) + clearWFlags( WPaintUnclipped ); + p.end(); +} + +void +FormWidgetBase::closeEvent(QCloseEvent *ev) +{ + Form *form = KFormDesigner::FormManager::self()->formForWidget(this); + if(!form || !form->isModified() || !form->objectTree()) // == preview form + ev->accept(); + else + { + bool close = m_part->closeForm(form); + if(close) + ev->accept(); + else + ev->ignore(); + } +} + +void KFormDesignerPart::slotPropertySetSwitched(KoProperty::Set *set, bool forceReload, + const QCString& propertyToSelect) +{ + if (m_editor) { + if (propertyToSelect.isEmpty() && forceReload) + m_editor->changeSet(set, propertyToSelect); + else + m_editor->changeSet(set); + } +} + +K_EXPORT_COMPONENT_FACTORY(libkformdesigner_part, KFDFactory) + +#include "kfd_part.moc" + diff --git a/kexi/formeditor/test/kfd_part.h b/kexi/formeditor/test/kfd_part.h new file mode 100644 index 00000000..77b809ca --- /dev/null +++ b/kexi/formeditor/test/kfd_part.h @@ -0,0 +1,142 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ + +#ifndef KFORMDESIGNER_PART_H +#define KFORMDESIGNER_PART_H + +#include <qwidget.h> +#include <qpixmap.h> + +#include <kparts/part.h> +#include <kparts/factory.h> + +#include "form.h" + +class KAboutData; +class KInstance; +class QWorkspace; +class QCloseEvent; + +using KFormDesigner::Form; + +class KFORMEDITOR_EXPORT KFDFactory : public KParts::Factory +{ + Q_OBJECT + + public: + KFDFactory(); + virtual ~KFDFactory(); + + virtual KParts::Part* createPartObject(QWidget *parentWidget=0, const char *widgetName=0, QObject *parent=0, const char *name=0, + const char *classname="KParts::Part", const QStringList &args=QStringList()); + + static KInstance *instance(); + static KAboutData *aboutData(); + + private: + static KInstance *m_instance; +}; + +class KFORMEDITOR_EXPORT KFormDesignerPart: public KParts::ReadWritePart +{ + Q_OBJECT + + public: + KFormDesignerPart(QWidget *parent, const char *name, bool readOnly=true, const QStringList &args=QStringList()); + virtual ~KFormDesignerPart(); + + static KFormDesigner::WidgetLibrary* formsLibrary(); + +// KFormDesigner::FormManager* manager() { return m_manager; } + void setUniqueFormMode(bool enable) { m_uniqueFormMode = enable; } + + bool closeForm(Form *form); + bool closeForms(); + + virtual bool closeURL(); + + public slots: + /*! Creates a new blank Form. The new Form is shown and become the active Form. */ + void createBlankForm(); + + /*! Loads a Form from a UI file. A "Open File" dialog is shown to select the file. The loaded Form is shown and becomes + the active Form. */ + void open(); + + void slotPreviewForm(); + void saveAs(); + //void slotCreateFormSlot(KFormDesigner::Form *form, const QString &widget, const QString &signal); + + protected slots: + void slotFormModified(KFormDesigner::Form *form, bool isDirty); +//moved to manager void slotWidgetSelected(KFormDesigner::Form *form, bool multiple); +//moved to manager void slotFormWidgetSelected(KFormDesigner::Form *form); +//moved to manager void slotNoFormSelected(); + void setUndoEnabled(bool enabled, const QString &text); + void setRedoEnabled(bool enabled, const QString &text); + + /*! Shows a property set \a set in a Property Editor. */ + void slotPropertySetSwitched(KoProperty::Set *set, bool forceReload = false, + const QCString& propertyToSelect = QCString()); + + protected: + virtual bool openFile(); + virtual bool saveFile(); + void disableWidgetActions(); + void enableFormActions(); + void setupActions(); + + private: + static KFormDesigner::WidgetLibrary* static_formsLibrary; +// KFormDesigner::FormManager *m_manager; + QWorkspace *m_workspace; + QGuardedPtr<KoProperty::Editor> m_editor; + int m_count; + bool m_uniqueFormMode; + bool m_openingFile; + bool m_inShell; +}; + +//! Helper: this widget is used to create form's surface +class KFORMEDITOR_EXPORT FormWidgetBase : public QWidget, public KFormDesigner::FormWidget +{ + Q_OBJECT + + public: + FormWidgetBase(KFormDesignerPart *part, QWidget *parent = 0, const char *name = 0, int WFlags = WDestructiveClose) + : QWidget(parent, name, WFlags), m_part(part) {} + ~FormWidgetBase() {;} + + void drawRect(const QRect& r, int type); + void drawRects(const QValueList<QRect> &list, int type); + void initBuffer(); + void clearForm(); + void highlightWidgets(QWidget *from, QWidget *to);//, const QPoint &p); + + protected: + void closeEvent(QCloseEvent *ev); + + private: + QPixmap buffer; //!< stores grabbed entire form's area for redraw + QRect prev_rect; //!< previously selected rectangle + KFormDesignerPart *m_part; +}; + +#endif + diff --git a/kexi/formeditor/test/kformdesigner.desktop b/kexi/formeditor/test/kformdesigner.desktop new file mode 100644 index 00000000..4a018915 --- /dev/null +++ b/kexi/formeditor/test/kformdesigner.desktop @@ -0,0 +1,61 @@ +[Desktop Entry] +Name=KFormDesigner +Name[cs]=Návrhář formulářů +Name[cy]=DylunyddKForm +Name[fa]=طراح KForm +Name[ne]=केडीई फाराम डिजाइनकर्ता +Name[sv]=Kformdesigner +Name[ta]=படிவம் வடிவமைப்பவர் +Name[tg]=KДизайнгари шакл +Name[tr]=KFormTasarımcısı +Name[zh_CN]=KForm 设计器 +Exec=kformdesigner %i %m -caption "%c" +Icon=kformdesigner +Type=Application +DocPath=kformdesigner/kformdesigner.html +GenericName=Form Designer +GenericName[bg]=Проектиране на форми +GenericName[br]=Ergrafer ar paperenn-reol +GenericName[ca]=Dissenyador de formulari +GenericName[cy]=Dylunydd Ffurflenni +GenericName[de]=Formular-Designer +GenericName[el]=Σχεδιαστής φόρμας +GenericName[eo]=Formulardesegnilo +GenericName[es]=Diseñador de formularios +GenericName[et]=Vormikujundaja +GenericName[eu]=Formularioen diseinatzailea +GenericName[fa]=طراح برگه +GenericName[fi]=Lomakkeen suunnittleija +GenericName[fr]=Concepteur d'interfaces graphiques +GenericName[gl]=Deseño de Formularios +GenericName[he]=מעצב טפסים +GenericName[hr]=Dizajner obrazaca +GenericName[hu]=Űrlaptervező +GenericName[is]=Form hönnuður +GenericName[it]=Progetto dei moduli +GenericName[ja]=フォームデザイナー +GenericName[km]=កម្មវិធីរចនាសំណុំបែបបទ +GenericName[lv]=Formu veidotājs +GenericName[ms]=Pereka Bentuk Borang +GenericName[nb]=Skjemautforming +GenericName[nds]=Kiekwark-Maker +GenericName[ne]=फारम डिजाइनकर्ता +GenericName[nn]=Skjemautforming +GenericName[pl]=Projektant formularzy +GenericName[pt]=Desenho de Formulários +GenericName[pt_BR]=Desenhista de Formulário +GenericName[ru]=Редактор форм +GenericName[se]=Skovvehápmejeaddji +GenericName[sl]=Oblikovalec obrazcev +GenericName[sr]=Дизајнер форми +GenericName[sr@Latn]=Dizajner formi +GenericName[sv]=Formulärkonstruktion +GenericName[uk]=Дизайнер форм +GenericName[uz]=Shakl dizayneri +GenericName[uz@cyrillic]=Шакл дизайнери +GenericName[zh_CN]=表单设计器 +GenericName[zh_TW]=表單設計師 +MimeType=application/x-designer; +Terminal=false +Categories=Qt;KDE;Development; + diff --git a/kexi/formeditor/test/kformdesigner_part.desktop b/kexi/formeditor/test/kformdesigner_part.desktop new file mode 100644 index 00000000..b0f38454 --- /dev/null +++ b/kexi/formeditor/test/kformdesigner_part.desktop @@ -0,0 +1,52 @@ +[Desktop Entry] +Name=Form Designer +Name[bg]=Проектиране на форми +Name[br]=Ergrafer ar paperenn-reol +Name[ca]=Dissenyador de formulari +Name[cs]=Návrhář formulářů +Name[cy]=Dylunydd Ffurflenni +Name[de]=Formular-Designer +Name[el]=Σχεδιαστής φόρμας +Name[eo]=Formulardesegnilo +Name[es]=Diseñador de formularios +Name[et]=Vormikujundaja +Name[eu]=Formularioen diseinatzailea +Name[fa]=طراح برگه +Name[fi]=Lomakkeen suunnittelija +Name[fr]=Composeur d'interfaces graphiques +Name[gl]=Deseño de Formularios +Name[he]=מעצב טפסים +Name[hr]=Dizajner obrazaca +Name[hu]=Űrlaptervező +Name[is]=Form hönnuður +Name[it]=Progetto dei moduli +Name[ja]=フォームデザイナー +Name[km]=កម្មវិធីរចនាសំណុំបែបបទ +Name[lt]=Formų kūrimo programa +Name[lv]=Formu veidotājs +Name[ms]=Pereka Bentuk Borang +Name[nb]=Skjemautforming +Name[nds]=Kiekwark-Maker +Name[ne]=फारम डिजाइनकर्ता +Name[nn]=Skjemautforming +Name[pl]=Projektant formularzy +Name[pt]=Desenho de Formulários +Name[pt_BR]=Desenhista de Formulário +Name[ru]=Редактор форм +Name[se]=Skovvehápmejeaddji +Name[sl]=Oblikovalec obrazcev +Name[sr]=Дизајнер форми +Name[sr@Latn]=Dizajner formi +Name[sv]=Formulärkonstruktion +Name[ta]=படிவ வடிவமைப்பாளர் +Name[tg]=Дизайнгари шакл +Name[tr]=FormTasarımcısı +Name[uk]=Дизайнер форм +Name[uz]=Shakl dizayneri +Name[uz@cyrillic]=Шакл дизайнери +Name[zh_CN]=表单设计器 +Name[zh_TW]=表單設計師 +MimeType=application/x-designer; +ServiceTypes=KParts/ReadOnlyPart,KParts/ReadWritePart +X-KDE-Library=libkformdesigner_part +Type=Service diff --git a/kexi/formeditor/test/kformdesigner_part.rc b/kexi/formeditor/test/kformdesigner_part.rc new file mode 100644 index 00000000..03c25f19 --- /dev/null +++ b/kexi/formeditor/test/kformdesigner_part.rc @@ -0,0 +1,125 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="kfd_part" version="2"> + +<MenuBar> + <Menu name="edit" noMerge="1"> + <Action name="edit_undo" group="edit_undo_merge"/> + <Action name="edit_redo" group="edit_undo_merge"/> + <Separator group="edit_undo_merge"/> + <Action name="edit_cut" group="edit_paste_merge"/> + <Action name="edit_copy" group="edit_paste_merge"/> + <Action name="edit_paste" group="edit_paste_merge"/> + <Action name="edit_delete" group="edit_paste_merge"/> + <Action name="clear_contents" group="edit_paste_merge"/> + <Action name="edit_select_all" group="edit_select_merge"/> + </Menu> + <Menu name="tools" noMerge="1"> + <Merge/> + <Separator/> + <Action name="taborder"/> + <Action name="change_style"/> + <Action name="pixmap_collection"/> + <Action name="form_connections"/> + </Menu> + <Menu name="widgets" noMerge="1"> + <text>&Widgets</text> + <Merge/> + <Action name="pointer"/> + <Action name="drag_connection"/> + <Separator/> + <Action name="library_widget_SubForm"/> + <Action name="library_widget_QGroupBox"/> + <Action name="library_widget_KFDTabWidget"/> + <Action name="library_widget_QWidgetStack"/> + <Action name="library_widget_QFrame"/> + <Separator/> + <Action name="library_widget_KLineEdit"/> + <Action name="library_widget_QLabel"/> + <Action name="library_widget_KexiPictureLabel"/> + <Action name="library_widget_KPushButton"/> + <Action name="library_widget_QRadioButton"/> + <Action name="library_widget_QCheckBox"/> + <Action name="library_widget_KIntSpinBox"/> + <Action name="library_widget_KComboBox"/> + <Action name="library_widget_KListBox"/> + <Action name="library_widget_KTextEdit"/> + <Action name="library_widget_KListView"/> + <Action name="library_widget_QSlider"/> + <Action name="library_widget_KProgress"/> + <Action name="library_widget_KTimeWidget"/> + <Action name="library_widget_KDateWidget"/> + <Action name="library_widget_KDateTimeWidget"/> + <Action name="library_widget_Line"/> + <Action name="library_widget_Spring"/> + </Menu> + <Menu name="format" noMerge="1"> + <text>&Format</text> + <Action name="snap_to_grid"/> + <Separator/> + <Action name="layout_menu"/> + <Action name="break_layout"/> + <Separator/> + <Action name="formpart_break_layout"/> + <Action name="align_menu"/> + <Action name="adjust_size_menu"/> + <Separator/> + <Action name="format_raise"/> + <Action name="format_lower"/> + </Menu> +</MenuBar> + +<ToolBar name="fileToolBar" noMerge="1"><text>Main Toolbar</text> + <Action name="preview_form"/> + <Separator/> + <Action name="edit_undo"/> + <Action name="edit_redo"/> + <Separator/> + <Action name="edit_cut"/> + <Action name="edit_copy"/> + <Action name="edit_paste"/> +</ToolBar> +<ToolBar name="containers" fullWidth="false" noMerge="1"> + <text>Containers</text> + <Action name="library_widget_SubForm"/> + <Action name="library_widget_QGroupBox"/> + <Action name="library_widget_KFDTabWidget"/> + <Action name="library_widget_QWidgetStack"/> + <Action name="library_widget_QFrame"/> +</ToolBar> +<ToolBar name="widgets" fullWidth="false" noMerge="1"> + <text>Widgets</text> + <Action name="pointer"/> + <Action name="drag_connection"/> + <Separator/> + <Action name="library_widget_KLineEdit"/> + <Action name="library_widget_QLabel"/> + <Action name="library_widget_KexiPictureLabel"/> + <Action name="library_widget_KPushButton"/> + <Action name="library_widget_QRadioButton"/> + <Action name="library_widget_QCheckBox"/> + <Action name="library_widget_KIntSpinBox"/> + <Action name="library_widget_KComboBox"/> + <Action name="library_widget_KListBox"/> + <Action name="library_widget_KTextEdit"/> + <Action name="library_widget_KListView"/> + <Action name="library_widget_QSlider"/> + <Action name="library_widget_KProgress"/> + <Action name="library_widget_KTimeWidget"/> + <Action name="library_widget_KDateWidget"/> + <Action name="library_widget_KDateTimeWidget"/> + <Action name="library_widget_Line"/> + <Action name="library_widget_Spring"/> + <ActionList name="undo_actions" /> +</ToolBar> +<ToolBar name="tools" fullWidth="false" noMerge="1"> +<text>Tools Toolbar</text> + <Action name="pixmap_collection"/> + <!-- <Action name="change_style"/> !--> +</ToolBar> +<ToolBar name="format" fullWidth="false" noMerge="1"> +<text>Format Toolbar</text> + <Action name="align_menu"/> + <Action name="adjust_size_menu"/> +</ToolBar> + +</kpartgui>
\ No newline at end of file diff --git a/kexi/formeditor/test/kformdesigner_part_shell.rc b/kexi/formeditor/test/kformdesigner_part_shell.rc new file mode 100644 index 00000000..8163cab3 --- /dev/null +++ b/kexi/formeditor/test/kformdesigner_part_shell.rc @@ -0,0 +1,138 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="kfd_part" version="2"> + +<MenuBar> + <Menu name="file" noMerge="1"> + <Action name="file_new"/> + <Action name="file_open"/> + <Separator /> + <Action name="file_save"/> + <Action name="file_save_as"/> + <Separator/> + </Menu> + <Menu name="edit" noMerge="1"> + <Action name="edit_undo" group="edit_undo_merge"/> + <Action name="edit_redo" group="edit_undo_merge"/> + <Separator group="edit_undo_merge"/> + <Action name="edit_cut" group="edit_paste_merge"/> + <Action name="edit_copy" group="edit_paste_merge"/> + <Action name="edit_paste" group="edit_paste_merge"/> + <Action name="edit_delete" group="edit_paste_merge"/> + <Action name="clear_contents" group="edit_paste_merge"/> + <Separator group="edit_select_merge"/> + <Action name="edit_select_all" group="edit_select_merge"/> + <Separator group="edit_paste_merge"/> + </Menu> + <Menu name="view" noMerge="1"> + <Action name="preview_form"/> + </Menu> + <Menu name="tools" noMerge="1"> + <Action name="taborder"/> + <Action name="change_style"/> + <Action name="pixmap_collection"/> + <Action name="form_connections"/> + </Menu> + <Menu name="widgets" noMerge="1"> + <text>&Widgets</text> + <Merge/> + <Action name="pointer"/> + <Action name="drag_connection"/> + <Separator/> + <Action name="library_widget_SubForm"/> + <Action name="library_widget_QGroupBox"/> + <Action name="library_widget_KFDTabWidget"/> + <Action name="library_widget_QWidgetStack"/> + <Action name="library_widget_QFrame"/> + <Separator/> + <Action name="library_widget_KLineEdit"/> + <Action name="library_widget_QLabel"/> + <Action name="library_widget_KexiPictureLabel"/> + <Action name="library_widget_KPushButton"/> + <Action name="library_widget_QRadioButton"/> + <Action name="library_widget_QCheckBox"/> + <Action name="library_widget_KIntSpinBox"/> + <Action name="library_widget_KComboBox"/> + <Action name="library_widget_KListBox"/> + <Action name="library_widget_KTextEdit"/> + <Action name="library_widget_KListView"/> + <Action name="library_widget_QSlider"/> + <Action name="library_widget_KProgress"/> + <Action name="library_widget_KTimeWidget"/> + <Action name="library_widget_KDateWidget"/> + <Action name="library_widget_KDateTimeWidget"/> + <Action name="library_widget_Line"/> + <Action name="library_widget_Spring"/> + </Menu> + <Menu name="format" noMerge="1"> + <text>&Format</text> + <Action name="snap_to_grid"/> + <Separator/> + <Action name="layout_menu"/> + <Action name="break_layout"/> + <Separator/> + <Action name="align_menu"/> + <Action name="adjust_size_menu"/> + <Separator/> + <Action name="format_raise"/> + <Action name="format_lower"/> + </Menu> +</MenuBar> + +<ToolBar name="fileToolBar" noMerge="1"><text>Main Toolbar</text> + <Action name="file_new"/> + <Action name="file_open"/> + <Action name="file_save"/> + <Action name="preview_form"/> + <Separator/> + <Action name="edit_undo"/> + <Action name="edit_redo"/> + <Separator/> + <Action name="edit_cut"/> + <Action name="edit_copy"/> + <Action name="edit_paste"/> +</ToolBar> +<ToolBar name="containers" fullWidth="false" noMerge="1"> + <text>Containers</text> + <Action name="library_widget_SubForm"/> + <Action name="library_widget_QGroupBox"/> + <Action name="library_widget_KFDTabWidget"/> + <Action name="library_widget_QWidgetStack"/> + <Action name="library_widget_QFrame"/> +</ToolBar> +<ToolBar name="widgets" fullWidth="false" noMerge="1"> + <text>Widgets</text> + <Action name="pointer"/> + <Action name="drag_connection"/> + <Separator/> + <Action name="library_widget_KLineEdit"/> + <Action name="library_widget_QLabel"/> + <Action name="library_widget_KexiPictureLabel"/> + <Action name="library_widget_KPushButton"/> + <Action name="library_widget_QRadioButton"/> + <Action name="library_widget_QCheckBox"/> + <Action name="library_widget_KIntSpinBox"/> + <Action name="library_widget_KComboBox"/> + <Action name="library_widget_KListBox"/> + <Action name="library_widget_KTextEdit"/> + <Action name="library_widget_KListView"/> + <Action name="library_widget_QSlider"/> + <Action name="library_widget_KProgress"/> + <Action name="library_widget_KTimeWidget"/> + <Action name="library_widget_KDateWidget"/> + <Action name="library_widget_KDateTimeWidget"/> + <Action name="library_widget_Line"/> + <Action name="library_widget_Spring"/> + <ActionList name="undo_actions" /> +</ToolBar> +<ToolBar name="tools" fullWidth="false" noMerge="1"> +<text>Tools Toolbar</text> + <Action name="pixmap_collection"/> + <!-- <Action name="change_style"/> !--> +</ToolBar> +<ToolBar name="format" fullWidth="false" noMerge="1"> +<text>Format Toolbar</text> + <Action name="align_menu"/> + <Action name="adjust_size_menu"/> +</ToolBar> + +</kpartgui>
\ No newline at end of file diff --git a/kexi/formeditor/test/main.cpp b/kexi/formeditor/test/main.cpp new file mode 100644 index 00000000..f4866f29 --- /dev/null +++ b/kexi/formeditor/test/main.cpp @@ -0,0 +1,81 @@ +/* This file is part of the KDE project + Copyright (C) 2004 Cedric Pasteur <cedric.pasteur@free.fr> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. +*/ +#include "kfd_mainwindow.h" + +#include <kapplication.h> +#include <kiconloader.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <klocale.h> + +static const char *description = + I18N_NOOP("KFormDesigner"); + +static const char *version = "0.3"; + +static KCmdLineOptions options[] = +{ + { "+[URL]", I18N_NOOP( "Document to open" ), 0 }, + KCmdLineLastOption +}; + +int main(int argc, char **argv) +{ + KAboutData about("kformdesigner", I18N_NOOP("KFormDesigner"), version, description, + KAboutData::License_LGPL, "(C) 2003-2005 Kexi Team", 0, 0); + about.addCredit( "Lucijan Busch", "Original author", 0, "lucijan@kde.org" ); + about.addAuthor( "Cedric Pasteur", 0, "cedric.pasteur@free.fr"); + about.addCredit( "Jarosław Staniek", "Win32 version, some icons, many fixes, ideas and bug reports", "js@iidea.pl", 0); + about.addCredit( "Kristof Borrey ", "Icons", 0, "kristof.borrey@skynet.be" ); + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions(options); + KApplication app; + + KGlobal::iconLoader()->addAppDir("kexi"); + + KFDMainWindow *v = new KFDMainWindow(); + if (!v->centralWidget()) { //KFD part could be not found + delete v; + return 1; + } + app.setMainWidget(v); + v->show(); + + + + // see if we are starting with session management + if (app.isRestored()) + { + RESTORE(KFDMainWindow); + } + else + { + // no session.. just start up normally + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + if (args->count() >= 1) + { + for (int i = 0; i < args->count(); i++) + /** @todo report loading errors here */ + v->loadUIFile(args->url(i)); + } + args->clear(); + } + + return app.exec(); +} |