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" 68 YUI_CHECK_PTR( packageSelector );
73 event = packageSelector->findDialog()->waitForEvent();
75 catch ( YUIException & uiEx )
79 catch ( std::exception & e)
81 yuiError() <<
"Caught std::exception: " << e.what() <<
"\n" 82 <<
"This is a libzypp problem. Do not file a bug against the UI!" 87 yuiError() <<
"Caught unspecified exception.\n" 88 <<
"This is a libzypp problem. Do not file a bug against the UI!" 102 QWidget * dialog = (QWidget *) YDialog::currentDialog()->widgetRep();
103 YUI_CHECK_PTR( dialog );
104 QWidget * topLevelWidget = dialog->window();
105 YUI_CHECK_PTR( topLevelWidget );
106 QWindow * window = topLevelWidget->windowHandle();
107 YUI_CHECK_PTR( window );
108 QPixmap screenShot = window->screen()->grabWindow( window->winId() );
109 XSync( QX11Info::display(),
false );
110 QString fileName ( stl_filename.c_str() );
111 bool interactive =
false;
113 if ( fileName.isEmpty() )
124 QString home = QDir::homePath();
125 char * ssdir = getenv(
"Y2SCREENSHOTS" );
126 QString dir = ssdir ? fromUTF8( ssdir ) :
"yast2-screen-shots";
139 if ( mkdir( toUTF8( dir ).c_str(), 0700 ) == -1 )
148 dir = home +
"/" + dir;
149 (void) mkdir( toUTF8( dir ).c_str(), 0750 );
157 const char * baseName =
"yast2";
159 int no = screenShotNo[ baseName ];
160 fileName = QString(
"%1/%2-%3.png" )
168 yuiDebug() <<
"Screenshot: " << fileName << endl;
172 _(
"Save screen shot to..." ) );
174 if ( fileName.isEmpty() )
176 yuiDebug() <<
"Save screen shot canceled by user" << endl;
180 screenShotNo.insert( baseName, ++no );
188 yuiDebug() <<
"Saving screen shot to " << fileName << endl;
189 bool success = screenShot.save( fileName,
"PNG" );
193 yuiError() <<
"Couldn't save screen shot " << fileName << endl;
198 YDialog * currentDialog = YDialog::currentDialog(
false );
201 parent = (QWidget *) currentDialog->widgetRep();
203 QMessageBox::warning( parent,
205 QString(
"Couldn't save screen shot\nto %1" ).arg( fileName ),
206 QMessageBox::Ok | QMessageBox::Default,
217 QString(
"*.tgz *.tar.gz" ),
218 QString(
"Save y2logs to..." ) );
221 YDialog * currentDialog = YDialog::currentDialog(
false );
224 parent = (QWidget *) currentDialog->widgetRep();
226 if ( ! fileName.isEmpty() )
228 QString saveLogsCommand =
"/usr/sbin/save_y2logs";
230 if ( access( saveLogsCommand.toLatin1(), X_OK ) == 0 )
232 saveLogsCommand +=
" '" + fileName +
"'";
233 yuiMilestone() <<
"Saving y2logs: " << saveLogsCommand << endl;
234 int result = system( qPrintable( saveLogsCommand ) );
238 yuiError() <<
"Error saving y2logs: \"" << saveLogsCommand
239 <<
"\" exited with " << result
242 QMessageBox::warning( parent,
244 QString(
"Couldn't save y2logs to %1 - " 245 "exit code %2" ).arg( fileName ).arg( result ),
246 QMessageBox::Ok | QMessageBox::Default,
247 QMessageBox::NoButton,
248 QMessageBox::NoButton );
252 yuiMilestone() <<
"y2logs saved to " << fileName << endl;
257 yuiError() <<
"Error saving y2logs: Command \"" 258 << saveLogsCommand <<
"\" not found" 261 QMessageBox::warning( parent,
263 QString(
"Couldn't save y2logs to %1:\n" 264 "Command %2 not found" ).arg( fileName ).arg( saveLogsCommand ),
265 QMessageBox::Ok | QMessageBox::Default,
266 QMessageBox::NoButton,
267 QMessageBox::NoButton );
275 bool okButtonPressed =
false;
277 items <<
"Debug logging off" 278 <<
"Debug logging on";
282 YDialog * currentDialog = YDialog::currentDialog(
false );
285 parent = (QWidget *) currentDialog->widgetRep();
287 QString result = QInputDialog::getItem( parent,
289 _(
"Configure YaST Logging:"),
291 YUILog::debugLoggingEnabled() ? 1 : 0,
293 if ( okButtonPressed )
295 YUILog::enableDebugLogging( result.endsWith(
"on" ) );
296 yuiMilestone() <<
"Changing logging: " << result << endl;
304 YDialog * currentDialog = YDialog::currentDialog(
false );
307 parent = (QWidget *) currentDialog->widgetRep();
310 if ( YMacro::recording() )
312 YMacro::endRecording();
315 QMessageBox::information( parent,
316 "YaST2 Macro Recorder",
317 "Macro recording done.",
318 QMessageBox::Ok | QMessageBox::Default,
319 QMessageBox::NoButton,
320 QMessageBox::NoButton );
327 QFileDialog::getSaveFileName( parent,
328 "Select Macro File to Record to",
329 DEFAULT_MACRO_FILE_NAME,
332 QFileDialog::DontUseNativeDialog
335 if ( ! filename.isEmpty() )
337 YMacro::record( toUTF8( filename ) );
348 YDialog * currentDialog = YDialog::currentDialog(
false );
351 parent = (QWidget *) currentDialog->widgetRep();
355 QFileDialog::getOpenFileName( parent,
356 "Select Macro File to Play",
357 DEFAULT_MACRO_FILE_NAME,
358 "*.ycp", 0, QFileDialog::DontUseNativeDialog );
361 if ( ! filename.isEmpty() )
363 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) ...