author | ar <ar> | 2004-02-21 16:02:01 (UTC) |
---|---|---|
committer | ar <ar> | 2004-02-21 16:02:01 (UTC) |
commit | db2afda83e495bff9fc19fa14a30072f1cd4c67a (patch) (side-by-side diff) | |
tree | 0281ec10dad24d83179283370661ae9225016de0 | |
parent | 460258f203be746ff79e14f32a823f381b8ea513 (diff) | |
download | opie-db2afda83e495bff9fc19fa14a30072f1cd4c67a.zip opie-db2afda83e495bff9fc19fa14a30072f1cd4c67a.tar.gz opie-db2afda83e495bff9fc19fa14a30072f1cd4c67a.tar.bz2 |
improve support for BigScreen
-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 162 | ||||
-rw-r--r-- | noncore/settings/appearance2/stylelistitem.h | 8 | ||||
-rw-r--r-- | noncore/settings/aqpkg/categoryfilterimpl.cpp | 20 | ||||
-rw-r--r-- | noncore/settings/aqpkg/instoptionsimpl.cpp | 16 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 38 | ||||
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 35 | ||||
-rw-r--r-- | noncore/settings/backup/backuprestore.cpp | 17 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/devices.cpp | 25 | ||||
-rw-r--r-- | noncore/settings/networksettings/ppp/edit.cpp | 233 | ||||
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 16 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 14 | ||||
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 149 |
12 files changed, 462 insertions, 271 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index 9e5eede..ba12e55 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp @@ -1,856 +1,890 @@ /* This file is part of the OPIE Project Copyright (c) 2002 Trolltech AS <info@trolltech.com> =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> .>+-= _;:, .> :=|. 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 "appearance.h" +#include "editScheme.h" +#include "stylelistitem.h" +#include "decolistitem.h" +#include "colorlistitem.h" +#include "exceptlistitem.h" +#include "sample.h" + +/* OPIE */ +#include <opie/ofontselector.h> +#include <opie/odevice.h> +#include <opie/ofiledialog.h> +#include <opie/otabwidget.h> + +#include <qpe/config.h> +#include <qpe/global.h> +#include <qpe/qpeapplication.h> +#include <qpe/qpemessagebox.h> +#include <qpe/qcopenvelope_qws.h> +#include <qpe/qpestyle.h> +#include <qpe/lightstyle.h> +#include <qpe/styleinterface.h> + +/* QT */ #include <qbuttongroup.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qdialog.h> #include <qdir.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistbox.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qradiobutton.h> #if QT_VERSION >= 300 #include <qstylefactory.h> #endif #include <qtoolbutton.h> #include <qwindowsstyle.h> #include <qlistview.h> #include <qheader.h> #include <qvbox.h> #include <qwhatsthis.h> -#include <qpe/config.h> -#include <qpe/global.h> -#include <qpe/resource.h> -#include <qpe/qpeapplication.h> -#include <qpe/qpemessagebox.h> -#include <qpe/qcopenvelope_qws.h> -#include <qpe/qpestyle.h> -#include <qpe/lightstyle.h> -#include <qpe/qlibrary.h> -#include <qpe/styleinterface.h> - -#include <opie/ofontselector.h> -#include <opie/odevice.h> -#include <opie/ofiledialog.h> -#include <opie/otabwidget.h> - -#include "appearance.h" -#include "editScheme.h" -#include "stylelistitem.h" -#include "decolistitem.h" -#include "colorlistitem.h" -#include "exceptlistitem.h" -#include "sample.h" - - using namespace Opie; class DefaultWindowDecoration : public WindowDecorationInterface { public: DefaultWindowDecoration() : ref(0) {} - QString name() const { + QString name() const + { return "Default"; } -QPixmap icon() const { + QPixmap icon() const + { return QPixmap(); } - QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { + QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) + { *iface = 0; if ( uuid == IID_QUnknown ) *iface = this; else if ( uuid == IID_WindowDecoration ) *iface = this; if ( *iface ) (*iface)->addRef(); return QS_OK; } Q_REFCOUNT private: ulong ref; }; QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) { QWidget* tab = new QWidget( parent, "StyleTab" ); QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); m_style_list = new QListBox( tab, "m_style_list" ); vertLayout->addWidget( m_style_list ); QWhatsThis::add( m_style_list, tr( "Styles control the way items such as buttons and scroll bars appear in all applications.\n\nClick here to select an available style." ) ); m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); vertLayout-> addWidget ( m_style_settings ); QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) ); QString s = cfg. readEntry ( "Style", "Light" ); #if QT_VERSION >= 300 m_style_list->insertStringList(QStyleFactory::styles()); #else m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); #endif + { QString path = QPEApplication::qpeDir ( ); path.append( "/plugins/styles/" ); QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); - for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { + for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) + { QString libstr = path; libstr.append( "/" ); libstr.append( *it ); QLibrary *lib = new QLibrary ( libstr ); StyleInterface *iface; - if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) { + if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) + { StyleListItem *slit = new StyleListItem ( lib, iface ); m_style_list-> insertItem ( slit ); if ( slit-> key ( ) == s ) m_style_list-> setCurrentItem ( slit ); } else delete lib; } } m_original_style = m_style_list-> currentItem ( ); styleClicked ( m_original_style ); connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); return tab; } QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) { QWidget* tab = new QWidget( parent, "DecoTab" ); QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); m_deco_list = new QListBox( tab, "m_deco_list" ); vertLayout->addWidget( m_deco_list ); QWhatsThis::add( m_deco_list, tr( "Window decorations control the way the application title bar and its buttons appear.\n\nClick here to select an available decoration." ) ); QString s = cfg. readEntry ( "Decoration", "libflat.so" ); m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); { QString path = QPEApplication::qpeDir(); path.append( "/plugins/decorations/" ); QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); - for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { + for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) + { QString libstr = path; libstr.append( "/" ); libstr.append( *it ); QLibrary *lib = new QLibrary ( libstr ); WindowDecorationInterface *iface; - if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) { + if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) + { DecoListItem *dlit = new DecoListItem ( lib, iface ); m_deco_list-> insertItem ( dlit ); if ( dlit-> key ( ) == s ) m_deco_list-> setCurrentItem ( dlit ); } else delete lib; } } m_original_deco = m_deco_list-> currentItem ( ); if ( m_deco_list-> currentItem ( ) < 0 ) m_deco_list-> setCurrentItem ( 0 ); decoClicked ( m_original_deco ); connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); return tab; } QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) { QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); int size = cfg. readNumEntry ( "FontSize", 10 ); m_fontselect = new OFontSelector ( false, parent, "FontTab" ); m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), this, SLOT( fontClicked ( const QFont & ))); return m_fontselect; } QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) { QWidget *tab = new QWidget( parent, "ColorTab" ); QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); gridLayout->setRowStretch ( 3, 10 ); m_color_list = new QListBox ( tab ); gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); QWhatsThis::add( m_color_list, tr( "Color schemes are a collection of colors which are used for various parts of the display.\n\nClick here to select an available scheme." ) ); m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); QString path = QPEApplication::qpeDir ( ); path.append( "/etc/colors/" ); QStringList sl = QDir ( path ). entryList ( "*.scheme" ); - for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { + for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) + { QString name = (*it). left ((*it). find ( ".scheme" )); QString pathstr = path; pathstr.append( *it ); Config config ( pathstr, Config::File ); config. setGroup ( "Colors" ); m_color_list-> insertItem ( new ColorListItem ( name, config )); } m_color_list-> setCurrentItem ( 0 ); QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); tempButton->setText( tr( "Edit..." ) ); connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); gridLayout->addWidget( tempButton, 0, 1 ); QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); tempButton = new QPushButton( tab, "deleteSchemeButton" ); tempButton->setText( tr( "Delete" ) ); connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); gridLayout->addWidget( tempButton, 1, 1 ); QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); tempButton = new QPushButton( tab, "saveSchemeButton" ); tempButton->setText( tr( "Save" ) ); connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); gridLayout->addWidget( tempButton, 2, 1 ); QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); return tab; } QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) { QWidget *tab = new QWidget ( parent ); QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) ); QLabel *l = new QLabel ( tab ); l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); QWhatsThis::add( l, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); m_except = new QListView ( tab ); m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 ); m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 ); m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 ); m_except-> addColumn ( tr( "Binary file(s)" )); m_except-> setColumnAlignment ( 0, AlignCenter ); m_except-> setColumnAlignment ( 1, AlignCenter ); m_except-> setColumnAlignment ( 2, AlignCenter ); m_except-> setAllColumnsShowFocus ( true ); m_except-> setMinimumHeight ( 30 ); m_except-> header ( )-> setClickEnabled ( false ); m_except-> header ( )-> setResizeEnabled ( false ); m_except-> header ( )-> setMovingEnabled ( false ); m_except-> setSorting ( -1 ); lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); QWhatsThis::add( m_except, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int ))); QToolButton *tb = new QToolButton ( tab ); tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); tb-> setFocusPolicy ( QWidget::StrongFocus ); lay-> addWidget ( tb, 2, 1 ); connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( ))); QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) ); tb = new QToolButton ( tab ); tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); tb-> setFocusPolicy ( QWidget::StrongFocus ); lay-> addWidget ( tb, 3, 1 ); connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( ))); QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) ); tb = new QToolButton ( tab ); tb-> setIconSet ( Resource::loadIconSet ( "up" )); tb-> setFocusPolicy ( QWidget::StrongFocus ); lay-> addWidget ( tb, 4, 1 ); connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( ))); QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) ); tb = new QToolButton ( tab ); tb-> setIconSet ( Resource::loadIconSet ( "down" )); tb-> setFocusPolicy ( QWidget::StrongFocus ); lay-> addWidget ( tb, 5, 1 ); connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); lay-> setRowStretch ( 6, 10 ); lay-> setColStretch ( 0, 10 ); QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); QListViewItem *lvit = 0; - for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { + for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) + { int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); } vertLayout-> addSpacing ( 3 ); QFrame *f = new QFrame ( tab ); f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); vertLayout-> addWidget ( f ); vertLayout-> addSpacing ( 3 ); QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); QLabel* label = new QLabel( tr( "Tab style:" ), tab ); gridLayout-> addWidget ( label, 0, 0 ); QWhatsThis::add( label, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); btngrp-> hide ( ); btngrp-> setExclusive ( true ); m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); m_tabstyle_list-> insertItem ( tr( "Tabs" )); m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); m_tabstyle_list-> insertItem ( tr( "Drop down list" )); m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); m_tabstyle_list-> setCurrentItem ( style ); gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); QWhatsThis::add( m_tabstyle_list, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); btngrp-> insert ( m_tabstyle_top ); gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); btngrp-> insert ( m_tabstyle_bottom ); gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); m_tabstyle_top-> setChecked ( tabtop ); m_tabstyle_bottom-> setChecked ( !tabtop ); m_original_tabstyle = style; m_original_tabpos = tabtop; vertLayout-> addSpacing ( 3 ); QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 ); QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab ); m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" ); QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( ); m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" ); QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 ); QPixmap ccw1; m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" ); QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( ); QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" ); rotbtngrp-> hide ( ); rotbtngrp-> setExclusive ( true ); rotbtngrp-> insert ( m_rotdir_cw ); rotbtngrp-> insert ( m_rotdir_ccw ); rotbtngrp-> insert ( m_rotdir_flip ); ccw1. convertFromImage( ccwImage ); m_rotdir_cw-> setPixmap( cw1 ); m_rotdir_ccw-> setPixmap( ccw1 ); m_rotdir_flip-> setPixmap( flip1 ); rotLay-> addWidget ( rotlabel, 0 ); rotLay-> addWidget ( m_rotdir_cw, 0 ); rotLay-> addWidget ( m_rotdir_ccw, 0 ); rotLay-> addWidget ( m_rotdir_flip, 0 ); int rotDirection = cfg.readNumEntry( "rotatedir" ); ODirection rot = CW; - if (rotDirection == -1) { + if (rotDirection == -1) + { rot = ODevice::inst ( )-> direction ( ); - } else { + } + else + { rot = (ODirection)rotDirection; } m_rotdir_cw-> setChecked ( rot == CW ); m_rotdir_ccw-> setChecked ( rot == CCW ); m_rotdir_flip-> setChecked ( rot == Flip ); return tab; } Appearance::Appearance( QWidget* parent, const char* name, WFlags ) : QDialog ( parent, name, true, WStyle_ContextHelp ) { setCaption( tr( "Appearance Settings" ) ); Config config( "qpe" ); config.setGroup( "Appearance" ); QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); m_sample = new SampleWindow ( this ); m_sample-> setDecoration ( new DefaultWindowDecoration ( ) ); QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); QWidget *styletab; m_color_list = 0; tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); top-> addWidget ( tw, 10 ); top-> addWidget ( m_sample, 1 ); tw-> setCurrentTab ( styletab ); connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; } Appearance::~Appearance() -{ -} +{} void Appearance::tabChanged ( QWidget *w ) { - if ( w == m_advtab ) { + if ( w == m_advtab ) + { m_sample-> hide ( ); updateGeometry ( ); // shouldn't be necessary ... } else m_sample-> show ( ); } void Appearance::accept ( ) { bool newtabpos = m_tabstyle_top-> isChecked ( ); int newtabstyle = m_tabstyle_list-> currentItem ( ); Config config ( "qpe" ); config. setGroup ( "Appearance" ); - if ( m_style_changed ) { + if ( m_style_changed ) + { StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); if ( item ) config.writeEntry( "Style", item-> key ( )); } - if ( m_deco_changed ) { + if ( m_deco_changed ) + { DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); if ( item ) config.writeEntry( "Decoration", item-> key ( )); } - if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { + if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) + { config. writeEntry ( "TabStyle", newtabstyle + 1 ); config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); } - if ( m_font_changed ) { + if ( m_font_changed ) + { config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); } if ( m_color_changed ) { ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); if ( item ) item-> save ( config ); } ODirection rot; - if (m_rotdir_ccw-> isChecked ( )) { + if (m_rotdir_ccw-> isChecked ( )) + { rot = CCW; - } else if (m_rotdir_cw-> isChecked ( )) { + } + else if (m_rotdir_cw-> isChecked ( )) + { rot = CW; - } else { + } + else + { rot = Flip; } config. writeEntry ( "rotatedir", (int)rot ); m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated QStringList sl; QString exceptstr; - for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { + for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) + { int fl = 0; fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); fl |= ( it-> noFont ( ) ? 0x02 : 0 ); fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); exceptstr = QString::number ( fl, 32 ); exceptstr.append( it-> pattern ( )); sl << exceptstr; } config. writeEntry ( "NoStyle", sl, ';' ); config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); config. write ( ); // need to flush the config info first Global::applyStyle ( ); QDialog::accept ( ); } void Appearance::done ( int r ) { QDialog::done ( r ); close ( ); } void Appearance::styleClicked ( int index ) { StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); - if ( m_sample && sli && sli-> style ( )) { + if ( m_sample && sli && sli-> style ( )) + { int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); } m_style_changed |= ( index != m_original_style ); } void Appearance::styleSettingsClicked ( ) { StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); - if ( item && item-> hasSettings ( )) { + if ( item && item-> hasSettings ( )) + { QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); QWidget *w = item-> settings ( d ); - if ( w ) { + if ( w ) + { vbox-> addWidget ( w ); d-> setCaption ( w-> caption ( )); - d-> showMaximized ( ); - bool accepted = ( d-> exec ( ) == QDialog::Accepted ); + bool accepted = ( QPEApplication::execDialog ( d ) == QDialog::Accepted ); if ( item-> setSettings ( accepted )) m_style_changed = true; } delete d; } } void Appearance::decoClicked ( int index ) { DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); - if ( m_sample ) { + if ( m_sample ) + { if ( dli && dli-> interface ( )) m_sample-> setDecoration ( dli-> interface ( )); else m_sample-> setDecoration ( new DefaultWindowDecoration ( )); m_sample-> repaint ( ); } m_deco_changed |= ( index != m_original_deco ); } void Appearance::fontClicked ( const QFont &f ) { m_font_changed |= ( f != m_sample-> font ( )); m_sample-> setFont ( f ); } void Appearance::colorClicked ( int index ) { ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); if ( item ) m_sample-> setPalette ( item-> palette ( )); m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); } void Appearance::editSchemeClicked ( ) { ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); int cnt = 0; QString labels [QColorGroup::NColorRoles]; QColor colors [QColorGroup::NColorRoles]; - for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { + for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) + { QColor col = item-> color ( role ); - if ( col. isValid ( )) { + if ( col. isValid ( )) + { labels [cnt] = item-> label ( role ); colors [cnt] = col; cnt++; } } EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); - editdlg-> showMaximized ( ); - if ( editdlg-> exec ( ) == QDialog::Accepted ) { + if ( QPEApplication::execDialog( editdlg ) == QDialog::Accepted ) + { ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); cnt = 0; - for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { - if ( item-> color ( role ). isValid ( )) { + for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) + { + if ( item-> color ( role ). isValid ( )) + { citem-> setColor ( role, colors [cnt] ); cnt++; } } m_color_list-> setCurrentItem ( 0 ); colorClicked ( 0 ); m_color_changed = true; } delete editdlg; } void Appearance::saveSchemeClicked() { ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); if ( !item ) return; QDialog *d = new QDialog ( this, 0, true ); d-> setCaption ( tr( "Save Scheme" )); QLineEdit *ed = new QLineEdit ( d ); ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); ed-> setFocus ( ); - if ( d-> exec ( ) == QDialog::Accepted ) { + if ( d-> exec ( ) == QDialog::Accepted ) + { QString schemename = ed-> text ( ); QString filestr = QPEApplication::qpeDir(); filestr.append( "/etc/colors/" ); filestr.append( schemename ); filestr.append( ".scheme" ); QFile file ( filestr ); if ( !file. exists ( )) { QPalette p = item-> palette ( ); Config config ( file.name(), Config::File ); config. setGroup( "Colors" ); item-> save ( config ); config. write ( ); // need to flush the config info first m_color_list-> insertItem ( new ColorListItem ( schemename, config )); } else { QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); } } delete d; } void Appearance::deleteSchemeClicked() { ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); if ( !item ) return; if ( m_color_list-> currentItem ( ) > 0 ) { if ( QPEMessageBox::confirmDelete ( this, tr( "Delete scheme" ), item-> text ( ) ) ) { QString filestr = QPEApplication::qpeDir ( ); filestr.append( "/etc/colors/" ); filestr.append( item-> text ( ) ); filestr.append( ".scheme" ); QFile::remove ( filestr ); delete item; } } else { QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); } } void Appearance::addExcept ( ) { ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true ); m_except-> ensureItemVisible ( it ); m_except-> setSelected ( it, true ); } void Appearance::delExcept ( ) { - if ( m_except-> selectedItem ( )) { + if ( m_except-> selectedItem ( )) + { m_except-> setFocus ( ); delete m_except-> selectedItem ( ); } } void Appearance::upExcept ( ) { ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); if ( it && it-> itemAbove ( )) it-> itemAbove ( )-> moveItem ( it ); } void Appearance::downExcept ( ) { ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); if ( it && it-> itemBelow ( )) it-> moveItem ( it-> itemBelow ( )); } -class ExEdit : public QLineEdit { +class ExEdit : public QLineEdit +{ public: ExEdit ( ExceptListItem *item ) : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) { setFrame ( false ); QRect r = it-> listView ( )-> itemRect ( it ); int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; int y = r. y ( ); int w = it-> listView ( )-> viewport ( )-> width ( ) - x; int h = r. height ( ); // + 2; setText ( it-> pattern ( )); setGeometry ( x, y, w, h ); qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); m_out = true; show ( ); setFocus ( ); selectAll ( ); end ( true ); } virtual void focusOutEvent ( QFocusEvent * ) { hide ( ); if ( m_out ) it-> setPattern ( text ( )); delete this; } virtual void keyPressEvent ( QKeyEvent *e ) { if ( e-> key ( ) == Key_Return ) it-> listView ( )-> setFocus ( ); - else if ( e-> key ( ) == Key_Escape ) { + else if ( e-> key ( ) == Key_Escape ) + { m_out = false; it-> listView ( )-> setFocus ( ); } else QLineEdit::keyPressEvent ( e ); } private: ExceptListItem *it; bool m_out; }; void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c ) { if ( !item || c < 0 || c > 3 ) return; ExceptListItem *it = (ExceptListItem *) item; if ( c == 0 ) it-> setNoStyle ( !it-> noStyle ( )); else if ( c == 1 ) it-> setNoFont ( !it-> noFont ( )); else if ( c == 2 ) it-> setNoDeco ( !it-> noDeco ( )); - else if ( c == 3 ) { + else if ( c == 3 ) + { m_except-> ensureItemVisible ( it ); new ExEdit ( it ); } } diff --git a/noncore/settings/appearance2/stylelistitem.h b/noncore/settings/appearance2/stylelistitem.h index caefad8..b6c72c3 100644 --- a/noncore/settings/appearance2/stylelistitem.h +++ b/noncore/settings/appearance2/stylelistitem.h @@ -1,112 +1,118 @@ /* =. This file is part of the OPIE Project .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> .>+-= _;:, .> :=|. 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 STYLELISTITEM_H #define STYLELISTITEM_H -#include <qlistbox.h> +/* OPIE */ #include <qpe/styleinterface.h> +#include <qpe/qlibrary.h> +#include <qpe/resource.h> + +/* QT */ +#include <qlistbox.h> +#include <qfileinfo.h> #include <stdio.h> class StyleListItem : public QListBoxText { public: StyleListItem ( const QString &t, QStyle *sty ) : QListBoxText ( t ) { m_lib = 0; m_style_if = 0; m_settings_if = 0; m_style = sty; } StyleListItem ( QLibrary *lib, StyleInterface *iface ) : QListBoxText ( iface-> name ( )) { m_lib = lib; m_style_if = iface; m_settings_if = 0; m_style = iface-> style ( ); iface-> queryInterface ( IID_StyleExtended, (QUnknownInterface **) &m_settings_if ); } virtual ~StyleListItem ( ) { delete m_style; if ( m_settings_if ) m_settings_if-> release ( ); if ( m_style_if ) m_style_if-> release ( ); delete m_lib; } bool hasSettings ( ) const { return m_settings_if ? m_settings_if-> hasSettings ( ) : false; } QWidget *settings ( QWidget *parent ) { return m_settings_if ? m_settings_if-> create ( parent ) : 0; } bool setSettings ( bool accepted ) { if ( !m_settings_if ) return false; if ( accepted ) return m_settings_if-> accept ( ); else { m_settings_if-> reject ( ); return false; } } QString key ( ) { if ( m_lib ) return QFileInfo ( m_lib-> library ( )). fileName ( ); else return text ( ); } QStyle *style ( ) { return m_style; } private: QLibrary *m_lib; QStyle *m_style; StyleInterface *m_style_if; StyleExtendedInterface *m_settings_if; }; #endif diff --git a/noncore/settings/aqpkg/categoryfilterimpl.cpp b/noncore/settings/aqpkg/categoryfilterimpl.cpp index 61e1f93..217d2c9 100644 --- a/noncore/settings/aqpkg/categoryfilterimpl.cpp +++ b/noncore/settings/aqpkg/categoryfilterimpl.cpp @@ -1,107 +1,113 @@ /* This file is part of the OPIE Project =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> .=l. Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. 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 <iostream> -using namespace std; +#include "categoryfilterimpl.h" +/* OPIE */ +#include <qpe/qpeapplication.h> + +/* QT */ #include <qgroupbox.h> #include <qlayout.h> #include <qlistbox.h> #include <qstring.h> -#include "categoryfilterimpl.h" +/* STD */ +#include <iostream> +using namespace std; + CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QString &selectedCategories, QWidget *parent, const char *name ) : QDialog( parent, name, true ) { setCaption( tr( "Category Filter" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Select one or more groups" ), this ); grpbox->layout()->setSpacing( 2 ); grpbox->layout()->setMargin( 4 ); layout->addWidget( grpbox ); QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); lstCategories = new QListBox( grpbox ); lstCategories->setSelectionMode( QListBox::Multi ); grplayout->addWidget( lstCategories ); // Split up categories and add them to the listbox int start = 1; QString item; int end; QString finditem; do { end = categories.find( "#", start ); item = categories.mid( start, end - start ); if ( item != "" ) { lstCategories->insertItem( item ); finditem = QString( "#%1#" ).arg( item ); if ( selectedCategories.find( finditem ) != -1 ) lstCategories->setSelected( lstCategories->count()-1, true ); } start = end + 1; - } while ( start < (int)categories.length() ); + } + while ( start < (int)categories.length() ); lstCategories->sort( true ); - showMaximized(); + QPEApplication::showDialog( this ); } CategoryFilterImpl :: ~CategoryFilterImpl() -{ -} +{} QString CategoryFilterImpl :: getSelectedFilter() { // Grab cetegories from listbox QString ret = "#"; for ( int i = 0 ; i < (int)lstCategories->count() ; ++i ) { if ( lstCategories->isSelected( i ) ) { ret.append( lstCategories->text( i ) ); ret.append( "#" ); } } if ( ret == "#" ) ret = ""; return ret; } diff --git a/noncore/settings/aqpkg/instoptionsimpl.cpp b/noncore/settings/aqpkg/instoptionsimpl.cpp index 9d52013..126e3b9 100644 --- a/noncore/settings/aqpkg/instoptionsimpl.cpp +++ b/noncore/settings/aqpkg/instoptionsimpl.cpp @@ -1,128 +1,130 @@ /* This file is part of the OPIE Project =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> .=l. Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. 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 "global.h" +#include "instoptionsimpl.h" +#include "ipkg.h" + +/* OPIE */ #ifdef QWS #include <qpe/config.h> #endif +#include <qpe/qpeapplication.h> +/* QT */ #include <qcheckbox.h> #include <qcombobox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlayout.h> -#include "global.h" -#include "instoptionsimpl.h" -#include "ipkg.h" - InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { setCaption( tr( "Options" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Options" ), this ); grpbox->layout()->setSpacing( 2 ); grpbox->layout()->setMargin( 4 ); layout->addWidget( grpbox ); QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); forceDepends = new QCheckBox( tr( "Force Depends" ), grpbox ); grplayout->addWidget( forceDepends ); forceReinstall = new QCheckBox( tr( "Force Reinstall" ), grpbox ); grplayout->addWidget( forceReinstall ); forceRemove = new QCheckBox( tr( "Force Remove" ), grpbox ); grplayout->addWidget( forceRemove ); forceOverwrite = new QCheckBox( tr( "Force Overwrite" ), grpbox ); grplayout->addWidget( forceOverwrite ); QLabel *l = new QLabel( tr( "Information Level" ), grpbox ); grplayout->addWidget( l ); verboseIpkg = new QComboBox( grpbox ); verboseIpkg->insertItem( tr( "Errors only" ) ); verboseIpkg->insertItem( tr( "Normal messages" ) ); verboseIpkg->insertItem( tr( "Informative messages" ) ); verboseIpkg->insertItem( tr( "Troubleshooting output" ) ); verboseIpkg->setCurrentItem( verb ); grplayout->addWidget( verboseIpkg ); grplayout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); if ( flags & FORCE_DEPENDS ) forceDepends->setChecked( true ); if ( flags & FORCE_REINSTALL ) forceReinstall->setChecked( true ); if ( flags & FORCE_REMOVE ) forceRemove->setChecked( true ); if ( flags & FORCE_OVERWRITE ) forceOverwrite->setChecked( true ); // if ( flags & VERBOSE_WGET ) // verboseWget->setChecked( true ); // if ( flags & MAKE_LINKS ) // makeLinks->setChecked( true ); - showMaximized(); + QPEApplication::showDialog( this ); } InstallOptionsDlgImpl::~InstallOptionsDlgImpl() -{ -} +{} int InstallOptionsDlgImpl :: getFlags() { int flags = 0; if ( forceDepends->isChecked() ) flags |= FORCE_DEPENDS; if ( forceReinstall->isChecked() ) flags |= FORCE_REINSTALL; if ( forceRemove->isChecked() ) flags |= FORCE_REMOVE; if ( forceOverwrite->isChecked() ) flags |= FORCE_OVERWRITE; if ( verboseWget->isChecked() ) flags |= VERBOSE_WGET; return flags; } int InstallOptionsDlgImpl :: getInfoLevel() { return verboseIpkg->currentItem(); } diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index dbe694e..6f5c712 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp @@ -1,257 +1,260 @@ /* This file is part of the OPIE Project =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> .=l. Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. 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 <linux/limits.h> -#include <unistd.h> +#include "categoryfilterimpl.h" +#include "datamgr.h" +#include "global.h" +#include "inputdlg.h" +#include "ipkg.h" +#include "installdlgimpl.h" +#include "letterpushbutton.h" +#include "mainwin.h" +#include "packagewin.h" +#include "settingsimpl.h" +#include "utils.h" +/* OPIE */ #include <qpe/qcopenvelope_qws.h> -#include <qmenubar.h> #include <qpe/qpeapplication.h> -#include <qtoolbar.h> #include <qpe/config.h> #include <qpe/resource.h> +/* QT */ +#include <qmenubar.h> +#include <qtoolbar.h> #include <qaction.h> #include <qcombobox.h> #include <qfile.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistview.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qprogressbar.h> #include <qtimer.h> #include <qwhatsthis.h> #include <qwidgetstack.h> -#include "categoryfilterimpl.h" -#include "datamgr.h" -#include "global.h" -#include "inputdlg.h" -#include "ipkg.h" -#include "installdlgimpl.h" -#include "letterpushbutton.h" -#include "mainwin.h" -#include "packagewin.h" -#include "settingsimpl.h" -#include "utils.h" +/* STD */ +#include <linux/limits.h> +#include <unistd.h> extern int compareVersions( const char *v1, const char *v2 ); MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl || WStyle_ContextHelp ) { // Disable suspend mode QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; LOCAL_SERVER = QObject::tr( "Installed packages" ); LOCAL_IPKGS = QObject::tr( "Local packages" ); setCaption( tr( "AQPkg - Package Manager" ) ); // Create UI widgets initMainWidget(); initProgressWidget(); // Build menu and tool bars setToolBarsMovable( FALSE ); QToolBar *bar = new QToolBar( this ); bar->setHorizontalStretchable( TRUE ); QMenuBar *mb = new QMenuBar( bar ); mb->setMargin( 0 ); bar = new QToolBar( this ); // Find toolbar findBar = new QToolBar( this ); addToolBar( findBar, QMainWindow::Top, true ); findBar->setHorizontalStretchable( true ); findEdit = new QLineEdit( findBar ); QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); findBar->setStretchableWidget( findEdit ); connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); // Quick jump toolbar jumpBar = new QToolBar( this ); addToolBar( jumpBar, QMainWindow::Top, true ); jumpBar->setHorizontalStretchable( true ); QWidget *w = new QWidget( jumpBar ); jumpBar->setStretchableWidget( w ); QGridLayout *layout = new QGridLayout( w ); char text[2]; text[1] = '\0'; for ( int i = 0 ; i < 26 ; ++i ) { text[0] = 'A' + i; LetterPushButton *b = new LetterPushButton( text, w ); connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); layout->addWidget( b, i / 13, i % 13); } QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); a->addTo( jumpBar ); jumpBar->hide(); // Packages menu QPopupMenu *popup = new QPopupMenu( this ); a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); a->addTo( popup ); a->addTo( bar ); actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); actionUpgrade->addTo( popup ); actionUpgrade->addTo( bar ); iconDownload = Resource::loadPixmap( "aqpkg/download" ); iconRemove = Resource::loadPixmap( "aqpkg/remove" ); actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); actionDownload->addTo( popup ); actionDownload->addTo( bar ); a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); a->addTo( popup ); a->addTo( bar ); popup->insertSeparator(); a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to configure this application." ) ); connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); a->addTo( popup ); mb->insertItem( tr( "Actions" ), popup ); // View menu popup = new QPopupMenu( this ); actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); actionUninstalled->setToggleAction( TRUE ); actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); actionUninstalled->addTo( popup ); actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); actionInstalled->setToggleAction( TRUE ); actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); actionInstalled->addTo( popup ); actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); actionUpdated->setToggleAction( TRUE ); actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); actionUpdated->addTo( popup ); popup->insertSeparator(); actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); actionFilter->setToggleAction( TRUE ); actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); actionFilter->addTo( popup ); a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); a->addTo( popup ); popup->insertSeparator(); a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to search for text in package names." ) ); connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); a->addTo( popup ); actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); actionFindNext->setEnabled( FALSE ); actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); actionFindNext->addTo( popup ); actionFindNext->addTo( findBar ); popup->insertSeparator(); a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); a->addTo( popup ); mb->insertItem( tr( "View" ), popup ); // Finish find toolbar creation a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); a->addTo( findBar ); findBar->hide(); // Create widget stack and add UI widgets stack = new QWidgetStack( this ); stack->addWidget( progressWindow, 2 ); stack->addWidget( networkPkgWindow, 1 ); setCentralWidget( stack ); stack->raiseWidget( progressWindow ); // Delayed call to finish initialization QTimer::singleShot( 100, this, SLOT( init() ) ); } MainWindow :: ~MainWindow() { delete mgr; // Reenable suspend mode QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; } void MainWindow :: initMainWidget() { networkPkgWindow = new QWidget( this ); QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); serversList = new QComboBox( networkPkgWindow ); connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); @@ -992,249 +995,250 @@ void MainWindow :: applyChanges() } // decide what to do - either remove, upgrade or install // Current rules: // If not installed - install // If installed and different version available - upgrade // If installed and version up to date - remove InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) { QString name = item->text(); // Get package Server *s = mgr->getServer( serversList->currentText() ); Package *p = s->getPackage( name ); // If the package has a filename then it is a local file if ( p->isPackageStoredLocally() ) name = p->getFilename(); QString option; QString dest = "root"; if ( !p->isInstalled() ) { InstallData *newitem = new InstallData(); newitem->option = "I"; newitem->packageName = name; return newitem; } else { InstallData *newitem = new InstallData(); newitem->option = "D"; // If local file, remove using package name, not filename if ( p->isPackageStoredLocally() ) name = item->text(); if ( !p->isPackageStoredLocally() ) newitem->packageName = p->getInstalledPackageName(); else newitem->packageName = name; if ( p->getInstalledTo() ) { newitem->destination = p->getInstalledTo(); } else { newitem->destination = p->getLocalPackage()->getInstalledTo(); } // Now see if version is newer or not int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); // If the version requested is older and user selected a local ipk file, then reinstall the file if ( p->isPackageStoredLocally() && val == -1 ) val = 0; if ( val == -2 ) { // Error - should handle } else if ( val == -1 ) { // Version available is older - remove only newitem->option = "D"; // If local file, remove using package name, not filename if ( p->isPackageStoredLocally() ) name = item->text(); } else { QString caption; QString text; QString secondButton; QString secondOption; if ( val == 0 ) { // Version available is the same - option to remove or reinstall caption = tr( "Do you wish to remove or reinstall\n%1?" ); text = tr( "Remove or ReInstall" ); secondButton = tr( "ReInstall" ); secondOption = "R"; // Internal action code, do not translate } else if ( val == 1 ) { // Version available is newer - option to remove or upgrade caption = tr( "Do you wish to remove or upgrade\n%1?" ); text = tr( "Remove or Upgrade" ); secondButton = tr( "Upgrade" ); secondOption = "U"; // Internal action code, do not translate } // Sticky option not implemented yet, but will eventually allow // the user to say something like 'remove all' if ( stickyOption == "" ) { QString msgtext; msgtext = caption.arg( ( const char * )name ); QuestionDlg dlg( text, msgtext, secondButton ); switch( dlg.exec() ) { case 0: // Cancel delete newitem; return 0x0; break; case 1: // Remove newitem->option = "D"; // If local file, remove using package name, not filename if ( p->isPackageStoredLocally() ) name = item->text(); break; case 2: // Reinstall or Upgrade newitem->option = secondOption; break; } } else { // newitem->option = stickyOption; } } // Check if we are reinstalling the same version if ( newitem->option != "R" ) newitem->recreateLinks = true; else newitem->recreateLinks = false; // User hit cancel (on dlg - assume remove) return newitem; } } void MainWindow :: reloadData( InstallDlgImpl *dlg ) { stack->raiseWidget( progressWindow ); if ( dlg ) { dlg->close(); delete dlg; } mgr->reloadServerData(); serverSelected( -1, FALSE ); #ifdef QWS if ( reloadDocuments ) { m_status->setText( tr( "Updating Launcher..." ) ); // Finally let the main system update itself QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; } #endif stack->raiseWidget( networkPkgWindow ); } void MainWindow :: letterPushed( QString t ) { QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); if ( packagesList->firstChild() == 0 ) return; QCheckListItem *item; if ( start == 0 ) { item = (QCheckListItem *)packagesList->firstChild(); start = top; } else item = (QCheckListItem *)start->nextSibling(); if ( item == 0 ) item = (QCheckListItem *)packagesList->firstChild(); do { if ( item->text().lower().startsWith( t.lower() ) ) { packagesList->setSelected( item, true ); packagesList->ensureItemVisible( item ); break; } item = (QCheckListItem *)item->nextSibling(); if ( !item ) item = (QCheckListItem *)packagesList->firstChild(); - } while ( item != start); + } + while ( item != start); } void MainWindow :: slotDisplayPackage( QListViewItem *item ) { QString itemstr( ((QCheckListItem*)item)->text() ); PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); - p->showMaximized(); + QPEApplication::showWidget( p ); } QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) { setCaption( caption ); resize( 175, 100 ); QGridLayout *layout = new QGridLayout( this ); QLabel *l = new QLabel( text, this ); l->setAlignment( AlignCenter | WordBreak ); layout->addMultiCellWidget( l, 0, 0, 0, 1 ); btn1 = new QPushButton( tr( "Remove" ), this ); connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); layout->addWidget( btn1, 1, 0 ); btn2 = new QPushButton( secondbtn, this ); connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); layout->addWidget( btn2, 1, 1 ); executing = FALSE; } int QuestionDlg::exec() { show(); if ( !executing ) { executing = TRUE; qApp->enter_loop(); } return buttonpressed; } void QuestionDlg::slotButtonPressed() { if ( sender() == btn1 ) buttonpressed = 1; else if ( sender() == btn2 ) buttonpressed = 2; else buttonpressed = 0; qApp->exit_loop(); } diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp index 4887ceb..9fdf31e 100644 --- a/noncore/settings/aqpkg/settingsimpl.cpp +++ b/noncore/settings/aqpkg/settingsimpl.cpp @@ -1,493 +1,494 @@ /* This file is part of the OPIE Project =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> .=l. Dan Williams <drw@handhelds.org> .>+-= _;:, .> :=|. 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 <fstream> -#include <algorithm> -using namespace std; +#include "settingsimpl.h" +#include "global.h" + +/* OPIE */ +#include <opie/otabwidget.h> +#ifdef QWS +#include <qpe/config.h> +#include <qpe/resource.h> +#endif +#include <qpe/qpeapplication.h> +/* QT */ #include <qcheckbox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qlistbox.h> #include <qpushbutton.h> -#include <opie/otabwidget.h> - -#ifdef QWS -#include <qpe/config.h> -#include <qpe/resource.h> -#endif - -#include "settingsimpl.h" - -#include "global.h" +/* STD */ +#include <fstream> +#include <algorithm> +using namespace std; SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { setCaption( tr( "Configuration" ) ); // Setup layout to make everything pretty QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); // Setup tabs for all info OTabWidget *tabwidget = new OTabWidget( this ); layout->addWidget( tabwidget ); tabwidget->addTab( initServerTab(), "aqpkg/servertab", tr( "Servers" ) ); tabwidget->addTab( initDestinationTab(), "aqpkg/desttab", tr( "Destinations" ) ); tabwidget->addTab( initProxyTab(), "aqpkg/proxytab", tr( "Proxies" ) ); tabwidget->setCurrentTab( tr( "Servers" ) ); dataMgr = dataManager; setupData(); changed = false; newserver = false; newdestination = false; } SettingsImpl :: ~SettingsImpl() { - } bool SettingsImpl :: showDlg() { - showMaximized(); - exec(); - + QPEApplication::execDialog( this ); if ( changed ) dataMgr->writeOutIpkgConf(); return changed; } QWidget *SettingsImpl :: initServerTab() { QWidget *control = new QWidget( this ); QVBoxLayout *vb = new QVBoxLayout( control ); QScrollView *sv = new QScrollView( control ); 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 ); layout->setSpacing( 2 ); layout->setMargin( 4 ); servers = new QListBox( container ); servers->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); connect( servers, SIGNAL( highlighted( int ) ), this, SLOT( editServer( int ) ) ); layout->addMultiCellWidget( servers, 0, 0, 0, 1 ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); connect( btn, SIGNAL( clicked() ), this, SLOT( newServer() ) ); layout->addWidget( btn, 1, 0 ); btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); connect( btn, SIGNAL( clicked() ), this, SLOT( removeServer() ) ); layout->addWidget( btn, 1, 1 ); QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); grpbox->layout()->setSpacing( 2 ); grpbox->layout()->setMargin( 4 ); layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); QLabel *label = new QLabel( tr( "Name:" ), grpbox ); grplayout->addWidget( label, 0, 0 ); servername = new QLineEdit( grpbox ); grplayout->addWidget( servername, 0, 1 ); label = new QLabel( tr( "Address:" ), grpbox ); grplayout->addWidget( label, 1, 0 ); serverurl = new QLineEdit( grpbox ); grplayout->addWidget( serverurl, 1, 1 ); active = new QCheckBox( tr( "Active Server" ), grpbox ); grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); connect( btn, SIGNAL( clicked() ), this, SLOT( changeServerDetails() ) ); grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); return control; } QWidget *SettingsImpl :: initDestinationTab() { QWidget *control = new QWidget( this ); QVBoxLayout *vb = new QVBoxLayout( control ); QScrollView *sv = new QScrollView( control ); 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 ); layout->setSpacing( 2 ); layout->setMargin( 4 ); destinations = new QListBox( container ); destinations->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); connect( destinations, SIGNAL( highlighted( int ) ), this, SLOT( editDestination( int ) ) ); layout->addMultiCellWidget( destinations, 0, 0, 0, 1 ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); connect( btn, SIGNAL( clicked() ), this, SLOT( newDestination() ) ); layout->addWidget( btn, 1, 0 ); btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); connect( btn, SIGNAL( clicked() ), this, SLOT( removeDestination() ) ); layout->addWidget( btn, 1, 1 ); QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); grpbox->layout()->setSpacing( 2 ); grpbox->layout()->setMargin( 4 ); layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); QLabel *label = new QLabel( tr( "Name:" ), grpbox ); grplayout->addWidget( label, 0, 0 ); destinationname = new QLineEdit( grpbox ); grplayout->addWidget( destinationname, 0, 1 ); label = new QLabel( tr( "Location:" ), grpbox ); grplayout->addWidget( label, 1, 0 ); destinationurl = new QLineEdit( grpbox ); grplayout->addWidget( destinationurl, 1, 1 ); linkToRoot = new QCheckBox( tr( "Link to root" ), grpbox ); grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); connect( btn, SIGNAL( clicked() ), this, SLOT( changeDestinationDetails() ) ); grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); return control; } QWidget *SettingsImpl :: initProxyTab() { QWidget *control = new QWidget( this ); QVBoxLayout *vb = new QVBoxLayout( control ); QScrollView *sv = new QScrollView( control ); 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 ); layout->setSpacing( 2 ); layout->setMargin( 4 ); 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() ); txtHttpProxy = new QLineEdit( grpbox ); grplayout->addWidget( txtHttpProxy ); chkHttpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); grplayout->addWidget( chkHttpProxyEnabled ); 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() ); txtFtpProxy = new QLineEdit( grpbox ); grplayout->addWidget( txtFtpProxy ); chkFtpProxyEnabled = new QCheckBox( tr( "Enabled" ), grpbox ); grplayout->addWidget( chkFtpProxyEnabled ); QLabel *label = new QLabel( tr( "Username:" ), container ); layout->addWidget( label, 2, 0 ); txtUsername = new QLineEdit( container ); layout->addWidget( txtUsername, 2, 1 ); label = new QLabel( tr( "Password:" ), container ); layout->addWidget( label, 3, 0 ); txtPassword = new QLineEdit( container ); layout->addWidget( txtPassword, 3, 1 ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), container ); connect( btn, SIGNAL( clicked() ), this, SLOT( proxyApplyChanges() ) ); layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); return control; } void SettingsImpl :: setupData() { // add servers QString serverName; QListIterator<Server> it( dataMgr->getServerList() ); for ( ; it.current(); ++it ) { serverName = it.current()->getServerName(); if ( serverName == LOCAL_SERVER || serverName == LOCAL_IPKGS ) continue; servers->insertItem( serverName ); } // add destinations QListIterator<Destination> it2( dataMgr->getDestinationList() ); for ( ; it2.current(); ++it2 ) destinations->insertItem( it2.current()->getDestinationName() ); // setup proxy tab txtHttpProxy->setText( dataMgr->getHttpProxy() ); txtFtpProxy->setText( dataMgr->getFtpProxy() ); txtUsername->setText( dataMgr->getProxyUsername() ); txtPassword->setText( dataMgr->getProxyPassword() ); chkHttpProxyEnabled->setChecked( dataMgr->getHttpProxyEnabled() ); chkFtpProxyEnabled->setChecked( dataMgr->getFtpProxyEnabled() ); } //------------------ Servers tab ---------------------- void SettingsImpl :: editServer( int sel ) { currentSelectedServer = sel; Server *s = dataMgr->getServer( servers->currentText() ); if ( s ) { serverName = s->getServerName(); servername->setText( s->getServerName() ); serverurl->setText( s->getServerUrl() ); active->setChecked( s->isServerActive() ); } else { serverName = ""; servername->setText( "" ); serverurl->setText( "" ); active->setChecked( false ); } } void SettingsImpl :: newServer() { newserver = true; servername->setText( "" ); serverurl->setText( "" ); servername->setFocus(); active->setChecked( true ); } void SettingsImpl :: removeServer() { changed = true; Server *s = dataMgr->getServer( servers->currentText() ); if ( s ) { dataMgr->getServerList().removeRef( s ); servers->removeItem( currentSelectedServer ); } } void SettingsImpl :: changeServerDetails() { changed = true; QString newName = servername->text(); // Convert any spaces to underscores char *tmpStr = new char[newName.length() + 1]; for ( unsigned int i = 0 ; i < newName.length() ; ++i ) { if ( newName[i] == ' ' ) tmpStr[i] = '_'; else tmpStr[i] = newName[i].latin1(); } tmpStr[newName.length()] = '\0'; newName = tmpStr; delete tmpStr; if ( !newserver ) { Server *s = dataMgr->getServer( servers->currentText() ); if ( s ) { // Update url s->setServerUrl( serverurl->text() ); s->setActive( active->isChecked() ); // Check if server name has changed, if it has then we need to replace the key in the map if ( serverName != newName ) { // Update server name s->setServerName( newName ); } // Update list box servers->changeItem( newName, currentSelectedServer ); } } else { Server s( newName, serverurl->text() ); dataMgr->getServerList().append( new Server( newName, serverurl->text() ) ); dataMgr->getServerList().last()->setActive( active->isChecked() ); servers->insertItem( newName ); servers->setCurrentItem( servers->count() ); newserver = false; } } //------------------ Destinations tab ---------------------- void SettingsImpl :: editDestination( int sel ) { currentSelectedDestination = sel; Destination *d = dataMgr->getDestination( destinations->currentText() ); if ( d ) { destinationName = d->getDestinationName(); destinationname->setText( d->getDestinationName() ); destinationurl->setText( d->getDestinationPath() ); linkToRoot->setChecked( d->linkToRoot() ); } else { destinationName = ""; destinationname->setText( "" ); destinationurl->setText( "" ); linkToRoot->setChecked( false ); } } void SettingsImpl :: newDestination() { newdestination = true; destinationname->setText( "" ); destinationurl->setText( "" ); destinationname->setFocus(); linkToRoot->setChecked( true ); } void SettingsImpl :: removeDestination() { changed = true; Destination *d = dataMgr->getDestination( destinations->currentText() ); if ( d ) { dataMgr->getDestinationList().removeRef( d ); destinations->removeItem( currentSelectedDestination ); } } void SettingsImpl :: changeDestinationDetails() { changed = true; #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "destinations" ); #endif QString newName = destinationname->text(); if ( !newdestination ) { Destination *d = dataMgr->getDestination( destinations->currentText() ); if ( d ) { // Update url d->setDestinationPath( destinationurl->text() ); d->linkToRoot( linkToRoot->isChecked() ); // Check if server name has changed, if it has then we need to replace the key in the map if ( destinationName != newName ) { // Update server name d->setDestinationName( newName ); // Update list box destinations->changeItem( newName, currentSelectedDestination ); } #ifdef QWS QString key = newName; key += "_linkToRoot"; int val = d->linkToRoot(); cfg.writeEntry( key, val ); #endif + } } else { dataMgr->getDestinationList().append( new Destination( newName, destinationurl->text() ) ); destinations->insertItem( newName ); destinations->setCurrentItem( destinations->count() ); newdestination = false; #ifdef QWS QString key = newName; key += "_linkToRoot"; cfg.writeEntry( key, true ); #endif + } } //------------------ Proxy tab ---------------------- void SettingsImpl :: proxyApplyChanges() { changed = true; dataMgr->setHttpProxy( txtHttpProxy->text() ); dataMgr->setFtpProxy( txtFtpProxy->text() ); dataMgr->setProxyUsername( txtUsername->text() ); dataMgr->setProxyPassword( txtPassword->text() ); dataMgr->setHttpProxyEnabled( chkHttpProxyEnabled->isChecked() ); dataMgr->setFtpProxyEnabled( chkFtpProxyEnabled->isChecked() ); } diff --git a/noncore/settings/backup/backuprestore.cpp b/noncore/settings/backup/backuprestore.cpp index a00193d..977c283 100644 --- a/noncore/settings/backup/backuprestore.cpp +++ b/noncore/settings/backup/backuprestore.cpp @@ -1,480 +1,481 @@ #include "backuprestore.h" -//#include "output.h" #include "errordialog.h" +/* OPIE */ +#include <opie2/ostorageinfo.h> +#include <qpe/qpeapplication.h> + +/* QT */ #include <qapplication.h> #include <qmultilineedit.h> - #include <qdir.h> #include <qfile.h> #include <qfileinfo.h> #include <qlistview.h> #include <qpushbutton.h> #include <qheader.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qmessagebox.h> #include <qcombobox.h> #include <qlist.h> #include <stdlib.h> #include <qregexp.h> #include <qtextstream.h> #include <qtextview.h> -#include <opie2/ostorageinfo.h> +/* STD */ #include <errno.h> #include <stdlib.h> #include <unistd.h> #include <sys/stat.h> #include <dirent.h> #define HEADER_NAME 0 #define HEADER_BACKUP 1 #define BACKUP_LOCATION 2 #define EXTENSION ".bck" const QString tempFileName = "/tmp/backup.err"; BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags fl) : BackupAndRestoreBase(parent, name, fl) { - this->showMaximized(); backupList->header()->hide(); restoreList->header()->hide(); connect(backupButton, SIGNAL(clicked()), this, SLOT(backup())); connect(restoreButton, SIGNAL(clicked()), this, SLOT(restore())); connect(backupList, SIGNAL(clicked( QListViewItem * )), this, SLOT(selectItem(QListViewItem*))); connect(restoreSource, SIGNAL(activated( int )), this, SLOT(sourceDirChanged(int))); connect(updateList, SIGNAL(clicked()), this, SLOT( fileListUpdate())); //add directorys for backing up applicationSettings = new QListViewItem(backupList, "Application Settings", "", "Settings/"); selectItem(applicationSettings); applicationSettings = new QListViewItem(backupList, "Application Data", "", "Applications/"); selectItem(applicationSettings); documents= new QListViewItem(backupList, "Documents", "", "Documents/"); selectItem(documents); scanForApplicationSettings(); OStorageInfo storage; backupLocations.insert( "Documents", QDir::homeDirPath() + "/Documents" ); if ( storage.hasCf() ) { backupLocations.insert( "CF", storage.cfPath() ); qDebug( "Cf Path: " + storage.cfPath() ); } if ( storage.hasSd() ) { backupLocations.insert( "SD", storage.sdPath() ); qDebug( " Sd Path: " + storage.sdPath() ); } if ( storage.hasMmc() ) { backupLocations.insert( "MMC", storage.mmcPath() ); qDebug( "Mmc Path: " + storage.mmcPath() ); } Config config("BackupAndRestore"); //read last locations config.setGroup("LastLocation"); QString lastStoreLocation = config.readEntry( "LastStoreLocation", "" ); QString lastRestoreLocation = config.readEntry( "LastRestoreLocation", "" ); int locationIndex = 0; QMap<QString, QString>::Iterator it; for( it = backupLocations.begin(); it != backupLocations.end(); ++it ) { storeToLocation->insertItem(it.key()); restoreSource->insertItem(it.key()); //check for last locations if ( it.key() == lastStoreLocation ) storeToLocation->setCurrentItem( locationIndex ); if ( it.key() == lastRestoreLocation ) restoreSource->setCurrentItem( locationIndex ); locationIndex++; } // Read the list of items to ignore. QList<QString> dontBackupList; dontBackupList.setAutoDelete(true); config.setGroup("DontBackup"); int total = config.readNumEntry("Total", 0); for(int i = 0; i < total; i++) { dontBackupList.append(new QString(config.readEntry(QString("%1").arg(i), ""))); } QList<QListViewItem> list; getAllItems(backupList->firstChild(), list); for(uint i = 0; i < list.count(); i++) { QString text = list.at(i)->text(HEADER_NAME); for(uint i2 = 0; i2 < dontBackupList.count(); i2++) { if(*dontBackupList.at(i2) == text) { selectItem(list.at(i)); break; } } } + QPEApplication::showWidget( this ); } BackupAndRestore::~BackupAndRestore() { QList<QListViewItem> list; getAllItems(backupList->firstChild(), list); Config config("BackupAndRestore"); config.setGroup("DontBackup"); config.clearGroup(); int count = 0; for(uint i = 0; i < list.count(); i++) { if(list.at(i)->text(HEADER_BACKUP) == "") { config.writeEntry(QString("%1").arg(count), list.at(i)->text(HEADER_NAME)); count++; } } config.writeEntry("Total", count); // Remove Temp File if ( QFile::exists( tempFileName ) ) QFile::remove( tempFileName ); } QList<QListViewItem> BackupAndRestore::getAllItems(QListViewItem *item, QList<QListViewItem> &list) { while(item) { if(item->childCount() > 0) getAllItems(item->firstChild(), list); list.append(item); item = item->nextSibling(); } return list; } /** * Selects and unselects the item by setting the HEADER_BACKUP to B or !. * and changing the icon to match * @param currentItem the item to swich the selection choice. */ void BackupAndRestore::selectItem(QListViewItem *currentItem) { if(!currentItem) return; if(currentItem->text(HEADER_BACKUP) == "B") { currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/null")); currentItem->setText(HEADER_BACKUP, ""); } else { currentItem->setPixmap(HEADER_NAME, Resource::loadPixmap("backup/check")); currentItem->setText(HEADER_BACKUP, "B"); } } void BackupAndRestore::scanForApplicationSettings() { QDir d( QDir::homeDirPath() + "/" + QString( applicationSettings->text(BACKUP_LOCATION) ) ); d.setFilter( QDir::Dirs | QDir::Files | QDir::NoSymLinks ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; while ( (fi=it.current()) ) { //qDebug((d.path()+"/"+fi->fileName()).latin1()); if ( ( fi->fileName() != "." ) && ( fi->fileName() != ".." ) ) { QListViewItem *newItem = new QListViewItem(applicationSettings, fi->fileName()); selectItem(newItem); } ++it; } } /** * The "Backup" button has been pressed. Get a list of all of the files that * should be backed up. If there are no files, emit and error and exit. * Determine the file name to store the backup in. Backup the file(s) using * tar and gzip --best. Report failure or success */ void BackupAndRestore::backup() { QString backupFiles; if(getBackupFiles(backupFiles, NULL) == 0) { QMessageBox::critical(this, "Message", "No items selected.",QString("Ok") ); return; } setCaption(tr("Backup and Restore... working...")); QString outputFile = backupLocations[storeToLocation->currentText()]; QDateTime datetime = QDateTime::currentDateTime(); QString dateString = QString::number( datetime.date().year() ) + QString::number( datetime.date().month() ).rightJustify(2, '0') + QString::number( datetime.date().day() ).rightJustify(2, '0'); outputFile += "/" + dateString; QString t = outputFile; int c = 1; while(QFile::exists(outputFile + EXTENSION)) { outputFile = t + QString("%1").arg(c); c++; } // We execute tar and compressing its output with gzip.. // The error output will be written into a temp-file which could be provided // for debugging.. qDebug( "Storing file: %s", outputFile.latin1() ); outputFile += EXTENSION; QString commandLine = QString( "(tar -C %1 -z --exclude=*.bck -c %2 > %3 ) 2> %4" ).arg( QDir::homeDirPath() ) .arg( backupFiles ) .arg( outputFile.latin1() ) .arg( tempFileName.latin1() ); qDebug( commandLine ); int r = system( commandLine ); if(r != 0) { perror("Error: "); QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); switch( QMessageBox::critical(this, tr( "Message" ), tr( "Backup Failed!" ) + "\n" + errorMsg, QString( tr( "Ok" ) ), QString( tr( "Details" ) ) ) ) { case 1: qWarning("Details pressed !"); ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); QFile errorFile( tempFileName ); if ( errorFile.open(IO_ReadOnly) ) { QTextStream t( &errorFile ); QString s; while ( !t.eof() ) { // until end of file... s += t.readLine(); // line of text excluding '\n' } errorFile.close(); pErrDialog->m_textarea->setText( s ); } else { pErrDialog->m_textarea->setText( "Unable to open File: /tmp/backup.er" ); } - pErrDialog->showMaximized(); - pErrDialog->exec(); + QPEApplication::execDialog( pErrDialog ); delete pErrDialog; break; } setCaption(tr("Backup and Restore.. Failed !!")); return; } else { QMessageBox::information(this, tr( "Message" ), tr( "Backup Successful." ), QString(tr( "Ok" ) ) ); } //write store-location Config config( "BackupAndRestore" ); config.setGroup( "LastLocation" ); config.writeEntry( "LastStoreLocation", storeToLocation->currentText() ); setCaption(tr("Backup and Restore")); } /*** * Get a list of all of the files to backup. */ int BackupAndRestore::getBackupFiles(QString &backupFiles, QListViewItem *parent) { QListViewItem * currentItem; QString currentHome; if(!parent) currentItem = backupList->firstChild(); else { currentItem = parent->firstChild(); currentHome = parent->text(BACKUP_LOCATION); } uint count = 0; while( currentItem != 0 ) { if(currentItem->text(HEADER_BACKUP) == "B" ) { if(currentItem->childCount() == 0 ) { if(parent == NULL) backupFiles += currentItem->text(BACKUP_LOCATION); else backupFiles += currentHome + currentItem->text(HEADER_NAME); backupFiles += " "; count++; } else { count += getBackupFiles(backupFiles, currentItem); } } currentItem = currentItem->nextSibling(); } return count; } void BackupAndRestore::sourceDirChanged(int selection) { restoreList->clear(); rescanFolder(backupLocations[restoreSource->text(selection)]); } void BackupAndRestore::fileListUpdate() { qWarning("void BackupAndRestore::fileListUpdate()"); restoreList->clear(); rescanFolder( backupLocations[restoreSource->currentText()] ); } /** * Scans directory for any backup files. Will recursivly go down, * but will not follow symlinks. * @param directory - the directory to look in. */ void BackupAndRestore::rescanFolder(QString directory) { //qDebug(QString("rescanFolder: ") + directory.latin1()); QDir d(directory); if(!d.exists()) return; d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *file; while ( (file=it.current()) ) { // for each file... // If it is a dir and not .. or . then add it as a tab and go down. if(file->isDir()) { if(file->fileName() != ".." && file->fileName() != ".") { rescanFolder(directory + "/" + file->fileName()); } } else { // If it is a backup file add to list. if(file->fileName().contains(EXTENSION)) (void)new QListViewItem(restoreList, file->fileName()); } ++it; } } /** * Restore a backup file. * Report errors or success */ void BackupAndRestore::restore() { QListViewItem *restoreItem = restoreList->currentItem(); if(!restoreItem) { QMessageBox::critical(this, tr( "Message" ), tr( "Please select something to restore." ),QString( tr( "Ok") ) ); return; } setCaption(tr("Backup and Restore... working...")); QString restoreFile = backupLocations[restoreSource->currentText()]; restoreFile += "/" + restoreItem->text(0); qDebug( restoreFile ); QString commandLine = QString( "tar -C %1 -zxf %2 2> %3" ).arg( QDir::homeDirPath() ) .arg( restoreFile.latin1() ) .arg( tempFileName.latin1() ); qDebug( commandLine ); int r = system( commandLine ); if(r != 0) { QString errorMsg= tr( "Error from System:\n" ) + (QString)strerror( errno ); switch( QMessageBox::critical(this, tr( "Message" ), tr( "Restore Failed." ) + "\n" + errorMsg, QString( tr( "Ok") ), QString( tr( "Details" ) ) ) ) { case 1: qWarning("Details pressed !"); ErrorDialog* pErrDialog = new ErrorDialog( this, NULL, true ); QFile errorFile( tempFileName ); if ( errorFile.open(IO_ReadOnly) ) { QTextStream t( &errorFile ); QString s; while ( !t.eof() ) { // until end of file... s += t.readLine(); // line of text excluding '\n' } errorFile.close(); pErrDialog->m_textarea->setText( s ); } else { pErrDialog->m_textarea->setText( tr( "Unable to open File: %1" ).arg( "/tmp/backup.er" ) ); } - pErrDialog->showMaximized(); - pErrDialog->exec(); + QPEApplication::execDialog( pErrDialog ); delete pErrDialog; setCaption(tr("Backup and Restore.. Failed !!")); return; break; } } else { QMessageBox::information(this, tr( "Message" ), tr( "Restore Successful." ), QString( tr( "Ok") ) ); } //write restore-location Config config( "BackupAndRestore" ); config.setGroup( "LastLocation" ); config.writeEntry( "LastRestoreLocation", restoreSource->currentText() ); setCaption(tr("Backup and Restore")); } // backuprestore.cpp diff --git a/noncore/settings/networksettings/ppp/devices.cpp b/noncore/settings/networksettings/ppp/devices.cpp index e94904b..9da090d 100644 --- a/noncore/settings/networksettings/ppp/devices.cpp +++ b/noncore/settings/networksettings/ppp/devices.cpp @@ -1,212 +1,217 @@ /* * kPPP: A pppd front end for the KDE project * * $Id$ * * Copyright (C) 1997 Bernd Johannes Wuebben * wuebben@math.cornell.edu * * based on EzPPP: * Copyright (C) 1997 Jay Painter * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * 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 program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "interfaceppp.h" +#include "devices.h" +#include "authwidget.h" +#include "pppdata.h" +#include "edit.h" +#include "general.h" + +/* OPIE */ +#include <qpe/qpeapplication.h> + +/* QT */ #include <qdir.h> -#include <stdlib.h> #include <qlayout.h> #include <qtabwidget.h> #include <qtabdialog.h> #include <qwhatsthis.h> #include <qmessagebox.h> - #include <qapplication.h> #include <qbuttongroup.h> #include <qmessagebox.h> #include <qvgroupbox.h> -#include "interfaceppp.h" -#include "devices.h" -#include "authwidget.h" -#include "pppdata.h" -#include "edit.h" -#include "general.h" +/* STD */ +#include <stdlib.h> + void parseargs(char* buf, char** args); DevicesWidget::DevicesWidget( InterfacePPP* ip, QWidget *parent, const char *name, WFlags f ) : ChooserWidget(ip->data(), parent, name, f) { _ifaceppp = ip; QWhatsThis::add(edit_b, tr("Allows you to modify the selected device")); QWhatsThis::add(new_b, tr("Create a new device") ); QWhatsThis::add(copy_b, tr("Makes a copy of the selected device. All\n" "settings of the selected device are copied\n" "to a new device, that you can modify to fit your\n" "needs")); QWhatsThis::add(delete_b, tr("<p>Deletes the selected device\n\n" "<font color=\"red\"><b>Use with care!</b></font>")); copy_b->setEnabled( false ); //FIXME // delete_b->setEnabled( false ); //FIXME QStringList tmp = _pppdata->getDevicesNamesList(); qDebug("DevicesWidget::DevicesWidget got devices %s",tmp.join("--").latin1()); listListbox->insertStringList(tmp); for (uint i = 0; i < listListbox->count(); i++){ qDebug("listListbox->text(i) %s == _pppdata->devname() %s",listListbox->text(i).latin1(), _pppdata->devname().latin1()); if ( listListbox->text(i) == _pppdata->devname() ) listListbox->setCurrentItem( i ); } } void DevicesWidget::slotListBoxSelect(int idx) { bool ok = _pppdata->setDevice( listListbox->text(idx) ); delete_b->setEnabled((bool)(idx != -1)); edit_b->setEnabled((bool)(idx != -1)); //FIXME copy_b->setEnabled((bool)(idx != -1)); } void DevicesWidget::edit() { _pppdata->setDevice(listListbox->text(listListbox->currentItem())); int result = doTab(); if(result == QDialog::Accepted) { listListbox->changeItem(_pppdata->devname(),listListbox->currentItem()); _pppdata->save(); } } void DevicesWidget::create() { // if(listListbox->count() == MAX_ACCOUNTS) { // QMessageBox::information(this, "sorry", // tr("Maximum number of accounts reached.")); // return; // } int result; if (_pppdata->newdevice() == -1){ return; } result = doTab(); if(result == QDialog::Accepted) { listListbox->insertItem(_pppdata->devname()); listListbox->setSelected(listListbox->findItem(_pppdata->devname()),true ); _pppdata->save(); } else _pppdata->deleteDevice(); } void DevicesWidget::copy() { // if(listListbox->count() == MAX_ACCOUNTS) { // QMessageBox::information(this, "sorry", tr("Maximum number of accounts reached.")); // return; // } if(listListbox->currentItem()<0) { QMessageBox::information(this, "sorry", tr("No devices selected.")); return; } _pppdata->copydevice(listListbox->currentText()); listListbox->insertItem(_pppdata->devname()); _pppdata->save(); } void DevicesWidget::remove() { QString s = tr("Are you sure you want to delete\nthe device \"%1\"?") .arg(listListbox->text(listListbox->currentItem())); if(QMessageBox::warning(this,tr("Confirm"),s, QMessageBox::Yes,QMessageBox::No ) != QMessageBox::Yes) return; if(_pppdata->deleteDevice(listListbox->text(listListbox->currentItem()))) listListbox->removeItem(listListbox->currentItem()); // _pppdata->save(); slotListBoxSelect(listListbox->currentItem()); } int DevicesWidget::doTab(){ QDialog *dlg = new QDialog( 0, "newDevice", true, Qt::WStyle_ContextHelp ); QVBoxLayout *layout = new QVBoxLayout( dlg ); layout->setSpacing( 0 ); layout->setMargin( 1 ); QTabWidget *tabWindow = new QTabWidget( dlg, "tabWindow" ); layout->addWidget( tabWindow ); bool isnew; if(_pppdata->devname().isEmpty()) { dlg->setCaption(tr("New Device")); isnew = true; } else { QString tit = tr("Edit Device: "); tit += _pppdata->devname(); dlg->setCaption(tit); isnew = false; } modem1 = new ModemWidget( _pppdata, tabWindow, "modem1" ); tabWindow->addTab( modem1, tr("&Device") ); modem2 = new ModemWidget2( _pppdata, _ifaceppp, tabWindow, "modem2" ); tabWindow->addTab( modem2, tr("&Modem") ); int result = 0; bool ok = false; while (!ok){ - dlg->showMaximized(); - result = dlg->exec(); + result = QPEApplication::execDialog( dlg ); ok = true; if(result == QDialog::Accepted) { if (!modem1->save()){ QMessageBox::critical(this, "error", tr( "You must enter a unique device name")); ok = false; }else{ modem2->save(); } } } delete dlg; return result; } diff --git a/noncore/settings/networksettings/ppp/edit.cpp b/noncore/settings/networksettings/ppp/edit.cpp index ceac90c..7d21605 100644 --- a/noncore/settings/networksettings/ppp/edit.cpp +++ b/noncore/settings/networksettings/ppp/edit.cpp @@ -1,1134 +1,1211 @@ /* * kPPP: A pppd Front End for the KDE project * * $Id$ * Copyright (C) 1997 Bernd Johannes Wuebben * wuebben@math.cornell.edu * * based on EzPPP: * Copyright (C) 1997 Jay Painter * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * 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 program; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include <string.h> -#include <termios.h> +#include "edit.h" +#include "pppdata.h" +#include "iplined.h" +#include "auth.h" + +/* OPIE */ +#include <qpe/resource.h> +#include <qpe/qpeapplication.h> + +/* QT */ #include <qlayout.h> #include <qmessagebox.h> #include <qwhatsthis.h> #include <qregexp.h> #include <qapplication.h> #include <qbuttongroup.h> #include <qvgroupbox.h> #include <qhbox.h> #include <qdialog.h> -#include <qpe/resource.h> -#include "edit.h" -#include "pppdata.h" -#include "iplined.h" -#include "auth.h" +/* STD */ + +#include <string.h> +#include <termios.h> DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount , const char *name ) : QWidget(parent, name), _pppdata(pd) { const int GRIDROWS = 6; QGridLayout *tl = new QGridLayout(this, GRIDROWS, 2, 0 ); connect_label = new QLabel(tr("Connection name:"), this); tl->addWidget(connect_label, 0, 0); connectname_l = new QLineEdit(this); // connectname_l->setMaxLength(ACCNAME_SIZE); tl->addWidget(connectname_l, 0, 1); QString tmp = tr("Type in a unique name for this connection"); QWhatsThis::add(connect_label,tmp); QWhatsThis::add(connectname_l,tmp); number_label = new QLabel(tr("Phone number:"), this); number_label->setAlignment(AlignTop|AlignLeft); tl->addWidget(number_label, 1, 0); QHBoxLayout *lpn = new QHBoxLayout(5); tl->addLayout(lpn, 1, 1); numbers = new QListBox(this); // numbers->setMinimumSize(120, 70); lpn->addWidget(numbers); QVBoxLayout *lpn1 = new QVBoxLayout; lpn->addLayout(lpn1); add = new QPushButton(tr("&Add..."), this); del = new QPushButton(tr("&Remove"), this); up = new QPushButton(this); up->setPixmap( Resource::loadPixmap("up") ); down = new QPushButton(this); down->setPixmap( Resource::loadPixmap("down") ); lpn1->addWidget(add); lpn1->addWidget(del); lpn1->addStretch(1); lpn1->addWidget(up); lpn1->addWidget(down); connect(add, SIGNAL(clicked()), this, SLOT(addNumber())); connect(del, SIGNAL(clicked()), this, SLOT(delNumber())); connect(up, SIGNAL(clicked()), this, SLOT(upNumber())); connect(down, SIGNAL(clicked()), this, SLOT(downNumber())); connect(numbers, SIGNAL(highlighted(int)), this, SLOT(selectionChanged(int))); numbersChanged(); tmp = tr("<p>Specifies the phone numbers to dial. You\n" "can supply multiple numbers here, simply\n" "click on \"Add\". You can arrange the\n" "order the numbers are tried by using the\n" "arrow buttons.\n\n" "When a number is busy or fails, <i>kppp</i> will \n" "try the next number and so on"); QWhatsThis::add(number_label,tmp); QWhatsThis::add(numbers,tmp); pppdargs = new QPushButton(tr("Customize pppd Arguments..."), this); connect(pppdargs, SIGNAL(clicked()), SLOT(pppdargsbutton())); tl->addMultiCellWidget(pppdargs, 5, 5, 0, 1, AlignCenter); // Set defaults if editing an existing connection - if(!isnewaccount) { + if(!isnewaccount) + { connectname_l->setText(_pppdata->accname()); // insert the phone numbers into the listbox QString n = _pppdata->phonenumber(); QString tmp = ""; uint idx = 0; - while(idx != n.length()) { - if(n[idx] == ':') { + while(idx != n.length()) + { + if(n[idx] == ':') + { if(tmp.length() > 0) numbers->insertItem(tmp); tmp = ""; - } else + } + else tmp += n[idx]; idx++; } if(tmp.length() > 0) numbers->insertItem(tmp); } numbersChanged(); tl->activate(); } -bool DialWidget::save() { +bool DialWidget::save() +{ //first check to make sure that the account name is unique! if(connectname_l->text().isEmpty() || - !_pppdata->isUniqueAccname(connectname_l->text())) { + !_pppdata->isUniqueAccname(connectname_l->text())) + { return false; - } else { + } + else + { _pppdata->setAccname(connectname_l->text()); QString number = ""; - for(uint i = 0; i < numbers->count(); i++) { + for(uint i = 0; i < numbers->count(); i++) + { if(i != 0) number += ":"; number += numbers->text(i); } _pppdata->setPhonenumber(number); return true; } } -void DialWidget::numbersChanged() { +void DialWidget::numbersChanged() +{ int sel = numbers->currentItem(); del->setEnabled(sel != -1); up->setEnabled(sel != -1 && sel != 0); down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); } -void DialWidget::selectionChanged(int) { +void DialWidget::selectionChanged(int) +{ numbersChanged(); } -void DialWidget::addNumber() { +void DialWidget::addNumber() +{ PhoneNumberDialog dlg(this); - if(dlg.exec()) { + if(dlg.exec()) + { numbers->insertItem(dlg.phoneNumber()); numbersChanged(); } } -void DialWidget::delNumber() { - if(numbers->currentItem() != -1) { +void DialWidget::delNumber() +{ + if(numbers->currentItem() != -1) + { numbers->removeItem(numbers->currentItem()); numbersChanged(); } } -void DialWidget::upNumber() { +void DialWidget::upNumber() +{ int idx = numbers->currentItem(); - if(idx != -1) { + if(idx != -1) + { QString item = numbers->text(idx); numbers->removeItem(idx); numbers->insertItem(item, idx-1); numbers->setCurrentItem(idx-1); numbersChanged(); } } -void DialWidget::downNumber() { +void DialWidget::downNumber() +{ int idx = numbers->currentItem(); - if(idx != -1) { + if(idx != -1) + { QString item = numbers->text(idx); numbers->removeItem(idx); numbers->insertItem(item, idx+1); numbers->setCurrentItem(idx+1); numbersChanged(); } } -void DialWidget::pppdargsbutton() { +void DialWidget::pppdargsbutton() +{ PPPdArguments pa(_pppdata, this); - pa.showMaximized(); - pa.exec(); + QPEApplication::execDialog( &pa ); } ///////////////////////////////////////////////////////////////////////////// // ExecWidget ///////////////////////////////////////////////////////////////////////////// ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : QWidget(parent, name), _pppdata(pd) { QVBoxLayout *tl = new QVBoxLayout(this, 0 );//, KDialog::spacingHint()); QLabel *l = new QLabel( tr("Here you can select commands to run at certain stages of the connection. The commands are run with your real user id, so you cannot run any commands here requiring root permissions (unless, of course, you are root).<br><br>Be sure to supply the whole path to the program otherwise we might be unable to find it."), this); tl->addWidget(l); tl->addStretch(1); QGridLayout *l1 = new QGridLayout(4, 2, 10); tl->addLayout(l1); l1->setColStretch(0, 0); l1->setColStretch(1, 1); before_connect_l = new QLabel(tr("Before connect:"), this); before_connect_l->setAlignment(AlignVCenter); l1->addWidget(before_connect_l, 0, 0); before_connect = new QLineEdit(this); // before_connect->setMaxLength(COMMAND_SIZE); l1->addWidget(before_connect, 0, 1); QString tmp = tr("Allows you to run a program <b>before</b> a connection\n" "is established. It is called immediately before\n" "dialing has begun.\n\n" "This might be useful, e.g. to stop HylaFAX blocking the\n" "modem."); QWhatsThis::add(before_connect_l,tmp); QWhatsThis::add(before_connect,tmp); command_label = new QLabel(tr("Upon connect:"), this); command_label->setAlignment(AlignVCenter); l1->addWidget(command_label, 1, 0); command = new QLineEdit(this); // command->setMaxLength(COMMAND_SIZE); l1->addWidget(command, 1, 1); tmp = tr("Allows you to run a program <b>after</b> a connection\n" "is established. When your program is called, all\n" "preparations for an Internet connection are finished.\n" "\n" "Very useful for fetching mail and news"); QWhatsThis::add(command_label,tmp); QWhatsThis::add(command,tmp); predisconnect_label = new QLabel(tr("Before disconnect:"), this); predisconnect_label->setAlignment(AlignVCenter); l1->addWidget(predisconnect_label, 2, 0); predisconnect = new QLineEdit(this); // predisconnect->setMaxLength(COMMAND_SIZE); l1->addWidget(predisconnect, 2, 1); tmp = tr("Allows you to run a program <b>before</b> a connection\n" "is closed. The connection will stay open until\n" "the program exits."); QWhatsThis::add(predisconnect_label,tmp); QWhatsThis::add(predisconnect,tmp); discommand_label = new QLabel(tr("Upon disconnect:"), this); discommand_label->setAlignment(AlignVCenter); l1->addWidget(discommand_label, 3, 0); discommand = new QLineEdit(this); // discommand->setMaxLength(COMMAND_SIZE); l1->addWidget(discommand, 3, 1); tmp = tr("Allows you to run a program <b>after</b> a connection\n" "has been closed."); QWhatsThis::add(discommand_label,tmp); QWhatsThis::add(discommand,tmp); // extra space between entries l1->addRowSpacing(1, 5); l1->addRowSpacing(3, 5); tl->addStretch(1); tl->activate(); // Set defaults if editing an existing connection - if(!isnewaccount) { + if(!isnewaccount) + { before_connect->setText(_pppdata->command_before_connect()); command->setText(_pppdata->command_on_connect()); discommand->setText(_pppdata->command_on_disconnect()); predisconnect->setText(_pppdata->command_before_disconnect()); } } -bool ExecWidget::save() { +bool ExecWidget::save() +{ _pppdata->setCommand_before_connect(before_connect->text()); _pppdata->setCommand_on_connect(command->text()); _pppdata->setCommand_before_disconnect(predisconnect->text()); _pppdata->setCommand_on_disconnect(discommand->text()); return true; } ///////////////////////////////////////////////////////////////////////////// // // IPWidget // ///////////////////////////////////////////////////////////////////////////// IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) : QWidget(parent, name), _pppdata(pd) { QVBoxLayout *topLayout = new QVBoxLayout(this); topLayout->setSpacing( 3 );//KDialog::spacingHint()); box = new QVGroupBox(tr("Configuration"), this); // box->setInsideSpacing( 1 );//KDialog::spacingHint()); rb = new QButtonGroup(this); rb->hide(); connect(rb, SIGNAL(clicked(int)), SLOT(hitIPSelect(int))); dynamicadd_rb = new QRadioButton(box); dynamicadd_rb->setText(tr("Dynamic IP address")); QWhatsThis::add(dynamicadd_rb, tr("Select this option when your computer gets an\n" "internet address (IP) every time a\n" "connection is made.\n" "\n" "Almost every Internet Service Provider uses\n" "this method, so this should be turned on.")); staticadd_rb = new QRadioButton(box); staticadd_rb->setText(tr("Static IP address")); rb->insert(dynamicadd_rb, 0); rb->insert(staticadd_rb, 1); QWhatsThis::add(staticadd_rb, tr("Select this option when your computer has a\n" "fixed internet address (IP). Most computers\n" "don't have this, so you should probably select\n" "dynamic IP addressing unless you know what you\n" "are doing.")); QWidget *ipWidget = new QWidget(box); QGridLayout *ipLayout = new QGridLayout(ipWidget, 2, 2); ipLayout->setSpacing( 2 );//KDialog::spacingHint()); ipaddress_label = new QLabel(tr("IP address:"), ipWidget); QString tmp = tr("If your computer has a permanent internet\n" "address, you must supply your IP address here."); ipLayout->addWidget(ipaddress_label, 0, 0); ipaddress_l = new IPLineEdit(ipWidget); ipLayout->addWidget(ipaddress_l, 0, 1); QWhatsThis::add(ipaddress_label,tmp); QWhatsThis::add(ipaddress_l,tmp); sub_label = new QLabel(tr("Subnet mask:"), ipWidget); tmp = tr("<p>If your computer has a static Internet address,\n" "you must supply a network mask here. In almost\n" "all cases this netmask will be <b>255.255.255.0</b>,\n" "but your mileage may vary.\n" "\n" "If unsure, contact your Internet Service Provider"); ipLayout->addWidget(sub_label, 1, 0); subnetmask_l = new IPLineEdit(ipWidget); ipLayout->addWidget(subnetmask_l, 1, 1); QWhatsThis::add(sub_label,tmp); QWhatsThis::add(subnetmask_l,tmp); autoname = new QCheckBox(tr("Auto-configure hostname from this IP"), this); autoname->setChecked(_pppdata->autoname()); connect(autoname,SIGNAL(toggled(bool)), this,SLOT(autoname_t(bool))); QWhatsThis::add(autoname, tr("<p>Whenever you connect, this reconfigures\n" "your hostname to match the IP address you\n" "got from the PPP server. This may be useful\n" "if you need to use a protocol which depends\n" "on this information, but it can also cause several\n" "<a href=\"kppp-7.html#autohostname\">problems</a>.\n" "\n" "Don't enable this unless you really need it.")); topLayout->addWidget(box); topLayout->addWidget(autoname); topLayout->addStretch(); //load info from gpppdata - if(!isnewaccount) { + if(!isnewaccount) + { if(_pppdata->ipaddr() == "0.0.0.0" && - _pppdata->subnetmask() == "0.0.0.0") { + _pppdata->subnetmask() == "0.0.0.0") + { dynamicadd_rb->setChecked(true); hitIPSelect(0); autoname->setChecked(_pppdata->autoname()); } - else { + else + { ipaddress_l->setText(_pppdata->ipaddr()); subnetmask_l->setText(_pppdata->subnetmask()); staticadd_rb->setChecked(true); autoname->setChecked(false); } } - else { + else + { dynamicadd_rb->setChecked(true); hitIPSelect(0); } } -void IPWidget::autoname_t(bool on) { +void IPWidget::autoname_t(bool on) +{ static bool was_warned = false; // big-fat warning when selecting the auto configure hostname option - if(on && !was_warned) { + if(on && !was_warned) + { QMessageBox::information(this, tr("Selecting this option might cause some weird " "problems with the X-server and applications " "while kppp is connected. Don't use it until " "you know what you are doing!\n" "For more information take a look at the " "handbook (or help) in the section \"Frequently " "asked questions\"."), tr("Warning")); was_warned = true; } } -void IPWidget::save() { - if(dynamicadd_rb->isChecked()) { +void IPWidget::save() +{ + if(dynamicadd_rb->isChecked()) + { _pppdata->setIpaddr("0.0.0.0"); _pppdata->setSubnetmask("0.0.0.0"); - } else { + } + else + { _pppdata->setIpaddr(ipaddress_l->text()); _pppdata->setSubnetmask(subnetmask_l->text()); } _pppdata->setAutoname(autoname->isChecked()); } -void IPWidget::hitIPSelect( int i ) { - if(i == 0) { +void IPWidget::hitIPSelect( int i ) +{ + if(i == 0) + { ipaddress_label->setEnabled(false); sub_label->setEnabled(false); ipaddress_l->setEnabled(false); subnetmask_l->setEnabled(false); } - else { + else + { ipaddress_label->setEnabled(true); sub_label->setEnabled(true); ipaddress_l->setEnabled(true); subnetmask_l->setEnabled(true); } } DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) : QWidget(parent, name), _pppdata(pd) { QGridLayout *tl = new QGridLayout(this, 7, 2, 0 ); dnsdomain_label = new QLabel(tr("Domain name:"), this); tl->addWidget(dnsdomain_label, 0, 0); dnsdomain = new QLineEdit(this); tl->addWidget(dnsdomain, 0, 1); QString tmp = tr("If you enter a domain name here, this domain\n" "name is used for your computer while you are\n" "connected. When the connection is closed, the\n" "original domain name of your computer is\n" "restored.\n" "\n" "If you leave this field blank, no changes are\n" "made to the domain name."); QWhatsThis::add(dnsdomain_label,tmp); QWhatsThis::add(dnsdomain,tmp); conf_label = new QLabel(tr("Configuration:"), this); tl->addWidget(conf_label, 1, 0); bg = new QButtonGroup("Group", this); connect(bg, SIGNAL(clicked(int)), SLOT(DNS_Mode_Selected(int))); bg->hide(); autodns = new QRadioButton(tr("Automatic"), this); bg->insert(autodns, 0); tl->addWidget(autodns, 1, 1); if(!_pppdata->pppdVersionMin(2, 3, 7)) autodns->setEnabled(false); mandns = new QRadioButton(tr("Manual"), this); bg->insert(mandns, 1); tl->addWidget(mandns, 2, 1); dns_label = new QLabel(tr("DNS IP address:"), this); tl->addWidget(dns_label, 3, 0); QHBoxLayout *l2 = new QHBoxLayout; tl->addLayout(l2, 3, 1); dnsipaddr = new IPLineEdit(this); connect(dnsipaddr, SIGNAL(returnPressed()), SLOT(adddns())); connect(dnsipaddr, SIGNAL(textChanged(const QString &)), SLOT(DNS_Edit_Changed(const QString &))); l2->addWidget(dnsipaddr, 1); l2->addStretch(1); tmp = tr("<p>Allows you to specify a new DNS server to be\n" "used while you are connected. When the\n" "connection is closed, this DNS entry will be\n" "removed again.\n" "\n" "To add a DNS server, type in the IP address of\n" "the DNS server here and click on <b>Add</b>"); QWhatsThis::add(dns_label, tmp); QWhatsThis::add(dnsipaddr, tmp); QHBoxLayout *l1 = new QHBoxLayout; tl->addLayout(l1, 4, 1); add = new QPushButton(tr("Add"), this); connect(add, SIGNAL(clicked()), SLOT(adddns())); l1->addWidget(add); // l1->addStretch(1); QWhatsThis::add(add, tr("Click this button to add the DNS server\n" "specified in the field above. The entry\n" "will then be added to the list below")); remove = new QPushButton(tr("Remove"), this); connect(remove, SIGNAL(clicked()), SLOT(removedns())); l1->addWidget(remove); QWhatsThis::add(remove, tr("Click this button to remove the selected DNS\n" "server entry from the list below")); servers_label = new QLabel(tr("DNS address list:"), this); servers_label->setAlignment(AlignTop|AlignLeft); tl->addWidget(servers_label, 5, 0); dnsservers = new QListBox(this); dnsservers->setMinimumSize(150, 80); connect(dnsservers, SIGNAL(highlighted(int)), SLOT(DNS_Entry_Selected(int))); tl->addWidget(dnsservers, 5, 1); tmp = tr("<p>This shows all defined DNS servers to use\n" "while you are connected. Use the <b>Add</b> and\n" "<b>Remove</b> buttons to modify the list"); QWhatsThis::add(servers_label,tmp); QWhatsThis::add(dnsservers,tmp); exdnsdisabled_toggle = new QCheckBox(tr("Disable DNS servers during connection"), this); // exdnsdisabled_toggle = new QCheckBox(tr("Disable existing DNS servers during connection"), this); exdnsdisabled_toggle->setChecked(_pppdata->exDNSDisabled()); tl->addMultiCellWidget(exdnsdisabled_toggle, 6, 6, 0, 1, AlignCenter); QWhatsThis::add(exdnsdisabled_toggle, tr("<p>When this option is selected, all DNS\n" "servers specified in <tt>/etc/resolv.conf</tt> are\n" "temporary disabled while the dialup connection\n" "is established. After the connection is\n" "closed, the servers will be re-enabled\n" "\n" "Typically, there is no reason to use this\n" "option, but it may become useful under \n" "some circumstances.")); // restore data if editing - if(!isnewaccount) { + if(!isnewaccount) + { dnsservers->insertStringList(_pppdata->dns()); dnsdomain->setText(_pppdata->domain()); } int mode = _pppdata->autoDNS() ? 0 : 1; bg->setButton(mode); DNS_Mode_Selected(mode); tl->activate(); } -void DNSWidget::DNS_Edit_Changed(const QString &text) { +void DNSWidget::DNS_Edit_Changed(const QString &text) +{ QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); add->setEnabled(text.find(r) != -1); } -void DNSWidget::DNS_Entry_Selected(int) { +void DNSWidget::DNS_Entry_Selected(int) +{ remove->setEnabled(true); } -void DNSWidget::DNS_Mode_Selected(int mode) { +void DNSWidget::DNS_Mode_Selected(int mode) +{ bool on = (mode == 1); dns_label->setEnabled(on); servers_label->setEnabled(on); dnsipaddr->setText(""); dnsipaddr->setEnabled(on); add->setEnabled(false); remove->setEnabled(dnsservers->count()>0 && on); dnsservers->clearSelection(); dnsservers->setEnabled(on); dnsservers->triggerUpdate(false); } -void DNSWidget::save() { +void DNSWidget::save() +{ _pppdata->setAutoDNS(bg->id(bg->selected()) == 0); QStringList serverlist; for(uint i=0; i < dnsservers->count(); i++) serverlist.append(dnsservers->text(i)); _pppdata->setDns(serverlist); // strip leading dot QString s(dnsdomain->text()); if(s.left(1) == ".") _pppdata->setDomain(s.mid(1)); else _pppdata->setDomain(dnsdomain->text()); _pppdata->setExDNSDisabled(exdnsdisabled_toggle->isChecked()); } -void DNSWidget::adddns() { - if(dnsservers->count() < MAX_DNS_ENTRIES) { +void DNSWidget::adddns() +{ + if(dnsservers->count() < MAX_DNS_ENTRIES) + { dnsservers->insertItem(dnsipaddr->text()); dnsipaddr->setText(""); } } -void DNSWidget::removedns() { +void DNSWidget::removedns() +{ int i; i = dnsservers->currentItem(); if(i != -1) dnsservers->removeItem(i); remove->setEnabled(dnsservers->count()>0); } // // GatewayWidget // GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) : QWidget(parent, name), _pppdata(pd) { QVBoxLayout *topLayout = new QVBoxLayout(this); topLayout->setSpacing( 2 ); topLayout->setMargin( 0 ); box = new QVGroupBox(tr("Configuration"), this); rb = new QButtonGroup(this); rb->hide(); connect(rb, SIGNAL(clicked(int)), SLOT(hitGatewaySelect(int))); defaultgateway = new QRadioButton(box); defaultgateway->setText(tr("Default gateway")); rb->insert(defaultgateway, 0); QWhatsThis::add(defaultgateway, tr("This makes the PPP peer computer (the computer\n" "you are connected to with your modem) to act as\n" "a gateway. Your computer will send all packets not\n" "going to a computer inside your local net to this\n" "computer, which will route these packets.\n" "\n" "This is the default for most ISPs, so you should\n" "probably leave this option on.")); staticgateway = new QRadioButton(box); staticgateway->setText(tr("Static gateway")); rb->insert(staticgateway, 1); QWhatsThis::add(staticgateway, tr("<p>Allows you to specify which computer you want\n" "to use as gateway (see <i>Default Gateway</i> above)")); QHBox *gateBox = new QHBox(box); gate_label = new QLabel(tr("Gateway IP address:"), gateBox); gatewayaddr = new IPLineEdit(gateBox); defaultroute = new QCheckBox(tr("Assign the default route to this gateway"), this); QWhatsThis::add(defaultroute, tr("If this option is enabled, all packets not\n" "going to the local net are routed through\n" "the PPP connection.\n" "\n" "Normally, you should turn this on")); topLayout->addWidget(box); topLayout->addWidget(defaultroute); topLayout->addStretch(); //load info from gpppdata - if(!isnewaccount) { - if(_pppdata->gateway() == "0.0.0.0") { + if(!isnewaccount) + { + if(_pppdata->gateway() == "0.0.0.0") + { defaultgateway->setChecked(true); hitGatewaySelect(0); } - else { + else + { gatewayaddr->setText(_pppdata->gateway()); staticgateway->setChecked(true); } defaultroute->setChecked(_pppdata->defaultroute()); } - else { + else + { defaultgateway->setChecked(true); hitGatewaySelect(0); defaultroute->setChecked(true); } } -void GatewayWidget::save() { +void GatewayWidget::save() +{ _pppdata->setGateway(gatewayaddr->text()); _pppdata->setDefaultroute(defaultroute->isChecked()); } -void GatewayWidget::hitGatewaySelect( int i ) { - if(i == 0) { +void GatewayWidget::hitGatewaySelect( int i ) +{ + if(i == 0) + { gatewayaddr->setText("0.0.0.0"); gatewayaddr->setEnabled(false); gate_label->setEnabled(false); } - else { + else + { gatewayaddr->setEnabled(true); gatewayaddr->setText(""); gate_label->setEnabled(true); } } ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) : QWidget(parent, name),_pppdata(pd) { QVBoxLayout *tl = new QVBoxLayout(this, 0 ); se = new ScriptEdit(this); connect(se, SIGNAL(returnPressed()), SLOT(addButton())); tl->addWidget(se); // insert equal-sized buttons QHBoxLayout *hl = new QHBoxLayout( this ); tl->addLayout( hl ); add = new QPushButton( tr("Add"), this ); hl->addWidget( add ); connect(add, SIGNAL(clicked()), SLOT(addButton())); insert = new QPushButton( tr("Insert"), this ); hl->addWidget( insert ); connect(insert, SIGNAL(clicked()), SLOT(insertButton())); remove = new QPushButton( tr("Remove"), this ); hl->addWidget( remove ); connect(remove, SIGNAL(clicked()), SLOT(removeButton())); QHBoxLayout *l12 = new QHBoxLayout(0); tl->addLayout(l12); stl = new QListBox(this); // stl->setVScrollBarMode( QScrollView::AlwaysOff ); connect(stl, SIGNAL(highlighted(int)), SLOT(stlhighlighted(int))); // stl->setMinimumSize(QSize(70, 140)); sl = new QListBox(this); // sl->setVScrollBarMode( QScrollView::AlwaysOff ); connect(sl, SIGNAL(highlighted(int)), SLOT(slhighlighted(int))); // sl->setMinimumSize(QSize(150, 140)); slb = new QScrollBar(this); // slb->setFixedWidth(slb->sizeHint().width()); connect(slb, SIGNAL(valueChanged(int)), SLOT(scrolling(int))); l12->addWidget(stl, 1); l12->addWidget(sl, 3); l12->addWidget(slb, 0); //load data from gpppdata - if(!isnewaccount) { + if(!isnewaccount) + { QStringList &comlist = _pppdata->scriptType(); QStringList &arglist = _pppdata->script(); QStringList::Iterator itcom = comlist.begin(); QStringList::Iterator itarg = arglist.begin(); for ( ; itcom != comlist.end() && itarg != arglist.end(); ++itcom, ++itarg ) { stl->insertItem(*itcom); sl->insertItem(*itarg); } } insert->setEnabled(false); remove->setEnabled(false); adjustScrollBar(); tl->activate(); } -bool ScriptWidget::check() { +bool ScriptWidget::check() +{ uint lstart = 0; uint lend = 0; uint errcnt = 0; - if(sl->count() > 0) { - for( uint i=0; i <= sl->count()-1; i++) { - if(stl->text(i) == "LoopStart") { + if(sl->count() > 0) + { + for( uint i=0; i <= sl->count()-1; i++) + { + if(stl->text(i) == "LoopStart") + { lstart++; } - if (stl->text(i) == "LoopEnd") { + if (stl->text(i) == "LoopEnd") + { lend++; } if ( lend > lstart ) errcnt++; } return ( (errcnt == 0 ) && (lstart == lend) ); } return true; } -void ScriptWidget::save() { +void ScriptWidget::save() +{ QStringList typelist, arglist; - for(uint i=0; i < sl->count(); i++) { + for(uint i=0; i < sl->count(); i++) + { typelist.append(stl->text(i)); arglist.append(sl->text(i)); } _pppdata->setScriptType(typelist); _pppdata->setScript(arglist); } -void ScriptWidget::adjustScrollBar() { +void ScriptWidget::adjustScrollBar() +{ if((int)sl->count() <= sl->numItemsVisible()) slb->setRange(0, 0); else slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); } -void ScriptWidget::scrolling(int i) { +void ScriptWidget::scrolling(int i) +{ sl->setTopItem(i); stl->setTopItem(i); } -void ScriptWidget::slhighlighted(int i) { +void ScriptWidget::slhighlighted(int i) +{ insert->setEnabled(true); remove->setEnabled(true); stl->setCurrentItem(i); } -void ScriptWidget::stlhighlighted(int i) { +void ScriptWidget::stlhighlighted(int i) +{ insert->setEnabled(true); remove->setEnabled(true); sl->setCurrentItem(i); } -void ScriptWidget::addButton() { +void ScriptWidget::addButton() +{ //don't allow more than the maximum script entries if(sl->count() == MAX_SCRIPT_ENTRIES-1) return; - switch(se->type()) { + switch(se->type()) + { case ScriptEdit::Expect: stl->insertItem("Expect"); sl->insertItem(se->text()); break; case ScriptEdit::Send: stl->insertItem("Send"); sl->insertItem(se->text()); break; case ScriptEdit::SendNoEcho: stl->insertItem("SendNoEcho"); sl->insertItem(se->text()); break; case ScriptEdit::Pause: stl->insertItem("Pause"); sl->insertItem(se->text()); break; case ScriptEdit::Hangup: stl->insertItem("Hangup"); sl->insertItem(""); break; case ScriptEdit::Answer: stl->insertItem("Answer"); sl->insertItem(""); break; case ScriptEdit::Timeout: stl->insertItem("Timeout"); sl->insertItem(se->text()); break; case ScriptEdit::Password: stl->insertItem("Password"); sl->insertItem(se->text()); break; case ScriptEdit::ID: stl->insertItem("ID"); sl->insertItem(se->text()); break; case ScriptEdit::Prompt: stl->insertItem("Prompt"); sl->insertItem(se->text()); break; case ScriptEdit::PWPrompt: stl->insertItem("PWPrompt"); sl->insertItem(se->text()); break; case ScriptEdit::LoopStart: stl->insertItem("LoopStart"); sl->insertItem(se->text()); break; case ScriptEdit::LoopEnd: stl->insertItem("LoopEnd"); sl->insertItem(se->text()); break; case ScriptEdit::Scan: stl->insertItem("Scan"); sl->insertItem(se->text()); break; case ScriptEdit::Save: stl->insertItem("Save"); sl->insertItem(se->text()); break; default: break; } //get the scrollbar adjusted, and scroll the list so we can see what //we're adding to adjustScrollBar(); slb->setValue(slb->maxValue()); //clear the text in the entry box se->setText(""); } -void ScriptWidget::insertButton() { +void ScriptWidget::insertButton() +{ //exit if there is no highlighted item, or we've reached the //maximum entries in the script list if(sl->currentItem() < 0 || (sl->count() == MAX_SCRIPT_ENTRIES-1)) return; - switch(se->type()) { + switch(se->type()) + { case ScriptEdit::Expect: stl->insertItem("Expect", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Send: stl->insertItem("Send", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::SendNoEcho: stl->insertItem("SendNoEcho", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Pause: stl->insertItem("Pause", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Hangup: stl->insertItem("Hangup", stl->currentItem()); sl->insertItem("", sl->currentItem()); break; case ScriptEdit::Answer: stl->insertItem("Answer", stl->currentItem()); sl->insertItem("", sl->currentItem()); break; case ScriptEdit::Timeout: stl->insertItem("Timeout", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Password: stl->insertItem("Password", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::ID: stl->insertItem("ID", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Prompt: stl->insertItem("Prompt", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::PWPrompt: stl->insertItem("PWPrompt", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::LoopStart: stl->insertItem("LoopStart", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::LoopEnd: stl->insertItem("LoopEnd", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Scan: stl->insertItem("Scan", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; case ScriptEdit::Save: stl->insertItem("Save", stl->currentItem()); sl->insertItem(se->text(), sl->currentItem()); break; default: break; } adjustScrollBar(); se->setText(""); } -void ScriptWidget::removeButton() { - if(sl->currentItem() >= 0) { +void ScriptWidget::removeButton() +{ + if(sl->currentItem() >= 0) + { int stlc = stl->currentItem(); sl->removeItem(sl->currentItem()); stl->removeItem(stlc); adjustScrollBar(); insert->setEnabled(sl->currentItem() != -1); remove->setEnabled(sl->currentItem() != -1); } } ///////////////////////////////////////////////////////////////////////////// // // Used to specify a new phone number // ///////////////////////////////////////////////////////////////////////////// PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) : QDialog(parent,"PhoneNumberDialog",true) { setCaption( tr("Add Phone Number") ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setSpacing( 3 ); layout->setMargin( 3 ); // QHBox *hbox = new QHBox(this); // setMainWidget(hbox); // hbox->setSpacing( 2 );//KDialog::spacingHint()); QLabel *label = new QLabel(this, tr("Enter a phone number:")); layout->addWidget( label ); le = new QLineEdit(this, "lineEdit"); layout->addWidget( le ); connect(le, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &))); le->setFocus(); textChanged(""); } -QString PhoneNumberDialog::phoneNumber() { +QString PhoneNumberDialog::phoneNumber() +{ QString s = le->text(); return s; } -void PhoneNumberDialog::textChanged(const QString &s) { +void PhoneNumberDialog::textChanged(const QString &s) +{ // enableButtonOK(s.length() > 0); } //#include "edit.moc" diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index 566b179..9cb8ad2 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp @@ -1,188 +1,190 @@ /********************************************************************** ** ModulesInfo ** ** Display Modules information ** ** Copyright (C) 2002, Michael Lauer ** mickey@tm.informatik.uni-frankfurt.de ** http://www.Vanille.de ** ** Based on ProcessInfo by Dan Williams <williamsdr@acm.org> ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ +#include "modulesinfo.h" +#include "detail.h" + +/* OPIE */ #include <qpe/qpeapplication.h> +/* QT */ #include <qfile.h> #include <qlayout.h> #include <qmessagebox.h> #include <qtimer.h> #include <qwhatsthis.h> -#include "modulesinfo.h" -#include "detail.h" - ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QGridLayout *layout = new QGridLayout( this ); layout->setSpacing( 4 ); layout->setMargin( 4 ); ModulesView = new QListView( this ); int colnum = ModulesView->addColumn( tr( "Module" ) ); colnum = ModulesView->addColumn( tr( "Size" ) ); ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ModulesView->addColumn( tr( "Use#" ) ); ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ModulesView->addColumn( tr( "Used by" ) ); ModulesView->setAllColumnsShowFocus( TRUE ); layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); // Test if we have /sbin/modinfo, and if so, allow module detail window if ( QFile::exists( "/sbin/modinfo" ) ) { QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), this, SLOT( viewModules( QListViewItem * ) ) ); } CommandCB = new QComboBox( FALSE, this ); CommandCB->insertItem( "modprobe -r" ); CommandCB->insertItem( "rmmod" ); // I can't think of other useful commands yet. Anyone? layout->addWidget( CommandCB, 1, 0 ); QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); QPushButton *btn = new QPushButton( this ); btn->setMinimumSize( QSize( 50, 24 ) ); btn->setMaximumSize( QSize( 50, 24 ) ); btn->setText( tr( "Send" ) ); connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); layout->addWidget( btn, 1, 1 ); QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); QTimer *t = new QTimer( this ); connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); t->start( 5000 ); updateData(); ModulesDtl = new Detail(); QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); } ModulesInfo::~ModulesInfo() -{ -} +{} void ModulesInfo::updateData() { char modname[64]; char usage[200]; int modsize, usecount; QString selectedmod; QListViewItem *curritem = ModulesView->currentItem(); if ( curritem ) { selectedmod = curritem->text( 0 ); } ModulesView->clear(); FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); if ( procfile ) { QListViewItem *newitem; QListViewItem *selecteditem = 0x0; - while ( true ) { + while ( true ) + { modname[0] = '\0'; usage[0] = '\0'; int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); if ( success == EOF ) break; QString qmodname = QString( modname ); QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); QString qusage = QString( usage ); newitem = new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); if ( qmodname == selectedmod ) { selecteditem = newitem; } } ModulesView->setCurrentItem( selecteditem ); fclose( procfile ); } } void ModulesInfo::slotSendClicked() { if ( !ModulesView->currentItem() ) { return; } QString capstr = tr( "You really want to execute %1 for this module?" ).arg( CommandCB->currentText() ); QString modname = ModulesView->currentItem()->text( 0 ); if ( QMessageBox::warning( this, modname, capstr, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) { QString command = "/sbin/"; command.append( CommandCB->currentText() ); command.append( " " ); command.append( modname ); FILE* stream = popen( command, "r" ); if ( stream ) pclose( stream ); } } void ModulesInfo::viewModules( QListViewItem *modules ) { QString modname = modules->text( 0 ); QString capstr = "Module: "; capstr.append( modname ); ModulesDtl->setCaption( capstr ); QString command = "/sbin/modinfo "; command.append( modname ); FILE* modinfo = popen( command, "r" ); if ( modinfo ) { char line[200]; ModulesDtl->detailView->setText( " Details:\n------------\n" ); while( true ) { int success = fscanf( modinfo, "%[^\n]\n", line ); if ( success == EOF ) break; ModulesDtl->detailView->append( line ); } pclose( modinfo ); } - ModulesDtl->showMaximized(); + QPEApplication::showWidget( ModulesDtl ); } diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index af0fe26..2a90b0f 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp @@ -1,200 +1,202 @@ /********************************************************************** ** ProcessInfo ** ** Display process information ** ** Copyright (C) 2002, Dan Williams ** williamsdr@acm.org ** http://draknor.net ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ +#include "processinfo.h" +#include "detail.h" + +/* OPIE */ #include <qpe/qpeapplication.h> +/* QT */ #include <qdir.h> #include <qlayout.h> #include <qmessagebox.h> #include <qtimer.h> #include <qwhatsthis.h> +/* STD */ #include <sys/types.h> #include <signal.h> -#include "processinfo.h" -#include "detail.h" - ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) : QWidget( parent, name, fl ) { QGridLayout *layout = new QGridLayout( this ); layout->setSpacing( 4 ); layout->setMargin( 4 ); ProcessView = new QListView( this, "ProcessView" ); int colnum = ProcessView->addColumn( tr( "PID" ) ); ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); colnum = ProcessView->addColumn( tr( "Command" ),96 ); colnum = ProcessView->addColumn( tr( "Status" ) ); colnum = ProcessView->addColumn( tr( "Time" ) ); ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); ProcessView->setAllColumnsShowFocus( TRUE ); QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), this, SLOT( viewProcess( QListViewItem * ) ) ); layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); SignalCB = new QComboBox( FALSE, this, "SignalCB" ); SignalCB->insertItem( " 1: SIGHUP" ); SignalCB->insertItem( " 2: SIGINT" ); SignalCB->insertItem( " 3: SIGQUIT" ); SignalCB->insertItem( " 5: SIGTRAP" ); SignalCB->insertItem( " 6: SIGABRT" ); SignalCB->insertItem( " 9: SIGKILL" ); SignalCB->insertItem( "14: SIGALRM" ); SignalCB->insertItem( "15: SIGTERM" ); SignalCB->insertItem( "18: SIGCONT" ); SignalCB->insertItem( "19: SIGSTOP" ); layout->addWidget( SignalCB, 1, 0 ); QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); SendButton = new QPushButton( this, "SendButton" ); SendButton->setMinimumSize( QSize( 50, 24 ) ); SendButton->setMaximumSize( QSize( 50, 24 ) ); SendButton->setText( tr( "Send" ) ); connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); layout->addWidget( SendButton, 1, 1 ); QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); QTimer *t = new QTimer( this ); connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); t->start( 5000 ); updateData(); ProcessDtl = new Detail(); QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); } ProcessInfo::~ProcessInfo() -{ -} +{} void ProcessInfo::updateData() { int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, signal, blocked, sigignore, sigcatch; uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, endcode, startstack, kstkesp, kstkeip, wchan; char state; char comm[64]; QString selectedpid; QListViewItem *curritem = ProcessView->currentItem(); if ( curritem ) { selectedpid = curritem->text( 0 ); } ProcessView->clear(); QListViewItem *newitem; QListViewItem *selecteditem = 0x0; QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); if ( proclist ) { QFileInfoListIterator it(*proclist); QFileInfo *f; while ( ( f = it.current() ) != 0 ) { ++it; QString processnum = f->fileName(); if ( processnum >= "1" && processnum <= "99999" ) { FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); if ( procfile ) { fscanf( procfile, "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); processnum = processnum.rightJustify( 5, ' ' ); QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); QString processstatus = QChar(state); QString processtime = QString::number( ( utime + stime ) / 100 ); processtime = processtime.rightJustify( 9, ' ' ); fclose( procfile ); newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); if ( processnum == selectedpid ) { selecteditem = newitem; } } } } ProcessView->setCurrentItem( selecteditem ); } delete proclist; delete procdir; } void ProcessInfo::slotSendClicked() { QListViewItem *currprocess = ProcessView->currentItem(); if ( !currprocess ) { return; } QString capstr = tr( "Really want to send %1\nto this process?" ).arg( SignalCB->currentText() ); if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) { currprocess = ProcessView->currentItem(); if ( currprocess ) { QString sigstr = SignalCB->currentText(); sigstr.truncate(2); int sigid = sigstr.toUInt(); kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); } } } void ProcessInfo::viewProcess( QListViewItem *process ) { QString pid= process->text( 0 ).stripWhiteSpace(); QString command = process->text( 1 ); ProcessDtl->setCaption( pid + " - " + command ); FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); if ( statfile ) { char line[81]; fgets( line, 81, statfile ); ProcessDtl->detailView->setText( line ); while ( fgets( line, 81, statfile ) ) { ProcessDtl->detailView->append( line ); } fclose( statfile ); } - ProcessDtl->showMaximized(); + QPEApplication::showWidget( ProcessDtl ); } diff --git a/noncore/settings/usermanager/userdialog.cpp b/noncore/settings/usermanager/userdialog.cpp index d87a005..08de352 100644 --- a/noncore/settings/usermanager/userdialog.cpp +++ b/noncore/settings/usermanager/userdialog.cpp @@ -1,438 +1,489 @@ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "userdialog.h" +#include "passwd.h" + +/* OPIE */ +#include <opie/odevice.h> +#include <qpe/qpeapplication.h> +/* QT */ #include <qlayout.h> #include <qlabel.h> #include <qmessagebox.h> #include <qfile.h> +/* STD */ #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <signal.h> -#include "passwd.h" -#include <opie/odevice.h> using namespace Opie; /** * UserDialog constructor. Setup the dialog, fill the groupComboBox & groupsListView with all groups. * */ -UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) { +UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog(parent, name, modal, fl) +{ vm=viewmode; QVBoxLayout *layout = new QVBoxLayout(this); myTabWidget=new QTabWidget(this,"User Tab Widget"); layout->addWidget(myTabWidget); setupTab1(); setupTab2(); accounts->groupStringList.sort(); // And also fill the listview & the combobox with all available groups. - for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) { + for( QStringList::Iterator it = accounts->groupStringList.begin(); it!=accounts->groupStringList.end(); ++it) + { accounts->splitGroupEntry(*it); - if(accounts->gr_name.find(QRegExp("^#"),0)) { // Skip commented lines. + if(accounts->gr_name.find(QRegExp("^#"),0)) + { // Skip commented lines. new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); groupComboBox->insertItem(accounts->gr_name); } } - showMaximized(); + QPEApplication::showDialog( this ); } /** * Empty destructor. * */ -UserDialog::~UserDialog() { -} +UserDialog::~UserDialog() +{} /** * Creates the first tab, all userinfo is here. * */ -void UserDialog::setupTab1() { +void UserDialog::setupTab1() +{ QPixmap mypixmap; QWidget *tabpage = new QWidget(myTabWidget,"page1"); QVBoxLayout *layout = new QVBoxLayout(tabpage); layout->setMargin(5); // Picture picturePushButton = new QPushButton(tabpage,"Label"); picturePushButton->setMinimumSize(48,48); picturePushButton->setMaximumSize(48,48); picturePushButton->setPixmap(Resource::loadPixmap("usermanager/usericon")); // Load default usericon. connect(picturePushButton,SIGNAL(clicked()),this,SLOT(clickedPicture())); // Clicking the picture should invoke pictureselector. // Login QLabel *loginLabel=new QLabel(tabpage,"Login: "); loginLabel->setText("Login: "); loginLineEdit=new QLineEdit(tabpage,"Login: "); // UID QLabel *uidLabel=new QLabel(tabpage,"uid: "); uidLabel->setText("UserID: "); uidLineEdit=new QLineEdit(tabpage,"uid: "); uidLineEdit->setEnabled(false); // Username (gecos) QLabel *gecosLabel=new QLabel(tabpage,"gecos"); gecosLabel->setText("Username: "); gecosLineEdit=new QLineEdit(tabpage,"gecos"); // Password QLabel *passwordLabel=new QLabel(tabpage,"password"); passwordLabel->setText("Password: "); passwordLineEdit=new QLineEdit(tabpage,"password"); passwordLineEdit->setEchoMode(QLineEdit::Password); // Shell QLabel *shellLabel=new QLabel(tabpage,"shell"); shellLabel->setText("Shell: "); shellComboBox=new QComboBox(tabpage,"shell"); shellComboBox->setEditable(true); shellComboBox->insertItem("/bin/sh"); shellComboBox->insertItem("/bin/ash"); shellComboBox->insertItem("/bin/false"); // Primary Group QLabel *groupLabel=new QLabel(tabpage,"group"); groupLabel->setText("Primary group: "); groupComboBox=new QComboBox(tabpage,"PrimaryGroup"); - if(vm==VIEWMODE_NEW) { + if(vm==VIEWMODE_NEW) + { // Copy /etc/skel skelLabel=new QLabel(tabpage,"skel"); skelLabel->setText("Copy /etc/skel: "); skelCheckBox=new QCheckBox(tabpage); skelCheckBox->setChecked(true); } // Widget layout QHBoxLayout *hlayout=new QHBoxLayout(-1,"hlayout"); layout->addWidget(picturePushButton); layout->addSpacing(5); layout->addLayout(hlayout); QVBoxLayout *vlayout1=new QVBoxLayout(-1,"vlayout1"); QVBoxLayout *vlayout2=new QVBoxLayout(-1,"vlayout2"); // First column, labels vlayout1->addWidget(loginLabel); vlayout1->addSpacing(5); vlayout1->addWidget(uidLabel); vlayout1->addSpacing(5); vlayout1->addWidget(gecosLabel); vlayout1->addSpacing(5); vlayout1->addWidget(passwordLabel); vlayout1->addSpacing(5); vlayout1->addWidget(shellLabel); vlayout1->addSpacing(5); vlayout1->addWidget(groupLabel); - if(vm==VIEWMODE_NEW) { + if(vm==VIEWMODE_NEW) + { vlayout1->addSpacing(5); vlayout1->addWidget(skelLabel); } // Second column, data vlayout2->addWidget(loginLineEdit); vlayout2->addSpacing(5); vlayout2->addWidget(uidLineEdit); vlayout2->addSpacing(5); vlayout2->addWidget(gecosLineEdit); vlayout2->addSpacing(5); vlayout2->addWidget(passwordLineEdit); vlayout2->addSpacing(5); vlayout2->addWidget(shellComboBox); vlayout2->addSpacing(5); vlayout2->addWidget(groupComboBox); - if(vm==VIEWMODE_NEW) { + if(vm==VIEWMODE_NEW) + { vlayout2->addSpacing(5); vlayout2->addWidget(skelCheckBox); } hlayout->addLayout(vlayout1); hlayout->addLayout(vlayout2); myTabWidget->addTab(tabpage,"User Info"); } /** * Creates the second tab containing additional groups for the user. * */ -void UserDialog::setupTab2() { +void UserDialog::setupTab2() +{ QWidget *tabpage = new QWidget(myTabWidget,"page2"); QVBoxLayout *layout = new QVBoxLayout(tabpage); layout->setMargin(5); // Additional groups groupsListView=new QListView(tabpage,"groups"); groupsListView->addColumn("Additional groups"); groupsListView->setColumnWidthMode(0,QListView::Maximum); groupsListView->setMultiSelection(false); groupsListView->setAllColumnsShowFocus(false); layout->addSpacing(5); // Grouplist layout->addWidget(groupsListView); myTabWidget->addTab(tabpage,"User Groups"); } /** * Static function that creates the userinfo dialog. * The user will be prompted to add a user. * * @param uid This is a suggested available UID. * @param gid This is a suggested available GID. * * @return <code>true</code> if the user was successfully added, otherwise <code>false</code>. * */ -bool UserDialog::addUser(int uid, int gid) { +bool UserDialog::addUser(int uid, int gid) +{ QCheckListItem *temp; QFile ozTest; int oz=false; if(ODevice::inst()->system()==System_OpenZaurus) oz=true; // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating adduserDialog's widgets here. UserDialog *adduserDialog=new UserDialog(VIEWMODE_NEW); adduserDialog->setCaption(tr("Add User")); adduserDialog->userID=uid; // Set next available UID as default uid. adduserDialog->groupID=gid; // Set next available GID as default gid. // Insert default group into groupComboBox adduserDialog->groupComboBox->insertItem("<create new group>",0); adduserDialog->uidLineEdit->setText(QString::number(uid)); // If we're running on OZ, add new users to some default groups. - if(oz) { + if(oz) + { QListViewItemIterator iter( adduserDialog->groupsListView ); - for ( ; iter.current(); ++iter ) { + for ( ; iter.current(); ++iter ) + { temp=(QCheckListItem*)iter.current(); if (temp->text()=="video") temp->setOn(true); if (temp->text()=="audio") temp->setOn(true); if (temp->text()=="time") temp->setOn(true); if (temp->text()=="power") temp->setOn(true); if (temp->text()=="input") temp->setOn(true); if (temp->text()=="sharp") temp->setOn(true); if (temp->text()=="tty") temp->setOn(true); } } // Show the dialog! if(!(adduserDialog->exec())) return false; - if((adduserDialog->groupComboBox->currentItem()!=0)) { + if((adduserDialog->groupComboBox->currentItem()!=0)) + { accounts->findGroup(adduserDialog->groupComboBox->currentText()); adduserDialog->groupID=accounts->gr_gid; qWarning(QString::number(accounts->gr_gid)); } if(!(accounts->addUser(adduserDialog->loginLineEdit->text(), adduserDialog->passwordLineEdit->text(), adduserDialog->uidLineEdit->text().toInt(), adduserDialog->groupID, adduserDialog->gecosLineEdit->text(), - QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) { + QString("/home/")+adduserDialog->loginLineEdit->text() , adduserDialog->shellComboBox->currentText()))) + { QMessageBox::information(0,"Ooops!","Something went wrong!\nUnable to add user."); return false; } // Add User to additional groups. QListViewItemIterator it( adduserDialog->groupsListView ); - for ( ; it.current(); ++it ) { + for ( ; it.current(); ++it ) + { temp=(QCheckListItem*)it.current(); if (temp->isOn() ) accounts->addGroupMember(it.current()->text(0),adduserDialog->loginLineEdit->text()); } // Copy image to pics/users/ - if(!(adduserDialog->userImage.isNull())) { + if(!(adduserDialog->userImage.isNull())) + { QDir d; - if(!(d.exists("/opt/QtPalmtop/pics/users"))) { + if(!(d.exists("/opt/QtPalmtop/pics/users"))) + { d.mkdir("/opt/QtPalmtop/pics/users"); } QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; // adduserDialog->userImage=adduserDialog->userImage.smoothScale(48,48); adduserDialog->userImage.save(filename,"PNG"); } // Should we copy the skeleton homedirectory /etc/skel to the user's homedirectory? accounts->findUser(adduserDialog->loginLineEdit->text()); - if(adduserDialog->skelCheckBox->isChecked()) { + if(adduserDialog->skelCheckBox->isChecked()) + { QString command_cp; QString command_chown; command_cp.sprintf("cp -a /etc/skel/* %s/",accounts->pw_dir.latin1()); system(command_cp); command_cp.sprintf("cp -a /etc/skel/.[!.]* %s/",accounts->pw_dir.latin1()); // Bug in busybox, ".*" includes parent directory, does this work as a workaround? system(command_cp); command_chown.sprintf("chown -R %d:%d %s",accounts->pw_uid,accounts->pw_gid,accounts->pw_dir.latin1()); system(command_chown); } return true; } /** * Deletes the user account. * * @param username User to be deleted. * * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. * */ -bool UserDialog::delUser(const char *username) { - if((accounts->findUser(username))) { // Does that user exist? - if(!(accounts->delUser(username))) { // Delete the user. +bool UserDialog::delUser(const char *username) +{ + if((accounts->findUser(username))) + { // Does that user exist? + if(!(accounts->delUser(username))) + { // Delete the user. QMessageBox::information(0,"Ooops!","Something went wrong\nUnable to delete user: "+QString(username)+"."); } - } else { + } + else + { QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); return false; } return true; } /** * This displays a confirmation dialog wether a user should be deleted or not. * (And also deletes the account) * * @param username User to be deleted. * * @return <code>true</code> if the user was successfully deleted, otherwise <code>false</code>. * */ -bool UserDialog::editUser(const char *username) { +bool UserDialog::editUser(const char *username) +{ int invalid_group=0; // viewmode is a workaround for a bug in qte-2.3.4 that gives bus error on manipulating edituserDialog's widgets here. UserDialog *edituserDialog=new UserDialog(VIEWMODE_EDIT); // Create Dialog edituserDialog->setCaption(tr("Edit User")); accounts->findUser(username); // Locate user in database and fill variables in 'accounts' object. - if(!(accounts->findGroup(accounts->pw_gid))) { // Locate the user's primary group, and fill group variables in 'accounts' object. + if(!(accounts->findGroup(accounts->pw_gid))) + { // Locate the user's primary group, and fill group variables in 'accounts' object. invalid_group=1; } // Fill widgets with userinfo. edituserDialog->loginLineEdit->setText(accounts->pw_name); edituserDialog->uidLineEdit->setText(QString::number(accounts->pw_uid)); edituserDialog->gecosLineEdit->setText(accounts->pw_gecos); // Set password to '........', we will later check if this still is the contents, if not, the password has been changed. edituserDialog->passwordLineEdit->setText("........"); // If this user is not using /bin/sh,/bin/ash or /bin/false as shell, add that entry to the shell-combobox. - if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") { + if(accounts->pw_shell!="/bin/sh" && accounts->pw_shell!="/bin/ash" && accounts->pw_shell!="/bin/false") + { edituserDialog->shellComboBox->insertItem(accounts->pw_shell,0); edituserDialog->shellComboBox->setCurrentItem(0); } // Select the primary group for this user. - for(int i=0;i<edituserDialog->groupComboBox->count();++i) { - if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) { + for(int i=0;i<edituserDialog->groupComboBox->count();++i) + { + if(accounts->gr_name==edituserDialog->groupComboBox->text(i)) + { edituserDialog->groupComboBox->setCurrentItem(i); break; } } - if(invalid_group) { + if(invalid_group) + { edituserDialog->groupComboBox->insertItem("<Undefined group>",0); edituserDialog->groupComboBox->setCurrentItem(0); } // Select the groups in the listview, to which the user belongs. QCheckListItem *temp; // BAH!!! QRegExp in qt2 sucks... or maybe I do... can't figure out how to check for EITHER end of input ($) OR a comma, so here we do two different QRegExps instead. QRegExp userRegExp(QString("[:,]%1$").arg(username)); // The end of line variant. QStringList tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. - for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { // Iterate over all of them. + for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) + { // Iterate over all of them. qWarning(*it); QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. - for ( ; lvit.current(); ++lvit ) { - if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { + for ( ; lvit.current(); ++lvit ) + { + if(lvit.current()->text(0)==(*it).left((*it).find(":"))) + { temp=(QCheckListItem*)lvit.current(); temp->setOn(true); // If we find a line with that groupname, select it.; } } } userRegExp=QRegExp(QString("[:,]%1,").arg(username)); // And the other one. (not end of line.) tempList=accounts->groupStringList.grep(userRegExp); // Find all entries in the group database, that the user is a member of. - for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { // Iterate over all of them. + for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) + { // Iterate over all of them. qWarning(*it); QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. - for ( ; lvit.current(); ++lvit ) { - if(lvit.current()->text(0)==(*it).left((*it).find(":"))) { + for ( ; lvit.current(); ++lvit ) + { + if(lvit.current()->text(0)==(*it).left((*it).find(":"))) + { temp=(QCheckListItem*)lvit.current(); temp->setOn(true); // If we find a line with that groupname, select it.; } } } if(!(edituserDialog->exec())) return false; // SHOW THE DIALOG! accounts->findUser(username); // Fill user variables in 'acccounts' object. accounts->pw_name=edituserDialog->loginLineEdit->text(); // Has the password been changed ? Make a new "crypt":ed password. if(edituserDialog->passwordLineEdit->text()!="........") accounts->pw_passwd=crypt(edituserDialog->passwordLineEdit->text(), accounts->crypt_make_salt()); // Set all variables in accounts object, that will be used when calling 'updateUser()' accounts->pw_uid=edituserDialog->uidLineEdit->text().toInt(); - if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) { // Fill all group variables in 'accounts' object. + if(accounts->findGroup(edituserDialog->groupComboBox->currentText())) + { // Fill all group variables in 'accounts' object. accounts->pw_gid=accounts->gr_gid; // Only do this if the group is a valid group (ie. "<Undefined group>"), otherwise keep the old group. } accounts->pw_gecos=edituserDialog->gecosLineEdit->text(); accounts->pw_shell=edituserDialog->shellComboBox->currentText(); // Update userinfo, using the information stored in the user variables stored in the accounts object. accounts->updateUser(username); // Remove user from all groups he/she is a member of. (could be done in a better way I guess, this was simple though.) - for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) { + for(QStringList::Iterator it=tempList.begin(); it!=tempList.end(); ++it) + { accounts->delGroupMember((*it).left((*it).find(":")),username); } // Add User to additional groups that he/she is a member of. QListViewItemIterator it( edituserDialog->groupsListView ); - for ( ; it.current(); ++it ) { + for ( ; it.current(); ++it ) + { temp=(QCheckListItem*)it.current(); if ( temp->isOn() ) accounts->addGroupMember(it.current()->text(0),edituserDialog->loginLineEdit->text()); } // Copy image to pics/users/ - if(!(edituserDialog->userImage.isNull())) { + if(!(edituserDialog->userImage.isNull())) + { QDir d; - if(!(d.exists("/opt/QtPalmtop/pics/users"))) { + if(!(d.exists("/opt/QtPalmtop/pics/users"))) + { d.mkdir("/opt/QtPalmtop/pics/users"); } QString filename="/opt/QtPalmtop/pics/users/"+accounts->pw_name+".png"; // edituserDialog->userImage=edituserDialog->userImage.smoothScale(48,48); edituserDialog->userImage.save(filename,"PNG"); } return true; } /** * "OK" has been clicked. Verify some information before closing the dialog. * */ -void UserDialog::accept() { +void UserDialog::accept() +{ // Add checking... valid username? username taken? - if(loginLineEdit->text().isEmpty()) { + if(loginLineEdit->text().isEmpty()) + { QMessageBox::information(0,"Empty Login","Please enter a login."); return; } QDialog::accept(); } /** * This slot is called when the usericon is clicked, this loads (should) the iconselector. * */ -void UserDialog::clickedPicture() { +void UserDialog::clickedPicture() +{ QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); - if(!(filename.isEmpty())) { + if(!(filename.isEmpty())) + { userImage.reset(); - if(!(userImage.load(filename))) { + if(!(userImage.load(filename))) + { QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); - } else { + } + else + { // userImage=userImage.smoothScale(48,48); QPixmap *picture; picture=(QPixmap *)picturePushButton->pixmap(); picture->convertFromImage(userImage,0); picturePushButton->update(); } } } |