diff options
Diffstat (limited to 'app_templates/kdeapp/src')
| -rw-r--r-- | app_templates/kdeapp/src/hi16-app-kdeapp.png | 8 | ||||
| -rw-r--r-- | app_templates/kdeapp/src/hi32-app-kdeapp.png | 26 | ||||
| -rw-r--r-- | app_templates/kdeapp/src/kdeapp.desktop | 35 | ||||
| -rw-r--r-- | app_templates/kdeapp/src/kdeapp.lsm | 16 | ||||
| -rwxr-xr-x | app_templates/kdeapp/src/kdeapp.py | 280 | ||||
| -rw-r--r-- | app_templates/kdeapp/src/kdeappiface.py | 26 | ||||
| -rw-r--r-- | app_templates/kdeapp/src/kdeappui.rc | 8 | ||||
| -rw-r--r-- | app_templates/kdeapp/src/kdeappview.py | 91 | ||||
| -rw-r--r-- | app_templates/kdeapp/src/prefdialog.py | 53 |
9 files changed, 543 insertions, 0 deletions
diff --git a/app_templates/kdeapp/src/hi16-app-kdeapp.png b/app_templates/kdeapp/src/hi16-app-kdeapp.png new file mode 100644 index 0000000..40fe05e --- /dev/null +++ b/app_templates/kdeapp/src/hi16-app-kdeapp.png @@ -0,0 +1,8 @@ +PNG + + +IHDR +5MZfθ92@ +2wlA;vc)\)/l F\ϓ~SXŦ=tj76{rumu_% }fb{ZRdY7C2TWՓӲO>fXGȵ,F&/#x<&P%]EܖCfUS +"l+*JǰMJde9Hz]qTPBI +}Q bR ]nvbf,û:Ld4PuC7AK\^ϟ=.~|َ2w|xwNVd/RK6+ɤĦ7fmc5hr96MD#x=IaނOHxc7=# UDoVi diff --git a/app_templates/kdeapp/src/hi32-app-kdeapp.png b/app_templates/kdeapp/src/hi32-app-kdeapp.png new file mode 100644 index 0000000..8a6093e --- /dev/null +++ b/app_templates/kdeapp/src/hi32-app-kdeapp.png @@ -0,0 +1,26 @@ +PNG + + +IHDR +:IDATx{\}?wy;;}`k̲~&qR-HGpk +PPJ&( +JEQ4Iq QDHC~D6Bصٵ̝ٝ;;?f1 i{+]}k_åòBe,ˢ3֖6Tض3'``Iem=}j^wO<wYkV_˺x,M?.x!cČl8voZ;ퟙ<rV͌O>\OzU#fha7YI5r엇@[ +>u;joQk╳?ڕkq +-t/E(tB 06se_?u7сQ3r)%H+B +֎6CHWRШ7ؾk33M_<dzGfXbq@YӷƬ\o֭Z8B!</MP Xi-zJA(AHHGD\fcTJekVa lYk/r +:.bX,[ws yh) +ta# H㶸>g~So +/Y58ȗ$iTJjA +50> +ntMt?gj|#O=]d۶ȕr(߱z'N̐)E +<ABP0[,fTR Va# _y3z&˛KgAPTBcpno&+NIfS9~*K˒ҌMQ(MͲSFHA(dDjmB`aﭷfhz +cӳ +PJ8^*K. +OP >(--H,$Rj9 '$z1C/;8>|p-ZfRYx?%7!%c+EĪѡmmb#I3x AB3vnF4qvSuBBIT +G)^s~*G&b~.N46ǩ3HH_lϻ%:ґm-dbi\ +YTR~ +3`ʮ +xS(W˖eY,8a{Qnf*0%I] +Uܲ!Eg(6-:.JJTEZ ^:E$rbjqK*"͖L\ +i#hh-ƖM[rήGk eTNrbH6ʼn/? he3ZBTl*J6])X?C{GZGQLT!ʒMdDS/YC^]M[?~/E,T(B\oղ,g}<| h0[,_ H'<ٸG*5WfIZXym/%uMTk5XaEkdpOe+($gb\8/ +l!0ZW'^],BwؼzF%9-+ڮhΧ,bl\l4f7 diff --git a/app_templates/kdeapp/src/kdeapp.desktop b/app_templates/kdeapp/src/kdeapp.desktop new file mode 100644 index 0000000..2787759 --- /dev/null +++ b/app_templates/kdeapp/src/kdeapp.desktop @@ -0,0 +1,35 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=$APPNAME$ +Exec=$APPNAMELC$ %i %m -caption "%c" +Icon=$APPNAMELC$ +Type=Application +DocPath=$APPNAMELC$/$APPNAMELC$.html +Comment=A KDE KPart Application +Comment[ca]=Una aplicació KPart per a KDE +Comment[cy]=Cymhwysiad KPart KDE +Comment[da]=Et KDE KPart program +Comment[de]=Eine KDE-Komponenten-Anwendung +Comment[el]=Μια εφαρμογή KPart του KDE +Comment[es]=Una aplicación KPart de KDE +Comment[et]=KDE KPart rakendus +Comment[fr]=Une application KPart pour KDE. +Comment[hi]=एक केडीई के-पार्ट अनुप्रयोग +Comment[hu]=KPart-alapú KDE-alkalmazás +Comment[is]=KDE KPart forrit +Comment[it]=Applicazione KPart di KDE +Comment[ja]=KDE KPart アプリケーション +Comment[nb]=Et KDE KPart-program +Comment[nl]=Een KDE KPart-toepassing +Comment[pl]=Aplikacja KDE +Comment[pt]=Uma aplicação KPart do KDE +Comment[pt_BR]=Um Aplicativo KPart do KDE +Comment[ru]=Приложение KPart для KDE +Comment[sl]=Program KPart za KDE +Comment[sr]=KDE KPart програм +Comment[sr@Latn]=KDE KPart program +Comment[sv]=Ett KDE Kpart-program +Comment[ta]=கெடி கெபார்ட் பயன்பாடு +Comment[tg]=Ба кор андохтани KPart барои KDE +Comment[zh_CN]=一个 KDE KPart 应用程序 +Terminal=0 diff --git a/app_templates/kdeapp/src/kdeapp.lsm b/app_templates/kdeapp/src/kdeapp.lsm new file mode 100644 index 0000000..43d0d5f --- /dev/null +++ b/app_templates/kdeapp/src/kdeapp.lsm @@ -0,0 +1,16 @@ +Begin3 +Title: $APPNAME$ -- Some description +Version: $VERSION$ +Entered-date: +Description: +Keywords: KDE Qt +Author: $AUTHOR$ <$EMAIL$> +Maintained-by: $AUTHOR$ <$EMAIL$> +Home-page: +Alternate-site: +Primary-site: ftp://ftp.kde.org/pub/kde/unstable/apps/utils + xxxxxx $APPNAMELC$-$VERSION$.tar.gz + xxx $APPNAMELC$-$VERSION$.lsm +Platform: Linux. Needs KDE +Copying-policy: $LICENSE$ +End diff --git a/app_templates/kdeapp/src/kdeapp.py b/app_templates/kdeapp/src/kdeapp.py new file mode 100755 index 0000000..6c9b921 --- /dev/null +++ b/app_templates/kdeapp/src/kdeapp.py @@ -0,0 +1,280 @@ +#!/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 qt import * +from kdecore import * +from kdeui import * +import sys +from prefdialog import * +from kdeappview import * + +description = "A KDE Application" +version = "0.1"; + +class KdeApp(KMainWindow): + def __init__(self): + KMainWindow.__init__(self,None,"KdeApp") + + self._view = KdeAppView(self) + self._printer = None + + # accept dnd + self.setAcceptDrops(True) + + # tell the KMainWindow 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 = QString() + # 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 KIO.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 + KIO.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 = KAction(i18n("Cus&tom Menuitem"), KShortcut(), + 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 Qt 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(QString::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 Qt, you always "print" to a + # QPainter.. whether the output medium is a pixmap, a screen, + # or paper + p = QPainter() + p.begin(self._printer) + + # we let our view do the actual printing + metrics = QPaintDeviceMetrics(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(KGlobal.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(KGlobal.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 = KAboutData("kdeapp", "KdeApp", version, description, \ + KAboutData.License_GPL, "(C) 2005 AUTHOR", None, None, "your@email.com") + aboutdata.addAuthor("AUTHOR", None, "your@email.com") + KCmdLineArgs.init(sys.argv,aboutdata) + KCmdLineArgs.addCmdLineOptions(options) + kapp = KApplication() + + # 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 KMainWindow.canBeRestored(n): + KdeApp().restore(n) + n += 1 + else: + # no session.. just start up normally + args = KCmdLineArgs.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 new file mode 100644 index 0000000..1ff3b0f --- /dev/null +++ b/app_templates/kdeapp/src/kdeappiface.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(QString url)", self.openURL) + + def openURL(self,url): + pass diff --git a/app_templates/kdeapp/src/kdeappui.rc b/app_templates/kdeapp/src/kdeappui.rc new file mode 100644 index 0000000..6c3f6a9 --- /dev/null +++ b/app_templates/kdeapp/src/kdeappui.rc @@ -0,0 +1,8 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="testapp" version="1"> +<MenuBar> + <Menu name="custom"><text>C&ustom</text> + <Action name="custom_action" /> + </Menu> +</MenuBar> +</kpartgui> diff --git a/app_templates/kdeapp/src/kdeappview.py b/app_templates/kdeapp/src/kdeappview.py new file mode 100644 index 0000000..af28a44 --- /dev/null +++ b/app_templates/kdeapp/src/kdeappview.py @@ -0,0 +1,91 @@ +#!/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 qt import * +from kdecore import * +from kdeui import * +from kio import * +from khtml import * +from kparts import * +#from kdeappiface import * + +class KdeAppView(QWidget): + def __init__(self,parent): + QWidget.__init__(self,parent) + #self._dcopclient= KdeAppIface(self,"KdeAppIface") + + # setup our layout manager to automatically add our widgets + top_layout = QHBoxLayout(self) + top_layout.setAutoAdd(True) + + if True: + self._html = KHTMLPart(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 = KTrader.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",QStringList()) + 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 + + QObject.connect(self._html, SIGNAL("setWindowCaption(const QString&)"), self.slotSetTitle) + QObject.connect(self._html, SIGNAL("setStatusBarText(const QString&)"), 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,QString): + 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/prefdialog.py b/app_templates/kdeapp/src/prefdialog.py new file mode 100644 index 0000000..7932f84 --- /dev/null +++ b/app_templates/kdeapp/src/prefdialog.py @@ -0,0 +1,53 @@ +#!/usr/bin/python +########################################################################### +# testapp - 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 qt import * +from kdecore import * +from kdeui import * + +class TestAppPrefDialog(KDialogBase): + def __init__(self): + KDialogBase.__init__(TreeList, i18n("TestApp Preferences"), + KDialogBase.Help|KDialogBase.Default|KDialogBase.Ok|KDialogBase.Apply|KDialogBase.Cancel, Ok) + + # this is the base class for your preferences dialog. it is now + # a Treelist dialog.. but there are a number of other + # possibilities (including Tab, Swallow, and just Plain) + frame = self.addPage(i18n("First Page"), i18n("Page One Options")) + self._pageOne = TestAppPrefPageOne(frame) + + frame = self.addPage(i18n("Second Page"), i18n("Page Two Options")) + self._pageTwo = TestAppPrefPageTwo(frame) + +class TestAppPrefPageOne(QFrame): + def __init__(self,parent): + QFrame.__init__(self,parent) + + layout = QHBoxLayout(self) + layout.setAutoAdd(True) + + QLabel(i18n("Add something here"), self) + +class TestAppPrefPageTwo(QFrame): + def __init__(self,parent): + QFrame.__init__(self,parent) + + layout = QHBoxLayout(self) + layout.setAutoAdd(True) + + QLabel(i18n("Add something here"), self) + |
