From f753872b9ffefec5cb39363c276e553b6643977a Mon Sep 17 00:00:00 2001 From: visnov Date: Mon, 12 Nov 2007 14:59:28 +0000 Subject: [PATCH] added all missing methods, web UI loads and fails git-svn-id: http://svn.opensuse.org/svn/yast/branches/tmp/sh/mod-ui/web-wt@41975 e0cc52ee-31ee-0310-8b87-e83c4596d67c --- MAINTAINER | 1 + Makefile.cvs | 23 ++ RPMNAME | 1 + SUBDIRS | 1 + VERSION | 1 + configure.in.in | 15 ++ doc/Makefile.am | 11 + doc/autodocs/Makefile.am | 23 ++ src/Makefile.am | 87 +++++++ src/Y2CCWeb.cc | 30 +++ src/Y2CCWeb.h | 63 +++++ src/YWebDialog.cc | 37 +++ src/YWebDialog.h | 52 +++++ src/YWebOptionalWidgetFactory.h | 135 +++++++++++ src/YWebUI.h | 398 ++++++++++++++++++++++++++++++++ src/YWebUIComponent.h | 79 +++++++ src/YWebUI_builtins.cc | 166 +++++++++++++ src/YWebUI_core.cc | 290 +++++++++++++++++++++++ src/YWebUI_widgets.cc | 127 ++++++++++ src/YWebWidgetFactory.cc | 150 ++++++++++++ src/YWebWidgetFactory.h | 170 ++++++++++++++ yast2-web.spec.in | 52 +++++ 22 files changed, 1912 insertions(+) create mode 100644 MAINTAINER create mode 100644 Makefile.cvs create mode 100644 RPMNAME create mode 100644 SUBDIRS create mode 100644 VERSION create mode 100644 configure.in.in create mode 100644 doc/Makefile.am create mode 100644 doc/autodocs/Makefile.am create mode 100644 src/Makefile.am create mode 100644 src/Y2CCWeb.cc create mode 100644 src/Y2CCWeb.h create mode 100644 src/YWebDialog.cc create mode 100644 src/YWebDialog.h create mode 100644 src/YWebOptionalWidgetFactory.h create mode 100644 src/YWebUI.h create mode 100644 src/YWebUIComponent.h create mode 100644 src/YWebUI_builtins.cc create mode 100644 src/YWebUI_core.cc create mode 100644 src/YWebUI_widgets.cc create mode 100644 src/YWebWidgetFactory.cc create mode 100644 src/YWebWidgetFactory.h create mode 100644 yast2-web.spec.in diff --git a/MAINTAINER b/MAINTAINER new file mode 100644 index 0000000..58a2de1 --- /dev/null +++ b/MAINTAINER @@ -0,0 +1 @@ +Stanislav Visnovsky diff --git a/Makefile.cvs b/Makefile.cvs new file mode 100644 index 0000000..5146757 --- /dev/null +++ b/Makefile.cvs @@ -0,0 +1,23 @@ +# +# Makefile.cvs +# + +LIB = $(shell y2tool get-lib) + +PREFIX = /usr + +configure: all + ./configure --prefix=$(PREFIX) --libdir=$(PREFIX)/$(LIB) + +all: + y2tool y2autoconf + y2tool y2automake + autoreconf --force --install + +install: configure + make + make install + +reconf: all + ./config.status --recheck + ./config.status diff --git a/RPMNAME b/RPMNAME new file mode 100644 index 0000000..396ecac --- /dev/null +++ b/RPMNAME @@ -0,0 +1 @@ +yast2-web diff --git a/SUBDIRS b/SUBDIRS new file mode 100644 index 0000000..574e9d6 --- /dev/null +++ b/SUBDIRS @@ -0,0 +1 @@ +src doc diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..68e69e4 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2.15.0 diff --git a/configure.in.in b/configure.in.in new file mode 100644 index 0000000..0380745 --- /dev/null +++ b/configure.in.in @@ -0,0 +1,15 @@ +## general configure.in.in + +## initialize +@YAST2-INIT-COMMON@ +@YAST2-INIT-PROGRAM@ + +## some common checks +@YAST2-CHECKS-COMMON@ +@YAST2-CHECKS-PROGRAM@ + +## special stuff +PKG_CHECK_MODULES([ZYPP], [libzypp]) + +## and generate the output +@YAST2-OUTPUT@ diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..2e0ca83 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,11 @@ +# +# Makefile.am for qt/doc +# + +SUBDIRS = autodocs + +htmldir = $(docdir) + +html_DATA = + +EXTRA_DIST = $(html_DATA) diff --git a/doc/autodocs/Makefile.am b/doc/autodocs/Makefile.am new file mode 100644 index 0000000..0d2535f --- /dev/null +++ b/doc/autodocs/Makefile.am @@ -0,0 +1,23 @@ +# +# Makefile.am for qt/doc/autodocs +# +# Parameters: +# +# AUTODOCS_CC: Directories that the C++ autodocs is built from +# Optional - the default is $(srcdir)/../../src +# AUTODOCS_DEPS: dependencies of the docs, default is $(AUTODOCS_CC)/*.h +# AUTODOCS_PARAMS: more params for ydoxygen +# +# see also mvidner's post on yast2-announce on 2006-02-21 + +# AUTODOCS_CC = $(srcdir)/../../src/ + +AUTODOCS_DEPS = $(srcdir)/../../src/include/*.h + +# Use this to enable generating autodocs: +# +# include $(top_srcdir)/autodocs-cc.ami +# +# and this to disable it: +# +include $(top_srcdir)/autodocs-cc-off.ami diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..1fdcf84 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,87 @@ +# +# Makefile.am for web/src +# + +# SUBDIRS = pkg + +WTLIBDIR=/usr/local/lib/ + +AM_CXXFLAGS = -DY2LOG=\"ui-web\" \ + -DWTLIBDIR=\"$(WTLIBDIR)\" + +serversdir = $(execcompdir)/servers + +# plugin, libtool forces 'lib' prefix +plugin_LTLIBRARIES = libpy2web.la +libpy2web_la_LDFLAGS = -version-info 2:0 + +# compile using internal wthttp daemon +libpy2web_la_LIBADD = \ + -L$(plugindir) -lpy2UI \ + -lboost_thread-mt -lboost_signals -lboost_program_options -lmxml -lwt -lwthttp + +noinst_HEADERS = $(wildcard *.h) + +libpy2web_la_SOURCES = \ + Y2CCWeb.cc \ + \ + YWebUI_core.cc \ + YWebUI_widgets.cc \ + YWebUI_builtins.cc \ + YWebWidgetFactory.cc \ + YWebDialog.cc + + +# YQPackageSelectorPlugin.cc \ +# \ +# YQIconPool.cc \ +# \ +# YQAlignment.cc \ +# YQBarGraph.cc \ +# YQCheckBox.cc \ +# YQCheckBoxFrame.cc \ +# YQColoredLabel.cc \ +# YQComboBox.cc \ +# YQDate.cc \ +# YQDialog.cc \ +# YQDownloadProgress.cc \ +# YQDumbTab.cc \ +# YQEmpty.cc \ +# YQFrame.cc \ +# YQGenericButton.cc \ +# YQImage.cc \ +# YQIntField.cc \ +# YQLogView.cc \ +# YQMenuButton.cc \ +# YQMultiLineEdit.cc \ +# YQMultiProgressMeter.cc \ +# YQMultiSelectionBox.cc \ +# YQPartitionSplitter.cc \ +# YQProgressBar.cc \ +# YQPushButton.cc \ +# YQRadioButton.cc \ +# YQRadioButtonGroup.cc \ +# YQReplacePoint.cc \ +# YQRichText.cc \ +# YQSelectionBox.cc \ +# YQSlider.cc \ +# YQSpacing.cc \ +# YQSplit.cc \ +# YQSquash.cc \ +# YQTable.cc \ +# YQTextEntry.cc \ +# YQTime.cc \ +# YQTree.cc \ +# YQWizard.cc \ +# YQWizardButton.cc \ +# \ +# YFrameBuffer.cc \ +# QY2BarGraph.cc \ +# QY2ComboTabWidget.cc \ +# QY2DiskUsageList.cc \ +# QY2CharValidator.cc \ +# QY2ListView.cc \ +# QY2Settings.cc \ +# QY2LayoutUtils.cc + +INCLUDES = -I$(WTDIR)/include -I$(includedir) -I$(includedir)/yui diff --git a/src/Y2CCWeb.cc b/src/Y2CCWeb.cc new file mode 100644 index 0000000..c4c258b --- /dev/null +++ b/src/Y2CCWeb.cc @@ -0,0 +1,30 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: Y2CCWeb.cc + + Author: Stanislav Visnovsky + Maintainer: Stanislav Visnovsky + +/-*/ + + +#include "Y2CCWeb.h" + +// This is very important: We create one global variable of +// Y2CCWeb. Its constructor will register it automatically to +// the Y2ComponentBroker, so that will be able to find it. +// This all happens before main() is called! + +Y2CCWeb g_y2ccweb; + + diff --git a/src/Y2CCWeb.h b/src/Y2CCWeb.h new file mode 100644 index 0000000..bf08663 --- /dev/null +++ b/src/Y2CCWeb.h @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: Y2CCWeb.h + + Author: Mathias Kettner + Maintainer: Stefan Hundhammer + +/-*/ + + + +#ifndef _Y2CCWeb_h +#define _Y2CCWeb_h + +#include "YWebUIComponent.h" + +/** + * @short Y2ComponentCreator that can create Wt user interfaces + * A Y2ComponentCreator is an object, that can create components. + * It is given a component name and - if it knows how to create + * such a component - returns a newly created component of this + * type. The Y2CCWeb can create components with the name "web". + */ +class Y2CCWeb : public Y2ComponentCreator +{ +public: + /** + * Creates a Web component creator + */ + Y2CCWeb() : Y2ComponentCreator(Y2ComponentBroker::BUILTIN) { }; + + /** + * Returns true, since the qt component is a + * YaST2 server. + */ + bool isServerCreator() const { return true; }; + + /** + * Creates a new Qt UI component. + */ + Y2Component *create(const char * name) const + { + if (!strcmp(name, "web") ) + return new YWebUIComponent(); + else + return 0; + } +}; + +#endif // ifndef _Y2CCWeb_h + + +// EOF diff --git a/src/YWebDialog.cc b/src/YWebDialog.cc new file mode 100644 index 0000000..2f8c7dd --- /dev/null +++ b/src/YWebDialog.cc @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YWebDialog.cc + + Author: Stefan Hundhammer + +/-*/ + + +#define y2log_component "web-ui" +#include "YWebDialog.h" + +using std::string; + +YWebDialog::YWebDialog( const YWidgetOpt & opt ) + : YDialog( opt ) +{ +} + + +YWebDialog::~YWebDialog() +{ +} + + + + diff --git a/src/YWebDialog.h b/src/YWebDialog.h new file mode 100644 index 0000000..49eb8e6 --- /dev/null +++ b/src/YWebDialog.h @@ -0,0 +1,52 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YWebDialog.h + + Author: Stefan Hundhammer + +/-*/ + + +#ifndef YWebDialog_h +#define YWebDialog_h + +#include +#include + + +class YWebDialog : public YDialog +{ +protected: + /** + * Constructor. + **/ + YWebDialog( const YWidgetOpt & opt ); + + /** + * Destructor. + * Don't delete a dialog directly, use YWebDialog::deleteTopmostDialog(). + **/ + virtual ~YWebDialog(); + +public: + + /** + * Returns a descriptive name of this widget class for logging, + * debugging etc. + **/ + virtual const char * widgetClass() const { return "YWebDialog"; } + +}; + + +#endif // YWebDialog_h diff --git a/src/YWebOptionalWidgetFactory.h b/src/YWebOptionalWidgetFactory.h new file mode 100644 index 0000000..95d9186 --- /dev/null +++ b/src/YWebOptionalWidgetFactory.h @@ -0,0 +1,135 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YWebOptionalWidgetFactory.h + + Author: Stanislav Visnovsky + +/-*/ + +#ifndef YWebOptionalWidgetFactory_h +#define YWebOptionalWidgetFactory_h + +#include +#include + +#include + +using std::string; +using std::vector; + +class YBarGraph; +class YDateField; +class YDownloadProgress; +class YDumbTab; +class YDummySpecialWidget; +class YMultiProgressMeter; +class YPartitionSplitter; +class YSlider; +class YTimeField; +class YWidget; +class YWizard; + + +/** + * Abstract widget factory for optional ("special") widgets. + * + * Remember to always check with the corresponding "has..()" method if the + * current UI actually provides the requested widget. Otherwise the + * "create...()" method will throw an exception. + **/ +class YWebOptionalWidgetFactory: public YOptionalWidgetFactory +{ +public: + + // + // Optional Widgets + // + + virtual bool hasWizard(); + YWizard * createWizard ( YWidget * parent, + const string & backButtonLabel, + const string & abortButtonLabel, + const string & nextButtonLabel, + YWizardMode wizardMode = YWizardMode_Standard ); + + virtual YWizard * createWizard ( YWidget * parent, + YWidgetID * backButtonId, const string & backButtonLabel, + YWidgetID * abortButtonId, const string & abortButtonLabel, + YWidgetID * nextButtonId, const string & nextButtonLabel, + YWizardMode wizardMode = YWizardMode_Standard ); + + virtual bool hasDumbTab(); + virtual YDumbTab * createDumbTab ( YWidget * parent ); + + virtual bool hasSlider(); + virtual YSlider * createSlider ( YWidget * parent, + const string & label, + int minVal, + int maxVal, + int initialVal ); + + virtual bool hasDateField(); + virtual YDateField * createDateField ( YWidget * parent, const string & label ); + + virtual bool hasTimeField(); + virtual YTimeField * createTimeField ( YWidget * parent, const string & label ); + + virtual bool hasBarGraph(); + virtual YBarGraph * createBarGraph ( YWidget * parent, const vector & values, const vector & labels ); + + virtual bool hasPatternSelector(); + virtual YWidget * createPatternSelector ( YWidget * parent, long modeFlags = 0 ); + + virtual bool hasSimplePatchSelector(); + virtual YWidget * createSimplePatchSelector( YWidget * parent, long modeFlags = 0 ); + + virtual bool hasMultiProgressMeter(); + YMultiProgressMeter * createHMultiProgressMeter( YWidget * parent, const vector & maxValues ); + YMultiProgressMeter * createVMultiProgressMeter( YWidget * parent, const vector & maxValues ); + virtual YMultiProgressMeter * createMultiProgressMeter ( YWidget * parent, YUIDimension dim, const vector & maxValues ); + + virtual bool hasPartitionSplitter(); + virtual YPartitionSplitter * createPartitionSplitter ( YWidget * parent ); + + virtual bool hasDownloadProgress(); + virtual YDownloadProgress * createDownloadProgress ( YWidget * parent, + const string & label, + const string & filename, + long expectedFileSize ); + + bool hasDummySpecialWidget(); + YWidget * createDummySpecialWidget( YWidget * parent ); + + + +protected: + + friend class YWebUI; + + /** + * Constructor. + * + * Use YUI::optionalWidgetFactory() to get the singleton for this class. + **/ + YWebOptionalWidgetFactory(); + + /** + * Destructor. + **/ + virtual ~YWebOptionalWidgetFactory(); + +}; // class YWebOptionalWidgetFactory + + + +#endif // YOptionalWidgetFactory_h diff --git a/src/YWebUI.h b/src/YWebUI.h new file mode 100644 index 0000000..287b077 --- /dev/null +++ b/src/YWebUI.h @@ -0,0 +1,398 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YWebUI.h + + Author: Stefan Hundhammer + Stanislav Visnovsky + +/-*/ + +#ifndef YWebUI_h +#define YWebUI_h + +#include "YSimpleEventHandler.h" +#include + +#include + +class YEvent; +class YWebOptionalWidgetFactory; +class YWebWidgetFactory; + +using std::string; +using std::vector; + + +class YWebUI: public Wt::WApplication, public YUI +{ +public: + + /** + * Constructor. + **/ + YWebUI( const Wt::WEnvironment& env, + const char * macro_file ); + + /** + * Destructor. + **/ + ~YWebUI(); + + /** + * Access the global Qt-UI. + **/ + static YWebUI * ui() { return _ui; } + + +protected: + /** + * Create the widget factory that provides all the createXY() methods for + * standard (mandatory, i.e. non-optional) widgets. + * + * Reimplemented from YUI. + **/ + virtual YWidgetFactory * createWidgetFactory(); + + /** + * Create the widget factory that provides all the createXY() methods for + * optional ("special") widgets and the corresponding hasXYWidget() + * methods. + * + * Reimplemented from YUI. + **/ + virtual YOptionalWidgetFactory * createOptionalWidgetFactory(); + + /* + * Create the YApplication object that provides global methods. + * + * Reimplemented from YUI. + **/ + virtual YApplication * createApplication(); + +public: + + /** + * Widget event handlers (slots) call this when an event occured that + * should be the answer to a UserInput() / PollInput() (etc.) call. + * + * The UI assumes ownership of the event object that 'event' points to. + * In particular, it takes care to delete that object. + * + * It is an error to pass 0 for 'event'. + **/ + void sendEvent( YEvent * event ); + + /** + * Returns 'true' if there is any event pending for the specified widget. + **/ + bool eventPendingFor( YWidget * widget ) const + { return _event_handler.eventPendingFor( widget ); } + + /** + * Returns the last event that isn't processed yet or 0 if there is none. + * + * The Qt UI keeps track of only one single (the last one) event. + **/ + YEvent * pendingEvent() const { return _event_handler.pendingEvent(); } + + /** + * Returns 'true' if the UI had a fatal error that requires the application + * to abort. + **/ + bool fatalError() const { return _fatal_error; } + + /** + * Raise a fatal UI error. It will be delivered when it is safe to do so. + * The caller should make sure it can continue for some time until the + * error is delivered. + **/ + void raiseFatalError() { _fatal_error = true; } + + /** + * UI-specific runPkgSeleciton method: Start the package selection. + * This implementation does the same as UserInput(). + * + * Reimplemented from YUI. + **/ + YCPValue runPkgSelection( YWidget * packageSelector ); + + /** + * Issue an internal error: Open popup with that message and wait. + * + * Reimplemented from YUI. + **/ + void internalError( const char * msg ); + + + /** + * Block (or unblock) events. If events are blocked, any event sent + * should be ignored until events are unblocked again. + * + * Reimplemented from YUI. + **/ + virtual void blockEvents( bool block = true ) + { _event_handler.blockEvents( block ); } + + /** + * Returns 'true' if events are currently blocked. + * + * Reimplemented from YUI. + **/ + virtual bool eventsBlocked() const + { return _event_handler.eventsBlocked(); } + +protected: + + /** + * Idle around until fd_ycp is readable and handle repaints. + * This is only used when a separate ui thread is running. + * + * Reimplemented from YUI. + **/ + void idleLoop( int fd_ycp ); + + /** + * Return a representation for the glyph symbol specified in UTF-8 encoding + * or an empty string to get a default textual representation. + * + * Reimplemented from YUI. + **/ + YCPString glyph( const YCPSymbol & glyphSymbol ); + + /** + * Go into event loop until next user input is available. + * + * Reimplemented from YUI. + **/ + YEvent * userInput( unsigned long timeout_millisec = 0 ); + + /** + * Check the event queue for user input. Don't wait. + * + * Reimplemented from YUI. + **/ + YEvent * pollInput(); + + /** + * Create a dialog. + * + * Reimplemented from YUI. + **/ + YDialog * createDialog( YWidgetOpt & opt ); + + /** + * Show and activate a dialog. + * + * Reimplemented from YUI. + **/ + void showDialog( YDialog * dialog ); + + /** + * Decativate and close a dialog. This does not delete the dialog yet. + * + * Reimplemented from YUI. + **/ + void closeDialog( YDialog * dialog ); + + /*** Widget creation methods for optional widgets, all reimplemented from YUI ***/ + + bool hasBarGraph(); + YWidget * createBarGraph ( YWidget * parent, YWidgetOpt & opt); + + + bool hasDownloadProgress(); + YWidget * createDownloadProgress ( YWidget * parent, + YWidgetOpt & opt, + const YCPString & label, + const YCPString & filename, + int expectedSize ); + + bool hasDumbTab(); + YWidget * createDumbTab ( YWidget * parent, + YWidgetOpt & opt ); + + bool hasSlider(); + YWidget * createSlider ( YWidget * parent, + YWidgetOpt & opt, + const YCPString & label, + int minValue, + int maxValue, + int initialValue ); + + bool hasPartitionSplitter(); + YWidget * createPartitionSplitter( YWidget * parent, + YWidgetOpt & opt, + int usedSize, + int totalFreeSize, + int newPartSize, + int minNewPartSize, + int minFreeSize, + const YCPString & usedLabel, + const YCPString & freeLabel, + const YCPString & newPartLabel, + const YCPString & freeFieldLabel, + const YCPString & newPartFieldLabel ); + + + /*** END widget creation methods ***/ + + +public: + + /** + * + * Open a directory selection box and prompt the user for an existing directory. + * [Reimplemented from YUI] + * + * 'startDir' is the initial directory that is displayed. + * + * 'headline' is an explanatory text for the directory selection box. + * Graphical UIs may omit that if no window manager is running. + * + * Returns the selected directory name + * or 'nil' (YCPVoid() ) if the user canceled the operation. + **/ + YCPValue askForExistingDirectory ( const YCPString & startDir, + const YCPString & headline ); + + /** + * Open a file selection box and prompt the user for an existing file. + * [Reimplemented from YUI] + * + * 'startWith' is the initial directory or file. + * + * 'filter' is one or more blank-separated file patterns, e.g. "*.png *.jpg" + * + * 'headline' is an explanatory text for the file selection box. + * Graphical UIs may omit that if no window manager is running. + * + * Returns the selected file name + * or 'nil' (YCPVoid() ) if the user canceled the operation. + **/ + YCPValue askForExistingFile ( const YCPString & startWith, + const YCPString & filter, + const YCPString & headline ); + + /** + * Open a file selection box and prompt the user for a file to save data to. + * Automatically asks for confirmation if the user selects an existing file. + * [Reimplemented from YUI] + * + * 'startWith' is the initial directory or file. + * + * 'filter' is one or more blank-separated file patterns, e.g. "*.png *.jpg" + * + * 'headline' is an explanatory text for the file selection box. + * Graphical UIs may omit that if no window manager is running. + * + * Returns the selected file name + * or 'nil' (YCPVoid() ) if the user canceled the operation. + **/ + YCPValue askForSaveFileName ( const YCPString & startWith, + const YCPString & filter, + const YCPString & headline ); + + /** + * Lower-level version that works with QStrings and does not change + * the mouse cursor. + **/ + string askForSaveFileName( const string & startWith, + const string & filter, + const string & headline ); + +protected: + + /** + * Display capabilities. + * [Reimplemented from YUI] + * See UI builtin GetDisplayInfo() doc for details. + **/ + bool textMode() { return false; } + bool hasImageSupport() { return true; } + bool hasLocalImageSupport() { return false; } + bool hasAnimationSupport() { return true; } + bool hasIconSupport() { return false; } // not yet + bool hasFullUtf8Support() { return true; } + bool richTextSupportsTable() { return true; } + + + /** + * Sets @ref #leave_idle_loop to true. + **/ + void leaveIdleLoop( int ); + + +protected: + + /** + * Handle command line args + **/ + void processCommandLineArgs( int argc, char **argv ); + + /** + * Calculate size of `opt(`defaultsize) dialogs + **/ + void calcDefaultSize(); + + + // + // Data members + // + + /** + * Stack to keep track of the stacking order of popup dialogs. + **/ + // FIXME: vector _popup_stack; + + /** + * Numeric ID for defaultsize dialogs for the widget stack + **/ + int _main_dialog_id; + + /** + * A flag used during the idle loop. If it is set to true, + * the idle loop is left. This happens, if the ycp-ui-communication + * pipe to the ui gets readable. + **/ + bool _leave_idle_loop; + + /** + * This flag is set during @ref #userInput in order to tell + * @ref #returnNow to call exit_loop, which only may be called + * after enter_loop. + **/ + bool _do_exit_loop; + + + /** + * Global reference to the UI + **/ + static YWebUI * _ui; + + /** + * Indicate a fatal error that requires the UI to terminate + **/ + bool _fatal_error; + + /** + * The handler for the single pending event this UI keeps track of + **/ + YSimpleEventHandler _event_handler; + +public: + static int _argc; + static char** _argv; +}; + + +#endif // YWebUI_h diff --git a/src/YWebUIComponent.h b/src/YWebUIComponent.h new file mode 100644 index 0000000..87afaf8 --- /dev/null +++ b/src/YWebUIComponent.h @@ -0,0 +1,79 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YQUIComponent.h + + Author: Stefan Hundhammer + Stanislav Visnovsky + +/-*/ + +#ifndef YWebUIComponent_h +#define YWebUIComponent_h + +#include + +#define y2log_component "web-ui" +#include + +#include "YWebUI.h" + +extern void *start_webserver_thread( void * yui ); + +class YWebUIComponent : public YUIComponent +{ +public: + + YWebUIComponent(): YUIComponent() {} + + /** + * Create a Web UI. This is called from within setServerOptions(). + * + * Reimplemented from YUIComponent. + **/ + virtual YUI * createUI( int argc, char **argv, bool with_threads, const char * macro_file ) + { + // save the arguments for the UI thread (http server args etc) + YWebUI::_argc = argc; + YWebUI::_argv = argv; + + pthread_t webserver_thread; + pthread_attr_t attr; + pthread_attr_init( & attr ); + + if( pthread_create( & webserver_thread, & attr, start_webserver_thread, 0 ) > 0 ) + { + y2internal ("Could not create Web server thread, aborting"); + abort(); + } + + y2milestone( "Server thread running"); + + // wait until the UI thread is ready + while (! YWebUI::ui() ) + { + sleep( 1 ); + } + return YWebUI::ui(); + } + + /** + * Returns the name of this YaST2 component. + * + * Reimplemented from YUIComponent. + **/ + virtual string name() const { return "web"; } + +}; + + +#endif // YWebUIComponent_h diff --git a/src/YWebUI_builtins.cc b/src/YWebUI_builtins.cc new file mode 100644 index 0000000..c771530 --- /dev/null +++ b/src/YWebUI_builtins.cc @@ -0,0 +1,166 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YWebUI_builtins.cc + + Author: Stefan Hundhammer + Stanislav Visnovsky + +/-*/ + +#include +#include + +#include +#define y2log_component "web-ui" +#include + +#include "YWebUI.h" +#include "YEvent.h" +#include "YUISymbols.h" + +YCPString +YWebUI::glyph( const YCPSymbol & glyphSymbol ) +{ + string sym = glyphSymbol->symbol(); + + return YCPString( sym ); + + // FIXME: +#if 0 + QChar unicodeChar; + + // Hint: Use 'xfd' to view characters available in the Unicode font. + + if ( sym == YUIGlyph_ArrowLeft ) unicodeChar = QChar( 0x2190 ); + else if ( sym == YUIGlyph_ArrowRight ) unicodeChar = QChar( 0x2192 ); + else if ( sym == YUIGlyph_ArrowUp ) unicodeChar = QChar( 0x2191 ); + else if ( sym == YUIGlyph_ArrowDown ) unicodeChar = QChar( 0x2193 ); + else if ( sym == YUIGlyph_CheckMark ) unicodeChar = QChar( 0x2714 ); + else if ( sym == YUIGlyph_BulletArrowRight ) unicodeChar = QChar( 0x279c ); + else if ( sym == YUIGlyph_BulletCircle ) unicodeChar = QChar( 0x274d ); + else if ( sym == YUIGlyph_BulletSquare ) unicodeChar = QChar( 0x274f ); + else return YCPString( "" ); + + QString qstr( unicodeChar ); + + return YCPString( toUTF8( qstr ) ); +#endif +} + + +YCPValue YWebUI::runPkgSelection( YWidget * packageSelector ) +{ + + y2milestone( "Running package selection..." ); + return YCPVoid(); +#if 0 + _wm_close_blocked = true; + _auto_activate_dialogs = false; + + YCPValue input = YCPVoid(); + + try + { + input = evaluateUserInput(); + } + catch (const std::exception & e) + { + y2error( "Caught std::exception: %s", e.what() ); + y2error( "This is a libzypp problem. Do not file a bug against the UI!" ); + } + catch (...) + { + y2error( "Caught unspecified exception." ); + y2error( "This is a libzypp problem. Do not file a bug against the UI!" ); + } + + _auto_activate_dialogs = true; + _wm_close_blocked = false; + y2milestone( "Package selection done - returning %s", input->toString().c_str() ); + + return input; +#endif +} + + +YCPValue YWebUI::askForExistingDirectory( const YCPString & startDir, + const YCPString & headline ) +{ + return YCPVoid(); + +#if 0 + normalCursor(); + + QString dir_name = + QFileDialog::getExistingDirectory( fromUTF8( startDir->value() ), + _main_win, // parent + "dir_selector", // name + fromUTF8( headline->value() ) ); // caption + busyCursor(); + + if ( dir_name.isEmpty() ) // this includes dir_name.isNull() + return YCPVoid(); // nothing selected -> return 'nil' + + return YCPString( toUTF8( dir_name ) ); +#endif +} + + +YCPValue YWebUI::askForExistingFile( const YCPString & startWith, + const YCPString & filter, + const YCPString & headline ) +{ + return YCPVoid (); +#if 0 + normalCursor(); + + QString file_name = + QFileDialog::getOpenFileName( fromUTF8( startWith->value() ), + fromUTF8( filter->value() ), + _main_win, // parent + "file_selector", // name + fromUTF8( headline->value() ) ); // caption + busyCursor(); + + if ( file_name.isEmpty() ) // this includes file_name.isNull() + return YCPVoid(); // nothing selected -> return 'nil' + + return YCPString( toUTF8( file_name ) ); +#endif +} + + +YCPValue YWebUI::askForSaveFileName( const YCPString & startWith, + const YCPString & filter, + const YCPString & headline ) +{ + return YCPVoid(); +#if 0 + normalCursor(); + + QString file_name = askForSaveFileName( fromUTF8( startWith->value() ), + fromUTF8( filter->value() ), + fromUTF8( headline->value() ) ); + busyCursor(); + + if ( file_name.isEmpty() ) // this includes file_name.isNull() + return YCPVoid(); // nothing selected -> return 'nil' + + return YCPString( toUTF8( file_name ) ); +#endif +} + + + + +// EOF diff --git a/src/YWebUI_core.cc b/src/YWebUI_core.cc new file mode 100644 index 0000000..8ed20a1 --- /dev/null +++ b/src/YWebUI_core.cc @@ -0,0 +1,290 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YWebUI_core.cc + + Author: Stefan Hundhammer + Stanislav Visnovsky + +/-*/ + +#include // MAXHOSTNAMELEN +#include + +#include +#include + +#define y2log_component "web-ui" +#include + +#include +#include + +#include "YWebUI.h" +#include "YWebWidgetFactory.h" +#include "YWebOptionalWidgetFactory.h" +#include "YEvent.h" +#include "YUISymbols.h" + +using namespace Wt; + +YWebUI * YWebUI::_ui = 0; +int YWebUI::_argc = 0; +char ** YWebUI::_argv = 0L; + +YWebUI::YWebUI( const Wt::WEnvironment& env, const char * macro_file ) + : WApplication(env), + YUI( true /* with_threads */ ) + , _main_dialog_id(0) + , _do_exit_loop( false ) +{ + _ui = this; + _fatal_error = false; + +// processCommandLineArgs( argc, argv ); + + topmostConstructorHasFinished(); +} + + +void YWebUI::processCommandLineArgs( int argc, char **argv ) +{ + if ( argv ) + { + for( int i=0; i < argc; i++ ) + { + string opt = argv[i]; + + y2milestone ("Web argument: %s", argv[i]); + + } + } +} + + + +YWebUI::~YWebUI() +{ + y2debug("Closing down Web UI."); +} + + + +YWidgetFactory * +YWebUI::createWidgetFactory() +{ + YWebWidgetFactory * factory = new YWebWidgetFactory(); + YUI_CHECK_NEW( factory ); + + return factory; +} + + + +YOptionalWidgetFactory * +YWebUI::createOptionalWidgetFactory() +{ + YWebOptionalWidgetFactory * factory = new YWebOptionalWidgetFactory(); + YUI_CHECK_NEW( factory ); + + return factory; +} + + +YApplication * +YWebUI::createApplication() +{ +// YApplication * app = new YApplication(); +// YUI_CHECK_NEW( app ); +// FIXME + return 0L; +} + + + +void YWebUI::internalError( const char * msg ) +{ + raiseFatalError(); + abort(); +} + + +void YWebUI::idleLoop( int fd_ycp ) +{ + // FIXME + _leave_idle_loop = true; +} + + +void YWebUI::leaveIdleLoop( int ) +{ + // FIXME + _leave_idle_loop = true; +} + + +void YWebUI::sendEvent( YEvent * event ) +{ + if ( event ) + { + _event_handler.sendEvent( event ); + + if ( _do_exit_loop ) { + // FIXME: + } + } +} + + +YEvent * YWebUI::userInput( unsigned long timeout_millisec ) +{ + YEvent * event = 0; +#if 0 + YQDialog * dialog = dynamic_cast ( YDialog::currentDialog( false ) ); + + if ( _user_input_timer.isActive() ) + _user_input_timer.stop(); + + if ( dialog ) + { + if ( timeout_millisec > 0 ) + _user_input_timer.start( timeout_millisec, true ); // single shot + + dialog->activate( true ); + + if ( qApp->focusWidget() ) + qApp->focusWidget()->setFocus(); + + normalCursor(); + _do_exit_loop = true; // should exit_loop() be called in sendEvent()? + + while ( ! pendingEvent() ) + { + qApp->enter_loop(); + } + + _do_exit_loop = false; + event = _event_handler.consumePendingEvent(); + dialog->activate( false ); + + // Display a busy cursor, but only if there is no other activity within + // BUSY_CURSOR_TIMEOUT milliseconds (avoid cursor flicker) + + _busy_cursor_timer.start( BUSY_CURSOR_TIMEOUT, true ); // single shot + } + + if ( _user_input_timer.isActive() ) + _user_input_timer.stop(); + +#endif + return event; +} + + +YEvent * YWebUI::pollInput() +{ + YEvent * event = 0; + +#if 0 + if ( _user_input_timer.isActive() ) + _user_input_timer.stop(); + + if ( ! pendingEvent() ) + { + YQDialog * dialog = dynamic_cast ( YDialog::currentDialog( false ) ); + + if ( dialog ) + { + dialog->activate( true ); + qApp->processEvents(); + event = _event_handler.consumePendingEvent(); + dialog->activate( false ); + } + } + + if ( pendingEvent() ) + event = _event_handler.consumePendingEvent(); +#endif + return event; +} + + +YDialog * YWebUI::createDialog( YWidgetOpt & opt ) +{ + // FIXME + return 0L; +} + + +void YWebUI::showDialog( YDialog * dialog ) +{ + // FIXME + // event loop in Qt is here +} + + +void YWebUI::closeDialog( YDialog * dialog ) +{ + // FIXME +} + + +WApplication *createApplication(const WEnvironment& env) +{ + // Instantiate the Wt application. + YWebUI *appl = new YWebUI( env, 0 ); + + // Set window title + + std::string title( "YaST2" ); + char hostname[ MAXHOSTNAMELEN+1 ]; + + if ( gethostname( hostname, sizeof( hostname )-1 ) == 0 ) + { + hostname[ sizeof( hostname ) -1 ] = '\0'; // make sure it's terminated + + if ( strlen( hostname ) > 0 ) + { + if ( ( strcmp( hostname, "(none)" ) != 0 && + strcmp( hostname, "linux" ) != 0 ) + ) + { + title += "@"; + title += hostname; + } + } + } + + y2milestone( "Created WApplication (%p)", appl ); + + // Set application title + appl->setTitle(title); + +#if 0 + // Set up a timer for handling YaST requests + appl->createTimer(); + + _wtimer_work = true; +#endif + + return appl; +} + +void *start_webserver_thread( void * yui ) +{ + // FIXME: do the work + YWebUI* ui = (YWebUI*)yui; + + WRun(ui->_argc, ui->_argv, &createApplication); + + return 0; +} diff --git a/src/YWebUI_widgets.cc b/src/YWebUI_widgets.cc new file mode 100644 index 0000000..aacf1ea --- /dev/null +++ b/src/YWebUI_widgets.cc @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YWebUI_widgets.cc + + Author: Stefan Hundhammer + Stanislav Visnovsky + +/-*/ + +#define y2log_component "web-ui" +#include + +#include "YWebUI.h" + + +//========= Optional widgets ======================================================== + + +bool YWebUI::hasBarGraph() +{ + return false; +} + +YWidget * YWebUI::createBarGraph( YWidget * parent, YWidgetOpt & opt) +{ + return 0L; //new YQBarGraph( (QWidget *) ( parent->widgetRep() ), opt ); +} + + +bool YWebUI::hasDownloadProgress() +{ + return false; +} + +YWidget * YWebUI::createDownloadProgress ( YWidget * parent, + YWidgetOpt & opt, + const YCPString & label, + const YCPString & filename, + int expectedSize) +{ + return 0L; //new YQDownloadProgress( (QWidget *) ( parent->widgetRep() ), + // opt, + // label, + // filename, + // expectedSize ); +} + + +bool YWebUI::hasDumbTab() +{ + return false; +} + +YWidget * YWebUI::createDumbTab ( YWidget * parent, + YWidgetOpt & opt ) +{ + return 0L; //new YQDumbTab( (QWidget *) ( parent->widgetRep() ), opt ); +} + + +bool YWebUI::hasSlider() +{ + return false; +} + + +YWidget * YWebUI::createSlider( YWidget * parent, + YWidgetOpt & opt, + const YCPString & label, + int minValue, + int maxValue, + int initialValue ) +{ + return 0L; // new YQSlider( (QWidget *) ( parent->widgetRep() ), + // opt, + // label, + // minValue, + // maxValue, + // initialValue ); +} + + +bool YWebUI::hasPartitionSplitter() +{ + return false; +} + +YWidget * YWebUI::createPartitionSplitter( YWidget * parent, + YWidgetOpt & opt, + int usedSize, + int totalFreeSize, + int newPartSize, + int minNewPartSize, + int minFreeSize, + const YCPString & usedLabel, + const YCPString & freeLabel, + const YCPString & newPartLabel, + const YCPString & freeFieldLabel, + const YCPString & newPartFieldLabel ) +{ + return 0L; //new YQPartitionSplitter( (QWidget *) ( parent->widgetRep() ), + // opt, + // usedSize, + // totalFreeSize, + // newPartSize, + // minNewPartSize, + // minFreeSize, + // usedLabel, + // freeLabel, + // newPartLabel, + // freeFieldLabel, + // newPartFieldLabel ); +} + + + +// EOF diff --git a/src/YWebWidgetFactory.cc b/src/YWebWidgetFactory.cc new file mode 100644 index 0000000..1372ef4 --- /dev/null +++ b/src/YWebWidgetFactory.cc @@ -0,0 +1,150 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YWebWidgetFactory.cc + + Author: Stanislav Visnovsky + +/-*/ + +#include "YWebWidgetFactory.h" + +#include + +#include "YTypes.h" + +using std::string; + +class YWidget; +class YAlignment; +class YCheckBox; +class YCheckBoxFrame; +class YComboBox; +class YDialog; +class YEmpty; +class YFrame; +class YImage; +class YInputField; +class YIntField; +class YLabel; +class YLayoutBox; +class YLogView; +class YMenuButton; +class YMultiLineEdit; +class YMultiSelectionBox; +class YPackageSelector; +class YProgressBar; +class YPushButton; +class YRadioButton; +class YRadioButtonGroup; +class YReplacePoint; +class YRichText; +class YSelectionBox; +class YSpacing; +class YSquash; +class YTable; +class YTableHeader; +class YTimeField; +class YTree; + + + +/** + * Abstract widget factory for mandatory widgets. + * Use YOptionalWidgetFactory for optional ("special") widgets. + * + * Refer to the respective widget's documentation (in the header file) for + * documentation about the function parameters. + **/ + + // + // Dialogs + // + + YDialog * YWebWidgetFactory::createMainDialog() {} + YDialog * YWebWidgetFactory::createPopupDialog() {} + + // + // Layout Boxes + // + + YLayoutBox * YWebWidgetFactory::createVBox ( YWidget * parent ){} + YLayoutBox * YWebWidgetFactory::createHBox ( YWidget * parent ){} + YLayoutBox * YWebWidgetFactory::createLayoutBox ( YWidget * parent, YUIDimension dimension ) {} + YAlignment * YWebWidgetFactory::createAlignment ( YWidget * parent, YAlignmentType horAlignment, YAlignmentType vertAlignment ) {} + // + // Common Leaf Widgets + // + + YPushButton * YWebWidgetFactory::createPushButton ( YWidget * parent, const string & label ) {} + YLabel * YWebWidgetFactory::createLabel ( YWidget * parent, const string & text, bool isHeading, bool isOutputField ) {} + YInputField * YWebWidgetFactory::createInputField ( YWidget * parent, const string & label, bool passwordMode ) {} + YCheckBox * YWebWidgetFactory::createCheckBox ( YWidget * parent, const string & label, bool isChecked ) {} + YRadioButton * YWebWidgetFactory::createRadioButton ( YWidget * parent, const string & label, bool isChecked ) {} + YComboBox * YWebWidgetFactory::createComboBox ( YWidget * parent, const string & label, bool editable ) {} + YSelectionBox * YWebWidgetFactory::createSelectionBox ( YWidget * parent, const string & label ) {} + YTree * YWebWidgetFactory::createTree ( YWidget * parent, const string & label ) {} + YTable * YWebWidgetFactory::createTable ( YWidget * parent, YTableHeader * header ) {} + YProgressBar * YWebWidgetFactory::createProgressBar ( YWidget * parent, const string & label, int maxValue ) {} + YRichText * YWebWidgetFactory::createRichText ( YWidget * parent, const string & text, bool plainTextMode ) {} + + // + // Less Common Leaf Widgets + // + + YIntField * YWebWidgetFactory::createIntField ( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal ) {} + + YMenuButton * YWebWidgetFactory::createMenuButton ( YWidget * parent, const string & label ) {} + YMultiLineEdit * YWebWidgetFactory::createMultiLineEdit ( YWidget * parent, const string & label ) {} + YImage * YWebWidgetFactory::createImage ( YWidget * parent, const string & imageFileName, bool animated ) {} + YLogView * YWebWidgetFactory::createLogView ( YWidget * parent, const string & label, int visibleLines, int storedLines ) {} + YMultiSelectionBox *YWebWidgetFactory::createMultiSelectionBox ( YWidget * parent, const string & label ) {} + + YPackageSelector * YWebWidgetFactory::createPackageSelector( YWidget * parent, long ModeFlags ) {} + YWidget * YWebWidgetFactory::createPkgSpecial ( YWidget * parent, const string & subwidgetName ) {} // NCurses only + + // + // Layout Helpers + // + + YSpacing * YWebWidgetFactory::createSpacing ( YWidget * parent, YUIDimension dim, bool stretchable, YLayoutSize_t size ) {} + YEmpty * YWebWidgetFactory::createEmpty ( YWidget * parent ) {} + + YSquash * YWebWidgetFactory::createSquash ( YWidget * parent, bool horSquash, bool vertSquash ) {} + + // + // Visual Grouping + // + + YFrame * YWebWidgetFactory::createFrame ( YWidget * parent, const string & label ) {} + YCheckBoxFrame * YWebWidgetFactory::createCheckBoxFrame ( YWidget * parent, const string & label, bool checked ) {} + + // + // Logical Grouping + // + + YRadioButtonGroup * YWebWidgetFactory::createRadioButtonGroup ( YWidget * parent ) {} + YReplacePoint * YWebWidgetFactory::createReplacePoint ( YWidget * parent ) {} + + + /** + * Constructor. + * + * Use YUI::widgetFactory() to get the singleton for this class. + **/ + YWebWidgetFactory::YWebWidgetFactory(){} + + /** + * Destructory. + **/ + YWebWidgetFactory::~YWebWidgetFactory(){} + diff --git a/src/YWebWidgetFactory.h b/src/YWebWidgetFactory.h new file mode 100644 index 0000000..70bd18a --- /dev/null +++ b/src/YWebWidgetFactory.h @@ -0,0 +1,170 @@ +/*---------------------------------------------------------------------\ +| | +| __ __ ____ _____ ____ | +| \ \ / /_ _/ ___|_ _|___ \ | +| \ V / _` \___ \ | | __) | | +| | | (_| |___) || | / __/ | +| |_|\__,_|____/ |_| |_____| | +| | +| core system | +| (C) SuSE GmbH | +\----------------------------------------------------------------------/ + + File: YWebWidgetFactory.h + + Author: Stefan Hundhammer + Stanislav Visnovsky + +/-*/ + +#ifndef YWebWidgetFactory_h +#define YWebWidgetFactory_h + +#include + +#include + +#include "YTypes.h" + +using std::string; + +class YWidget; +class YAlignment; +class YCheckBox; +class YCheckBoxFrame; +class YComboBox; +class YDialog; +class YEmpty; +class YFrame; +class YImage; +class YInputField; +class YIntField; +class YLabel; +class YLayoutBox; +class YLogView; +class YMenuButton; +class YMultiLineEdit; +class YMultiSelectionBox; +class YPackageSelector; +class YProgressBar; +class YPushButton; +class YRadioButton; +class YRadioButtonGroup; +class YReplacePoint; +class YRichText; +class YSelectionBox; +class YSpacing; +class YSquash; +class YTable; +class YTableHeader; +class YTimeField; +class YTree; + + + +/** + * Abstract widget factory for mandatory widgets. + * Use YOptionalWidgetFactory for optional ("special") widgets. + * + * Refer to the respective widget's documentation (in the header file) for + * documentation about the function parameters. + **/ +class YWebWidgetFactory: public YWidgetFactory +{ +public: + + // + // Dialogs + // + + virtual YDialog * createMainDialog() ; + virtual YDialog * createPopupDialog() ; + + // + // Layout Boxes + // + + YLayoutBox * createVBox ( YWidget * parent ); + YLayoutBox * createHBox ( YWidget * parent ); + virtual YLayoutBox * createLayoutBox ( YWidget * parent, YUIDimension dimension ) ; + + virtual YAlignment * createAlignment ( YWidget * parent, YAlignmentType horAlignment, YAlignmentType vertAlignment ) ; + // + // Common Leaf Widgets + // + + virtual YPushButton * createPushButton ( YWidget * parent, const string & label ) ; + virtual YLabel * createLabel ( YWidget * parent, const string & text, bool isHeading = false, bool isOutputField = false ) ; + virtual YInputField * createInputField ( YWidget * parent, const string & label, bool passwordMode = false ) ; + virtual YCheckBox * createCheckBox ( YWidget * parent, const string & label, bool isChecked = false ) ; + virtual YRadioButton * createRadioButton ( YWidget * parent, const string & label, bool isChecked = false ) ; + virtual YComboBox * createComboBox ( YWidget * parent, const string & label, bool editable = false ) ; + virtual YSelectionBox * createSelectionBox ( YWidget * parent, const string & label ) ; + virtual YTree * createTree ( YWidget * parent, const string & label ) ; + virtual YTable * createTable ( YWidget * parent, YTableHeader * header ) ; + virtual YProgressBar * createProgressBar ( YWidget * parent, const string & label, int maxValue = 100 ) ; + virtual YRichText * createRichText ( YWidget * parent, const string & text, bool plainTextMode = false ) ; + + // + // Less Common Leaf Widgets + // + + virtual YIntField * createIntField ( YWidget * parent, const string & label, int minVal, int maxVal, int initialVal ) ; + + virtual YMenuButton * createMenuButton ( YWidget * parent, const string & label ) ; + virtual YMultiLineEdit * createMultiLineEdit ( YWidget * parent, const string & label ) ; + virtual YImage * createImage ( YWidget * parent, const string & imageFileName, bool animated = false ) ; + virtual YLogView * createLogView ( YWidget * parent, const string & label, int visibleLines, int storedLines = 0 ) ; + virtual YMultiSelectionBox *createMultiSelectionBox ( YWidget * parent, const string & label ) ; + + virtual YPackageSelector * createPackageSelector ( YWidget * parent, long ModeFlags = 0 ) ; + virtual YWidget * createPkgSpecial ( YWidget * parent, const string & subwidgetName ) ; // NCurses only + + // + // Layout Helpers + // + + YSpacing * createHStretch ( YWidget * parent ); + YSpacing * createVStretch ( YWidget * parent ); + YSpacing * createHSpacing ( YWidget * parent, YLayoutSize_t size = 1.0 ); + YSpacing * createVSpacing ( YWidget * parent, YLayoutSize_t size = 1.0 ); + virtual YSpacing * createSpacing ( YWidget * parent, YUIDimension dim, bool stretchable = false, YLayoutSize_t size = 0.0 ) ; + virtual YEmpty * createEmpty ( YWidget * parent ) ; + + virtual YSquash * createSquash ( YWidget * parent, bool horSquash, bool vertSquash ) ; + + // + // Visual Grouping + // + + virtual YFrame * createFrame ( YWidget * parent, const string & label ) ; + virtual YCheckBoxFrame * createCheckBoxFrame ( YWidget * parent, const string & label, bool checked ) ; + + // + // Logical Grouping + // + + virtual YRadioButtonGroup * createRadioButtonGroup ( YWidget * parent ) ; + virtual YReplacePoint * createReplacePoint ( YWidget * parent ) ; + + +protected: + + friend class YWebUI; + + /** + * Constructor. + * + * Use YUI::widgetFactory() to get the singleton for this class. + **/ + YWebWidgetFactory(); + + /** + * Destructory. + **/ + virtual ~YWebWidgetFactory(); + +}; // class YWebWidgetFactory + + +#endif // YWebWidgetFactory_h diff --git a/yast2-web.spec.in b/yast2-web.spec.in new file mode 100644 index 0000000..00f1f00 --- /dev/null +++ b/yast2-web.spec.in @@ -0,0 +1,52 @@ +@HEADER-COMMENT@ + + +@HEADER@ +BuildRequires: dbus-1-devel boost-devel libzypp-devel curl-devel docbook-xsl-stylesheets doxygen libdrm-devel libjpeg-devel libxcrypt-devel libxslt perl-XML-Writer qt3-devel rpm-devel sgml-skel update-desktop-files yast2-devtools yast2-core-devel hal-devel + +Summary: - +BuildRequires: yast2-core-devel >= 2.15.6 +Requires: libzypp >= 2.13.0 +Provides: yast2_ui +Provides: y2base:/var/lib/YaST2/servers/qt +Provides: y2base:/usr/lib/YaST2/servers/qt +Provides: y2base:/usr/lib/YaST2/plugin/libpy2qt.so.2 +Provides: yast2-ui-qt yast2-ui-qt-devel +Obsoletes: yast2-ui-qt yast2-ui-qt-devel +Provides: y2qt +Obsoletes: y2qt + +%description +- + +@PREP@ + +@BUILD-QT@ + +@INSTALL@ +rm -f $RPM_BUILD_ROOT/@plugindir@/libpy2qt.la +rm -f $RPM_BUILD_ROOT/@plugindir@/libpy2qt_pkg.la + + +@CLEAN@ + +%if 0%{?suse_version} <= 1010 +%define _xorg7fonts /usr/X11R6/lib/X11/fonts +%else +%define _xorg7fonts /usr/share/fonts +%endif + +%files +%defattr (-, root, root) +@plugindir@/libpy2qt.so.* +@plugindir@/libpy2qt.so +@plugindir@/libpy2qt_pkg.so.* +@plugindir@/libpy2qt_pkg.so +@imagedir@ +%dir %{_xorg7fonts}/uni +%verify(not md5 size mtime) %{_xorg7fonts}/uni/fonts.dir +%{_xorg7fonts}/uni/newunifont.pcf.gz +%{_xorg7fonts}/uni/unifont.pcf.gz +%dir @ydatadir@ +@ydatadir@/lang_fonts +%doc @docdir@ -- 2.39.2