From 4e352ad3d1133d716cf2a12dca4ab12ed4bbf406 Mon Sep 17 00:00:00 2001 From: coolo Date: Mon, 10 Dec 2007 19:58:14 +0000 Subject: [PATCH] merge in the last changes git-svn-id: http://svn.opensuse.org/svn/yast/trunk/qt4@42925 e0cc52ee-31ee-0310-8b87-e83c4596d67c --- VERSION.cmake | 2 +- package/yast2-qt4.changes | 9 +++ src/YQApplication.cc | 148 ++++++++++++++++++++++++++++++---- src/YQApplication.h | 66 +++++++++++++++ src/YQUI.h | 61 -------------- src/YQUI_builtins.cc | 121 ++------------------------- src/pkg/YQPackageSelector.cc | 7 +- src/pkg/YQPkgConflictList.cc | 6 +- src/pkg/YQPkgDiskUsageList.cc | 2 +- src/pkg/YQPkgList.cc | 7 +- src/pkg/YQPkgPatternList.cc | 2 +- yast2-qt4.spec.in | 4 +- 12 files changed, 232 insertions(+), 203 deletions(-) diff --git a/VERSION.cmake b/VERSION.cmake index e2c3989..a63d1d7 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -1,3 +1,3 @@ SET(VERSION_MAJOR "2") SET(VERSION_MINOR "16") -SET(VERSION_PATCH "7") +SET(VERSION_PATCH "8") diff --git a/package/yast2-qt4.changes b/package/yast2-qt4.changes index c5142d7..9da0c13 100644 --- a/package/yast2-qt4.changes +++ b/package/yast2-qt4.changes @@ -1,3 +1,12 @@ +------------------------------------------------------------------- +Mon Dec 10 18:39:34 CET 2007 - sh@suse.de + +- Moved file and directory dialogs from YQUI to YQApplication: + - askForExistingDirectory() + - askForExistingFile() + - askForSaveFile() +- V 2.16.8 + ------------------------------------------------------------------- Fri Dec 7 16:07:05 CET 2007 - coolo@suse.de diff --git a/src/YQApplication.cc b/src/YQApplication.cc index 050b3c9..b49d51b 100644 --- a/src/YQApplication.cc +++ b/src/YQApplication.cc @@ -10,20 +10,27 @@ | (C) SuSE GmbH | \----------------------------------------------------------------------/ - File: YQApplication.cc + File: YQApplication.cc - Author: Stefan Hundhammer + Author: Stefan Hundhammer + Textdomain "packages-qt" /-*/ -#include -#include +#include +#include +#include // access() #include +#include +#include #define y2log_component "qt-ui" #include +#include "utf8.h" +#include "YQi18n.h" + #include "YQApplication.h" @@ -296,7 +303,7 @@ YQApplication::deleteFonts() _currentFont = 0; _headingFont = 0; - _boldFont = 0; + _boldFont = 0; } @@ -321,47 +328,46 @@ YQApplication::pickAutoFonts() int x = 800; int y = 600; - - int normal = 10; - int heading = 12; + int normal = 10; + int heading = 12; if ( x >= 800 && y >= 600 ) { normal = 10; - heading = 12; + heading = 12; } if ( x >= 1024 && y >= 768 ) { normal = 12; - heading = 14; + heading = 14; } if ( x >= 1280 && y >= 1024 ) { normal = 14; - heading = 18; + heading = 18; } if ( x >= 1400 ) { normal = 16; - heading = 20; + heading = 20; } if ( x >= 1600 ) { normal = 18; - heading = 24; + heading = 24; } if ( x >= 2048 ) // Sounds futuristic? Just wait one or two years... { normal = 20; - heading = 28; + heading = 28; } - _autoNormalFontSize = normal; + _autoNormalFontSize = normal; _autoHeadingFontSize = heading; y2milestone( "Selecting auto fonts - normal: %d, heading: %d (bold)", @@ -369,6 +375,118 @@ YQApplication::pickAutoFonts() } +string +YQApplication::askForExistingDirectory( const string & startDir, + const string & headline ) +{ +#if 0 + normalCursor(); +#endif + + QString dirName = + QFileDialog::getExistingDirectory( 0, + fromUTF8( startDir ), + fromUTF8( headline ) ); // caption +#if 0 + busyCursor(); +#endif + + return toUTF8( dirName ); +} + + +string +YQApplication::askForExistingFile( const string & startWith, + const string & filter, + const string & headline ) +{ +#if 0 + normalCursor(); +#endif + + QString fileName = + QFileDialog::getOpenFileName( 0, fromUTF8( startWith ), + fromUTF8( filter ), + fromUTF8( headline ) ); // caption + +#if 0 + busyCursor(); +#endif + + return toUTF8( fileName ); +} + + +string +YQApplication::askForSaveFileName( const string & startWith, + const string & filter, + const string & headline ) +{ +#if 0 + normalCursor(); +#endif + + QString fileName = askForSaveFileName( fromUTF8( startWith ), + fromUTF8( filter ), + fromUTF8( headline ) ); +#if 0 + busyCursor(); +#endif + + return toUTF8( fileName ); +} + + + +QString +YQApplication::askForSaveFileName( const QString & startWith, + const QString & filter, + const QString & headline ) +{ + QString fileName; + bool tryAgain = false; + + do + { + // Leave the mouse cursor alone - this function might be called from + // some other widget, not only from UI::AskForSaveFileName(). + + fileName = QFileDialog::getSaveFileName( 0, startWith, + filter, + headline ); // caption + + if ( fileName.isEmpty() ) // this includes fileName.isNull() + return QString::null; + + + if ( access( QFile::encodeName( fileName ), F_OK ) == 0 ) // file exists? + { + QString msg; + + if ( access( QFile::encodeName( fileName ), W_OK ) == 0 ) + { + // Confirm if the user wishes to overwrite an existing file + msg = ( _( "%1 exists! Really overwrite?" ) ).arg( fileName ); + } + else + { + // Confirm if the user wishes to overwrite a write-protected file %1 + msg = ( _( "%1 exists and is write-protected!\nReally overwrite?" ) ).arg( fileName ); + } + + int buttonNo = QMessageBox::information( 0, // parent widget + // Translators: Window title for confirmation dialog + _( "Confirm" ), + msg, + _( "C&ontinue" ), + _( "&Cancel" ) ); + tryAgain = ( buttonNo != 0 ); + } + + } while ( tryAgain ); + + return fileName; +} #include "YQApplication.moc" diff --git a/src/YQApplication.h b/src/YQApplication.h index 840d301..b9b93e5 100644 --- a/src/YQApplication.h +++ b/src/YQApplication.h @@ -124,7 +124,73 @@ public: **/ void setAutoFonts( bool useAutoFonts ); + /** + * Open a directory selection box and prompt the user for an existing + * directory. + * + * '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 an empty string if the user canceled the operation. + * + * Implemented from YApplication. + **/ + virtual string askForExistingDirectory( const string & startDir, + const string & headline ); + + /** + * Open a file selection box and prompt the user for an existing file. + * + * '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 an empty string if the user canceled the operation. + * + * Implemented from YApplication. + **/ + virtual string askForExistingFile( const string & startWith, + const string & filter, + const string & 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. + * + * '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 an empty string if the user canceled the operation. + * + * Implemented from YApplication. + **/ + virtual string askForSaveFileName( const string & startWith, + const string & filter, + const string & headline ); + /** + * Lower-level version that works with QStrings and does not change + * the mouse cursor. + **/ + static QString askForSaveFileName( const QString & startWith, + const QString & filter, + const QString & headline ); + protected: /** diff --git a/src/YQUI.h b/src/YQUI.h index d08ad32..f63e85f 100644 --- a/src/YQUI.h +++ b/src/YQUI.h @@ -314,67 +314,6 @@ protected: 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. - **/ - QString askForSaveFileName( const QString & startWith, - const QString & filter, - const QString & headline ); - /** * Initialize and set a textdomain for gettext() **/ diff --git a/src/YQUI_builtins.cc b/src/YQUI_builtins.cc index 58fe76c..0c187d3 100644 --- a/src/YQUI_builtins.cc +++ b/src/YQUI_builtins.cc @@ -30,6 +30,7 @@ #include #include #include +#include #define y2log_component "qt-ui" #include @@ -40,6 +41,7 @@ #include "YUISymbols.h" #include "YQDialog.h" #include "YQSignalBlocker.h" +#include "YQApplication.h" #include "utf8.h" #include "YQi18n.h" @@ -172,7 +174,9 @@ void YQUI::makeScreenShot( std::string stl_filename ) { YQSignalBlocker sigBlocker( _user_input_timer ); - fileName = askForSaveFileName( fileName, QString( "*.png" ) , _( "Save screen shot to..." ) ); + fileName = YQApplication::askForSaveFileName( fileName, + QString( "*.png" ) , + _( "Save screen shot to..." ) ); } if ( fileName.isEmpty() ) @@ -220,9 +224,9 @@ void YQUI::makeScreenShot( std::string stl_filename ) void YQUI::askSaveLogs() { - QString fileName = askForSaveFileName( "/tmp/y2logs.tgz", // startWith - "*.tgz *.tar.gz", // filter - "Save y2logs to..." ); // headline + QString fileName = YQApplication::askForSaveFileName( QString( "/tmp/y2logs.tgz" ), // startWith + QString( "*.tgz *.tar.gz" ), // filter + QString( "Save y2logs to..." ) ); // headline if ( ! fileName.isEmpty() ) { @@ -350,113 +354,4 @@ void YQUI::askPlayMacro() } - -YCPValue YQUI::askForExistingDirectory( const YCPString & startDir, - const YCPString & headline ) -{ - normalCursor(); - - QString dir_name = - QFileDialog::getExistingDirectory( _main_win, - fromUTF8( headline->value() ), - fromUTF8( startDir->value() ) ); - busyCursor(); - - if ( dir_name.isEmpty() ) // this includes dir_name.isNull() - return YCPVoid(); // nothing selected -> return 'nil' - - return YCPString( toUTF8( dir_name ) ); -} - - -YCPValue YQUI::askForExistingFile( const YCPString & startWith, - const YCPString & filter, - const YCPString & headline ) -{ - normalCursor(); - - QString file_name = - QFileDialog::getOpenFileName( _main_win, // parent - fromUTF8( headline->value() ), - fromUTF8( startWith->value() ), - fromUTF8( filter->value() ) ); - busyCursor(); - - if ( file_name.isEmpty() ) // this includes file_name.isNull() - return YCPVoid(); // nothing selected -> return 'nil' - - return YCPString( toUTF8( file_name ) ); -} - - -YCPValue YQUI::askForSaveFileName( const YCPString & startWith, - const YCPString & filter, - const YCPString & headline ) -{ - 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 ) ); -} - - - -QString YQUI::askForSaveFileName( const QString & startWith, - const QString & filter, - const QString & headline ) -{ - QString file_name; - bool try_again = false; - - do - { - // Leave the mouse cursor alone - this function might be called from - // some other widget, not only from UI::AskForSaveFileName(). - - file_name = QFileDialog::getSaveFileName( _main_win, - headline, - startWith, - filter ); - - if ( file_name.isEmpty() ) // this includes file_name.isNull() - return QString::null; - - - if ( access( qPrintable(file_name), F_OK ) == 0 ) // file exists? - { - QString msg; - - 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 ); - } - else - { - // Confirm if the user wishes to overwrite a write-protected file %1 - msg = ( _( "%1 exists and is write-protected!\nReally overwrite?" ) ).arg( file_name ); - } - - int button_no = QMessageBox::information( _main_win, - // Window title for confirmation dialog - _( "Confirm" ), - msg, - _( "C&ontinue" ), - _( "&Cancel" ) ); - try_again = ( button_no != 0 ); - } - - } while ( try_again ); - - return file_name; -} - - // EOF diff --git a/src/pkg/YQPackageSelector.cc b/src/pkg/YQPackageSelector.cc index ca3f34b..af1ebf5 100644 --- a/src/pkg/YQPackageSelector.cc +++ b/src/pkg/YQPackageSelector.cc @@ -81,6 +81,7 @@ #include "QY2ComboTabWidget.h" #include "YQDialog.h" +#include "YQApplication.h" #include "utf8.h" #include "YQUI.h" #include "YEvent.h" @@ -1106,9 +1107,9 @@ YQPackageSelector::connectPatchList() void YQPackageSelector::pkgExport() { - QString filename = YQUI::ui()->askForSaveFileName( QString( DEFAULT_EXPORT_FILE_NAME ), // startsWith - QString( "*.xml;;*" ), // filter - _( "Save Package List" ) ); + QString filename = YQApplication::askForSaveFileName( QString( DEFAULT_EXPORT_FILE_NAME ), // startsWith + QString( "*.xml;;*" ), // filter + _( "Save Package List" ) ); if ( ! filename.isEmpty() ) { diff --git a/src/pkg/YQPkgConflictList.cc b/src/pkg/YQPkgConflictList.cc index 8553295..ec2701f 100644 --- a/src/pkg/YQPkgConflictList.cc +++ b/src/pkg/YQPkgConflictList.cc @@ -122,9 +122,9 @@ YQPkgConflictList::applyResolutions() void YQPkgConflictList::askSaveToFile() const { - QString filename = YQUI::ui()->askForSaveFileName( "conflicts.txt", // startsWith - "*.txt", // filter - _( "Save Conflicts List" ) ); + QString filename = YQApplication::askForSaveFileName( "conflicts.txt", // startsWith + "*.txt", // filter + _( "Save Conflicts List" ) ); if ( ! filename.isEmpty() ) saveToFile( filename, true ); } diff --git a/src/pkg/YQPkgDiskUsageList.cc b/src/pkg/YQPkgDiskUsageList.cc index 145f105..a412a56 100644 --- a/src/pkg/YQPkgDiskUsageList.cc +++ b/src/pkg/YQPkgDiskUsageList.cc @@ -167,7 +167,7 @@ YQPkgDiskUsageList::keyPressEvent( QKeyEvent * event ) if ( event ) { - unsigned special_combo = ( Qt::ControlModifier| Qt::ShiftModifier | Qt::AltModifier ); + Qt::KeyboardModifiers special_combo = ( Qt::ControlModifier| Qt::ShiftModifier | Qt::AltModifier ); if ( ( event->modifiers() & special_combo ) == special_combo ) { diff --git a/src/pkg/YQPkgList.cc b/src/pkg/YQPkgList.cc index 7236db6..d8a9911 100644 --- a/src/pkg/YQPkgList.cc +++ b/src/pkg/YQPkgList.cc @@ -34,6 +34,7 @@ #include "YQUI.h" #include "YQi18n.h" #include "YQIconPool.h" +#include "YQApplication.h" YQPkgList::YQPkgList( QWidget * parent ) @@ -362,9 +363,9 @@ YQPkgList::updateActions( YQPkgObjListItem * pkgObjListItem ) void YQPkgList::askExportList() const { - QString filename = YQUI::ui()->askForSaveFileName( "pkglist.txt", // startsWith - "*.txt", // filter - _( "Export Package List" ) ); + QString filename = YQApplication::askForSaveFileName( "pkglist.txt", // startsWith + "*.txt", // filter + _( "Export Package List" ) ); if ( ! filename.isEmpty() ) exportList( filename, true ); } diff --git a/src/pkg/YQPkgPatternList.cc b/src/pkg/YQPkgPatternList.cc index 0e392e8..ff89505 100644 --- a/src/pkg/YQPkgPatternList.cc +++ b/src/pkg/YQPkgPatternList.cc @@ -418,7 +418,7 @@ bool YQPkgPatternCategoryItem::operator< ( const QTreeWidgetItem & otherListView if ( otherPatternListitem ) // Patterns without category should always be sorted return true; // before any category - QTreeWidgetItem::operator<( otherListViewItem ); + return QTreeWidgetItem::operator<( otherListViewItem ); } diff --git a/yast2-qt4.spec.in b/yast2-qt4.spec.in index 2153688..75a08ea 100644 --- a/yast2-qt4.spec.in +++ b/yast2-qt4.spec.in @@ -5,8 +5,8 @@ BuildRequires: dbus-1-devel boost-devel libzypp-devel curl-devel docbook-xsl-stylesheets doxygen libdrm-devel libjpeg-devel libxcrypt-devel libxslt perl-XML-Writer libqt4-devel rpm-devel sgml-skel update-desktop-files yast2-devtools hal-devel Summary: - -BuildRequires: yast2-core-devel >= 2.16.11 -Requires: yast2-core >= 2.16.11 +BuildRequires: yast2-core-devel >= 2.16.15 +Requires: yast2-core >= 2.16.15 Requires: libzypp >= 3.11.8 Provides: yast2_ui Provides: y2base:/usr/lib/YaST2/servers/qt -- 2.39.2