author | drw <drw> | 2004-11-18 15:49:02 (UTC) |
---|---|---|
committer | drw <drw> | 2004-11-18 15:49:02 (UTC) |
commit | 7ac32658ba09d8456cc75e5cf80707caa616848b (patch) (unidiff) | |
tree | 56bae9b9c75eae7a9096013830fe98d28a4de0ed | |
parent | 718a7a8ba68e10faa1a22fcc6bdc26e1723b2a40 (diff) | |
download | opie-7ac32658ba09d8456cc75e5cf80707caa616848b.zip opie-7ac32658ba09d8456cc75e5cf80707caa616848b.tar.gz opie-7ac32658ba09d8456cc75e5cf80707caa616848b.tar.bz2 |
UI tweaks for Installation dialog - 1. Show destination selection only when installing apps, 2. Update available disk space after each package is processed, 3. Disable destination selection once start button has been clicked
-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 61 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.h | 14 | ||||
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 2 |
3 files changed, 63 insertions, 14 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 945dfed..781f8f5 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp | |||
@@ -25,16 +25,17 @@ _;:, .> :=|. This file is free software; you can | |||
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "installdlg.h" | 30 | #include "installdlg.h" |
31 | 31 | ||
32 | #include <opie2/ofiledialog.h> | 32 | #include <opie2/ofiledialog.h> |
33 | #include <opie2/oprocess.h> | ||
33 | 34 | ||
34 | #include <qpe/fileselector.h> | 35 | #include <qpe/fileselector.h> |
35 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
36 | #include <qpe/storage.h> | 37 | #include <qpe/storage.h> |
37 | 38 | ||
38 | #include <qapplication.h> | 39 | #include <qapplication.h> |
39 | #include <qcombobox.h> | 40 | #include <qcombobox.h> |
40 | #include <qfileinfo.h> | 41 | #include <qfileinfo.h> |
@@ -52,16 +53,17 @@ _;:, .> :=|. This file is free software; you can | |||
52 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, | 53 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, |
53 | OPackage::Command command1, const QStringList &packages1, | 54 | OPackage::Command command1, const QStringList &packages1, |
54 | OPackage::Command command2, const QStringList &packages2, | 55 | OPackage::Command command2, const QStringList &packages2, |
55 | OPackage::Command command3, const QStringList &packages3 ) | 56 | OPackage::Command command3, const QStringList &packages3 ) |
56 | : QWidget( 0x0 ) | 57 | : QWidget( 0x0 ) |
57 | , m_packman( pm ) | 58 | , m_packman( pm ) |
58 | , m_numCommands( 0 ) | 59 | , m_numCommands( 0 ) |
59 | , m_currCommand( 0 ) | 60 | , m_currCommand( 0 ) |
61 | , m_destItem( 0x0 ) | ||
60 | { | 62 | { |
61 | // Save command/package list information | 63 | // Save command/package list information |
62 | if ( command1 != OPackage::NotDefined ) | 64 | if ( command1 != OPackage::NotDefined ) |
63 | { | 65 | { |
64 | m_command[ m_numCommands ] = command1; | 66 | m_command[ m_numCommands ] = command1; |
65 | m_packages[ m_numCommands ] = packages1; | 67 | m_packages[ m_numCommands ] = packages1; |
66 | ++m_numCommands; | 68 | ++m_numCommands; |
67 | } | 69 | } |
@@ -158,36 +160,33 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap | |||
158 | } | 160 | } |
159 | } | 161 | } |
160 | 162 | ||
161 | m_output->append( tr( "Press the start button to begin.\n" ) ); | 163 | m_output->append( tr( "Press the start button to begin.\n" ) ); |
162 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 164 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
163 | 165 | ||
164 | } | 166 | } |
165 | 167 | ||
166 | InstallDlg::~InstallDlg() | ||
167 | { | ||
168 | } | ||
169 | |||
170 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) | 168 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) |
171 | { | 169 | { |
172 | // If available space is not displayed, exit | 170 | // If available space is not displayed, exit |
173 | if ( !m_availSpace ) | 171 | if ( !m_availSpace ) |
174 | return; | 172 | return; |
175 | 173 | ||
176 | QString space = tr( "Unknown" ); | 174 | QString space = tr( "Unknown" ); |
177 | 175 | ||
178 | // Get destination | 176 | // Get destination |
179 | OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); | 177 | if ( !destination.isNull() ) |
178 | m_destItem = m_packman->findConfItem( OConfItem::Destination, destination ); | ||
180 | 179 | ||
181 | if ( dest ) | 180 | if ( m_destItem ) |
182 | { | 181 | { |
183 | // Calculate available space | 182 | // Calculate available space |
184 | struct statfs fs; | 183 | struct statfs fs; |
185 | if ( !statfs( dest->value(), &fs ) ) | 184 | if ( !statfs( m_destItem->value(), &fs ) ) |
186 | { | 185 | { |
187 | long mult = fs.f_bsize / 1024; | 186 | long mult = fs.f_bsize / 1024; |
188 | long div = 1024 / fs.f_bsize; | 187 | long div = 1024 / fs.f_bsize; |
189 | 188 | ||
190 | if ( !mult ) mult = 1; | 189 | if ( !mult ) mult = 1; |
191 | if ( !div ) div = 1; | 190 | if ( !div ) div = 1; |
192 | long avail = fs.f_bavail * mult / div; | 191 | long avail = fs.f_bavail * mult / div; |
193 | 192 | ||
@@ -215,37 +214,74 @@ void InstallDlg::slotBtnStart() | |||
215 | else if ( btnText == tr( "Close" ) ) | 214 | else if ( btnText == tr( "Close" ) ) |
216 | { | 215 | { |
217 | // TODO - force reload of package data | 216 | // TODO - force reload of package data |
218 | emit closeInstallDlg(); | 217 | emit closeInstallDlg(); |
219 | return; | 218 | return; |
220 | } | 219 | } |
221 | 220 | ||
222 | // Start was clicked, start executing | 221 | // Start was clicked, start executing |
222 | QString dest; | ||
223 | if ( m_destination ) | ||
224 | { | ||
225 | dest = m_destination->currentText(); | ||
226 | m_destination->setEnabled( false ); | ||
227 | } | ||
228 | |||
223 | m_btnOptions->setEnabled( false ); | 229 | m_btnOptions->setEnabled( false ); |
224 | if ( m_numCommands > 1 ) | 230 | if ( m_numCommands > 1 ) |
225 | { | 231 | { |
226 | m_btnStart->setText( tr( "Abort" ) ); | 232 | m_btnStart->setText( tr( "Abort" ) ); |
227 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); | 233 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); |
228 | } | 234 | } |
229 | else | 235 | else |
230 | { | 236 | { |
231 | m_btnStart->setEnabled( false ); | 237 | m_btnStart->setEnabled( false ); |
232 | } | 238 | } |
233 | 239 | ||
234 | QString dest; | ||
235 | if ( m_destination ) | ||
236 | dest = m_destination->currentText(); | ||
237 | |||
238 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) | 240 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) |
239 | { | 241 | { |
240 | // Execute next command | 242 | // Execute next command |
241 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, | 243 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, |
242 | this, SLOT(slotOutput(char*)), true ); | 244 | this, SLOT(slotOutput(char*)), true ); |
243 | } | 245 | } |
246 | slotProcessDone(0l); | ||
247 | |||
248 | // Get destination | ||
249 | /* | ||
250 | if ( dest == "root" ) | ||
251 | { | ||
252 | slotProcessDone(0l); | ||
253 | return; | ||
254 | } | ||
255 | |||
256 | m_destItem = m_packman->findConfItem( OConfItem::Destination, dest ); | ||
257 | if ( m_destItem ) | ||
258 | { | ||
259 | QString path = m_destItem->value(); | ||
260 | Opie::Core::OProcess *process = new Opie::Core::OProcess( this, "ipkg-link process" ); | ||
261 | connect( process, SIGNAL(processExited(Opie::Core::OProcess*)), | ||
262 | this, SLOT(slotProcessDone(Opie::Core::OProcess*)) ); | ||
263 | |||
264 | *process << "ipkg-link" << "mount" << path; | ||
265 | if ( !process->start( Opie::Core::OProcess::NotifyOnExit, | ||
266 | Opie::Core::OProcess::NoCommunication ) ) | ||
267 | slotProcessDone( 0l ); | ||
268 | m_output->append( tr( "Starting ipkg-link to link installed applications." ) ); | ||
269 | m_output->setCursorPosition( m_output->numLines(), 0 ); | ||
270 | } | ||
271 | */ | ||
272 | } | ||
273 | |||
274 | void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc ) | ||
275 | { | ||
276 | delete proc; | ||
277 | |||
278 | m_output->append( tr( "The package linking is done." ) ); | ||
279 | m_output->setCursorPosition( m_output->numLines(), 0 ); | ||
244 | 280 | ||
245 | // All commands executed, allow user to close dialog | 281 | // All commands executed, allow user to close dialog |
246 | m_btnStart->setEnabled( true ); | 282 | m_btnStart->setEnabled( true ); |
247 | m_btnStart->setText( tr( "Close" ) ); | 283 | m_btnStart->setText( tr( "Close" ) ); |
248 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | 284 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); |
249 | 285 | ||
250 | m_btnOptions->setEnabled( true ); | 286 | m_btnOptions->setEnabled( true ); |
251 | m_btnOptions->setText( tr( "Save output" ) ); | 287 | m_btnOptions->setText( tr( "Save output" ) ); |
@@ -289,9 +325,12 @@ void InstallDlg::slotOutput( char *msg ) | |||
289 | // Allow processing of other events | 325 | // Allow processing of other events |
290 | qApp->processEvents(); | 326 | qApp->processEvents(); |
291 | 327 | ||
292 | QString lineStr = msg; | 328 | QString lineStr = msg; |
293 | if ( lineStr[lineStr.length()-1] == '\n' ) | 329 | if ( lineStr[lineStr.length()-1] == '\n' ) |
294 | lineStr.truncate( lineStr.length() - 1 ); | 330 | lineStr.truncate( lineStr.length() - 1 ); |
295 | m_output->append( lineStr ); | 331 | m_output->append( lineStr ); |
296 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 332 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
333 | |||
334 | // Update available space | ||
335 | slotDisplayAvailSpace( QString::null ); | ||
297 | } | 336 | } |
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h index cddc911..f45c17c 100644 --- a/noncore/settings/packagemanager/installdlg.h +++ b/noncore/settings/packagemanager/installdlg.h | |||
@@ -34,55 +34,65 @@ _;:, .> :=|. This file is free software; you can | |||
34 | 34 | ||
35 | #include "opackage.h" | 35 | #include "opackage.h" |
36 | 36 | ||
37 | class QComboBox; | 37 | class QComboBox; |
38 | class QLabel; | 38 | class QLabel; |
39 | class QMultiLineEdit; | 39 | class QMultiLineEdit; |
40 | class QPushButton; | 40 | class QPushButton; |
41 | 41 | ||
42 | class OConfItem; | ||
42 | class OPackageManager; | 43 | class OPackageManager; |
43 | 44 | ||
45 | namespace Opie | ||
46 | { | ||
47 | namespace Core | ||
48 | { | ||
49 | class OProcess; | ||
50 | } | ||
51 | } | ||
52 | |||
44 | class InstallDlg : public QWidget | 53 | class InstallDlg : public QWidget |
45 | { | 54 | { |
46 | Q_OBJECT | 55 | Q_OBJECT |
47 | 56 | ||
48 | public: | 57 | public: |
49 | InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null, | 58 | InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null, |
50 | bool showDestInfo = true, | 59 | bool showDestInfo = true, |
51 | OPackage::Command command1 = OPackage::NotDefined, | 60 | OPackage::Command command1 = OPackage::NotDefined, |
52 | const QStringList &packages1 = QStringList(), | 61 | const QStringList &packages1 = QStringList(), |
53 | OPackage::Command command2 = OPackage::NotDefined, | 62 | OPackage::Command command2 = OPackage::NotDefined, |
54 | const QStringList &packages2 = QStringList(), | 63 | const QStringList &packages2 = QStringList(), |
55 | OPackage::Command command3 = OPackage::NotDefined, | 64 | OPackage::Command command3 = OPackage::NotDefined, |
56 | const QStringList &packages3 = QStringList() ); | 65 | const QStringList &packages3 = QStringList() ); |
57 | ~InstallDlg(); | ||
58 | 66 | ||
59 | private: | 67 | private: |
60 | OPackageManager *m_packman; // Pointer to application instance of package manager | 68 | OPackageManager *m_packman; // Pointer to application instance of package manager |
61 | 69 | ||
62 | // UI controls | 70 | // UI controls |
63 | QComboBox *m_destination; // Destination selection list | 71 | QComboBox *m_destination; // Destination selection list |
64 | QLabel *m_availSpace; // Text label to display available space on selected destination | 72 | QLabel *m_availSpace; // Text label to display available space on selected destination |
65 | QMultiLineEdit *m_output; // Multi-line edit to display status | 73 | QMultiLineEdit *m_output; // Multi-line edit to display status |
66 | QPushButton *m_btnStart; // Start/abort/close button | 74 | QPushButton *m_btnStart; // Start/abort/close button |
67 | QPushButton *m_btnOptions; // Installation options button | 75 | QPushButton *m_btnOptions; // Installation options button |
68 | 76 | ||
69 | // Commands and packages to execute | 77 | // Commands and packages to execute |
70 | int m_numCommands; // Number of commands to be executed | 78 | int m_numCommands; // Number of commands to be executed |
71 | int m_currCommand; // Number of currently executing command | 79 | int m_currCommand; // Number of currently executing command |
72 | OPackage::Command m_command[3]; // List of commands to be executed | 80 | OPackage::Command m_command[3]; // List of commands to be executed |
73 | QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) | 81 | QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) |
82 | OConfItem *m_destItem; // Pointer to destination for package installation | ||
74 | 83 | ||
75 | private slots: | 84 | private slots: |
76 | // UI control slots | 85 | // UI control slots |
77 | void slotDisplayAvailSpace( const QString &destination ); | 86 | void slotDisplayAvailSpace( const QString &destination ); |
78 | void slotBtnStart(); | 87 | void slotBtnStart(); |
79 | void slotBtnOptions(); | 88 | void slotBtnOptions(); |
80 | 89 | void slotProcessDone( Opie::Core::OProcess *proc ); | |
90 | |||
81 | // Execution slots | 91 | // Execution slots |
82 | void slotOutput( char *msg ); | 92 | void slotOutput( char *msg ); |
83 | 93 | ||
84 | signals: | 94 | signals: |
85 | void closeInstallDlg(); | 95 | void closeInstallDlg(); |
86 | }; | 96 | }; |
87 | 97 | ||
88 | #endif | 98 | #endif |
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 5e15874..459a75b 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp | |||
@@ -526,17 +526,17 @@ void MainWindow::slotApply() | |||
526 | OPackage::Command installCmd = OPackage::NotDefined; | 526 | OPackage::Command installCmd = OPackage::NotDefined; |
527 | if ( !installList.isEmpty() ) | 527 | if ( !installList.isEmpty() ) |
528 | installCmd = OPackage::Install; | 528 | installCmd = OPackage::Install; |
529 | OPackage::Command upgradeCmd = OPackage::NotDefined; | 529 | OPackage::Command upgradeCmd = OPackage::NotDefined; |
530 | if ( !upgradeList.isEmpty() ) | 530 | if ( !upgradeList.isEmpty() ) |
531 | upgradeCmd = OPackage::Upgrade; | 531 | upgradeCmd = OPackage::Upgrade; |
532 | 532 | ||
533 | // Create package manager output widget | 533 | // Create package manager output widget |
534 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, | 534 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), !installList.isEmpty(), |
535 | removeCmd, removeList, | 535 | removeCmd, removeList, |
536 | installCmd, installList, | 536 | installCmd, installList, |
537 | upgradeCmd, upgradeList ); | 537 | upgradeCmd, upgradeList ); |
538 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 538 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
539 | 539 | ||
540 | // Display widget | 540 | // Display widget |
541 | m_widgetStack.addWidget( dlg, 3 ); | 541 | m_widgetStack.addWidget( dlg, 3 ); |
542 | m_widgetStack.raiseWidget( dlg ); | 542 | m_widgetStack.raiseWidget( dlg ); |