author | drw <drw> | 2005-03-10 19:22:02 (UTC) |
---|---|---|
committer | drw <drw> | 2005-03-10 19:22:02 (UTC) |
commit | d798f87314392033ad1e18d01927c622aa4d9b02 (patch) (side-by-side diff) | |
tree | e6021dbe269c98c9653035aa119e29bcd8f88fc7 | |
parent | 3bf4809c4f2263f0130472c41aa6c85e46e61db9 (diff) | |
download | opie-d798f87314392033ad1e18d01927c622aa4d9b02.zip opie-d798f87314392033ad1e18d01927c622aa4d9b02.tar.gz opie-d798f87314392033ad1e18d01927c622aa4d9b02.tar.bz2 |
Some minor UI tweaks
-rw-r--r-- | noncore/settings/packagemanager/entrydlg.cpp | 74 | ||||
-rw-r--r-- | noncore/settings/packagemanager/entrydlg.h | 45 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 8 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkgconfigdlg.cpp | 10 |
4 files changed, 85 insertions, 52 deletions
diff --git a/noncore/settings/packagemanager/entrydlg.cpp b/noncore/settings/packagemanager/entrydlg.cpp index fd275e1..3b794b4 100644 --- a/noncore/settings/packagemanager/entrydlg.cpp +++ b/noncore/settings/packagemanager/entrydlg.cpp @@ -1,85 +1,107 @@ /* - This file is part of the OPIE Project + This file is part of the OPIE Project =. Copyright (c) 2004 Dan Williams <drw@handhelds.org> - .=l. - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This file is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., + .=l. + .>+-= +_;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: +: = ...= . :.=- You should have received a copy of the GNU +-. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "entrydlg.h" +#include <opie2/ofiledialog.h> + #include <qpe/qpeapplication.h> +#include <qpe/resource.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qpushbutton.h> EntryDlg::EntryDlg( const QString &label, QWidget* parent, const char* name, bool modal ) : QDialog( parent, name, modal ) { - QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); + QGridLayout *layout = new QGridLayout( this, 3, 2, 2, 4 ); QLabel *l = new QLabel( label, this ); l->setAlignment( AlignLeft | AlignTop | WordBreak ); - vbox->addWidget( l ); + layout->addMultiCellWidget( l, 0, 0, 0, 1 ); m_entry = new QLineEdit( this ); - vbox->addWidget( m_entry ); + layout->addWidget( m_entry, 1, 0 ); + connect( m_entry, SIGNAL(returnPressed()), this, SLOT(slotTryAccept()) ); + + QPixmap pic; + pic.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); + QPushButton *btn = new QPushButton( pic, QString::null, this ); + btn->setMaximumWidth( btn->height() ); + connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) ); + layout->addWidget( btn, 1, 1 ); + + layout->setRowStretch( 2, 10 ); - connect( m_entry, SIGNAL(returnPressed()), this, SLOT(tryAccept()) ); + resize( width(), l->height() + btn->height() + 8 ); } void EntryDlg::setText( const QString &text ) { m_entry->setText( text ); m_entry->selectAll(); } QString EntryDlg::getText() { return m_entry->text(); } QString EntryDlg::getText( const QString &caption, const QString &label, const QString &text, bool *ok, QWidget *parent, const char *name ) { EntryDlg *dlg = new EntryDlg( label, parent, name, true ); dlg->setCaption( caption ); dlg->setText( text ); QString result; *ok = ( QPEApplication::execDialog( dlg ) == QDialog::Accepted ); if ( *ok ) result = dlg->getText(); delete dlg; return result; } -void EntryDlg::tryAccept() +void EntryDlg::slotTryAccept() { if ( !m_entry->text().isEmpty() ) accept(); } + +void EntryDlg::slotSelectPath() +{ + QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_entry->text() ); + if ( path.at( path.length() - 1 ) == '/' ) + path.truncate( path.length() - 1 ); + if ( !path.isNull() ) + m_entry->setText( path ); +} diff --git a/noncore/settings/packagemanager/entrydlg.h b/noncore/settings/packagemanager/entrydlg.h index 33a7920..012589b 100644 --- a/noncore/settings/packagemanager/entrydlg.h +++ b/noncore/settings/packagemanager/entrydlg.h @@ -1,57 +1,58 @@ /* - This file is part of the OPIE Project + This file is part of the OPIE Project =. Copyright (c) 2004 Dan Williams <drw@handhelds.org> - .=l. - .>+-= - _;:, .> :=|. This file is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This file is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General -..}^=.= = ; Public License for more details. -++= -. .` .: - : = ...= . :.=- You should have received a copy of the GNU - -. .:....=;==+<; General Public License along with this file; - -_. . . )=. = see the file COPYING. If not, write to the - -- :-=` Free Software Foundation, Inc., + .=l. + .>+-= +_;:, .> :=|. This file is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU General Public +.="- .-=="i, .._ License as published by the Free Software +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This file is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General +..}^=.= = ; Public License for more details. +++= -. .` .: +: = ...= . :.=- You should have received a copy of the GNU +-. .:....=;==+<; General Public License along with this file; + -_. . . )=. = see the file COPYING. If not, write to the + -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef ENTRYDLG_H #define ENTRYDLG_H #include <qdialog.h> class QLineEdit; class EntryDlg : public QDialog { Q_OBJECT public: static QString getText( const QString &caption, const QString &label, const QString &text = QString::null, bool *ok = 0, QWidget *parent = 0, const char *name = 0 ); EntryDlg( const QString &label, QWidget* parent = 0, const char* name = 0, bool modal = true ); void setText( const QString &text ); QString getText(); private slots: - void tryAccept(); + void slotTryAccept(); + void slotSelectPath(); private: QLineEdit *m_entry; }; #endif // EntryDlg_H diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 36851b0..8aed10d 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp @@ -1,321 +1,323 @@ /* This file is part of the OPIE Project =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> .=l. .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "installdlg.h" #include <opie2/ofiledialog.h> #include <qpe/fileselector.h> #include <qpe/resource.h> #include <qpe/storage.h> #include <qapplication.h> #include <qcombobox.h> #include <qfileinfo.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlayout.h> #include <qmap.h> #include <qmultilineedit.h> #include <qpushbutton.h> #include <sys/vfs.h> #include "opackagemanager.h" InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, OPackage::Command command1, const QStringList &packages1, OPackage::Command command2, const QStringList &packages2, OPackage::Command command3, const QStringList &packages3 ) : QWidget( 0l ) , m_packman( pm ) , m_installFound( false ) , m_numCommands( 0 ) , m_currCommand( 0 ) , m_destItem( 0l ) { // Save command/package list information if ( command1 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command1; m_packages[ m_numCommands ] = packages1; ++m_numCommands; if ( command1 == OPackage::Install ) m_installFound = true; } if ( command2 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command2; m_packages[ m_numCommands ] = packages2; ++m_numCommands; if ( command2 == OPackage::Install ) m_installFound = true; } if ( command3 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command3; m_packages[ m_numCommands ] = packages3; ++m_numCommands; if ( command3 == OPackage::Install ) m_installFound = true; } // Initialize UI if ( parent ) parent->setCaption( caption ); QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); if ( m_installFound ) { QLabel *label = new QLabel( tr( "Destination" ), this ); layout->addWidget( label, 0, 0 ); m_destination = new QComboBox( this ); m_destination->insertStringList( m_packman->destinations() ); layout->addWidget( m_destination, 0, 1 ); connect( m_destination, SIGNAL(highlighted(const QString&)), this, SLOT(slotDisplayAvailSpace(const QString&)) ); label = new QLabel( tr( "Space Avail" ), this ); layout->addWidget( label, 1, 0 ); m_availSpace = new QLabel( this ); layout->addWidget( m_availSpace, 1, 1 ); // TODO - select correct destination slotDisplayAvailSpace( m_destination->currentText() ); } else { m_destination = 0l; m_availSpace = 0l; } QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); groupBox->layout()->setSpacing( 0 ); groupBox->layout()->setMargin( 4 ); QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); m_output = new QMultiLineEdit( groupBox ); m_output->setReadOnly( true ); groupBoxLayout->addWidget( m_output ); layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); QPixmap pic; pic.convertFromImage( Resource::loadImage( "packagemanager/apply" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_btnStart = new QPushButton( pic, tr( "Start" ), this ); + m_btnStart->setMinimumHeight( AppLnk::smallIconSize() ); layout->addWidget( m_btnStart, 3, 0 ); connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); pic.convertFromImage( Resource::loadImage( "SettingsIcon" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_btnOptions = new QPushButton( pic, tr( "Options" ), this ); + m_btnOptions->setMinimumHeight( AppLnk::smallIconSize() ); layout->addWidget( m_btnOptions, 3, 1 ); connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); // Display packages being acted upon in output widget for( int i = 0; i < m_numCommands; i++ ) { if ( !m_packages[ i ].isEmpty() ) { QString lineStr = tr( "Packages to " ); switch( m_command[ i ] ) { case OPackage::Install : lineStr.append( tr( "install" ) ); break; case OPackage::Remove : lineStr.append( tr( "remove" ) ); break; case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); break; case OPackage::Download : lineStr.append( tr( "download" ) ); break; default : break; }; lineStr.append( ":\n" ); QStringList tmpPackage = m_packages[ i ]; for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it ) { lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); } m_output->append( lineStr ); } } m_output->append( tr( "Press the start button to begin.\n" ) ); m_output->setCursorPosition( m_output->numLines(), 0 ); } void InstallDlg::slotDisplayAvailSpace( const QString &destination ) { // If available space is not displayed, exit if ( !m_availSpace ) return; QString space = tr( "Unknown" ); // Get destination if ( !destination.isNull() ) m_destItem = m_packman->findConfItem( OConfItem::Destination, destination ); if ( m_destItem ) { // Calculate available space struct statfs fs; if ( !statfs( m_destItem->value(), &fs ) ) { long mult = fs.f_bsize / 1024; long div = 1024 / fs.f_bsize; if ( !mult ) mult = 1; if ( !div ) div = 1; long avail = fs.f_bavail * mult / div; space = tr( "%1 Kb" ).arg( avail ); } } // Display available space m_availSpace->setText( space ); } void InstallDlg::slotBtnStart() { QString btnText = m_btnStart->text(); if ( btnText == tr( "Abort" ) ) { // Prevent unexecuted commands from executing m_currCommand = 999; // Allow user to close dialog m_btnStart->setText( tr( "Close" ) ); QPixmap pic; - pic.convertFromImage( Resource::loadImage( "enter" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); + pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_btnStart->setIconSet( pic ); return; } else if ( btnText == tr( "Close" ) ) { // TODO - force reload of package data emit closeInstallDlg(); return; } // Start was clicked, start executing QString dest; if ( m_installFound ) { dest = m_destination->currentText(); m_destination->setEnabled( false ); } m_btnOptions->setEnabled( false ); if ( m_numCommands > 1 ) { m_btnStart->setText( tr( "Abort" ) ); QPixmap pic; - pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); + pic.convertFromImage( Resource::loadImage( "reset" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_btnStart->setIconSet( pic ); } else { m_btnStart->setEnabled( false ); } for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) { // Execute next command m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, this, SLOT(slotOutput(const QString &)), true ); } // All commands executed, allow user to close dialog m_btnStart->setEnabled( true ); m_btnStart->setText( tr( "Close" ) ); QPixmap pic; - pic.convertFromImage( Resource::loadImage( "enter" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); + pic.convertFromImage( Resource::loadImage( "close" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_btnStart->setIconSet( pic ); m_btnOptions->setEnabled( true ); m_btnOptions->setText( tr( "Save output" ) ); pic.convertFromImage( Resource::loadImage( "save" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_btnOptions->setIconSet( pic ); } void InstallDlg::slotBtnOptions() { QString btnText = m_btnOptions->text(); if ( btnText == tr( "Options" ) ) { // Display configuration dialog (only options tab is enabled) m_packman->configureDlg( true ); return; } // Save output was clicked QMap<QString, QStringList> map; map.insert( tr( "All" ), QStringList() ); QStringList text; text << "text/*"; map.insert(tr( "Text" ), text ); text << "*"; map.insert( tr( "All" ), text ); QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); if( !filename.isEmpty() ) { QString currentFileName = QFileInfo( filename ).fileName(); DocLnk doc; doc.setType( "text/plain" ); doc.setFile( filename ); doc.setName( currentFileName ); FileManager fm; fm.saveFile( doc, m_output->text() ); } } void InstallDlg::slotOutput( const QString &msg ) { // Allow processing of other events qApp->processEvents(); QString lineStr = msg; if ( lineStr[lineStr.length()-1] == '\n' ) lineStr.truncate( lineStr.length() - 1 ); m_output->append( lineStr ); m_output->setCursorPosition( m_output->numLines(), 0 ); // Update available space slotDisplayAvailSpace( QString::null ); } diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp index 5f60990..d234251 100644 --- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp +++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp @@ -1,432 +1,438 @@ /* This file is part of the Opie Project Copyright (c) 2003 Dan Williams <drw@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "oipkgconfigdlg.h" #include <opie2/ofiledialog.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlineedit.h> #include <qlistbox.h> #include <qpushbutton.h> #include <qscrollview.h> #include <qwhatsthis.h> OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) : QDialog( parent, QString::null, true, WStyle_ContextHelp ) , m_ipkg( ipkg ) , m_configs( 0l ) , m_installOptions( installOptions ) , m_serverCurrent( -1 ) , m_destCurrent( -1 ) , m_layout( this, 2, 4 ) , m_tabWidget( this ) { setCaption( tr( "Configuration" ) ); // Initialize configuration widgets if ( !installOptions ) { initServerWidget(); initDestinationWidget(); initProxyWidget(); } initOptionsWidget(); // Load configuration information initData(); // Setup tabs for all info m_layout.addWidget( &m_tabWidget ); if ( !m_installOptions ) { m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); m_tabWidget.setCurrentTab( tr( "Servers" ) ); } else { m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); } } void OIpkgConfigDlg::accept() { // Save server, destination and proxy configuration if ( !m_installOptions ) { // Update proxy information before saving settings OConfItem *confItem = m_ipkg->findConfItem( OConfItem::Option, "http_proxy" ); if ( confItem ) { confItem->setValue( m_proxyHttpServer->text() ); confItem->setActive( m_proxyHttpActive->isChecked() ); } else m_configs->append( new OConfItem( OConfItem::Option, "http_proxy", m_proxyHttpServer->text(), QString::null, m_proxyHttpActive->isChecked() ) ); confItem = m_ipkg->findConfItem( OConfItem::Option, "ftp_proxy" ); if ( confItem ) { confItem->setValue( m_proxyFtpServer->text() ); confItem->setActive( m_proxyFtpActive->isChecked() ); } else m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy", m_proxyFtpServer->text(), QString::null, m_proxyFtpActive->isChecked() ) ); confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_username" ); if ( confItem ) confItem->setValue( m_proxyUsername->text() ); else m_configs->append( new OConfItem( OConfItem::Option, "proxy_username", m_proxyUsername->text() ) ); confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_password" ); if ( confItem ) confItem->setValue( m_proxyPassword->text() ); else m_configs->append( new OConfItem( OConfItem::Option, "proxy_password", m_proxyPassword->text() ) ); confItem = m_ipkg->findConfItem( OConfItem::Other, "lists_dir" ); if ( confItem ) confItem->setValue( m_optSourceLists->text() ); else m_configs->append( new OConfItem( OConfItem::Other, "lists_dir", m_optSourceLists->text(), "name" ) ); m_ipkg->setConfigItems( m_configs ); } // Save options configuration int options = 0; if ( m_optForceDepends->isChecked() ) options |= FORCE_DEPENDS; if ( m_optForceReinstall->isChecked() ) options |= FORCE_REINSTALL; if ( m_optForceRemove->isChecked() ) options |= FORCE_REMOVE; if ( m_optForceOverwrite->isChecked() ) options |= FORCE_OVERWRITE; m_ipkg->setIpkgExecOptions( options ); m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); QDialog::accept(); } void OIpkgConfigDlg::reject() { if ( m_configs ) delete m_configs; } void OIpkgConfigDlg::initServerWidget() { m_serverWidget = new QWidget( this ); // Initialize UI QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); QScrollView *sv = new QScrollView( m_serverWidget ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); m_serverList = new QListBox( container ); QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) ); m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) ); layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 ); QPixmap pic; pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); QPushButton *btn = new QPushButton( pic, tr( "New" ), container ); + btn->setMinimumHeight( AppLnk::smallIconSize() ); QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); layout->addWidget( btn, 1, 0 ); pic.convertFromImage( Resource::loadImage( "edit" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_serverEditBtn = new QPushButton( pic, tr( "Edit" ), container ); + m_serverEditBtn->setMinimumHeight( AppLnk::smallIconSize() ); m_serverEditBtn->setEnabled( false ); QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) ); connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) ); layout->addWidget( m_serverEditBtn, 1, 1 ); pic.convertFromImage( Resource::loadImage( "trash" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_serverDeleteBtn = new QPushButton( pic, tr( "Delete" ), container ); + m_serverDeleteBtn->setMinimumHeight( AppLnk::smallIconSize() ); m_serverDeleteBtn->setEnabled( false ); QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); layout->addWidget( m_serverDeleteBtn, 1, 2 ); } void OIpkgConfigDlg::initDestinationWidget() { m_destWidget = new QWidget( this ); // Initialize UI QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); QScrollView *sv = new QScrollView( m_destWidget ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); m_destList = new QListBox( container ); QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) ); m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestSelected(int)) ); layout->addMultiCellWidget( m_destList, 0, 0, 0, 2 ); QPixmap pic; pic.convertFromImage( Resource::loadImage( "new" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); QPushButton *btn = new QPushButton( pic, tr( "New" ), container ); + btn->setMinimumHeight( AppLnk::smallIconSize() ); QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); layout->addWidget( btn, 1, 0 ); pic.convertFromImage( Resource::loadImage( "edit" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_destEditBtn = new QPushButton( pic, tr( "Edit" ), container ); + m_destEditBtn->setMinimumHeight( AppLnk::smallIconSize() ); m_destEditBtn->setEnabled( false ); QWhatsThis::add( m_destEditBtn, tr( "Tap here to edit the entry selected above." ) ); connect( m_destEditBtn, SIGNAL(clicked()), this, SLOT(slotDestEdit()) ); layout->addWidget( m_destEditBtn, 1, 1 ); pic.convertFromImage( Resource::loadImage( "trash" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); m_destDeleteBtn = new QPushButton( pic, tr( "Delete" ), container ); + m_destDeleteBtn->setMinimumHeight( AppLnk::smallIconSize() ); m_destDeleteBtn->setEnabled( false ); QWhatsThis::add( m_destDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); connect( m_destDeleteBtn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); layout->addWidget( m_destDeleteBtn, 1, 2 ); } void OIpkgConfigDlg::initProxyWidget() { m_proxyWidget = new QWidget( this ); // Initialize UI QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); QScrollView *sv = new QScrollView( m_proxyWidget ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); // HTTP proxy server configuration QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); grpbox->layout()->setSpacing( 2 ); grpbox->layout()->setMargin( 4 ); layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); m_proxyHttpServer = new QLineEdit( grpbox ); QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) ); grplayout->addWidget( m_proxyHttpServer ); m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox ); QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) ); grplayout->addWidget( m_proxyHttpActive ); // FTP proxy server configuration grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); grpbox->layout()->setSpacing( 2 ); grpbox->layout()->setMargin( 4 ); layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); grplayout = new QVBoxLayout( grpbox->layout() ); m_proxyFtpServer = new QLineEdit( grpbox ); QWhatsThis::add( m_proxyFtpServer, tr( "Enter the URL address of the FTP proxy server here." ) ); grplayout->addWidget( m_proxyFtpServer ); m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox ); QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) ); grplayout->addWidget( m_proxyFtpActive ); // Proxy server username and password configuration QLabel *label = new QLabel( tr( "Username:" ), container ); QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) ); layout->addWidget( label, 2, 0 ); m_proxyUsername = new QLineEdit( container ); QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) ); layout->addWidget( m_proxyUsername, 2, 1 ); label = new QLabel( tr( "Password:" ), container ); QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) ); layout->addWidget( label, 3, 0 ); m_proxyPassword = new QLineEdit( container ); QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) ); layout->addWidget( m_proxyPassword, 3, 1 ); } void OIpkgConfigDlg::initOptionsWidget() { m_optionsWidget = new QWidget( this ); // Initialize UI QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget ); QScrollView *sv = new QScrollView( m_optionsWidget ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container, 8, 2, 2, 4 ); m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container ); QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) ); layout->addMultiCellWidget( m_optForceDepends, 0, 0, 0, 1 ); m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container ); QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) ); layout->addMultiCellWidget( m_optForceReinstall, 1, 1, 0, 1 ); m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container ); QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) ); layout->addMultiCellWidget( m_optForceRemove, 2, 2, 0, 1 ); m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container ); QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) ); layout->addMultiCellWidget( m_optForceOverwrite, 3, 3, 0, 1 ); QLabel *l = new QLabel( tr( "Information level:" ), container ); QWhatsThis::add( l, tr( "Select information level for Ipkg." ) ); layout->addMultiCellWidget( l, 4, 4, 0, 1 ); m_optVerboseIpkg = new QComboBox( container ); QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) ); m_optVerboseIpkg->insertItem( tr( "Errors only" ) ); m_optVerboseIpkg->insertItem( tr( "Normal messages" ) ); m_optVerboseIpkg->insertItem( tr( "Informative messages" ) ); m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) ); layout->addMultiCellWidget( m_optVerboseIpkg, 5, 5, 0, 1 ); l = new QLabel( tr( "Package source lists directory:" ), container ); QWhatsThis::add( l, tr( "Enter the directory where package source feed information is stored." ) ); layout->addMultiCellWidget( l, 6, 6, 0, 1 ); m_optSourceLists = new QLineEdit( container ); QWhatsThis::add( m_optSourceLists, tr( "Enter the directory where package source feed information is stored." ) ); layout->addWidget( m_optSourceLists, 7, 0 ); QPixmap pic; pic.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); QPushButton *btn = new QPushButton( pic, QString::null, container ); btn->setMaximumWidth( btn->height() ); QWhatsThis::add( btn, tr( "Tap here to select the directory where package source feed information is stored." ) ); connect( btn, SIGNAL(clicked()), this, SLOT(slotOptSelectSourceListsPath()) ); layout->addWidget( btn, 7, 1 ); layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); } void OIpkgConfigDlg::initData() { // Read ipkg configuration (server/destination/proxy) information if ( m_ipkg && !m_installOptions ) { m_configs = m_ipkg->configItems(); if ( m_configs ) { for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt ) { OConfItem *config = configIt.current(); // Add configuration item to the appropriate dialog controls if ( config ) { switch ( config->type() ) { case OConfItem::Source : m_serverList->insertItem( config->name() ); break; case OConfItem::Destination : m_destList->insertItem( config->name() ); break; case OConfItem::Option : { if ( config->name() == "http_proxy" ) { m_proxyHttpServer->setText( config->value() ); m_proxyHttpActive->setChecked( config->active() ); } else if ( config->name() == "ftp_proxy" ) { m_proxyFtpServer->setText( config->value() ); m_proxyFtpActive->setChecked( config->active() ); } else if ( config->name() == "proxy_username" ) { m_proxyUsername->setText( config->value() ); } else if ( config->name() == "proxy_password" ) { m_proxyPassword->setText( config->value() ); } } break; case OConfItem::Other : { if ( config->name() == "lists_dir" ) m_optSourceLists->setText( config->value() ); else // TODO - use proper libipkg define m_optSourceLists->setText( "/usr/lib/ipkg/lists" ); } break; default : break; }; } } } } // Get Ipkg execution options int options = m_ipkg->ipkgExecOptions(); if ( options & FORCE_DEPENDS ) m_optForceDepends->setChecked( true ); if ( options & FORCE_REINSTALL ) m_optForceReinstall->setChecked( true ); if ( options & FORCE_REMOVE ) m_optForceRemove->setChecked( true ); if ( options & FORCE_OVERWRITE ) m_optForceOverwrite->setChecked( true ); m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); } @@ -465,228 +471,230 @@ void OIpkgConfigDlg::slotServerEdit() // Edit server if ( server ) { QString origName = server->name(); OIpkgServerDlg dlg( server, this ); if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { // Check to see if name has changed, if so update the server list if ( server->name() != origName ) m_serverList->changeItem( server->name(), m_serverCurrent ); } } } void OIpkgConfigDlg::slotServerDelete() { // Find selected server in list OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() ); // Delete server if ( server ) { m_configs->removeRef( server ); m_serverList->removeItem( m_serverCurrent ); } } void OIpkgConfigDlg::slotDestSelected( int index ) { m_destCurrent = index; // Enable Edit and Delete buttons m_destEditBtn->setEnabled( true ); m_destDeleteBtn->setEnabled( true ); } void OIpkgConfigDlg::slotDestNew() { OConfItem *dest = new OConfItem( OConfItem::Destination ); OIpkgDestDlg dlg( dest, this ); if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { // Add to configuration option list m_configs->append( dest ); m_configs->sort(); // Add to destination list m_destList->insertItem( dest->name() ); m_destList->setCurrentItem( m_destList->count() ); } else delete dest; } void OIpkgConfigDlg::slotDestEdit() { // Find selected destination in list OConfItem *dest = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() ); // Edit destination if ( dest ) { QString origName = dest->name(); OIpkgDestDlg dlg( dest, this ); if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { // Check to see if name has changed, if so update the dest list if ( dest->name() != origName ) m_destList->changeItem( dest->name(), m_destCurrent ); } } } void OIpkgConfigDlg::slotDestDelete() { // Find selected destination in list OConfItem *destination = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() ); // Delete destination if ( destination ) { m_configs->removeRef( destination ); m_destList->removeItem( m_destCurrent ); } } void OIpkgConfigDlg::slotOptSelectSourceListsPath() { QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_optSourceLists->text() ); if ( path.at( path.length() - 1 ) == '/' ) path.truncate( path.length() - 1 ); if ( !path.isNull() ) m_optSourceLists->setText( path ); } OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent ) : QDialog( parent, QString::null, true, WStyle_ContextHelp ) , m_server( server ) { setCaption( tr( "Edit Server" ) ); // Initialize UI QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 ); m_active = new QCheckBox( tr( "Active" ), this ); QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) ); layout->addWidget( m_active ); layout->addStretch(); QLabel *label = new QLabel( tr( "Name:" ), this ); QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); layout->addWidget( label ); m_name = new QLineEdit( this ); QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) ); layout->addWidget( m_name ); layout->addStretch(); label = new QLabel( tr( "Address:" ), this ); QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) ); layout->addWidget( label ); m_location = new QLineEdit( this ); QWhatsThis::add( m_location, tr( "Enter the URL address of this entry here." ) ); layout->addWidget( m_location ); layout->addStretch(); m_compressed = new QCheckBox( tr( "Compressed server feed" ), this ); QWhatsThis::add( m_compressed, tr( "Tap here to indicate whether the server support compressed archives or not." ) ); layout->addWidget( m_compressed ); // Populate initial information if ( m_server ) { m_name->setText( m_server->name() ); m_location->setText( m_server->value() ); m_compressed->setChecked( m_server->features().contains( "Compressed" ) ); m_active->setChecked( m_server->active() ); } } void OIpkgServerDlg::accept() { // Save information entered QString name = m_name->text(); name.replace( QRegExp( " " ), "_" ); m_server->setName( name ); m_server->setValue( m_location->text() ); m_compressed->isChecked() ? m_server->setFeatures( "Compressed" ) : m_server->setFeatures( QString::null ); m_server->setActive( m_active->isChecked() ); QDialog::accept(); } OIpkgDestDlg::OIpkgDestDlg( OConfItem *dest, QWidget *parent ) : QDialog( parent, QString::null, true, WStyle_ContextHelp ) , m_dest( dest ) { setCaption( tr( "Edit Destination" ) ); // Initialize UI QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 ); m_active = new QCheckBox( tr( "Active" ), this ); QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) ); layout->addWidget( m_active ); layout->addStretch(); QLabel *label = new QLabel( tr( "Name:" ), this ); QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); layout->addWidget( label ); m_name = new QLineEdit( this ); QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) ); layout->addWidget( m_name ); layout->addStretch(); label = new QLabel( tr( "Location:" ), this ); QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) ); layout->addWidget( label ); QHBoxLayout *layout2 = new QHBoxLayout( this, 2, 4 ); layout->addLayout( layout2 ); m_location = new QLineEdit( this ); QWhatsThis::add( m_location, tr( "Enter the absolute directory path of this entry here." ) ); layout2->addWidget( m_location ); - QPushButton *btn = new QPushButton( Resource::loadPixmap( "folder" ), QString::null, this ); + QPixmap pic; + pic.convertFromImage( Resource::loadImage( "folder" ).smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ) ); + QPushButton *btn = new QPushButton( pic, QString::null, this ); btn->setMaximumWidth( btn->height() ); QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) ); connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) ); layout2->addWidget( btn ); // Populate initial information if ( m_dest ) { m_name->setText( m_dest->name() ); m_location->setText( m_dest->value() ); m_active->setChecked( m_dest->active() ); } } void OIpkgDestDlg::accept() { // Save information entered QString name = m_name->text(); name.replace( QRegExp( " " ), "_" ); m_dest->setName( name ); m_dest->setValue( m_location->text() ); m_dest->setActive( m_active->isChecked() ); QDialog::accept(); } void OIpkgDestDlg::slotSelectPath() { QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_location->text() ); if ( path.at( path.length() - 1 ) == '/' ) path.truncate( path.length() - 1 ); if ( !path.isNull() ) m_location->setText( path ); } |