From 309b140821b9d50daa26e6467f2934807aa6a412 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Sun, 19 Jan 2025 22:48:50 +0900 Subject: Use tdeApp Signed-off-by: Michele Calgaro --- .../kcontrol_module/src/kcontrol_module.py | 16 +- app_templates/kdeapp/setup.py | 8 +- app_templates/kdeapp/src/kdeapp.desktop | 35 --- app_templates/kdeapp/src/kdeapp.py | 280 --------------------- app_templates/kdeapp/src/kdeappiface.py | 26 -- app_templates/kdeapp/src/kdeappui.rc | 8 - app_templates/kdeapp/src/kdeappview.py | 91 ------- app_templates/kdeapp/src/tdeapp.desktop | 35 +++ app_templates/kdeapp/src/tdeapp.py | 280 +++++++++++++++++++++ app_templates/kdeapp/src/tdeappiface.py | 26 ++ app_templates/kdeapp/src/tdeappui.rc | 8 + app_templates/kdeapp/src/tdeappview.py | 91 +++++++ app_templates/kdeutility/src/kdeutility.py | 8 +- 13 files changed, 456 insertions(+), 456 deletions(-) delete mode 100644 app_templates/kdeapp/src/kdeapp.desktop delete mode 100755 app_templates/kdeapp/src/kdeapp.py delete mode 100644 app_templates/kdeapp/src/kdeappiface.py delete mode 100644 app_templates/kdeapp/src/kdeappui.rc delete mode 100644 app_templates/kdeapp/src/kdeappview.py create mode 100644 app_templates/kdeapp/src/tdeapp.desktop create mode 100755 app_templates/kdeapp/src/tdeapp.py create mode 100644 app_templates/kdeapp/src/tdeappiface.py create mode 100644 app_templates/kdeapp/src/tdeappui.rc create mode 100644 app_templates/kdeapp/src/tdeappview.py (limited to 'app_templates') diff --git a/app_templates/kcontrol_module/src/kcontrol_module.py b/app_templates/kcontrol_module/src/kcontrol_module.py index f1c18de..0f560f6 100755 --- a/app_templates/kcontrol_module/src/kcontrol_module.py +++ b/app_templates/kcontrol_module/src/kcontrol_module.py @@ -110,8 +110,8 @@ class KcontrolModuleApp(programbase): ######################################################################## def __loadOptions(self): - global kapp - config = kapp.config() + global tdeApp + config = tdeApp.config() config.setGroup("General") size = config.readSizeEntry("Geometry") if size.isEmpty()==False: @@ -119,8 +119,8 @@ class KcontrolModuleApp(programbase): ####################################################################### def __saveOptions(self): - global kapp - config = kapp.config() + global tdeApp + config = tdeApp.config() config.setGroup("General") config.writeEntry("Geometry", self.size()) config.sync() @@ -147,18 +147,18 @@ class KcontrolModuleApp(programbase): ############################################################################ # This is the entry point used when running this module outside of kcontrol. def main(): - global kapp + global tdeApp about_data = AboutData() TDECmdLineArgs.init(sys.argv,about_data) - kapp = TDEApplication() + tdeApp = TDEApplication() myapp = KcontrolModuleApp() myapp.exec_loop() ############################################################################ # Factory function for KControl def create_kcontrol_module(parent,name): - global kapp - kapp = TDEApplication.kApplication() + global tdeApp + tdeApp = TDEApplication.tdeApplication() return KcontrolModuleApp(parent, name) ############################################################################ diff --git a/app_templates/kdeapp/setup.py b/app_templates/kdeapp/setup.py index 21386c6..6c2c44b 100755 --- a/app_templates/kdeapp/setup.py +++ b/app_templates/kdeapp/setup.py @@ -17,14 +17,14 @@ import tdedistutils -tdedistutils.setup(name="kdeapp", +tdedistutils.setup(name="tdeapp", version="0.1.0", author="AUTHOR", author_email="YOUR@EMAIL.com", - url="http://www.KDEAPP.com/", + url="http://www.TDEAPP.com/", min_kde_version = "3.0.0", min_tqt_version = "3.0.0", license = "GPL", - application_data = ['src/kdeapp.py','src/prefdialog.py','src/kdeappview.py'], - executable_links = [('kdeapp','kdeapp.py')], + application_data = ['src/tdeapp.py','src/prefdialog.py','src/tdeappview.py'], + executable_links = [('tdeapp','tdeapp.py')], docbooks = [ ('doc/en','en') ] ) diff --git a/app_templates/kdeapp/src/kdeapp.desktop b/app_templates/kdeapp/src/kdeapp.desktop deleted file mode 100644 index d1d2ca4..0000000 --- a/app_templates/kdeapp/src/kdeapp.desktop +++ /dev/null @@ -1,35 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=$APPNAME$ -Exec=$APPNAMELC$ %i %m -caption "%c" -Icon=$APPNAMELC$ -Type=Application -X-DocPath=$APPNAMELC$/$APPNAMELC$.html -Comment=A TDE KPart Application -Comment[ca]=Una aplicació KPart per a TDE -Comment[cy]=Cymhwysiad KPart TDE -Comment[da]=Et TDE KPart program -Comment[de]=Eine TDE-Komponenten-Anwendung -Comment[el]=Μια εφαρμογή KPart του TDE -Comment[es]=Una aplicación KPart de TDE -Comment[et]=TDE KPart rakendus -Comment[fr]=Une application KPart pour TDE. -Comment[hi]=एक केडीई के-पार्ट अनुप्रयोग -Comment[hu]=KPart-alapú TDE-alkalmazás -Comment[is]=TDE KPart forrit -Comment[it]=Applicazione KPart di TDE -Comment[ja]=TDE KPart アプリケーション -Comment[nb]=Et TDE KPart-program -Comment[nl]=Een TDE KPart-toepassing -Comment[pl]=Aplikacja TDE -Comment[pt]=Uma aplicação KPart do TDE -Comment[pt_BR]=Um Aplicativo KPart do TDE -Comment[ru]=Приложение KPart для TDE -Comment[sl]=Program KPart za TDE -Comment[sr]=TDE KPart програм -Comment[sr@Latn]=TDE KPart program -Comment[sv]=Ett TDE Kpart-program -Comment[ta]=கெடி கெபார்ட் பயன்பாடு -Comment[tg]=Ба кор андохтани KPart барои TDE -Comment[zh_CN]=一个 TDE KPart 应用程序 -Terminal=0 diff --git a/app_templates/kdeapp/src/kdeapp.py b/app_templates/kdeapp/src/kdeapp.py deleted file mode 100755 index 68d07af..0000000 --- a/app_templates/kdeapp/src/kdeapp.py +++ /dev/null @@ -1,280 +0,0 @@ -#!/usr/bin/python -########################################################################### -# kdeapp - description # -# ------------------------------ # -# begin : Fri Jun 27 2005 # -# copyright : (C) 2005 by AUTHOR # -# email : your@email.com # -# # -########################################################################### -# # -# 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. # -# # -########################################################################### - -from PyTQt.tqt import * -from tdecore import * -from tdeui import * -import sys -from prefdialog import * -from kdeappview import * - -description = "A KDE Application" -version = "0.1"; - -class KdeApp(TDEMainWindow): - def __init__(self): - TDEMainWindow.__init__(self,None,"KdeApp") - - self._view = KdeAppView(self) - self._printer = None - - # accept dnd - self.setAcceptDrops(True) - - # tell the TDEMainWindow that this is indeed the main widget - self.setCentralWidget(self._view) - - # then, setup our actions - self._setupActions() - - # and a status bar - self.statusBar().show() - - # Apply the create the main window and ask the mainwindow to - # automatically save settings if changed: window size, toolbar - # position, icon size, etc. Also to add actions for the statusbar - # toolbar, and keybindings if necessary. - self.setAutoSaveSettings() - - # allow the view to change the statusbar and caption - self.connect(self._view, PYSIGNAL("signalChangeStatusbar"), self.changeStatusbar) - self.connect(self._view, PYSIGNAL("signalChangeCaption"), self.changeCaption) - - def load(self,url): - target = TQString() - # the below code is what you should normally do. in this - # example case, we want the url to our own. you probably - # want to use this code instead for your app - - if False: - # download the contents - if TDEIO.NetAccess.download(url, target): - # set our caption - self.setCaption(url) - - # load in the file (target is always local) - self.loadFile(target) - - # and remove the temp file - TDEIO.NetAccess.removeTempFile(target) - - self.setCaption(url.prettyURL()) - self._view.openURL(url) - - - def _setupActions(self): - global kapp - KStdAction.openNew(self.fileNew, self.actionCollection()) - KStdAction.open(self.fileOpen, self.actionCollection()) - KStdAction.save(self.fileSave, self.actionCollection()) - KStdAction.saveAs(self.fileSaveAs, self.actionCollection()) - KStdAction.print_(self.filePrint, self.actionCollection()) - KStdAction.quit(kapp.quit, self.actionCollection()) - - self._toolbarAction = KStdAction.showToolbar(self.optionsShowToolbar, self.actionCollection()) - self._statusbarAction = KStdAction.showStatusbar(self.optionsShowStatusbar, self.actionCollection()) - KStdAction.keyBindings(self.optionsConfigureKeys, self.actionCollection()) - - KStdAction.configureToolbars(self.optionsConfigureToolbars, self.actionCollection()) - KStdAction.preferences(self.optionsPreferences, self.actionCollection()) - - # this doesn't do anything useful. it's just here to illustrate - # how to insert a custom menu and menu item - custom = TDEAction(i18n("Cus&tom Menuitem"), TDEShortcut(), - self.optionsPreferences, - self.actionCollection(), "custom_action") - self.createGUI() - - def _saveProperties(self,config): - # the 'config' object points to the session managed - # config file. anything you write here will be available - # later when this app is restored - - if not self._view.currentURL().isEmpty(): - config.writeEntry("lastURL", self._view.currentURL()) - - def _readProperties(self,config): - # the 'config' object points to the session managed - # config file. this function is automatically called whenever - # the app is being restored. read in here whatever you wrote - # in 'saveProperties' - - url = config.readPathEntry("lastURL") - - if not url.isEmpty(): - self._view.openURL(KURL(url)) - - def dragEnterEvent(self,event): - # accept uri drops only - event.accept(KURLDrag.canDecode(event)) - - def dropEvent(self,event): - # this is a very simplistic implementation of a drop event. we - # will only accept a dropped URL. the TQt dnd code can do *much* - # much more, so please read the docs there - urls = KURL.List() - - # see if we can decode a URI.. if not, just ignore it - if KURLDrag.decode(event, urls) and not urls.isEmpty(): - # okay, we have a URI.. process it - url = urls.first() - - # load in the file - self.load(url) - - def fileNew(self): - # this slot is called whenever the File->New menu is selected, - # the New shortcut is pressed (usually CTRL+N) or the New toolbar - # button is clicked - - # create a new window - KdeApp().show() - - def fileOpen(self): - # this slot is called whenever the File->Open menu is selected, - # the Open shortcut is pressed (usually CTRL+O) or the Open toolbar - # button is clicked - - ## this brings up the generic open dialog - #KURL url = KURLRequesterDlg::getURL(TQString::null, this, i18n("Open Location") ); - - # standard filedialog - url = KFileDialog.getOpenURL(None, One, self, i18n("Open Location")) - if not url.isEmpty(): - self._view.openURL(url) - - def fileSave(self): - # this slot is called whenever the File->Save menu is selected, - # the Save shortcut is pressed (usually CTRL+S) or the Save toolbar - # button is clicked - - # save the current file - pass - - def fileSaveAs(self): - # this slot is called whenever the File->Save As menu is selected, - file_url = KFileDialog.getSaveURL() - if not file_url.isEmpty() and file_url.isValid(): - # save your info, here - pass - - - def filePrint(self): - # this slot is called whenever the File->Print menu is selected, - # the Print shortcut is pressed (usually CTRL+P) or the Print toolbar - # button is clicked - if self._printer is None: - self._printer = KPrinter() - - if self._printer.setup(self): - # setup the printer. with TQt, you always "print" to a - # TQPainter.. whether the output medium is a pixmap, a screen, - # or paper - p = TQPainter() - p.begin(self._printer) - - # we let our view do the actual printing - metrics = TQPaintDeviceMetrics(m_printer) - self._view.print_(p, metrics.height(), metrics.width()) - - # and send the result to the printer - p.end(); - - def optionsPreferences(self): - # popup some sort of preference dialog, here - dlg = PreferencesDialog() - if dlg.exec_loop(): - # redo your settings - pass - - def optionsShowToolbar(self): - # this is all very cut and paste code for showing/hiding the - # toolbar - if self._toolbarAction.isChecked(): - self.toolBar().show() - else: - self.toolBar().hide() - - def optionsShowStatusbar(self): - # this is all very cut and paste code for showing/hiding the - # statusbar - - if self._statusbarAction.isChecked(): - self.statusBar().show() - else: - self.statusBar().hide() - - def optionsConfigureKeys(self): - KKeyDialog.configure(self.actionCollection()) - - def optionsConfigureToolbars(self): - # use the standard toolbar editor - self.saveMainWindowSettings(TDEGlobal.config()) - - def newToolbarConfig(self): - # this slot is called when user clicks "Ok" or "Apply" in the toolbar editor. - # recreate our GUI, and re-apply the settings (e.g. "text under icons", etc.) - self.createGUI() - self.applyMainWindowSettings(TDEGlobal.config()) - - def changeStatusbar(self,text): - # display the text on the statusbar - self.statusBar().message(text) - - def changeCaption(self,text): - # display the text on the caption - self.setCaption(text) - - -options = [ ("+[URL]", "Document to open", "") ] - -def main(): - global kapp,version,description,options - - aboutdata = TDEAboutData("kdeapp", "KdeApp", version, description, \ - TDEAboutData.License_GPL, "(C) 2005 AUTHOR", None, None, "your@email.com") - aboutdata.addAuthor("AUTHOR", None, "your@email.com") - TDECmdLineArgs.init(sys.argv,aboutdata) - TDECmdLineArgs.addCmdLineOptions(options) - kapp = TDEApplication() - - # register ourselves as a dcop client - kapp.dcopClient().registerAs(kapp.name(), False) - - # see if we are starting with session management - if kapp.isRestored(): - n = 1 - while TDEMainWindow.canBeRestored(n): - KdeApp().restore(n) - n += 1 - else: - # no session.. just start up normally - args = TDECmdLineArgs.parsedArgs() - if args.count() == 0: - widget = KdeApp() - widget.show() - else: - i = 0 - for i in range(args.count()): - widget = KdeApp() - widget.show() - widget.load(args.url(i)) - - args.clear() - - return kapp.exec_loop() -main() diff --git a/app_templates/kdeapp/src/kdeappiface.py b/app_templates/kdeapp/src/kdeappiface.py deleted file mode 100644 index 5600437..0000000 --- a/app_templates/kdeapp/src/kdeappiface.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/python -########################################################################### -# testappiface - description # -# ------------------------------ # -# begin : Fri Jun 27 2003 # -# copyright : (C) 2005 by AUTHOR # -# email : your@email.com # -# # -########################################################################### -# # -# 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. # -# # -########################################################################### - -from dcopexport import DCOPExObj - -class TestAppIface(DCOPExObj): - def __init__(self, parent, id="Value"): - DCOPExObj.__init__(self, id) - self.addMethod("void openURL(TQString url)", self.openURL) - - def openURL(self,url): - pass diff --git a/app_templates/kdeapp/src/kdeappui.rc b/app_templates/kdeapp/src/kdeappui.rc deleted file mode 100644 index 6c3f6a9..0000000 --- a/app_templates/kdeapp/src/kdeappui.rc +++ /dev/null @@ -1,8 +0,0 @@ - - - - C&ustom - - - - diff --git a/app_templates/kdeapp/src/kdeappview.py b/app_templates/kdeapp/src/kdeappview.py deleted file mode 100644 index 69addb2..0000000 --- a/app_templates/kdeapp/src/kdeappview.py +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/python -########################################################################### -# kdeappview - description # -# ------------------------------ # -# begin : Fri Jun 27 2005 # -# copyright : (C) 2005 by AUTHOR # -# email : your@email.com # -# # -########################################################################### -# # -# 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. # -# # -########################################################################### - -from PyTQt.tqt import * -from tdecore import * -from tdeui import * -from tdeio import * -from tdehtml import * -from tdeparts import * -#from kdeappiface import * - -class KdeAppView(TQWidget): - def __init__(self,parent): - TQWidget.__init__(self,parent) - #self._dcopclient= KdeAppIface(self,"KdeAppIface") - - # setup our layout manager to automatically add our widgets - top_layout = TQHBoxLayout(self) - top_layout.setAutoAdd(True) - - if True: - self._html = TDEHTMLPart(self) - else: - - # we want to look for all components that satisfy our needs. the - # trader will actually search through *all* registered KDE - # applications and components -- not just KParts. So we have to - # specify two things: a service type and a constraint - # - # the service type is like a mime type. we say that we want all - # applications and components that can handle HTML -- 'text/html' - # - # however, by itself, this will return such things as Netscape.. - # not what we wanted. so we constrain it by saying that the - # string 'KParts/ReadOnlyPart' must be found in the ServiceTypes - # field. with this, only components of the type we want will be - # returned. - offers = TDETrader.self().query("text/html", "'KParts/ReadOnlyPart' in ServiceTypes") - - self._html = None - # in theory, we only care about the first one.. but let's try all - # offers just in case the first can't be loaded for some reason - for ptr in offers: - # we now know that our offer can handle HTML and is a part. - # since it is a part, it must also have a library... let's try to - # load that now - self._html = createReadOnlyPart(ptr.library(),self,ptr.name(),"KParts::ReadOnlyPart", TQStringList()) - if self._html is not None: - break - - # if our factory is invalid, then we never found our component - # and we might as well just exit now - if self._html is None: - KMessageBox.error(self, i18n("Could not find a suitable HTML component")) - return - - TQObject.connect(self._html, TQ_SIGNAL("setWindowCaption(const TQString&)"), self.slotSetTitle) - TQObject.connect(self._html, TQ_SIGNAL("setStatusBarText(const TQString&)"), self.slotOnURL) - - def print_(self,p,height,width): - pass - # do the actual printing, here - # p.drawText(etc..) - - def currentURL(self): - return self._html.url().url() - - def openURL(self,url): - if isinstance(url,TQString): - url = KURL(url) - self._html.openURL(url) - - def slotOnURL(self,url): - self.emit(PYSIGNAL("signalChangeStatusbar"),(url,) ) - - def slotSetTitle(self,title): - self.emit(PYSIGNAL("signalChangeCaption"),(title,) ) diff --git a/app_templates/kdeapp/src/tdeapp.desktop b/app_templates/kdeapp/src/tdeapp.desktop new file mode 100644 index 0000000..d1d2ca4 --- /dev/null +++ b/app_templates/kdeapp/src/tdeapp.desktop @@ -0,0 +1,35 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=$APPNAME$ +Exec=$APPNAMELC$ %i %m -caption "%c" +Icon=$APPNAMELC$ +Type=Application +X-DocPath=$APPNAMELC$/$APPNAMELC$.html +Comment=A TDE KPart Application +Comment[ca]=Una aplicació KPart per a TDE +Comment[cy]=Cymhwysiad KPart TDE +Comment[da]=Et TDE KPart program +Comment[de]=Eine TDE-Komponenten-Anwendung +Comment[el]=Μια εφαρμογή KPart του TDE +Comment[es]=Una aplicación KPart de TDE +Comment[et]=TDE KPart rakendus +Comment[fr]=Une application KPart pour TDE. +Comment[hi]=एक केडीई के-पार्ट अनुप्रयोग +Comment[hu]=KPart-alapú TDE-alkalmazás +Comment[is]=TDE KPart forrit +Comment[it]=Applicazione KPart di TDE +Comment[ja]=TDE KPart アプリケーション +Comment[nb]=Et TDE KPart-program +Comment[nl]=Een TDE KPart-toepassing +Comment[pl]=Aplikacja TDE +Comment[pt]=Uma aplicação KPart do TDE +Comment[pt_BR]=Um Aplicativo KPart do TDE +Comment[ru]=Приложение KPart для TDE +Comment[sl]=Program KPart za TDE +Comment[sr]=TDE KPart програм +Comment[sr@Latn]=TDE KPart program +Comment[sv]=Ett TDE Kpart-program +Comment[ta]=கெடி கெபார்ட் பயன்பாடு +Comment[tg]=Ба кор андохтани KPart барои TDE +Comment[zh_CN]=一个 TDE KPart 应用程序 +Terminal=0 diff --git a/app_templates/kdeapp/src/tdeapp.py b/app_templates/kdeapp/src/tdeapp.py new file mode 100755 index 0000000..c4d3f7b --- /dev/null +++ b/app_templates/kdeapp/src/tdeapp.py @@ -0,0 +1,280 @@ +#!/usr/bin/python +########################################################################### +# tdeapp - description # +# ------------------------------ # +# begin : Fri Jun 27 2005 # +# copyright : (C) 2005 by AUTHOR # +# email : your@email.com # +# # +########################################################################### +# # +# 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. # +# # +########################################################################### + +from PyTQt.tqt import * +from tdecore import * +from tdeui import * +import sys +from prefdialog import * +from tdeappview import * + +description = "A KDE Application" +version = "0.1"; + +class TdeApp(TDEMainWindow): + def __init__(self): + TDEMainWindow.__init__(self,None,"TdeApp") + + self._view = TdeAppView(self) + self._printer = None + + # accept dnd + self.setAcceptDrops(True) + + # tell the TDEMainWindow that this is indeed the main widget + self.setCentralWidget(self._view) + + # then, setup our actions + self._setupActions() + + # and a status bar + self.statusBar().show() + + # Apply the create the main window and ask the mainwindow to + # automatically save settings if changed: window size, toolbar + # position, icon size, etc. Also to add actions for the statusbar + # toolbar, and keybindings if necessary. + self.setAutoSaveSettings() + + # allow the view to change the statusbar and caption + self.connect(self._view, PYSIGNAL("signalChangeStatusbar"), self.changeStatusbar) + self.connect(self._view, PYSIGNAL("signalChangeCaption"), self.changeCaption) + + def load(self,url): + target = TQString() + # the below code is what you should normally do. in this + # example case, we want the url to our own. you probably + # want to use this code instead for your app + + if False: + # download the contents + if TDEIO.NetAccess.download(url, target): + # set our caption + self.setCaption(url) + + # load in the file (target is always local) + self.loadFile(target) + + # and remove the temp file + TDEIO.NetAccess.removeTempFile(target) + + self.setCaption(url.prettyURL()) + self._view.openURL(url) + + + def _setupActions(self): + global tdeApp + KStdAction.openNew(self.fileNew, self.actionCollection()) + KStdAction.open(self.fileOpen, self.actionCollection()) + KStdAction.save(self.fileSave, self.actionCollection()) + KStdAction.saveAs(self.fileSaveAs, self.actionCollection()) + KStdAction.print_(self.filePrint, self.actionCollection()) + KStdAction.quit(tdeApp.quit, self.actionCollection()) + + self._toolbarAction = KStdAction.showToolbar(self.optionsShowToolbar, self.actionCollection()) + self._statusbarAction = KStdAction.showStatusbar(self.optionsShowStatusbar, self.actionCollection()) + KStdAction.keyBindings(self.optionsConfigureKeys, self.actionCollection()) + + KStdAction.configureToolbars(self.optionsConfigureToolbars, self.actionCollection()) + KStdAction.preferences(self.optionsPreferences, self.actionCollection()) + + # this doesn't do anything useful. it's just here to illustrate + # how to insert a custom menu and menu item + custom = TDEAction(i18n("Cus&tom Menuitem"), TDEShortcut(), + self.optionsPreferences, + self.actionCollection(), "custom_action") + self.createGUI() + + def _saveProperties(self,config): + # the 'config' object points to the session managed + # config file. anything you write here will be available + # later when this app is restored + + if not self._view.currentURL().isEmpty(): + config.writeEntry("lastURL", self._view.currentURL()) + + def _readProperties(self,config): + # the 'config' object points to the session managed + # config file. this function is automatically called whenever + # the app is being restored. read in here whatever you wrote + # in 'saveProperties' + + url = config.readPathEntry("lastURL") + + if not url.isEmpty(): + self._view.openURL(KURL(url)) + + def dragEnterEvent(self,event): + # accept uri drops only + event.accept(KURLDrag.canDecode(event)) + + def dropEvent(self,event): + # this is a very simplistic implementation of a drop event. we + # will only accept a dropped URL. the TQt dnd code can do *much* + # much more, so please read the docs there + urls = KURL.List() + + # see if we can decode a URI.. if not, just ignore it + if KURLDrag.decode(event, urls) and not urls.isEmpty(): + # okay, we have a URI.. process it + url = urls.first() + + # load in the file + self.load(url) + + def fileNew(self): + # this slot is called whenever the File->New menu is selected, + # the New shortcut is pressed (usually CTRL+N) or the New toolbar + # button is clicked + + # create a new window + TdeApp().show() + + def fileOpen(self): + # this slot is called whenever the File->Open menu is selected, + # the Open shortcut is pressed (usually CTRL+O) or the Open toolbar + # button is clicked + + ## this brings up the generic open dialog + #KURL url = KURLRequesterDlg::getURL(TQString::null, this, i18n("Open Location") ); + + # standard filedialog + url = KFileDialog.getOpenURL(None, One, self, i18n("Open Location")) + if not url.isEmpty(): + self._view.openURL(url) + + def fileSave(self): + # this slot is called whenever the File->Save menu is selected, + # the Save shortcut is pressed (usually CTRL+S) or the Save toolbar + # button is clicked + + # save the current file + pass + + def fileSaveAs(self): + # this slot is called whenever the File->Save As menu is selected, + file_url = KFileDialog.getSaveURL() + if not file_url.isEmpty() and file_url.isValid(): + # save your info, here + pass + + + def filePrint(self): + # this slot is called whenever the File->Print menu is selected, + # the Print shortcut is pressed (usually CTRL+P) or the Print toolbar + # button is clicked + if self._printer is None: + self._printer = KPrinter() + + if self._printer.setup(self): + # setup the printer. with TQt, you always "print" to a + # TQPainter.. whether the output medium is a pixmap, a screen, + # or paper + p = TQPainter() + p.begin(self._printer) + + # we let our view do the actual printing + metrics = TQPaintDeviceMetrics(m_printer) + self._view.print_(p, metrics.height(), metrics.width()) + + # and send the result to the printer + p.end(); + + def optionsPreferences(self): + # popup some sort of preference dialog, here + dlg = PreferencesDialog() + if dlg.exec_loop(): + # redo your settings + pass + + def optionsShowToolbar(self): + # this is all very cut and paste code for showing/hiding the + # toolbar + if self._toolbarAction.isChecked(): + self.toolBar().show() + else: + self.toolBar().hide() + + def optionsShowStatusbar(self): + # this is all very cut and paste code for showing/hiding the + # statusbar + + if self._statusbarAction.isChecked(): + self.statusBar().show() + else: + self.statusBar().hide() + + def optionsConfigureKeys(self): + KKeyDialog.configure(self.actionCollection()) + + def optionsConfigureToolbars(self): + # use the standard toolbar editor + self.saveMainWindowSettings(TDEGlobal.config()) + + def newToolbarConfig(self): + # this slot is called when user clicks "Ok" or "Apply" in the toolbar editor. + # recreate our GUI, and re-apply the settings (e.g. "text under icons", etc.) + self.createGUI() + self.applyMainWindowSettings(TDEGlobal.config()) + + def changeStatusbar(self,text): + # display the text on the statusbar + self.statusBar().message(text) + + def changeCaption(self,text): + # display the text on the caption + self.setCaption(text) + + +options = [ ("+[URL]", "Document to open", "") ] + +def main(): + global tdeApp,version,description,options + + aboutdata = TDEAboutData("tdeapp", "TdeApp", version, description, \ + TDEAboutData.License_GPL, "(C) 2005 AUTHOR", None, None, "your@email.com") + aboutdata.addAuthor("AUTHOR", None, "your@email.com") + TDECmdLineArgs.init(sys.argv,aboutdata) + TDECmdLineArgs.addCmdLineOptions(options) + tdeApp = TDEApplication() + + # register ourselves as a dcop client + tdeApp.dcopClient().registerAs(tdeApp.name(), False) + + # see if we are starting with session management + if tdeApp.isRestored(): + n = 1 + while TDEMainWindow.canBeRestored(n): + TdeApp().restore(n) + n += 1 + else: + # no session.. just start up normally + args = TDECmdLineArgs.parsedArgs() + if args.count() == 0: + widget = TdeApp() + widget.show() + else: + i = 0 + for i in range(args.count()): + widget = TdeApp() + widget.show() + widget.load(args.url(i)) + + args.clear() + + return tdeApp.exec_loop() +main() diff --git a/app_templates/kdeapp/src/tdeappiface.py b/app_templates/kdeapp/src/tdeappiface.py new file mode 100644 index 0000000..5600437 --- /dev/null +++ b/app_templates/kdeapp/src/tdeappiface.py @@ -0,0 +1,26 @@ +#!/usr/bin/python +########################################################################### +# testappiface - description # +# ------------------------------ # +# begin : Fri Jun 27 2003 # +# copyright : (C) 2005 by AUTHOR # +# email : your@email.com # +# # +########################################################################### +# # +# 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. # +# # +########################################################################### + +from dcopexport import DCOPExObj + +class TestAppIface(DCOPExObj): + def __init__(self, parent, id="Value"): + DCOPExObj.__init__(self, id) + self.addMethod("void openURL(TQString url)", self.openURL) + + def openURL(self,url): + pass diff --git a/app_templates/kdeapp/src/tdeappui.rc b/app_templates/kdeapp/src/tdeappui.rc new file mode 100644 index 0000000..6c3f6a9 --- /dev/null +++ b/app_templates/kdeapp/src/tdeappui.rc @@ -0,0 +1,8 @@ + + + + C&ustom + + + + diff --git a/app_templates/kdeapp/src/tdeappview.py b/app_templates/kdeapp/src/tdeappview.py new file mode 100644 index 0000000..3d524d9 --- /dev/null +++ b/app_templates/kdeapp/src/tdeappview.py @@ -0,0 +1,91 @@ +#!/usr/bin/python +########################################################################### +# tdeappview - description # +# ------------------------------ # +# begin : Fri Jun 27 2005 # +# copyright : (C) 2005 by AUTHOR # +# email : your@email.com # +# # +########################################################################### +# # +# 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. # +# # +########################################################################### + +from PyTQt.tqt import * +from tdecore import * +from tdeui import * +from tdeio import * +from tdehtml import * +from tdeparts import * +#from tdeappiface import * + +class TdeAppView(TQWidget): + def __init__(self,parent): + TQWidget.__init__(self,parent) + #self._dcopclient= TdeAppIface(self,"TdeAppIface") + + # setup our layout manager to automatically add our widgets + top_layout = TQHBoxLayout(self) + top_layout.setAutoAdd(True) + + if True: + self._html = TDEHTMLPart(self) + else: + + # we want to look for all components that satisfy our needs. the + # trader will actually search through *all* registered KDE + # applications and components -- not just KParts. So we have to + # specify two things: a service type and a constraint + # + # the service type is like a mime type. we say that we want all + # applications and components that can handle HTML -- 'text/html' + # + # however, by itself, this will return such things as Netscape.. + # not what we wanted. so we constrain it by saying that the + # string 'KParts/ReadOnlyPart' must be found in the ServiceTypes + # field. with this, only components of the type we want will be + # returned. + offers = TDETrader.self().query("text/html", "'KParts/ReadOnlyPart' in ServiceTypes") + + self._html = None + # in theory, we only care about the first one.. but let's try all + # offers just in case the first can't be loaded for some reason + for ptr in offers: + # we now know that our offer can handle HTML and is a part. + # since it is a part, it must also have a library... let's try to + # load that now + self._html = createReadOnlyPart(ptr.library(),self,ptr.name(),"KParts::ReadOnlyPart", TQStringList()) + if self._html is not None: + break + + # if our factory is invalid, then we never found our component + # and we might as well just exit now + if self._html is None: + KMessageBox.error(self, i18n("Could not find a suitable HTML component")) + return + + TQObject.connect(self._html, TQ_SIGNAL("setWindowCaption(const TQString&)"), self.slotSetTitle) + TQObject.connect(self._html, TQ_SIGNAL("setStatusBarText(const TQString&)"), self.slotOnURL) + + def print_(self,p,height,width): + pass + # do the actual printing, here + # p.drawText(etc..) + + def currentURL(self): + return self._html.url().url() + + def openURL(self,url): + if isinstance(url,TQString): + url = KURL(url) + self._html.openURL(url) + + def slotOnURL(self,url): + self.emit(PYSIGNAL("signalChangeStatusbar"),(url,) ) + + def slotSetTitle(self,title): + self.emit(PYSIGNAL("signalChangeCaption"),(title,) ) diff --git a/app_templates/kdeutility/src/kdeutility.py b/app_templates/kdeutility/src/kdeutility.py index dc61002..ebd12f5 100755 --- a/app_templates/kdeutility/src/kdeutility.py +++ b/app_templates/kdeutility/src/kdeutility.py @@ -34,18 +34,18 @@ class KDEUtilityDialog(KDEUtilityDialogUI): options = [] # No command line options. def main(): - global kapp,version,description,options + global tdeApp,version,description,options aboutdata = TDEAboutData("kdeutility", "KdeUtility", version, description, \ TDEAboutData.License_GPL, "(C) 2005 AUTHOR", None, None, "your@email.com") aboutdata.addAuthor("AUTHOR", None, "your@email.com") TDECmdLineArgs.init(sys.argv,aboutdata) #TDECmdLineArgs.addCmdLineOptions(options) - kapp = TDEApplication() + tdeApp = TDEApplication() dialog = KDEUtilityDialog() - kapp.setMainWidget(dialog) + tdeApp.setMainWidget(dialog) dialog.show() - return kapp.exec_loop() + return tdeApp.exec_loop() main() -- cgit v1.2.1