1 /*---------------------------------------------------------------------\
3 | __ __ ____ _____ ____ |
4 | \ \ / /_ _/ ___|_ _|___ \ |
5 | \ V / _` \___ \ | | __) | |
6 | | | (_| |___) || | / __/ |
7 | |_|\__,_|____/ |_| |_____| |
11 \----------------------------------------------------------------------/
13 File: YWebUI_builtins.cc
15 Author: Stefan Hundhammer <sh@suse.de>
16 Stanislav Visnovsky <visnov@suse.de>
23 #include <ycp/YCPTerm.h>
24 #define y2log_component "web-ui"
25 #include <ycp/y2log.h>
29 #include "YUISymbols.h"
32 YWebUI::glyph( const YCPSymbol & glyphSymbol )
34 string sym = glyphSymbol->symbol();
36 return YCPString( sym );
42 // Hint: Use 'xfd' to view characters available in the Unicode font.
44 if ( sym == YUIGlyph_ArrowLeft ) unicodeChar = QChar( 0x2190 );
45 else if ( sym == YUIGlyph_ArrowRight ) unicodeChar = QChar( 0x2192 );
46 else if ( sym == YUIGlyph_ArrowUp ) unicodeChar = QChar( 0x2191 );
47 else if ( sym == YUIGlyph_ArrowDown ) unicodeChar = QChar( 0x2193 );
48 else if ( sym == YUIGlyph_CheckMark ) unicodeChar = QChar( 0x2714 );
49 else if ( sym == YUIGlyph_BulletArrowRight ) unicodeChar = QChar( 0x279c );
50 else if ( sym == YUIGlyph_BulletCircle ) unicodeChar = QChar( 0x274d );
51 else if ( sym == YUIGlyph_BulletSquare ) unicodeChar = QChar( 0x274f );
52 else return YCPString( "" );
54 QString qstr( unicodeChar );
56 return YCPString( toUTF8( qstr ) );
61 YCPValue YWebUI::runPkgSelection( YWidget * packageSelector )
64 y2milestone( "Running package selection..." );
67 _wm_close_blocked = true;
68 _auto_activate_dialogs = false;
70 YCPValue input = YCPVoid();
74 input = evaluateUserInput();
76 catch (const std::exception & e)
78 y2error( "Caught std::exception: %s", e.what() );
79 y2error( "This is a libzypp problem. Do not file a bug against the UI!" );
83 y2error( "Caught unspecified exception." );
84 y2error( "This is a libzypp problem. Do not file a bug against the UI!" );
87 _auto_activate_dialogs = true;
88 _wm_close_blocked = false;
89 y2milestone( "Package selection done - returning %s", input->toString().c_str() );
96 YCPValue YWebUI::askForExistingDirectory( const YCPString & startDir,
97 const YCPString & headline )
105 QFileDialog::getExistingDirectory( fromUTF8( startDir->value() ),
107 "dir_selector", // name
108 fromUTF8( headline->value() ) ); // caption
111 if ( dir_name.isEmpty() ) // this includes dir_name.isNull()
112 return YCPVoid(); // nothing selected -> return 'nil'
114 return YCPString( toUTF8( dir_name ) );
119 YCPValue YWebUI::askForExistingFile( const YCPString & startWith,
120 const YCPString & filter,
121 const YCPString & headline )
128 QFileDialog::getOpenFileName( fromUTF8( startWith->value() ),
129 fromUTF8( filter->value() ),
131 "file_selector", // name
132 fromUTF8( headline->value() ) ); // caption
135 if ( file_name.isEmpty() ) // this includes file_name.isNull()
136 return YCPVoid(); // nothing selected -> return 'nil'
138 return YCPString( toUTF8( file_name ) );
143 YCPValue YWebUI::askForSaveFileName( const YCPString & startWith,
144 const YCPString & filter,
145 const YCPString & headline )
151 QString file_name = askForSaveFileName( fromUTF8( startWith->value() ),
152 fromUTF8( filter->value() ),
153 fromUTF8( headline->value() ) );
156 if ( file_name.isEmpty() ) // this includes file_name.isNull()
157 return YCPVoid(); // nothing selected -> return 'nil'
159 return YCPString( toUTF8( file_name ) );