diff options
Diffstat (limited to 'kuiviewer')
-rw-r--r-- | kuiviewer/Makefile.am | 70 | ||||
-rw-r--r-- | kuiviewer/designerthumbnail.desktop | 53 | ||||
-rw-r--r-- | kuiviewer/hi16-app-kuiviewer.png | bin | 0 -> 845 bytes | |||
-rw-r--r-- | kuiviewer/hi32-app-kuiviewer.png | bin | 0 -> 2595 bytes | |||
-rw-r--r-- | kuiviewer/hi48-app-kuiviewer.png | bin | 0 -> 4954 bytes | |||
-rw-r--r-- | kuiviewer/kuiviewer.cpp | 165 | ||||
-rw-r--r-- | kuiviewer/kuiviewer.desktop | 58 | ||||
-rw-r--r-- | kuiviewer/kuiviewer.h | 103 | ||||
-rw-r--r-- | kuiviewer/kuiviewer_part.cpp | 211 | ||||
-rw-r--r-- | kuiviewer/kuiviewer_part.desktop | 9 | ||||
-rw-r--r-- | kuiviewer/kuiviewer_part.h | 80 | ||||
-rw-r--r-- | kuiviewer/kuiviewer_part.rc | 17 | ||||
-rw-r--r-- | kuiviewer/kuiviewerui.rc | 8 | ||||
-rw-r--r-- | kuiviewer/lo16-app-kuiviewer.png | bin | 0 -> 309 bytes | |||
-rw-r--r-- | kuiviewer/lo32-app-kuiviewer.png | bin | 0 -> 497 bytes | |||
-rw-r--r-- | kuiviewer/main.cpp | 88 | ||||
-rw-r--r-- | kuiviewer/quicreator.cpp | 61 | ||||
-rw-r--r-- | kuiviewer/quicreator.h | 36 |
18 files changed, 959 insertions, 0 deletions
diff --git a/kuiviewer/Makefile.am b/kuiviewer/Makefile.am new file mode 100644 index 00000000..e5713689 --- /dev/null +++ b/kuiviewer/Makefile.am @@ -0,0 +1,70 @@ +# this has all of the subdirectories that make will recurse into. if +# there are none, comment this out + +# set the include path for X, qt and KDE +INCLUDES = $(all_includes) + +# these are the headers for your project +noinst_HEADERS = kuiviewer.h kuiviewer_part.h + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kuiviewer.pot + +KDE_ICON = kuiviewer + +# this Makefile creates both a KPart application and a KPart +######################################################################### +# APPLICATION SECTION +######################################################################### +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +bin_PROGRAMS = kuiviewer + +# the application source, library search path, and link libraries +kuiviewer_SOURCES = main.cpp kuiviewer.cpp +kuiviewer_LDFLAGS = $(KDE_RPATH) $(all_libraries) +kuiviewer_LDADD = $(LIB_KPARTS) + +xdg_apps_DATA =kuiviewer.desktop + +# this is where the shell's XML-GUI resource file goes +shellrcdir = $(kde_datadir)/kuiviewer +shellrc_DATA = kuiviewerui.rc + +######################################################################### +# KPART SECTION +######################################################################### +kde_module_LTLIBRARIES = libkuiviewerpart.la quithumbnail.la + +# the Part's source, library search path, and link libraries +libkuiviewerpart_la_SOURCES = kuiviewer_part.cpp +libkuiviewerpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +libkuiviewerpart_la_LIBADD = $(LIB_KPARTS) $(LIB_KFILE) -lqui + +# this is where the desktop file will go +partdesktopdir = $(kde_servicesdir) +partdesktop_DATA = kuiviewer_part.desktop + +# this is where the part's XML-GUI resource file goes +partrcdir = $(kde_datadir)/kuiviewerpart +partrc_DATA = kuiviewer_part.rc + + +######################################################################### +# THUMBNAIL SECTION +######################################################################### +quithumbnail_la_SOURCES = quicreator.cpp +quithumbnail_la_LIBADD = $(LIB_KDECORE) -lqui +quithumbnail_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +services_DATA = designerthumbnail.desktop +servicesdir = $(kde_servicesdir) + +######################################################################### +# UTILS SECTION +######################################################################### +.PHONY: changes +changes: + cvs2cl.pl --window 3600 -w --hide-filenames -I '.desktop' diff --git a/kuiviewer/designerthumbnail.desktop b/kuiviewer/designerthumbnail.desktop new file mode 100644 index 00000000..ec98ccfd --- /dev/null +++ b/kuiviewer/designerthumbnail.desktop @@ -0,0 +1,53 @@ +[Desktop Entry] +Type=Service +Name=Qt Designer Files +Name[bg]=Файлове на дизайнера Qt +Name[br]=Restroù Ergrafer Qt +Name[bs]=Qt Designer datoteke +Name[ca]=Fitxers de Qt Designer +Name[cs]=Soubory Qt designeru +Name[cy]=Ffeiliau Qt Designer +Name[da]=Qt Designer-filer +Name[de]=Qt-Designer Dateien +Name[el]=Αρχεία Qt Designer +Name[es]=Archivos de Qt Designer +Name[et]=Qt Designeri failid +Name[eu]=Qt Designer fitxategiak +Name[fa]=پروندههای طراح Qt +Name[fi]=Qt Designer -tiedostot +Name[fr]=Fichiers Qt Designer +Name[ga]=Comhaid Qt Designer +Name[gl]=Ficheiros de Qt Designer +Name[hi]=क्यू-टी डिजाइनर फ़ाइलें +Name[hu]=Qt Designer fájlok +Name[is]=Qt Designer skrár +Name[it]=File di Qt Designer +Name[ja]=Qt デザイナーファイル +Name[ka]=Qt დიზაინერის ფაილები +Name[kk]=Qt Designer файлы +Name[lt]=Qt Designer bylos +Name[nb]=Qt Designer-filer +Name[nds]=Qt-Designer-Dateien +Name[ne]=Qt डिजाइनर फाइल +Name[nl]=Qt Designer-bestanden +Name[nn]=Qt Designer-filer +Name[pa]=Qt Designer ਫਾਇਲ +Name[pl]=Pliki Qt Designer +Name[pt]=Ficheiros do Qt Designer +Name[pt_BR]=Arquivos do Qt Designer +Name[ru]=Файлы Qt Designer +Name[sk]=Súbory Qt Designer +Name[sl]=Datoteke za Qt Designer +Name[sr]=Фајлови Qt Designer-а +Name[sr@Latn]=Fajlovi Qt Designer-a +Name[sv]=Qt-designer-filer +Name[ta]=Qt வடிவமை கோப்புகள் +Name[tg]=Файлҳои Qt Designer +Name[tr]=Qt Designer Dosyaları +Name[uk]=Файли Qt Designer +Name[zh_CN]=Qt 设计师文件 +Name[zh_TW]=Qt Designer 檔案 +ServiceTypes=ThumbCreator +MimeTypes=application/x-designer +X-KDE-Library=quithumbnail +CacheThumbnail=true diff --git a/kuiviewer/hi16-app-kuiviewer.png b/kuiviewer/hi16-app-kuiviewer.png Binary files differnew file mode 100644 index 00000000..43eab761 --- /dev/null +++ b/kuiviewer/hi16-app-kuiviewer.png diff --git a/kuiviewer/hi32-app-kuiviewer.png b/kuiviewer/hi32-app-kuiviewer.png Binary files differnew file mode 100644 index 00000000..ce9df987 --- /dev/null +++ b/kuiviewer/hi32-app-kuiviewer.png diff --git a/kuiviewer/hi48-app-kuiviewer.png b/kuiviewer/hi48-app-kuiviewer.png Binary files differnew file mode 100644 index 00000000..6464fb39 --- /dev/null +++ b/kuiviewer/hi48-app-kuiviewer.png diff --git a/kuiviewer/kuiviewer.cpp b/kuiviewer/kuiviewer.cpp new file mode 100644 index 00000000..f56b0985 --- /dev/null +++ b/kuiviewer/kuiviewer.cpp @@ -0,0 +1,165 @@ +/* + * + * This file is part of the kuiviewer package + * Copyright (c) 2003 Richard Moore <rich@kde.org> + * Copyright (c) 2003 Ian Reinhart Geiser <geiseri@kde.org> + * Copyright (c) 2004 Benjamin C. Meyer <ben+kuiviewer@meyerhome.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + **/ + +#include "kuiviewer.h" +#include "kuiviewer.moc" +#include "kuiviewer_part.h" + +#include <kdebug.h> + +#include <qobjectlist.h> +#include <qdockwindow.h> +#include <qpixmap.h> + +#include <kurl.h> + +#include <kaction.h> +#include <kstdaction.h> + +#include <kiconloader.h> +#include <klibloader.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kfiledialog.h> + +KUIViewer::KUIViewer() + : KParts::MainWindow( 0L, "KUIViewer" ) +{ + // setup our actions + setupActions(); + + setMinimumSize(300, 200); + + // Bring up the gui + setupGUI(); + + // this routine will find and load our Part. it finds the Part by + // name which is a bad idea usually.. but it's alright in this + // case since our Part is made for this Shell + KLibFactory *factory = KLibLoader::self()->factory("libkuiviewerpart"); + if (factory) + { + // now that the Part is loaded, we cast it to a Part to get + // our hands on it + m_part = static_cast<KParts::ReadOnlyPart *>(factory->create(this, + "kuiviewer_part", "KParts::ReadOnlyPart" )); + + if (m_part) + { + // tell the KParts::MainWindow that this is indeed the main widget + setCentralWidget(m_part->widget()); + + // and integrate the part's GUI with the shell's + createGUI(m_part); + } + } + else + { + // if we couldn't find our Part, we exit since the Shell by + // itself can't do anything useful + //FIXME improve message, which Part is this referring to? + KMessageBox::error(this, i18n("Unable to locate Kuiviewer kpart.")); + kapp->quit(); + // we return here, cause kapp->quit() only means "exit the + // next time we enter the event loop... + return; + } +} + +KUIViewer::~KUIViewer() +{ +} + +void KUIViewer::load(const KURL& url) +{ + m_part->openURL( url ); + adjustSize(); +} + +void KUIViewer::setupActions() +{ + KStdAction::open(this, SLOT(fileOpen()), actionCollection()); + KStdAction::quit(kapp, SLOT(quit()), actionCollection()); +} + +void KUIViewer::saveProperties(KConfig* /*config*/) +{ + // the 'config' object points to the session managed + // config file. anything you write here will be available + // later when this app is restored +} + +void KUIViewer::readProperties(KConfig* /*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' +} + +void KUIViewer::fileOpen() +{ + // 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 + KURL file_name = + KFileDialog::getOpenURL( QString::null, i18n("*.ui *.UI|User Interface Files"), this ); + + if (file_name.isEmpty() == false) + { + // About this function, the style guide ( + // http://developer.kde.org/documentation/standards/kde/style/basics/index.html ) + // says that it should open a new window if the document is _not_ + // in its initial state. This is what we do here.. + if ( m_part->url().isEmpty() ) + { + // we open the file in this window... + load( file_name ); + } + else + { + // we open the file in a new window... + KUIViewer* newWin = new KUIViewer; + newWin->load( file_name ); + newWin->show(); + } + } +} + +void KUIViewer::takeScreenshot(const QCString &filename, int w, int h){ + if(!m_part) + return; + showMinimized(); + if(w!=-1 && h!=-1){ + // resize widget to the desired size + m_part->widget()->setMinimumSize(w, h); + m_part->widget()->setMaximumSize(w, h); + m_part->widget()->repaint(); + // resize app to be as large as desired size + adjustSize(); + // Disable the saving of the size + setAutoSaveSettings(QString::fromLatin1("MainWindow"), false); + } + QPixmap pixmap = QPixmap::grabWidget( m_part->widget() ); + pixmap.save( filename, "PNG" ); +} + diff --git a/kuiviewer/kuiviewer.desktop b/kuiviewer/kuiviewer.desktop new file mode 100644 index 00000000..e1e62263 --- /dev/null +++ b/kuiviewer/kuiviewer.desktop @@ -0,0 +1,58 @@ +[Desktop Entry] +Name=KUIViewer +Name[cy]=KUIGwelydd +Name[hi]=के-यूआई-व्यूअर +Name[ja]=KUI ビューア +Name[sv]=KUIviewer +Name[ta]=KUIவியூவர் +Exec=kuiviewer %i %m -caption "%c" +Icon=kuiviewer +Type=Application +GenericName=Qt Designer UI File Viewer +GenericName[br]=Ur gweler restr UI Ergrafer Qt +GenericName[bs]=Preglednik Qt Designer UI datoteka +GenericName[ca]=Visor de fitxer UI de Qt Designer +GenericName[cs]=Prohlížeč UI souborů z Qt Designeru +GenericName[cy]=Gwelydd Ffeiliau UI Qt Designer +GenericName[da]=Qt Designer UI filviser +GenericName[de]=Betrachter für UI-Dateien des Qt-Designer +GenericName[el]=Προβολέας αρχείων Qt Designer UI +GenericName[es]=Visor de archivos UI de Qt Designer +GenericName[et]=Qt Designeri UI-failide näitaja +GenericName[eu]=Qt Designer UI fitxartegi ikusgailua +GenericName[fa]=مشاهدهگر پروندۀ واسط نگارهای طراح Qt +GenericName[fi]=Qt Designerin UI-tiedostojen katselin +GenericName[fr]=Afficheur de fichiers UI de QT Designer +GenericName[gl]=Visor de ficheiros de Qt Designer +GenericName[hu]=Qt Designer UI-fájlnézegető +GenericName[is]=Qt Designer UI skráaskoðari +GenericName[it]=Visualizzatore per file UI di Qt Designer +GenericName[ja]=Qt デザイナー UI ファイルビューア +GenericName[ka]=Qt დიზაინერის UI ფაილთა მხილველი +GenericName[kk]=Qt Designer пайдаланушы интерфейсінің файлдарын қарау құралы +GenericName[lt]=Qt Designer naudotojo sąsajos bylų žiūryklė +GenericName[nb]=Qt Designer UI-filviser +GenericName[nds]=Kieker för Qt-Designer sien UI-Dateien +GenericName[ne]=Qt डिजाइनर यूआई फाइल दर्शक +GenericName[nl]=Weergave van QT Designer UI-bestanden +GenericName[nn]=Qt Designer UI-filvisar +GenericName[pl]=Przeglądarka plików interfejsu użytkownika Qt Designera +GenericName[pt]=Visualizador de Ficheiros UI do Qt Designer +GenericName[pt_BR]=Visualizador de Arquivos e Interface do Qt Designer +GenericName[ru]=Просмотрщик UI-файлов Qt Designer +GenericName[sk]=Prehliadač súborov UI pre Qt Designer +GenericName[sl]=Pregledovalnik datotek UI za Qt Designer +GenericName[sr]=Приказивач UI фајлова Qt Designer-а +GenericName[sr@Latn]=Prikazivač UI fajlova Qt Designer-a +GenericName[sv]=Qt-designer UI-filvisning +GenericName[ta]=Qt வடிவமைப்பவர் UI கோப்புகள் காட்சியகம் +GenericName[tg]=Намоишгари UI-файлҳо Qt Designer +GenericName[tr]=Qt Designer UI Dosya Görüntüleyici +GenericName[uk]=Переглядач UI-файлів Qt Designer +GenericName[zh_CN]=Qt 设计师 UI 文件查看器 +GenericName[zh_TW]=Qt Designer UI 檔案檢視器 +MimeType=application/x-designer; +Terminal=false +X-DCOP-ServiceType=Multi +Categories=Qt;KDE;Development; +InitialPreference=10 diff --git a/kuiviewer/kuiviewer.h b/kuiviewer/kuiviewer.h new file mode 100644 index 00000000..c6194b4e --- /dev/null +++ b/kuiviewer/kuiviewer.h @@ -0,0 +1,103 @@ +/* + * + * This file is part of the kuiviewer package + * Copyright (c) 2003 Richard Moore <rich@kde.org> + * Copyright (c) 2003 Ian Reinhart Geiser <geiseri@kde.org> + * Copyright (c) 2004 Benjamin C. Meyer <ben+kuiviewer@meyerhome.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + **/ + +#ifndef KUIVIEWER_H +#define KUIVIEWER_H + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <kapplication.h> +#include <kparts/mainwindow.h> + +class KToggleAction; +class KListView; + +namespace KParts { +class ReadOnlyPart; +} + +/** + * This is the application "Shell". It has a menubar, toolbar, and + * statusbar but relies on the "Part" to do all the real work. + * + * @short KUI Viewer Shell + * @author Richard Moore <rich@kde.org> + * @author Ian Reinhart Geiser <geiser@kde.org> + * @version 1.0 + */ +class KUIViewer : public KParts::MainWindow +{ + Q_OBJECT +public: + /** + * Default Constructor + */ + KUIViewer(); + + /** + * Default Destructor + */ + virtual ~KUIViewer(); + + /** + * Use this method to load whatever file/URL you have + */ + void load(const KURL& url); + + /** + * Take screenshot of current ui file + * @param filename to save image in + * @param h height of image + * @param w width of image + */ + void takeScreenshot(const QCString &filename, int h=-1, int w=-1); + +protected: + /** + * This method is called when it is time for the app to save its + * properties for session management purposes. + */ + void saveProperties(KConfig *); + + /** + * This method is called when this app is restored. The KConfig + * object points to the session management config file that was saved + * with @ref saveProperties + */ + void readProperties(KConfig *); + +private slots: + void fileOpen(); + +private: + void setupActions(); + +private: + KParts::ReadOnlyPart *m_part; + KToggleAction *m_toolbarAction; + KToggleAction *m_statusbarAction; +}; + +#endif // KUIVIEWER_H + diff --git a/kuiviewer/kuiviewer_part.cpp b/kuiviewer/kuiviewer_part.cpp new file mode 100644 index 00000000..25ef1b2d --- /dev/null +++ b/kuiviewer/kuiviewer_part.cpp @@ -0,0 +1,211 @@ +/** + * + * This file is part of the kuiviewer package + * Copyright (c) 2003 Richard Moore <rich@kde.org> + * Copyright (c) 2003 Ian Reinhart Geiser <geiseri@kde.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + **/ + +#include "kuiviewer_part.h" +#include "kuiviewer_part.moc" + +#include <kaction.h> +#include <kapplication.h> +#include <kconfig.h> +#include <kdebug.h> +#include <kdialogbase.h> +#include <kiconloader.h> +#include <kinstance.h> +#include <kio/netaccess.h> +#include <klistview.h> +#include <kparts/genericfactory.h> +#include <kstdaction.h> +#include <kstyle.h> +#include <qmetaobject.h> + +#include <qclipboard.h> +#include <qcursor.h> +#include <qfile.h> +#include <qobjectlist.h> +#include <qpixmap.h> +#include <qstyle.h> +#include <qstylefactory.h> +#include <qvariant.h> +#include <qvbox.h> +#include <qvariant.h> +#include <qwidgetfactory.h> + +typedef KParts::GenericFactory<KUIViewerPart> KUIViewerPartFactory; +K_EXPORT_COMPONENT_FACTORY( libkuiviewerpart, KUIViewerPartFactory ) + +KUIViewerPart::KUIViewerPart( QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, + const QStringList & /*args*/ ) + : KParts::ReadOnlyPart(parent, name) +{ + // we need an instance + setInstance( KUIViewerPartFactory::instance() ); + + KGlobal::locale()->insertCatalogue("kuiviewer"); + + // this should be your custom internal widget + m_widget = new QVBox( parentWidget, widgetName ); + + // notify the part that this is our internal widget + setWidget(m_widget); + + // set our XML-UI resource file + setXMLFile("kuiviewer_part.rc"); + + m_style = new KListAction( i18n("Style"), + CTRL + Key_S, + this, + SLOT(slotStyle(int)), + actionCollection(), + "change_style"); + m_style->setEditable(false); + + kapp->config()->setGroup("General"); + const QString currentStyle = kapp->config()->readEntry("currentWidgetStyle", KStyle::defaultStyle()); + + const QStringList styles = QStyleFactory::keys(); + m_style->setItems(styles); + m_style->setCurrentItem(0); + + QStringList::ConstIterator it = styles.begin(); + QStringList::ConstIterator end = styles.end(); + int idx = 0; + for (; it != end; ++it, ++idx) { + if ((*it).lower() == currentStyle.lower()) { + m_style->setCurrentItem(idx); + break; + } + } + m_style->setToolTip(i18n("Set the current style to view.")); + m_style->setMenuAccelsEnabled(true); + + m_copy = KStdAction::copy(this, SLOT(slotGrab()), actionCollection()); + + updateActions(); + +// Commented out to fix warning (rich) +// slot should probably be called saveAs() for consistency with +// KParts::ReadWritePart BTW. +// KStdAction::saveAs(this, SLOT(slotSave()), actionCollection()); +} + +KUIViewerPart::~KUIViewerPart() +{ +} + +KAboutData *KUIViewerPart::createAboutData() +{ + // the non-i18n name here must be the same as the directory in + // which the part's rc file is installed ('partrcdir' in the + // Makefile) + KAboutData *aboutData = new KAboutData("kuiviewerpart", I18N_NOOP("KUIViewerPart"), "0.1", + I18N_NOOP("Displays Designer's UI files"), + KAboutData::License_LGPL ); + aboutData->addAuthor("Richard Moore", 0, "rich@kde.org"); + aboutData->addAuthor("Ian Reinhart Geiser", 0, "geiseri@kde.org"); + return aboutData; +} + +bool KUIViewerPart::openFile() +{ + // m_file is always local so we can use QFile on it + QFile file( m_file ); + if ( !file.open(IO_ReadOnly) ) + return false; + + delete m_view; + m_view = QWidgetFactory::create( &file, 0, m_widget ); + + file.close(); + updateActions(); + + if ( !m_view ) + return false; + + m_view->show(); + slotStyle(0); + return true; +} + +bool KUIViewerPart::openURL( const KURL& url) +{ + // just for fun, set the status bar + emit setStatusBarText( url.prettyURL() ); + emit setWindowCaption( url.prettyURL() ); + + m_url = url; + m_file = QString::null; + if (KIO::NetAccess::download(url, m_file)) + return openFile(); + else + return false; +} + +void KUIViewerPart::updateActions() +{ + if ( !m_view.isNull() ) { + m_style->setEnabled( true ); + m_copy->setEnabled( true ); + } + else { + m_style->setEnabled( false ); + m_copy->setEnabled( false ); + } +} + +void KUIViewerPart::slotStyle(int) +{ + if ( m_view.isNull() ) { + updateActions(); + return; + } + + QString styleName = m_style->currentText(); + QStyle* style = QStyleFactory::create(styleName); + kdDebug() << "Change style..." << endl; + m_widget->hide(); + QApplication::setOverrideCursor( WaitCursor ); + m_widget->setStyle( style); + + QObjectList *l = m_widget->queryList( "QWidget" ); + for ( QObject *o = l->first(); o; o = l->next() ) + ( static_cast<QWidget *>(o) )->setStyle( style ); + delete l; + + m_widget->show(); + QApplication::restoreOverrideCursor(); + + kapp->config()->setGroup("General"); + kapp->config()->writeEntry("currentWidgetStyle", m_style->currentText()); + kapp->config()->sync(); +} + +void KUIViewerPart::slotGrab() +{ + if ( m_view.isNull() ) { + updateActions(); + return; + } + + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setPixmap(QPixmap::grabWidget(m_widget)); +} + diff --git a/kuiviewer/kuiviewer_part.desktop b/kuiviewer/kuiviewer_part.desktop new file mode 100644 index 00000000..704eaf5d --- /dev/null +++ b/kuiviewer/kuiviewer_part.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=KUIViewerPart +Name[hi]=के-यूआई-व्यूअर-पार्ट +Name[sv]=KUIviewer-del +Name[ta]=KUIவியூவர் உறுப்பு +MimeType=application/x-designer; +ServiceTypes=KParts/ReadOnlyPart +X-KDE-Library=libkuiviewerpart +Type=Service diff --git a/kuiviewer/kuiviewer_part.h b/kuiviewer/kuiviewer_part.h new file mode 100644 index 00000000..e34f1f35 --- /dev/null +++ b/kuiviewer/kuiviewer_part.h @@ -0,0 +1,80 @@ +/** + * + * This file is part of the kuiviewer package + * Copyright (c) 2003 Richard Moore <rich@kde.org> + * Copyright (c) 2003 Ian Reinhart Geiser <geiseri@kde.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + **/ + +#ifndef KUIVIEWERPART_H +#define KUIVIEWERPART_H + +#include <qguardedptr.h> +#include <kparts/part.h> + +class QWidget; +class KURL; +class QVBox; +class KAboutData; +class KListAction; +class KListView; + +/** + * This is a "Part". It that does all the real work in a KPart + * application. + * + * @short Main Part + * @author Richard Moore <rich@kde.org> + * @version 0.1 + */ +class KUIViewerPart : public KParts::ReadOnlyPart +{ + Q_OBJECT +public: + /** + * Default constructor + */ + KUIViewerPart(QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, const QStringList &args); + + /** + * Destructor + */ + virtual ~KUIViewerPart(); + + static KAboutData *createAboutData(); + +public slots: + bool openURL( const KURL& ); + void slotStyle(int); + void slotGrab(); + void updateActions(); + +protected: + /** + * This must be implemented by each part + */ + virtual bool openFile(); + +private: + QVBox *m_widget; + QGuardedPtr<QWidget> m_view; + KListAction *m_style; + KAction *m_copy; +}; + +#endif // KUIVIEWERPART_H + diff --git a/kuiviewer/kuiviewer_part.rc b/kuiviewer/kuiviewer_part.rc new file mode 100644 index 00000000..26fead68 --- /dev/null +++ b/kuiviewer/kuiviewer_part.rc @@ -0,0 +1,17 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="kuiviewer_part" version="5"> +<MenuBar> + <Menu name="file"><Text>&File</Text> + <Action name="file_save_as"/> + </Menu> + <Menu name="edit"><Text>&Edit</Text> + <Action name="edit_copy"/> + </Menu> + <Menu name="view"><Text>&View</Text> + <Action name="change_style"/> + </Menu> +</MenuBar> +<ToolBar name="styleBar"><Text>Style</Text> + <Action name="change_style"/> +</ToolBar> +</kpartgui> diff --git a/kuiviewer/kuiviewerui.rc b/kuiviewer/kuiviewerui.rc new file mode 100644 index 00000000..296367af --- /dev/null +++ b/kuiviewer/kuiviewerui.rc @@ -0,0 +1,8 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="shell" version="1"> +<MenuBar> + <Menu name="file"><Text>&File</Text></Menu> + <Menu name="edit"><Text>&Edit</Text></Menu> + <Menu name="view"><Text>&View</Text></Menu> +</MenuBar> +</kpartgui> diff --git a/kuiviewer/lo16-app-kuiviewer.png b/kuiviewer/lo16-app-kuiviewer.png Binary files differnew file mode 100644 index 00000000..6983b6ab --- /dev/null +++ b/kuiviewer/lo16-app-kuiviewer.png diff --git a/kuiviewer/lo32-app-kuiviewer.png b/kuiviewer/lo32-app-kuiviewer.png Binary files differnew file mode 100644 index 00000000..8a55a122 --- /dev/null +++ b/kuiviewer/lo32-app-kuiviewer.png diff --git a/kuiviewer/main.cpp b/kuiviewer/main.cpp new file mode 100644 index 00000000..0ab53d0f --- /dev/null +++ b/kuiviewer/main.cpp @@ -0,0 +1,88 @@ +/** + * + * This file is part of the kuiviewer package + * Copyright (c) 2003 Richard Moore <rich@kde.org> + * Copyright (c) 2003 Ian Reinhart Geiser <geiseri@kde.org> + * Copyright (c) 2004 Benjamin C. Meyer <ben+kuiviewer@meyerhome.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + **/ + +#include "kuiviewer.h" +#include <kapplication.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <klocale.h> + +static KCmdLineOptions options[] = +{ + { "+[URL]", I18N_NOOP( "Document to open" ), 0 }, + { "s",0,0 }, + { "takescreenshot <filename>", I18N_NOOP( "Save screenshot to file and exit" ), 0 }, + { "w",0,0 }, + { "screenshotwidth <int>", I18N_NOOP( "Screenshot width" ), "-1" }, + { "h",0,0 }, + { "screenshotheight <int>", I18N_NOOP( "Screenshot height" ), "-1" }, + KCmdLineLastOption +}; + +int main(int argc, char **argv) +{ + KAboutData about("kuiviewer", I18N_NOOP("KUIViewer"), "0.1", + I18N_NOOP("Displays Designer's UI files"), + KAboutData::License_LGPL ); + about.addAuthor("Richard Moore", 0, "rich@kde.org"); + about.addAuthor("Ian Reinhart Geiser", 0, "geiseri@kde.org"); + // Screenshot capability + about.addAuthor("Benjamin C. Meyer", 0, "ben+kuiviewer@meyerhome.net"); + + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions( options ); + KApplication app; + + // see if we are starting with session management + if (app.isRestored()) + RESTORE(KUIViewer) + else + { + // no session.. just start up normally + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + if ( args->count() == 0 ) + { + KUIViewer *widget = new KUIViewer; + widget->show(); + } + else + { + int i = 0; + for (; i < args->count(); i++ ) { + KUIViewer *widget = new KUIViewer; + widget->load( args->url(i) ); + + if (args->isSet("takescreenshot")){ + widget->takeScreenshot(args->getOption("takescreenshot"), + QString(args->getOption("screenshotwidth")).toInt(), + QString(args->getOption("screenshotheight")).toInt()); + return 0; + } + widget->show(); + } + } + args->clear(); + } + + return app.exec(); +} diff --git a/kuiviewer/quicreator.cpp b/kuiviewer/quicreator.cpp new file mode 100644 index 00000000..0bf47e71 --- /dev/null +++ b/kuiviewer/quicreator.cpp @@ -0,0 +1,61 @@ +/** + * + * This file is part of the kuiviewer package + * Copyright (c) 2003 Richard Moore <rich@kde.org> + * Copyright (c) 2003 Ian Reinhart Geiser <geiseri@kde.org> + * Copyright (c) 2004 Benjamin C. Meyer <ben+kuiviewer@meyerhome.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + **/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <qpixmap.h> +#include <qimage.h> +#include <qwidgetfactory.h> + +#include "quicreator.h" + +#include <kdemacros.h> + +extern "C" +{ + KDE_EXPORT ThumbCreator *new_creator() + { + return new QUICreator; + } +} + +bool QUICreator::create(const QString &path, int width, int height, QImage & +img) +{ + QWidget *w = QWidgetFactory::create(path, 0, 0); + if ( w ) + { + QPixmap p = QPixmap::grabWidget(w); + img = p.convertToImage().smoothScale(width,height,QImage::ScaleMin); + return true; + } + else + return false; +} + +ThumbCreator::Flags QUICreator::flags() const +{ + return static_cast<Flags>(DrawFrame); +} + diff --git a/kuiviewer/quicreator.h b/kuiviewer/quicreator.h new file mode 100644 index 00000000..7127ecc7 --- /dev/null +++ b/kuiviewer/quicreator.h @@ -0,0 +1,36 @@ +/* + * + * This file is part of the kuiviewer package + * Copyright (c) 2003 Richard Moore <rich@kde.org> + * Copyright (c) 2003 Ian Reinhart Geiser <geiseri@kde.org> + * Copyright (c) 2004 Benjamin C. Meyer <ben+kuiviewer@meyerhome.net> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * 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., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + **/ +#ifndef UICREATOR_H +#define UICREATOR_H + +#include <kio/thumbcreator.h> + +class QUICreator : public ThumbCreator +{ +public: + QUICreator() {}; + virtual bool create(const QString &path, int, int, QImage &img); + virtual Flags flags() const; +}; + +#endif // UICREATOR_H + |