27 #define USE_QT_CURSORS 1 28 #define FORCE_UNICODE_FONT 0 34 #include <QFileDialog> 36 #include <QMessageBox> 38 #include <QInputDialog> 43 #define YUILogComponent "qt-ui" 44 #include <yui/YUILog.h> 47 #include <yui/YEvent.h> 48 #include <yui/YMacro.h> 49 #include <yui/YUISymbols.h> 51 #include "YQSignalBlocker.h" 52 #include "YQApplication.h" 60 #define DEFAULT_MACRO_FILE_NAME "macro.ycp" 69 YUI_CHECK_PTR( packageSelector );
74 event = packageSelector->findDialog()->waitForEvent();
76 catch ( YUIException & uiEx )
80 catch ( std::exception & e)
82 yuiError() <<
"Caught std::exception: " << e.what() <<
"\n" 83 <<
"This is a libzypp problem. Do not file a bug against the UI!" 88 yuiError() <<
"Caught unspecified exception.\n" 89 <<
"This is a libzypp problem. Do not file a bug against the UI!" 103 QWidget * dialog = (QWidget *) YDialog::currentDialog()->widgetRep();
104 YUI_CHECK_PTR( dialog );
105 QWidget * topLevelWidget = dialog->window();
106 YUI_CHECK_PTR( topLevelWidget );
107 QWindow * window = topLevelWidget->windowHandle();
108 YUI_CHECK_PTR( window );
109 QPixmap screenShot = window->screen()->grabWindow( window->winId() );
110 XSync( QX11Info::display(),
false );
111 QString fileName ( stl_filename.c_str() );
112 bool interactive =
false;
114 if ( fileName.isEmpty() )
125 QString home = QDir::homePath();
126 char * ssdir = getenv(
"Y2SCREENSHOTS" );
127 QString dir = ssdir ? fromUTF8( ssdir ) :
"yast2-screen-shots";
140 if ( mkdir( toUTF8( dir ).c_str(), 0700 ) == -1 )
149 dir = home +
"/" + dir;
150 (void) mkdir( toUTF8( dir ).c_str(), 0750 );
158 const char * baseName =
"yast2";
160 int no = screenShotNo[ baseName ];
161 fileName = QString(
"%1/%2-%3.png" )
169 yuiDebug() <<
"Screenshot: " << fileName << endl;
173 _(
"Save screen shot to..." ) );
175 if ( fileName.isEmpty() )
177 yuiDebug() <<
"Save screen shot canceled by user" << endl;
181 screenShotNo.insert( baseName, ++no );
189 yuiDebug() <<
"Saving screen shot to " << fileName << endl;
190 bool success = screenShot.save( fileName,
"PNG" );
194 yuiError() <<
"Couldn't save screen shot " << fileName << endl;
199 YDialog * currentDialog = YDialog::currentDialog(
false );
202 parent = (QWidget *) currentDialog->widgetRep();
204 QMessageBox::warning( parent,
206 QString(
"Couldn't save screen shot\nto %1" ).arg( fileName ),
207 QMessageBox::Ok | QMessageBox::Default,
218 QString(
"*.tgz *.tar.gz" ),
219 QString(
"Save y2logs to..." ) );
222 YDialog * currentDialog = YDialog::currentDialog(
false );
225 parent = (QWidget *) currentDialog->widgetRep();
227 if ( ! fileName.isEmpty() )
229 QString saveLogsCommand =
"/usr/sbin/save_y2logs";
231 if ( access( saveLogsCommand.toLatin1(), X_OK ) == 0 )
233 saveLogsCommand +=
" '" + fileName +
"'";
234 yuiMilestone() <<
"Saving y2logs: " << saveLogsCommand << endl;
235 int result = system( qPrintable( saveLogsCommand ) );
239 yuiError() <<
"Error saving y2logs: \"" << saveLogsCommand
240 <<
"\" exited with " << result
243 QMessageBox::warning( parent,
245 QString(
"Couldn't save y2logs to %1 - " 246 "exit code %2" ).arg( fileName ).arg( result ),
247 QMessageBox::Ok | QMessageBox::Default,
248 QMessageBox::NoButton,
249 QMessageBox::NoButton );
253 yuiMilestone() <<
"y2logs saved to " << fileName << endl;
258 yuiError() <<
"Error saving y2logs: Command \"" 259 << saveLogsCommand <<
"\" not found" 262 QMessageBox::warning( parent,
264 QString(
"Couldn't save y2logs to %1:\n" 265 "Command %2 not found" ).arg( fileName ).arg( saveLogsCommand ),
266 QMessageBox::Ok | QMessageBox::Default,
267 QMessageBox::NoButton,
268 QMessageBox::NoButton );
276 bool okButtonPressed =
false;
278 items <<
"Debug logging off" 279 <<
"Debug logging on";
283 YDialog * currentDialog = YDialog::currentDialog(
false );
286 parent = (QWidget *) currentDialog->widgetRep();
288 QString result = QInputDialog::getItem( parent,
290 _(
"Configure YaST Logging:"),
292 YUILog::debugLoggingEnabled() ? 1 : 0,
294 if ( okButtonPressed )
296 YUILog::enableDebugLogging( result.endsWith(
"on" ) );
297 yuiMilestone() <<
"Changing logging: " << result << endl;
305 YDialog * currentDialog = YDialog::currentDialog(
false );
308 parent = (QWidget *) currentDialog->widgetRep();
311 if ( YMacro::recording() )
313 YMacro::endRecording();
316 QMessageBox::information( parent,
317 "YaST2 Macro Recorder",
318 "Macro recording done.",
319 QMessageBox::Ok | QMessageBox::Default,
320 QMessageBox::NoButton,
321 QMessageBox::NoButton );
328 QFileDialog::getSaveFileName( parent,
329 "Select Macro File to Record to",
330 DEFAULT_MACRO_FILE_NAME,
333 QFileDialog::DontUseNativeDialog
336 if ( ! filename.isEmpty() )
338 YMacro::record( toUTF8( filename ) );
349 YDialog * currentDialog = YDialog::currentDialog(
false );
352 parent = (QWidget *) currentDialog->widgetRep();
356 QFileDialog::getOpenFileName( parent,
357 "Select Macro File to Play",
358 DEFAULT_MACRO_FILE_NAME,
359 "*.ycp", 0, QFileDialog::DontUseNativeDialog );
362 if ( ! filename.isEmpty() )
364 YMacro::play( toUTF8( filename ) );
void askConfigureLogging()
Open dialog to configure logging.
void makeScreenShot(std::string filename)
Make a screen shot in .png format and save it to 'filename'.
void askSaveLogs()
Open file selection box and let the user save y2logs to that location.
virtual YEvent * runPkgSelection(YWidget *packageSelector)
UI-specific runPkgSeleciton method: Start the package selection.
void toggleRecordMacro()
Toggle macro recording (activated by Ctrl-Shift-Alt-M): Stop macro recording if it is in progress...
void sendEvent(YEvent *event)
Widget event handlers (slots) call this when an event occured that should be the answer to a UserInpu...
virtual std::string askForSaveFileName(const std::string &startWith, const std::string &filter, const std::string &headline)
Open a file selection box and prompt the user for a file to save data to.
void busyCursor()
Show mouse cursor indicating busy state.
void normalCursor()
Show normal mouse cursor not indicating busy status.
void askPlayMacro()
Open file selection box and ask for a macro file to play (activated by Ctrl-Shift-Alt-P) ...