From 787c9471cc05c14ac27a74950fc2c9e1098dcecd Mon Sep 17 00:00:00 2001 From: dmacvicar Date: Mon, 3 Dec 2007 15:59:28 +0000 Subject: [PATCH] YQUI_builtins git-svn-id: http://svn.opensuse.org/svn/yast/branches/tmp/coolo/qt4-port@42618 e0cc52ee-31ee-0310-8b87-e83c4596d67c --- src/YQUI_builtins.cc | 110 ++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 60 deletions(-) diff --git a/src/YQUI_builtins.cc b/src/YQUI_builtins.cc index e18cad8..9beb939 100644 --- a/src/YQUI_builtins.cc +++ b/src/YQUI_builtins.cc @@ -17,7 +17,6 @@ Textdomain "packages-qt" /-*/ -#define QT3_SUPPORT #define USE_QT_CURSORS 1 #define FORCE_UNICODE_FONT 0 @@ -25,12 +24,11 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #define y2log_component "qt-ui" @@ -117,7 +115,7 @@ void YQUI::makeScreenShot( std::string stl_filename ) QWidget * dialog = (QWidget *) YDialog::currentDialog()->widgetRep(); QPixmap screenShot = QPixmap::grabWindow( dialog->winId() ); - XSync( dialog->x11Display(), false ); + //FIXME XSync( dialog->x11Display(), false ); QString fileName ( stl_filename.c_str() ); bool interactive = false; @@ -134,7 +132,7 @@ void YQUI::makeScreenShot( std::string stl_filename ) // Initialize screen shot directory // - QString home = QDir::homeDirPath(); + QString home = QDir::homePath(); char * ssdir = getenv("Y2SCREENSHOTS"); QString dir = ssdir ? ssdir : "yast2-screen-shots"; @@ -149,7 +147,7 @@ void YQUI::makeScreenShot( std::string stl_filename ) dir = "/tmp/" + dir; - if ( mkdir( dir, 0700 ) == -1 ) + if ( mkdir( qPrintable(dir), 0700 ) == -1 ) dir = ""; } else @@ -159,7 +157,7 @@ void YQUI::makeScreenShot( std::string stl_filename ) // chance to create symlinks to a better location if he wishes so. dir = home + "/" + dir; - (void) mkdir( dir, 0750 ); + (void) mkdir( qPrintable(dir), 0750 ); } screenShotNameTemplate = dir + "/%s-%03d.png"; @@ -173,8 +171,8 @@ void YQUI::makeScreenShot( std::string stl_filename ) const char * baseName = moduleName(); if ( ! baseName ) baseName = "scr"; int no = screenShotNo[ baseName ]; - fileName.sprintf( screenShotNameTemplate, baseName, no ); - y2debug( "screenshot: %s", (const char *) fileName ); + fileName.sprintf( qPrintable(screenShotNameTemplate), baseName, no ); + y2debug( "screenshot: %s", qPrintable(fileName) ); { YQSignalBlocker sigBlocker( &_user_input_timer ); @@ -196,12 +194,12 @@ void YQUI::makeScreenShot( std::string stl_filename ) // Actually save the screen shot // - y2debug( "Saving screen shot to %s", (const char *) fileName ); + y2debug( "Saving screen shot to %s", qPrintable(fileName) ); bool success = screenShot.save( fileName, "PNG" ); if ( ! success ) { - y2error( "Couldn't save screen shot %s", (const char *) fileName ); + y2error( "Couldn't save screen shot %s", qPrintable(fileName) ); if ( interactive ) { @@ -218,7 +216,7 @@ void YQUI::makeScreenShot( std::string stl_filename ) { macroRecorder->beginBlock(); YDialog::currentDialog()->saveUserInput( macroRecorder ); - macroRecorder->recordMakeScreenShot( true, (const char *) fileName ); + macroRecorder->recordMakeScreenShot( true, qPrintable(fileName) ); macroRecorder->recordUserInput( YCPVoid() ); macroRecorder->endBlock(); } @@ -235,16 +233,16 @@ void YQUI::askSaveLogs() { QString saveLogsCommand = "/sbin/save_y2logs"; - if ( access( saveLogsCommand.ascii(), X_OK ) == 0 ) + if ( access( saveLogsCommand.toAscii(), X_OK ) == 0 ) { saveLogsCommand += " '" + fileName + "'"; - y2milestone( "Saving y2logs: %s", saveLogsCommand.ascii() ); - int result = system( saveLogsCommand.ascii() ); + y2milestone( "Saving y2logs: %s", qPrintable(saveLogsCommand) ); + int result = system( qPrintable(saveLogsCommand) ); if ( result != 0 ) { y2error( "Error saving y2logs: \"%s\" exited with %d", - (const char *) saveLogsCommand, result ); + qPrintable(saveLogsCommand), result ); QMessageBox::warning( 0, // parent "Error", // caption QString( "Couldn't save y2logs to %1 - " @@ -255,13 +253,13 @@ void YQUI::askSaveLogs() } else { - y2milestone( "y2logs saved to %s", (const char *) fileName ); + y2milestone( "y2logs saved to %s", qPrintable(fileName) ); } } else { y2error( "Error saving y2logs: Command %s not found", - saveLogsCommand.ascii() ); + qPrintable(saveLogsCommand) ); QMessageBox::warning( 0, // parent "Error", // caption @@ -282,18 +280,14 @@ void YQUI::askConfigureLogging() items << "Debug logging off" << "Debug logging on"; - QString result = QInputDialog::getItem( "YaST2 Logging", // caption - "Configure YaST2 Logging:", // label - items, - get_log_debug() ? 1 : 0, - false, // editable - &okButtonPressed, - _main_win ); // parent - + QString result = QInputDialog::getItem( _main_win, + tr("YaST2 Logging"), + tr("Configure YaST2 Logging:"), + items, 0, get_log_debug() ? 1 : 0, &okButtonPressed); if ( okButtonPressed ) { set_log_debug( result.endsWith( "on" ) ); - y2milestone( "Changing logging: %s - %s", (const char *) result, + y2milestone( "Changing logging: %s - %s", qPrintable(result), get_log_debug() ? "y2debug on" : "y2debug off" ); } } @@ -318,15 +312,15 @@ void YQUI::toggleRecordMacro() normalCursor(); QString filename = - Q3FileDialog::getSaveFileName( DEFAULT_MACRO_FILE_NAME, // startWith - "*.ycp", // filter - 0, // parent - 0, // (widget) name - "Select Macro File to Record to" ); // caption + QFileDialog::getSaveFileName( 0, + "Select Macro File to Record to", + DEFAULT_MACRO_FILE_NAME, // startWith + "*.ycp" // filter + ); if ( ! filename.isEmpty() ) // file selection dialog has been cancelled { - recordMacro( (const char *) filename ); + recordMacro( qPrintable(filename) ); } } } @@ -337,16 +331,15 @@ void YQUI::askPlayMacro() normalCursor(); QString filename = - Q3FileDialog::getOpenFileName( DEFAULT_MACRO_FILE_NAME, // startWith - "*.ycp", // filter - 0, // parent - 0, // (widget) name - "Select Macro File to Play" ); // caption + QFileDialog::getOpenFileName( 0, + "Select Macro File to Play", + DEFAULT_MACRO_FILE_NAME, // startWith + "*.ycp" ); busyCursor(); if ( ! filename.isEmpty() ) // file selection dialog has been cancelled { - playMacro( (const char *) filename ); + playMacro( qPrintable(filename) ); // Do special magic to get out of any UserInput() loop right now // without doing any harm - otherwise this would hang until the next @@ -356,7 +349,7 @@ void YQUI::askPlayMacro() if ( _do_exit_loop ) { - qApp->exit_loop(); + _eventLoop->exit(); } } } @@ -369,10 +362,9 @@ YCPValue YQUI::askForExistingDirectory( const YCPString & startDir, normalCursor(); QString dir_name = - Q3FileDialog::getExistingDirectory( fromUTF8( startDir->value() ), - _main_win, // parent - "dir_selector", // name - fromUTF8( headline->value() ) ); // caption + QFileDialog::getExistingDirectory( _main_win, + fromUTF8( headline->value() ), + fromUTF8( startDir->value() ) ); busyCursor(); if ( dir_name.isEmpty() ) // this includes dir_name.isNull() @@ -389,11 +381,10 @@ YCPValue YQUI::askForExistingFile( const YCPString & startWith, normalCursor(); QString file_name = - Q3FileDialog::getOpenFileName( fromUTF8( startWith->value() ), - fromUTF8( filter->value() ), - _main_win, // parent - "file_selector", // name - fromUTF8( headline->value() ) ); // caption + QFileDialog::getOpenFileName( _main_win, // parent + fromUTF8( headline->value() ), + fromUTF8( startWith->value() ), + fromUTF8( filter->value() ) ); busyCursor(); if ( file_name.isEmpty() ) // this includes file_name.isNull() @@ -434,21 +425,20 @@ QString YQUI::askForSaveFileName( const QString & startWith, // Leave the mouse cursor alone - this function might be called from // some other widget, not only from UI::AskForSaveFileName(). - file_name = Q3FileDialog::getSaveFileName( startWith, - filter, - _main_win, // parent - "file_selector", // name - headline ); // caption + file_name = QFileDialog::getSaveFileName( _main_win, + headline, + startWith, + filter ); if ( file_name.isEmpty() ) // this includes file_name.isNull() return QString::null; - if ( access( (const char *) file_name, F_OK ) == 0 ) // file exists? + if ( access( qPrintable(file_name), F_OK ) == 0 ) // file exists? { QString msg; - if ( access( (const char *) file_name, W_OK ) == 0 ) + if ( access( qPrintable(file_name), W_OK ) == 0 ) { // Confirm if the user wishes to overwrite an existing file msg = ( _( "%1 exists! Really overwrite?" ) ).arg( file_name ); -- 2.39.2