diff options
Diffstat (limited to 'tdevdesigner/designer/tdevdesigner_part.cpp')
-rw-r--r-- | tdevdesigner/designer/tdevdesigner_part.cpp | 565 |
1 files changed, 0 insertions, 565 deletions
diff --git a/tdevdesigner/designer/tdevdesigner_part.cpp b/tdevdesigner/designer/tdevdesigner_part.cpp deleted file mode 100644 index def9aa7f..00000000 --- a/tdevdesigner/designer/tdevdesigner_part.cpp +++ /dev/null @@ -1,565 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004 by Alexander Dymo * - * [email protected] * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - ***************************************************************************/ - -#include "tdevdesigner_part.h" - -#include <kinstance.h> -#include <tdeaction.h> -#include <tdeactionclasses.h> -#include <kstdaction.h> -#include <tdefiledialog.h> -#include <kdebug.h> -#include <tdelocale.h> -#include <kiconloader.h> - -#include <tqfile.h> -#include <tqtextstream.h> -#include <tqtoolbar.h> -#include <tqmenubar.h> -#include <tqptrlist.h> -#include <tqstatusbar.h> - -#include "mainwindow.h" -#include "designeraction.h" -#include "formwindow.h" - -TDevDesignerPart::TDevDesignerPart( TQWidget *parentWidget, const char *// widgetName - , - TQObject *parent, const char *name, const TQStringList &args ) - : KInterfaceDesigner::Designer(parent, name) -{ - setInstance( TDevDesignerPartFactory::instance() ); - - m_widget = new MainWindow( this, true ); - m_widget->reparent(parentWidget, TQPoint(0,0)); - setupDesignerWindow(); - - setWidget(m_widget); - - setupActions(); - if (args.contains("in shell")) - setXMLFile("tdevdesigner_part_sh.rc"); - else - setXMLFile("tdevdesigner_part.rc"); - - setReadWrite(true); - setModified(false); - - connect(m_widget, TQT_SIGNAL(formModified(bool )), this, TQT_SLOT(formModified(bool))); -} - -void TDevDesignerPart::setupDesignerWindow() -{ - m_widget->menuBar()->hide(); - m_widget->layoutToolBar->hide(); - m_widget->projectToolBar->hide(); - m_widget->toolsToolBar->hide(); - m_widget->statusBar()->hide(); -} - -static TQIconSet createPartIconSet( const TQString &name ) -{ - TQIconSet ic( BarIcon( "" + name, TDevDesignerPartFactory::instance() ) ); - TQString prefix = "designer_"; - int right = name.length() - prefix.length(); - ic.setPixmap( BarIcon( prefix + "d_" + name.right( right ), TDevDesignerPartFactory::instance() ), - TQIconSet::Small, TQIconSet::Disabled ); - return ic; -} - -void TDevDesignerPart::setupActions( ) -{ - TDEAction *action; - action = KStdAction::openNew(this, TQT_SLOT(fileNew()), actionCollection()); - action = KStdAction::open(this, TQT_SLOT(fileOpen()), actionCollection()); - action = KStdAction::close(this, TQT_SLOT(fileClose()), actionCollection()); - stateSync(action, m_widget->actionFileClose); - action = KStdAction::save(this, TQT_SLOT(save()), actionCollection()); - stateSync(action, m_widget->actionFileSave); - action = KStdAction::saveAs(this, TQT_SLOT(fileSaveAs()), actionCollection()); - stateSync(action, m_widget->actionFileSaveAs); - action = new TDEAction(i18n("Save Al&l"), 0, this, TQT_SLOT(fileSaveAs()), actionCollection(), "file_saveall"); - stateSync(action, m_widget->actionFileSaveAll); - new TDEAction(i18n("Create &Template..."), 0, this, TQT_SLOT(fileCreateTemplate()), actionCollection(), "file_createtemplate"); - - action = KStdAction::undo(this, TQT_SLOT(editUndo()), actionCollection()); - stateSync(action, m_widget->actionEditUndo); - action = KStdAction::redo(this, TQT_SLOT(editRedo()), actionCollection()); - stateSync(action, m_widget->actionEditRedo); - action = KStdAction::cut(this, TQT_SLOT(editCut()), actionCollection()); - stateSync(action, m_widget->actionEditCut); - action = KStdAction::copy(this, TQT_SLOT(editCopy()), actionCollection()); - stateSync(action, m_widget->actionEditCopy); - action = KStdAction::paste(this, TQT_SLOT(editPaste()), actionCollection()); - stateSync(action, m_widget->actionEditPaste); - action = new TDEAction(i18n("&Delete"), Key_Delete, this, TQT_SLOT(editDelete()), actionCollection(), "edit_delete"); - stateSync(action, m_widget->actionEditDelete); - action = KStdAction::selectAll(this, TQT_SLOT(editSelectAll()), actionCollection()); - stateSync(action, m_widget->actionEditSelectAll); - action = new TDEAction(i18n("Chec&k Accelerators"), ALT + Key_R, this, TQT_SLOT(editAccels()), actionCollection(), "edit_accels"); - stateSync(action, m_widget->actionEditAccels); - action = new TDEAction(i18n("S&lots..."), createPartIconSet("designer_editslots.png"), 0, this, TQT_SLOT(editFunctions()), actionCollection(), "edit_functions"); - stateSync(action, m_widget->actionEditFunctions); - action = new TDEAction(i18n("Co&nnections..."), createPartIconSet("designer_connecttool.png"), 0, this, TQT_SLOT(editConnections()), actionCollection(), "edit_connections"); - stateSync(action, m_widget->actionEditConnections); - action = new TDEAction(i18n("&Form Settings..."), 0, this, TQT_SLOT(editFormSettings()), actionCollection(), "edit_formsettings"); - stateSync(action, m_widget->actionEditFormSettings); - - action = new TDEAction(i18n("&Add File..."), 0, this, TQT_SLOT(projectAddFile()), actionCollection(), "project_addfile"); - stateSync(action, m_widget->actionProjectAddFile); - action = new TDEAction(i18n("&Image Collection..."), 0, this, TQT_SLOT(projectImageCollection()), actionCollection(), "project_imagecollection"); - stateSync(action, m_widget->actionEditPixmapCollection); - action = new TDEAction(i18n("&Database Connections..."), 0, this, TQT_SLOT(projectDatabaseCollections()), actionCollection(), "project_databasecollections"); - stateSync(action, m_widget->actionEditDatabaseConnections); - action = new TDEAction(i18n("&Designer Project Settings..."), 0, this, TQT_SLOT(projectSettings()), actionCollection(), "project_settings"); - stateSync(action, m_widget->actionEditProjectSettings); - - TDERadioAction *toggle; - toggle = new TDERadioAction(i18n("&Pointer"), createPartIconSet("designer_pointer.png"), Key_F2, actionCollection(), "tools_pointer"); - setupToolsAction(toggle, m_widget->actionPointerTool); - pointerAction = toggle; - toggle = new TDERadioAction(i18n("&Connect Signal/Slots"), createPartIconSet("designer_connecttool.png"), Key_F3, actionCollection(), "tools_connect"); - setupToolsAction(toggle, m_widget->actionConnectTool); - toggle = new TDERadioAction(i18n("Tab &Order"), createPartIconSet("designer_ordertool.png"), Key_F4, actionCollection(), "tools_taborder"); - setupToolsAction(toggle, m_widget->actionOrderTool); - toggle = new TDERadioAction(i18n("Set &Buddy"), createPartIconSet("designer_setbuddy.png"), Key_F12, actionCollection(), "tools_setbuddy"); - setupToolsAction(toggle, m_widget->actionBuddyTool); - new TDEAction(i18n("Configure Toolbox..."), 0, this, TQT_SLOT(toolsConfigureToolbox()), actionCollection(), "tools_toolbox"); - new TDEAction(i18n("Edit &Custom Widgets..."), 0, this, TQT_SLOT(toolsEditCustomWidgets()), actionCollection(), "tools_editcustomwidgets"); - - action = new TDEAction(i18n("Adjust &Size"), createPartIconSet("designer_adjustsize.png"), CTRL + Key_J, this, TQT_SLOT(layoutAdjustSize()), actionCollection(), "layout_adjustsize"); - stateSync(action, m_widget->actionEditAdjustSize); - action = new TDEAction(i18n("Lay Out &Horizontally"), createPartIconSet("designer_edithlayout.png"), CTRL + Key_H, this, TQT_SLOT(layoutHLayout()), actionCollection(), "layout_h"); - stateSync(action, m_widget->actionEditHLayout); - action = new TDEAction(i18n("Lay Out &Vertically"), createPartIconSet("designer_editvlayout.png"), CTRL + Key_V, this, TQT_SLOT(layoutVLayout()), actionCollection(), "layout_v"); - stateSync(action, m_widget->actionEditVLayout); - action = new TDEAction(i18n("Lay Out in &Grid"), createPartIconSet("designer_editgrid.png"), CTRL + Key_G, this, TQT_SLOT(layoutGridLayout()), actionCollection(), "layout_grid"); - stateSync(action, m_widget->actionEditGridLayout); - action = new TDEAction(i18n("Lay OutQt::Horizontally (in S&plitter)"), createPartIconSet("designer_editvlayoutsplit.png"), 0, this, TQT_SLOT(layoutSplitHLayout()), actionCollection(), "layout_splith"); - stateSync(action, m_widget->actionEditSplitHorizontal); - action = new TDEAction(i18n("Lay OutQt::Vertically (in Sp&litter)"), createPartIconSet("designer_edithlayoutsplit.png"), 0, this, TQT_SLOT(layoutSplitVLayout()), actionCollection(), "layout_splitv"); - stateSync(action, m_widget->actionEditSplitVertical); - action = new TDEAction(i18n("&Break Layout"), createPartIconSet("designer_editbreaklayout.png"), CTRL + Key_B, this, TQT_SLOT(layoutBreak()), actionCollection(), "layout_break"); - stateSync(action, m_widget->actionEditBreakLayout); - toggle = new TDERadioAction(i18n("Add Spacer"), createPartIconSet("designer_spacer.png"), 0, actionCollection(), "layout_spacer"); - setupToolsAction(toggle, m_widget->actionInsertSpacer); - - action = new TDEAction(i18n("Preview &Form"), CTRL + Key_T, this, TQT_SLOT(windowPreview()), actionCollection(), "window_preview"); - stateSync(action, m_widget->actionPreview); - action = new TDEAction(i18n("Ne&xt Form"), CTRL + Key_F6, this, TQT_SLOT(windowNext()), actionCollection(), "window_next"); - stateSync(action, m_widget->actionWindowNext); - action = new TDEAction(i18n("Pre&vious Form"), CTRL + SHIFT + Key_F6, this, TQT_SLOT(windowPrev()), actionCollection(), "window_prev"); - stateSync(action, m_widget->actionWindowPrevious); - - action = KStdAction::preferences(this, TQT_SLOT(editPreferences()), actionCollection()); - action->setText(i18n("Configure &TDevDesigner...")); - stateSync(action, m_widget->actionEditPreferences); -} - -TDevDesignerPart::~TDevDesignerPart() -{ -} - -void TDevDesignerPart::setReadWrite(bool rw) -{ - ReadWritePart::setReadWrite(rw); -} - -void TDevDesignerPart::setModified(bool modified) -{ -/* TDEAction *save = actionCollection()->action(KStdAction::stdName(KStdAction::Save)); - if (!save) - return; - if (modified) - save->setEnabled(true); - else - save->setEnabled(false);*/ - - ReadWritePart::setModified(modified); -} - -bool TDevDesignerPart::openFile() -{ - m_widget->fileOpen("", "", m_file); - return true; -} - -bool TDevDesignerPart::saveFile() -{ - if (isReadWrite() == false) - return false; - m_widget->actionFileSaveAll->activate(); - return true; -} - -void TDevDesignerPart::stateSync( TDEAction * tdeaction, TQAction * qaction ) -{ - if (!qaction) - return; - tdeaction->setEnabled(qaction->isEnabled()); - DesignerAction *ac = dynamic_cast<DesignerAction*>(qaction); - if (!ac) - return; - connect(ac, TQT_SIGNAL(actionEnabled(bool )), tdeaction, TQT_SLOT(setEnabled(bool ))); -} - -void TDevDesignerPart::setupToolsAction( TDERadioAction * toggle, TQAction * action ) -{ - if (!action) - return; - - toggle->setGroup("tools"); - toggle->setExclusiveGroup("tools"); - connect(action, TQT_SIGNAL(toggled(bool )), this, TQT_SLOT(setToggleActionChecked(bool ))); - connect(toggle, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setToggleActionOn(bool))); - toggle->setChecked(action->isOn()); - m_actionMap[action] = toggle; - m_actionMap2[toggle] = action; -} - - -// It's usually safe to leave the factory code alone.. with the -// notable exception of the TDEAboutData data -#include <tdeaboutdata.h> -#include <tdelocale.h> - -TDEInstance* TDevDesignerPartFactory::s_instance = 0L; -TDEAboutData* TDevDesignerPartFactory::s_about = 0L; - -TDevDesignerPartFactory::TDevDesignerPartFactory() - : KParts::Factory() -{ -} - -TDevDesignerPartFactory::~TDevDesignerPartFactory() -{ - delete s_instance; - delete s_about; - - s_instance = 0L; -} - -KParts::Part* TDevDesignerPartFactory::createPartObject( TQWidget *parentWidget, const char *widgetName, - TQObject *parent, const char *name, - const char *classname, const TQStringList &args ) -{ - // Create an instance of our Part - TDevDesignerPart* obj = new TDevDesignerPart( parentWidget, widgetName, parent, name, args ); - - // See if we are to be read-write or not - if (TQCString(classname) == "KParts::ReadOnlyPart") - obj->setReadWrite(false); - - return obj; -} - -TDEInstance* TDevDesignerPartFactory::instance() -{ - if( !s_instance ) - { - s_about = new TDEAboutData("tdevdesignerpart", I18N_NOOP("TDevDesignerPart"), "0.1"); - s_about->addAuthor("Alexander Dymo", 0, "[email protected]"); - s_about->addAuthor("Trolltech AS", 0, "[email protected]"); - s_instance = new TDEInstance(s_about); - } - return s_instance; -} - -extern "C" -{ - void* init_libtdevdesignerpart() - { - return new TDevDesignerPartFactory; - } -} - -//actions - -void TDevDesignerPart::fileNew( ) -{ - if (!m_widget->actionNewFile) - { - tqWarning("wrong m_widget->actionNewFile"); - return; - } - m_widget->actionNewFile->activate(); -} - -void TDevDesignerPart::fileOpen() -{ - m_widget->fileOpen(); -} - -void TDevDesignerPart::fileSaveAs() -{ - m_widget->actionFileSaveAs->activate(); -} - -void TDevDesignerPart::fileClose( ) -{ - m_widget->actionFileClose->activate(); -} - -void TDevDesignerPart::fileCreateTemplate( ) -{ - m_widget->fileCreateTemplate(); -} - -void TDevDesignerPart::editUndo( ) -{ - m_widget->actionEditUndo->activate(); -} - -void TDevDesignerPart::editRedo( ) -{ - m_widget->actionEditRedo->activate(); -} - -void TDevDesignerPart::editCut( ) -{ - m_widget->actionEditCut->activate(); -} - -void TDevDesignerPart::editPaste( ) -{ - m_widget->actionEditPaste->activate(); -} - -void TDevDesignerPart::editCopy( ) -{ - m_widget->actionEditCopy->activate(); -} - -void TDevDesignerPart::editDelete( ) -{ - m_widget->actionEditDelete->activate(); -} - -void TDevDesignerPart::editSelectAll( ) -{ - m_widget->actionEditSelectAll->activate(); -} - -void TDevDesignerPart::editAccels( ) -{ - m_widget->actionEditAccels->activate(); -} - -void TDevDesignerPart::editFunctions( ) -{ - m_widget->actionEditFunctions->activate(); -} - -void TDevDesignerPart::editConnections( ) -{ - m_widget->actionEditConnections->activate(); -} - -void TDevDesignerPart::editFormSettings( ) -{ - m_widget->actionEditFormSettings->activate(); -} - -void TDevDesignerPart::editPreferences( ) -{ - m_widget->actionEditPreferences->activate(); -} - -void TDevDesignerPart::projectAddFile( ) -{ - m_widget->actionProjectAddFile->activate(); -} - -void TDevDesignerPart::projectImageCollection( ) -{ - m_widget->actionEditPixmapCollection->activate(); -} - -void TDevDesignerPart::projectDatabaseCollections( ) -{ - m_widget->actionEditDatabaseConnections->activate(); -} - -void TDevDesignerPart::projectSettings( ) -{ - m_widget->actionEditProjectSettings->activate(); -} - -void TDevDesignerPart::toolsConfigureToolbox( ) -{ - m_widget->toolsConfigure(); -} - -void TDevDesignerPart::layoutAdjustSize( ) -{ - m_widget->actionEditAdjustSize->activate(); -} - -void TDevDesignerPart::layoutHLayout( ) -{ - m_widget->actionEditHLayout->activate(); -} - -void TDevDesignerPart::layoutVLayout( ) -{ - m_widget->actionEditVLayout->activate(); -} - -void TDevDesignerPart::layoutGridLayout( ) -{ - m_widget->actionEditGridLayout->activate(); -} - -void TDevDesignerPart::layoutSplitHLayout( ) -{ - m_widget->actionEditSplitHorizontal->activate(); -} - -void TDevDesignerPart::layoutSplitVLayout( ) -{ - m_widget->actionEditSplitVertical->activate(); -} - -void TDevDesignerPart::layoutBreak( ) -{ - m_widget->actionEditBreakLayout->activate(); -} - -void TDevDesignerPart::windowPreview( ) -{ - m_widget->actionPreview->activate(); -} - -void TDevDesignerPart::windowNext( ) -{ - m_widget->actionWindowNext->activate(); -} - -void TDevDesignerPart::windowPrev( ) -{ - m_widget->actionWindowPrevious->activate(); -} - -void TDevDesignerPart::statusMessage( const TQString & msg ) -{ - emit setStatusBarText(msg); -} - -void TDevDesignerPart::setToggleActionChecked( bool b) -{ - if (!sender()) - return; - const TQAction *action = dynamic_cast<const TQAction*>(sender()); - if (!action) - return; - if (b) - { - if (action == m_widget->actionPointerTool) - pointerAction->setChecked(true); - return; - } - TDERadioAction *tdeaction = m_actionMap[action]; - if (!tdeaction) - return; -// kdDebug() << "untoggle action: " << tdeaction->text() << endl; - tdeaction->blockSignals(true); - tdeaction->setChecked(b); - tdeaction->blockSignals(false); -} - -void TDevDesignerPart::setToggleActionOn( bool b ) -{ - if (!sender()) - return; - const TDERadioAction *action = dynamic_cast<const TDERadioAction *>(sender()); - if (!action) - return; -// kdDebug() << (b?TQString("toggle"):TQString("untoggle")) << " action: " << action->text() << endl; - TQAction *qaction = m_actionMap2[action]; - if (!qaction) - return; - disconnect(qaction, TQT_SIGNAL(toggled(bool )), this, TQT_SLOT(setToggleActionChecked(bool ))); - qaction->setOn(b); - connect(qaction, TQT_SIGNAL(toggled(bool )), this, TQT_SLOT(setToggleActionChecked(bool ))); -} - -void TDevDesignerPart::openProject( const TQString & // projectFile - ) -{ - //TODO: implement - return; -} - -KInterfaceDesigner::DesignerType TDevDesignerPart::designerType( ) -{ - return KInterfaceDesigner::TQtDesigner; -} - -void TDevDesignerPart::emitAddedFunction( const TQString & form, KInterfaceDesigner::Function func ) -{ - kdDebug() << "TDevDesignerPart::emitAddedFunction: form " << form << ", function: " << func.function << endl; - emit addedFunction(designerType(), form, func); -} - -void TDevDesignerPart::emitRemovedFunction( const TQString & form, KInterfaceDesigner::Function func ) -{ - kdDebug() << "TDevDesignerPart::emitRemovedFunction: form " << form << ", function: " << func.function << endl; - emit removedFunction(designerType(), form, func); -} - -void TDevDesignerPart::emitEditedFunction( const TQString & form, KInterfaceDesigner::Function oldFunc, KInterfaceDesigner::Function func ) -{ - kdDebug() << "TDevDesignerPart::emitEditedFunction: form " << form - << ", old function: " << oldFunc.function - << ", function: " << func.function << endl; - -// m_widget->formWindow()->clearSelection(false); - emit editedFunction(designerType(), form, oldFunc, func); -} - -void TDevDesignerPart::emitEditFunction(const TQString &formName, const TQString &functionName) -{ - kdDebug() << "TDevDesignerPart::emitEditedFunction: form " << formName - << ", function: " << functionName << endl; - emit editFunction(designerType(), formName, functionName); -} - -void TDevDesignerPart::formModified(bool b) -{ - kdDebug() << "TDevDesignerPart::formModified " << b << endl; - setModified(b); -} - -void TDevDesignerPart::emitEditSource(const TQString &formName) -{ - emit editSource(designerType(), formName); -} - -void TDevDesignerPart::emitNewStatus(const TQString &formName, int status) -{ - emit newStatus(formName, status); -} - -void TDevDesignerPart::toolsEditCustomWidgets( ) -{ - m_widget->toolsCustomWidget(); -} - -#include "tdevdesigner_part.moc" |