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 | 968 | ||||
-rw-r--r-- | noncore/settings/appearance2/stylelistitem.h | 12 | ||||
-rw-r--r-- | noncore/settings/aqpkg/categoryfilterimpl.cpp | 28 | ||||
-rw-r--r-- | noncore/settings/aqpkg/instoptionsimpl.cpp | 44 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 176 | ||||
-rw-r--r-- | noncore/settings/aqpkg/settingsimpl.cpp | 243 | ||||
-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 | 1783 | ||||
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 88 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 76 | ||||
-rw-r--r-- | noncore/settings/usermanager/userdialog.cpp | 743 |
12 files changed, 2197 insertions, 2006 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 @@ -29,2 +29,26 @@ +#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> @@ -51,27 +75,2 @@ -#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; @@ -83,18 +82,21 @@ public: DefaultWindowDecoration() : ref(0) {} - QString name() const { - return "Default"; + QString name() const + { + return "Default"; } -QPixmap icon() const { - return QPixmap(); + QPixmap icon() const + { + return QPixmap(); } - 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; + 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; } @@ -103,3 +105,3 @@ QPixmap icon() const { private: - ulong ref; + ulong ref; }; @@ -119,3 +121,3 @@ QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) 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." ) ); + 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." ) ); @@ -124,3 +126,3 @@ QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) 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." ) ); + QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) ); @@ -136,25 +138,28 @@ QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) #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 ) { - 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 ) { - StyleListItem *slit = new StyleListItem ( lib, iface ); - m_style_list-> insertItem ( slit ); - - if ( slit-> key ( ) == s ) - m_style_list-> setCurrentItem ( slit ); - } - else - delete lib; - } - } + + { + 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 ) + { + 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 ) + { + StyleListItem *slit = new StyleListItem ( lib, iface ); + m_style_list-> insertItem ( slit ); + + if ( slit-> key ( ) == s ) + m_style_list-> setCurrentItem ( slit ); + } + else + delete lib; + } + } @@ -165,3 +170,3 @@ QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) - return tab; + return tab; } @@ -175,3 +180,3 @@ QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) 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." ) ); + 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." ) ); @@ -181,25 +186,27 @@ QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) - { - 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 ) { - QString libstr = path; - libstr.append( "/" ); - libstr.append( *it ); - QLibrary *lib = new QLibrary ( libstr ); - WindowDecorationInterface *iface; - - 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; - } - } + { + 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 ) + { + QString libstr = path; + libstr.append( "/" ); + libstr.append( *it ); + QLibrary *lib = new QLibrary ( libstr ); + WindowDecorationInterface *iface; + + 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; + } + } @@ -207,3 +214,3 @@ QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) if ( m_deco_list-> currentItem ( ) < 0 ) - m_deco_list-> setCurrentItem ( 0 ); + m_deco_list-> setCurrentItem ( 0 ); decoClicked ( m_original_deco ); @@ -212,3 +219,3 @@ QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) - return tab; + return tab; } @@ -223,3 +230,3 @@ QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) 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." ) ); + QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); @@ -240,19 +247,20 @@ QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) 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." ) ); + 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 )); + m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); - QString path = QPEApplication::qpeDir ( ); - path.append( "/etc/colors/" ); + QString path = QPEApplication::qpeDir ( ); + path.append( "/etc/colors/" ); QStringList sl = QDir ( path ). entryList ( "*.scheme" ); - 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" ); + 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-> insertItem ( new ColorListItem ( name, config )); + } @@ -264,3 +272,3 @@ QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) gridLayout->addWidget( tempButton, 0, 1 ); - QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); + QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); @@ -270,3 +278,3 @@ QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) gridLayout->addWidget( tempButton, 1, 1 ); - QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); + QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); @@ -276,3 +284,3 @@ QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) gridLayout->addWidget( tempButton, 2, 1 ); - QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); + QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); @@ -286,78 +294,79 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) - 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 ) { - 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 *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 ) + { + 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 ); @@ -366,4 +375,4 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) - int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; - bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); + int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; + bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); @@ -371,3 +380,3 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) 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" ) ); + 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" ) ); @@ -384,3 +393,3 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) 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" ) ); + 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" ) ); @@ -389,3 +398,3 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) 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." ) ); + QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); @@ -394,3 +403,3 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) 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." ) ); + QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); @@ -399,48 +408,51 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) - 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) { - rot = ODevice::inst ( )-> direction ( ); - } else { - rot = (ODirection)rotDirection; - } - - m_rotdir_cw-> setChecked ( rot == CW ); - m_rotdir_ccw-> setChecked ( rot == CCW ); - m_rotdir_flip-> setChecked ( rot == Flip ); - - return tab; + 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) + { + rot = ODevice::inst ( )-> direction ( ); + } + else + { + rot = (ODirection)rotDirection; + } + + m_rotdir_cw-> setChecked ( rot == CW ); + m_rotdir_ccw-> setChecked ( rot == CCW ); + m_rotdir_flip-> setChecked ( rot == Flip ); + + return tab; } @@ -449,3 +461,3 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) Appearance::Appearance( QWidget* parent, const char* name, WFlags ) - : QDialog ( parent, name, true, WStyle_ContextHelp ) + : QDialog ( parent, name, true, WStyle_ContextHelp ) { @@ -458,13 +470,13 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags ) - m_sample = new SampleWindow ( this ); + 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." ) ); + 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; + QWidget *styletab; - m_color_list = 0; + m_color_list = 0; - tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); + tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); @@ -472,9 +484,9 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags ) tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); - tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); + tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); - top-> addWidget ( tw, 10 ); - top-> addWidget ( m_sample, 1 ); + top-> addWidget ( tw, 10 ); + top-> addWidget ( m_sample, 1 ); tw-> setCurrentTab ( styletab ); - connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); + connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); @@ -484,4 +496,3 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags ) Appearance::~Appearance() -{ -} +{} @@ -489,8 +500,9 @@ void Appearance::tabChanged ( QWidget *w ) { - if ( w == m_advtab ) { - m_sample-> hide ( ); - updateGeometry ( ); // shouldn't be necessary ... - } - else - m_sample-> show ( ); + if ( w == m_advtab ) + { + m_sample-> hide ( ); + updateGeometry ( ); // shouldn't be necessary ... + } + else + m_sample-> show ( ); } @@ -499,4 +511,4 @@ void Appearance::accept ( ) { - bool newtabpos = m_tabstyle_top-> isChecked ( ); - int newtabstyle = m_tabstyle_list-> currentItem ( ); + bool newtabpos = m_tabstyle_top-> isChecked ( ); + int newtabstyle = m_tabstyle_list-> currentItem ( ); @@ -505,20 +517,24 @@ void Appearance::accept ( ) - if ( m_style_changed ) { - StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); - if ( item ) + 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 ) { - DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); - if ( item ) + 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 )) { - config. writeEntry ( "TabStyle", newtabstyle + 1 ); - config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); - } + 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 ( )); @@ -531,38 +547,44 @@ void Appearance::accept ( ) { - ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); - - if ( item ) - item-> save ( config ); - } - - ODirection rot; - if (m_rotdir_ccw-> isChecked ( )) { - rot = CCW; - } else if (m_rotdir_cw-> isChecked ( )) { - rot = CW; - } 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 ( )) { - 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 ( ); + ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); + + if ( item ) + item-> save ( config ); + } + + ODirection rot; + if (m_rotdir_ccw-> isChecked ( )) + { + rot = CCW; + } + else if (m_rotdir_cw-> isChecked ( )) + { + rot = CW; + } + 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 ( )) + { + 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 ( ); } @@ -571,4 +593,4 @@ void Appearance::done ( int r ) { - QDialog::done ( r ); - close ( ); + QDialog::done ( r ); + close ( ); } @@ -579,11 +601,12 @@ void Appearance::styleClicked ( int index ) StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); - m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); + m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); - if ( m_sample && sli && sli-> style ( )) { - int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; + 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_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); + } - m_style_changed |= ( index != m_original_style ); + m_style_changed |= ( index != m_original_style ); } @@ -592,23 +615,24 @@ void Appearance::styleSettingsClicked ( ) { - StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); + StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); - if ( item && item-> hasSettings ( )) { - QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); - QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); + if ( item && item-> hasSettings ( )) + { + QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); + QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); - QWidget *w = item-> settings ( d ); + QWidget *w = item-> settings ( d ); - if ( w ) { - vbox-> addWidget ( w ); + if ( w ) + { + vbox-> addWidget ( w ); - d-> setCaption ( w-> caption ( )); + 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; - } + if ( item-> setSettings ( accepted )) + m_style_changed = true; + } + delete d; + } } @@ -619,10 +643,11 @@ void Appearance::decoClicked ( int index ) - 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 ); + 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 ); } @@ -631,4 +656,4 @@ void Appearance::fontClicked ( const QFont &f ) { - m_font_changed |= ( f != m_sample-> font ( )); - m_sample-> setFont ( f ); + m_font_changed |= ( f != m_sample-> font ( )); + m_sample-> setFont ( f ); } @@ -637,8 +662,8 @@ void Appearance::colorClicked ( int index ) { - ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); + ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); - if ( item ) - m_sample-> setPalette ( item-> palette ( )); + if ( item ) + m_sample-> setPalette ( item-> palette ( )); - m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); + m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); } @@ -648,30 +673,34 @@ void Appearance::editSchemeClicked ( ) { - ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); + ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); - int cnt = 0; - QString labels [QColorGroup::NColorRoles]; - QColor colors [QColorGroup::NColorRoles]; + int cnt = 0; + QString labels [QColorGroup::NColorRoles]; + QColor colors [QColorGroup::NColorRoles]; - for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { - QColor col = item-> color ( role ); + for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) + { + QColor col = item-> color ( role ); - if ( col. isValid ( )) { - labels [cnt] = item-> label ( role ); - colors [cnt] = col; + if ( col. isValid ( )) + { + labels [cnt] = item-> label ( role ); + colors [cnt] = col; - cnt++; - } - } + cnt++; + } + } EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); - editdlg-> showMaximized ( ); - if ( editdlg-> exec ( ) == 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 ( )) { - citem-> setColor ( role, colors [cnt] ); - cnt++; - } + 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 ( )) + { + citem-> setColor ( role, colors [cnt] ); + cnt++; + } } @@ -689,19 +718,20 @@ void Appearance::saveSchemeClicked() { - ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); + ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); - if ( !item ) - return; + 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 ( ); + 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" ); + QString filestr = QPEApplication::qpeDir(); + filestr.append( "/etc/colors/" ); + filestr.append( schemename ); + filestr.append( ".scheme" ); QFile file ( filestr ); @@ -709,3 +739,3 @@ void Appearance::saveSchemeClicked() { - QPalette p = item-> palette ( ); + QPalette p = item-> palette ( ); @@ -714,3 +744,3 @@ void Appearance::saveSchemeClicked() - item-> save ( config ); + item-> save ( config ); @@ -722,3 +752,3 @@ void Appearance::saveSchemeClicked() { - QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); + QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); } @@ -730,6 +760,6 @@ void Appearance::deleteSchemeClicked() { - ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); + ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); - if ( !item ) - return; + if ( !item ) + return; @@ -737,10 +767,10 @@ void Appearance::deleteSchemeClicked() { - 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; + 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; } @@ -756,5 +786,5 @@ void Appearance::addExcept ( ) { - ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true ); - m_except-> ensureItemVisible ( it ); - m_except-> setSelected ( it, true ); + ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true ); + m_except-> ensureItemVisible ( it ); + m_except-> setSelected ( it, true ); } @@ -763,6 +793,7 @@ void Appearance::delExcept ( ) { - if ( m_except-> selectedItem ( )) { - m_except-> setFocus ( ); - delete m_except-> selectedItem ( ); - } + if ( m_except-> selectedItem ( )) + { + m_except-> setFocus ( ); + delete m_except-> selectedItem ( ); + } } @@ -771,6 +802,6 @@ void Appearance::upExcept ( ) { - ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); + ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); - if ( it && it-> itemAbove ( )) - it-> itemAbove ( )-> moveItem ( it ); + if ( it && it-> itemAbove ( )) + it-> itemAbove ( )-> moveItem ( it ); } @@ -779,58 +810,60 @@ void Appearance::downExcept ( ) { - ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); + ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); - if ( it && it-> itemBelow ( )) - it-> moveItem ( it-> itemBelow ( )); + 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 ) { - m_out = false; - it-> listView ( )-> setFocus ( ); - } - else - QLineEdit::keyPressEvent ( e ); - } + 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 ) + { + m_out = false; + it-> listView ( )-> setFocus ( ); + } + else + QLineEdit::keyPressEvent ( e ); + } private: - ExceptListItem *it; - bool m_out; + ExceptListItem *it; + bool m_out; }; @@ -839,17 +872,18 @@ 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 ) { - m_except-> ensureItemVisible ( it ); - new ExEdit ( it ); - } + 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 ) + { + 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 @@ -30,4 +30,10 @@ -#include <qlistbox.h> +/* OPIE */ #include <qpe/styleinterface.h> +#include <qpe/qlibrary.h> +#include <qpe/resource.h> + +/* QT */ +#include <qlistbox.h> +#include <qfileinfo.h> @@ -37,4 +43,4 @@ class StyleListItem : public QListBoxText { public: - StyleListItem ( const QString &t, QStyle *sty ) : QListBoxText ( t ) - { + StyleListItem ( const QString &t, QStyle *sty ) : QListBoxText ( t ) + { m_lib = 0; 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 @@ -29,7 +29,10 @@ -#include <iostream> -using namespace std; +#include "categoryfilterimpl.h" + +/* OPIE */ +#include <qpe/qpeapplication.h> +/* QT */ #include <qgroupbox.h> -#include <qlayout.h> +#include <qlayout.h> #include <qlistbox.h> @@ -37,6 +40,9 @@ using namespace std; -#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 ) + : QDialog( parent, name, true ) { @@ -54,3 +60,3 @@ CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QStrin QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); - + lstCategories = new QListBox( grpbox ); @@ -58,3 +64,3 @@ CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QStrin grplayout->addWidget( lstCategories ); - + // Split up categories and add them to the listbox @@ -78,3 +84,4 @@ CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QStrin start = end + 1; - } while ( start < (int)categories.length() ); + } + while ( start < (int)categories.length() ); @@ -82,3 +89,3 @@ CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QStrin - showMaximized(); + QPEApplication::showDialog( this ); } @@ -86,4 +93,3 @@ CategoryFilterImpl :: CategoryFilterImpl(const QString &categories, const QStrin CategoryFilterImpl :: ~CategoryFilterImpl() -{ -} +{} 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 @@ -29,2 +29,7 @@ +#include "global.h" +#include "instoptionsimpl.h" +#include "ipkg.h" + +/* OPIE */ #ifdef QWS @@ -32,3 +37,5 @@ #endif +#include <qpe/qpeapplication.h> +/* QT */ #include <qcheckbox.h> @@ -39,11 +46,7 @@ -#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 ) + : QDialog( parent, name, modal, fl ) { setCaption( tr( "Options" ) ); - + QVBoxLayout *layout = new QVBoxLayout( this ); @@ -58,3 +61,3 @@ InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * par QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); - + forceDepends = new QCheckBox( tr( "Force Depends" ), grpbox ); @@ -73,3 +76,3 @@ InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * par grplayout->addWidget( l ); - + verboseIpkg = new QComboBox( grpbox ); @@ -81,19 +84,19 @@ InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * par grplayout->addWidget( verboseIpkg ); - + grplayout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); - + if ( flags & FORCE_DEPENDS ) - forceDepends->setChecked( true ); + forceDepends->setChecked( true ); if ( flags & FORCE_REINSTALL ) - forceReinstall->setChecked( true ); + forceReinstall->setChecked( true ); if ( flags & FORCE_REMOVE ) - forceRemove->setChecked( true ); + forceRemove->setChecked( true ); if ( flags & FORCE_OVERWRITE ) - forceOverwrite->setChecked( true ); -// if ( flags & VERBOSE_WGET ) -// verboseWget->setChecked( true ); -// if ( flags & MAKE_LINKS ) -// makeLinks->setChecked( true ); + forceOverwrite->setChecked( true ); + // if ( flags & VERBOSE_WGET ) + // verboseWget->setChecked( true ); + // if ( flags & MAKE_LINKS ) + // makeLinks->setChecked( true ); - showMaximized(); + QPEApplication::showDialog( this ); @@ -102,4 +105,3 @@ InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * par InstallOptionsDlgImpl::~InstallOptionsDlgImpl() -{ -} +{} 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 @@ -2,3 +2,3 @@ This file is part of the OPIE Project - + =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> @@ -29,9 +29,17 @@ -#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> @@ -39,2 +47,5 @@ +/* QT */ +#include <qmenubar.h> +#include <qtoolbar.h> #include <qaction.h> @@ -54,13 +65,5 @@ -#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> @@ -69,3 +72,3 @@ extern int compareVersions( const char *v1, const char *v2 ); MainWindow :: MainWindow( QWidget* parent, const char* name, WFlags fl ) - : QMainWindow( parent, name, fl || WStyle_ContextHelp ) + : QMainWindow( parent, name, fl || WStyle_ContextHelp ) { @@ -241,3 +244,3 @@ MainWindow :: ~MainWindow() { - delete mgr; + delete mgr; @@ -298,3 +301,3 @@ void MainWindow :: init() currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); -// showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); + // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); @@ -339,4 +342,4 @@ void MainWindow :: setDocument( const QString &doc ) for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); - item != 0 ; - item = (QCheckListItem *)item->nextSibling() ) + item != 0 ; + item = (QCheckListItem *)item->nextSibling() ) { @@ -356,3 +359,3 @@ void MainWindow :: displaySettings() stack->raiseWidget( progressWindow ); - updateData(); + updateData(); stack->raiseWidget( networkPkgWindow ); @@ -584,8 +587,8 @@ void MainWindow :: updateData() if ( serverName == currentlySelectedServer ) - activeItem = i; - } + activeItem = i; + } - // set selected server to be active server - if ( activeItem != -1 ) - serversList->setCurrentItem( activeItem ); + // set selected server to be active server + if ( activeItem != -1 ) + serversList->setCurrentItem( activeItem ); serverSelected( 0, FALSE ); @@ -627,6 +630,6 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) #ifdef QWS - // read download directory from config file - Config cfg( "aqpkg" ); - cfg.setGroup( "settings" ); - cfg.writeEntry( "selectedServer", currentlySelectedServer ); + // read download directory from config file + Config cfg( "aqpkg" ); + cfg.setGroup( "settings" ); + cfg.writeEntry( "selectedServer", currentlySelectedServer ); #endif @@ -680,3 +683,3 @@ void MainWindow :: serverSelected( int, bool raiseProgress ) QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), - QCheckListItem::CheckBox ); + QCheckListItem::CheckBox ); @@ -740,3 +743,3 @@ void MainWindow :: searchForPackage( const QString &text ) for ( QCheckListItem *item = start; item != 0 ; - item = (QCheckListItem *)item->nextSibling() ) + item = (QCheckListItem *)item->nextSibling() ) { @@ -768,5 +771,5 @@ void MainWindow :: updateServer() InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), - tr( "Update lists" ) ); + tr( "Update lists" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); - reloadDocuments = FALSE; + reloadDocuments = FALSE; stack->addWidget( dlg, 3 ); @@ -774,3 +777,3 @@ void MainWindow :: updateServer() -// delete progDlg; + // delete progDlg; } @@ -784,5 +787,5 @@ void MainWindow :: upgradePackages() QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, - QMessageBox::Yes, - QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , - 0, this ); + QMessageBox::Yes, + QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , + 0, this ); warn.adjustSize(); @@ -799,5 +802,5 @@ void MainWindow :: upgradePackages() InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), - tr ( "Upgrade" ) ); + tr ( "Upgrade" ) ); connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); - reloadDocuments = TRUE; + reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); @@ -817,4 +820,4 @@ void MainWindow :: downloadPackage() for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); - item != 0 && !found; - item = (QCheckListItem *)item->nextSibling() ) + item != 0 && !found; + item = (QCheckListItem *)item->nextSibling() ) { @@ -838,4 +841,4 @@ void MainWindow :: downloadPackage() for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); - item != 0 ; - item = (QCheckListItem *)item->nextSibling() ) + item != 0 ; + item = (QCheckListItem *)item->nextSibling() ) { @@ -857,3 +860,3 @@ void MainWindow :: downloadPackage() if ( QMessageBox::information( this, tr( "Are you sure?" ), - msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) + msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) { @@ -910,4 +913,4 @@ void MainWindow :: downloadSelectedPackages() for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); - item != 0 ; - item = (QCheckListItem *)item->nextSibling() ) + item != 0 ; + item = (QCheckListItem *)item->nextSibling() ) { @@ -928,8 +931,8 @@ void MainWindow :: downloadRemotePackage() return; -// DownloadRemoteDlgImpl dlg( this, "Install", true ); -// if ( dlg.exec() == QDialog::Rejected ) -// return; + // DownloadRemoteDlgImpl dlg( this, "Install", true ); + // if ( dlg.exec() == QDialog::Rejected ) + // return; // grab details from dialog -// QString package = dlg.getPackageLocation(); + // QString package = dlg.getPackageLocation(); @@ -944,3 +947,3 @@ void MainWindow :: downloadRemotePackage() connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); - reloadDocuments = TRUE; + reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); @@ -963,4 +966,4 @@ void MainWindow :: applyChanges() for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); - item != 0 ; - item = (QCheckListItem *)item->nextSibling() ) + item != 0 ; + item = (QCheckListItem *)item->nextSibling() ) { @@ -973,3 +976,3 @@ void MainWindow :: applyChanges() return; - } + } } @@ -980,3 +983,3 @@ void MainWindow :: applyChanges() QMessageBox::information( this, tr( "Nothing to do" ), - tr( "No packages selected" ), tr( "OK" ) ); + tr( "No packages selected" ), tr( "OK" ) ); @@ -988,3 +991,3 @@ void MainWindow :: applyChanges() connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); - reloadDocuments = TRUE; + reloadDocuments = TRUE; stack->addWidget( dlg, 3 ); @@ -1026,3 +1029,3 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) name = item->text(); - + if ( !p->isPackageStoredLocally() ) @@ -1092,15 +1095,15 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) { - 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; + 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; } @@ -1109,3 +1112,3 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) { -// newitem->option = stickyOption; + // newitem->option = stickyOption; } @@ -1116,5 +1119,5 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) if ( newitem->option != "R" ) - newitem->recreateLinks = true; + newitem->recreateLinks = true; else - newitem->recreateLinks = false; + newitem->recreateLinks = false; @@ -1140,10 +1143,10 @@ void MainWindow :: reloadData( InstallDlgImpl *dlg ) 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; - } + { + 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 @@ -1183,3 +1186,4 @@ void MainWindow :: letterPushed( QString t ) item = (QCheckListItem *)packagesList->firstChild(); - } while ( item != start); + } + while ( item != start); } @@ -1190,3 +1194,3 @@ void MainWindow :: slotDisplayPackage( QListViewItem *item ) PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); - p->showMaximized(); + QPEApplication::showWidget( p ); } @@ -1194,3 +1198,3 @@ void MainWindow :: slotDisplayPackage( QListViewItem *item ) QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) - : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) + : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) { 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 @@ -26,9 +26,17 @@ 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> @@ -41,18 +49,12 @@ using namespace std; -#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 ) + : QDialog( parent, name, modal, fl ) { setCaption( tr( "Configuration" ) ); - + // Setup layout to make everything pretty @@ -70,3 +72,3 @@ SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const tabwidget->setCurrentTab( tr( "Servers" ) ); - + dataMgr = dataManager; @@ -80,3 +82,2 @@ SettingsImpl :: ~SettingsImpl() { - } @@ -85,9 +86,7 @@ bool SettingsImpl :: showDlg() { - showMaximized(); - exec(); - - if ( changed ) - dataMgr->writeOutIpkgConf(); + QPEApplication::execDialog( this ); + if ( changed ) + dataMgr->writeOutIpkgConf(); - return changed; + return changed; } @@ -120,3 +119,3 @@ QWidget *SettingsImpl :: initServerTab() layout->addWidget( btn, 1, 0 ); - + btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); @@ -124,3 +123,3 @@ QWidget *SettingsImpl :: initServerTab() layout->addWidget( btn, 1, 1 ); - + QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); @@ -131,3 +130,3 @@ QWidget *SettingsImpl :: initServerTab() QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); - + QLabel *label = new QLabel( tr( "Name:" ), grpbox ); @@ -144,3 +143,3 @@ QWidget *SettingsImpl :: initServerTab() grplayout->addMultiCellWidget( active, 2, 2, 0, 1 ); - + btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); @@ -148,3 +147,3 @@ QWidget *SettingsImpl :: initServerTab() grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); - + return control; @@ -178,3 +177,3 @@ QWidget *SettingsImpl :: initDestinationTab() layout->addWidget( btn, 1, 0 ); - + btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); @@ -182,3 +181,3 @@ QWidget *SettingsImpl :: initDestinationTab() layout->addWidget( btn, 1, 1 ); - + QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Destination" ), container ); @@ -189,3 +188,3 @@ QWidget *SettingsImpl :: initDestinationTab() QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); - + QLabel *label = new QLabel( tr( "Name:" ), grpbox ); @@ -202,3 +201,3 @@ QWidget *SettingsImpl :: initDestinationTab() grplayout->addMultiCellWidget( linkToRoot, 2, 2, 0, 1 ); - + btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); @@ -206,3 +205,3 @@ QWidget *SettingsImpl :: initDestinationTab() grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); - + return control; @@ -237,3 +236,3 @@ QWidget *SettingsImpl :: initProxyTab() grplayout->addWidget( chkHttpProxyEnabled ); - + grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); @@ -247,3 +246,3 @@ QWidget *SettingsImpl :: initProxyTab() grplayout->addWidget( chkFtpProxyEnabled ); - + QLabel *label = new QLabel( tr( "Username:" ), container ); @@ -261,3 +260,3 @@ QWidget *SettingsImpl :: initProxyTab() layout->addMultiCellWidget( btn, 4, 4, 0, 1 ); - + return control; @@ -271,3 +270,3 @@ void SettingsImpl :: setupData() for ( ; it.current(); ++it ) - { + { serverName = it.current()->getServerName(); @@ -277,3 +276,3 @@ void SettingsImpl :: setupData() servers->insertItem( serverName ); - } + } @@ -284,3 +283,3 @@ void SettingsImpl :: setupData() destinations->insertItem( it2.current()->getDestinationName() ); - + // setup proxy tab @@ -338,42 +337,42 @@ 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 - { + 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() ); @@ -381,6 +380,6 @@ void SettingsImpl :: changeServerDetails() dataMgr->getServerList().last()->setActive( active->isChecked() ); - servers->insertItem( newName ); - servers->setCurrentItem( servers->count() ); - newserver = false; - } + servers->insertItem( newName ); + servers->setCurrentItem( servers->count() ); + newserver = false; + } } @@ -411,6 +410,6 @@ void SettingsImpl :: newDestination() { - newdestination = true; - destinationname->setText( "" ); - destinationurl->setText( "" ); - destinationname->setFocus(); + newdestination = true; + destinationname->setText( "" ); + destinationurl->setText( "" ); + destinationname->setFocus(); linkToRoot->setChecked( true ); @@ -431,3 +430,3 @@ void SettingsImpl :: changeDestinationDetails() { - changed = true; + changed = true; @@ -439,35 +438,36 @@ void SettingsImpl :: changeDestinationDetails() 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 ); - } + 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; + 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; @@ -478,3 +478,4 @@ void SettingsImpl :: changeDestinationDetails() #endif - } + + } } 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 @@ -2,8 +2,11 @@ #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> @@ -23,4 +26,4 @@ #include <qtextview.h> -#include <opie2/ostorageinfo.h> +/* STD */ #include <errno.h> @@ -43,3 +46,2 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags f { - this->showMaximized(); backupList->header()->hide(); @@ -132,2 +134,3 @@ BackupAndRestore::BackupAndRestore( QWidget* parent, const char* name, WFlags f } + QPEApplication::showWidget( this ); } @@ -289,4 +292,3 @@ void BackupAndRestore::backup() } - pErrDialog->showMaximized(); - pErrDialog->exec(); + QPEApplication::execDialog( pErrDialog ); delete pErrDialog; @@ -454,4 +456,3 @@ void BackupAndRestore::restore() } - pErrDialog->showMaximized(); - pErrDialog->exec(); + QPEApplication::execDialog( pErrDialog ); delete pErrDialog; 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 @@ -26,4 +26,14 @@ +#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> @@ -33,3 +43,2 @@ #include <qmessagebox.h> - #include <qapplication.h> @@ -39,8 +48,5 @@ -#include "interfaceppp.h" -#include "devices.h" -#include "authwidget.h" -#include "pppdata.h" -#include "edit.h" -#include "general.h" +/* STD */ +#include <stdlib.h> + @@ -193,4 +199,3 @@ int DevicesWidget::doTab(){ while (!ok){ - dlg->showMaximized(); - result = dlg->exec(); + result = QPEApplication::execDialog( dlg ); ok = true; 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 @@ -25,4 +25,12 @@ -#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> @@ -36,8 +44,7 @@ #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> @@ -45,114 +52,123 @@ DialWidget::DialWidget( PPPData *pd, QWidget *parent, bool isnewaccount , const char *name ) - : QWidget(parent, name), _pppdata(pd) + : 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) { - 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] == ':') { - if(tmp.length() > 0) - numbers->insertItem(tmp); - tmp = ""; - } else - tmp += n[idx]; - idx++; - } - if(tmp.length() > 0) - numbers->insertItem(tmp); + 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) + { + 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] == ':') + { + if(tmp.length() > 0) + numbers->insertItem(tmp); + tmp = ""; + } + else + tmp += n[idx]; + idx++; + } + if(tmp.length() > 0) + numbers->insertItem(tmp); - numbersChanged(); - tl->activate(); + } + + numbersChanged(); + tl->activate(); } -bool DialWidget::save() { - //first check to make sure that the account name is unique! - if(connectname_l->text().isEmpty() || - !_pppdata->isUniqueAccname(connectname_l->text())) { - return false; - } else { - _pppdata->setAccname(connectname_l->text()); - - QString number = ""; - for(uint i = 0; i < numbers->count(); i++) { - if(i != 0) - number += ":"; - number += numbers->text(i); +bool DialWidget::save() +{ + //first check to make sure that the account name is unique! + if(connectname_l->text().isEmpty() || + !_pppdata->isUniqueAccname(connectname_l->text())) + { + return false; } + else + { + _pppdata->setAccname(connectname_l->text()); + + QString number = ""; + for(uint i = 0; i < numbers->count(); i++) + { + if(i != 0) + number += ":"; + number += numbers->text(i); + } - _pppdata->setPhonenumber(number); - return true; - } + _pppdata->setPhonenumber(number); + return true; + } } @@ -160,8 +176,9 @@ bool DialWidget::save() { -void DialWidget::numbersChanged() { - int sel = numbers->currentItem(); +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); + del->setEnabled(sel != -1); + up->setEnabled(sel != -1 && sel != 0); + down->setEnabled(sel != -1 && sel != (int)numbers->count()-1); } @@ -169,4 +186,5 @@ void DialWidget::numbersChanged() { -void DialWidget::selectionChanged(int) { - numbersChanged(); +void DialWidget::selectionChanged(int) +{ + numbersChanged(); } @@ -174,8 +192,10 @@ void DialWidget::selectionChanged(int) { -void DialWidget::addNumber() { +void DialWidget::addNumber() +{ PhoneNumberDialog dlg(this); - if(dlg.exec()) { - numbers->insertItem(dlg.phoneNumber()); - numbersChanged(); - } + if(dlg.exec()) + { + numbers->insertItem(dlg.phoneNumber()); + numbersChanged(); + } } @@ -183,7 +203,9 @@ void DialWidget::addNumber() { -void DialWidget::delNumber() { - if(numbers->currentItem() != -1) { - numbers->removeItem(numbers->currentItem()); - numbersChanged(); - } +void DialWidget::delNumber() +{ + if(numbers->currentItem() != -1) + { + numbers->removeItem(numbers->currentItem()); + numbersChanged(); + } } @@ -191,11 +213,13 @@ void DialWidget::delNumber() { -void DialWidget::upNumber() { - int idx = numbers->currentItem(); - if(idx != -1) { - QString item = numbers->text(idx); - numbers->removeItem(idx); - numbers->insertItem(item, idx-1); - numbers->setCurrentItem(idx-1); - numbersChanged(); - } +void DialWidget::upNumber() +{ + int idx = numbers->currentItem(); + if(idx != -1) + { + QString item = numbers->text(idx); + numbers->removeItem(idx); + numbers->insertItem(item, idx-1); + numbers->setCurrentItem(idx-1); + numbersChanged(); + } } @@ -203,11 +227,13 @@ void DialWidget::upNumber() { -void DialWidget::downNumber() { - int idx = numbers->currentItem(); - if(idx != -1) { - QString item = numbers->text(idx); - numbers->removeItem(idx); - numbers->insertItem(item, idx+1); - numbers->setCurrentItem(idx+1); - numbersChanged(); - } +void DialWidget::downNumber() +{ + int idx = numbers->currentItem(); + if(idx != -1) + { + QString item = numbers->text(idx); + numbers->removeItem(idx); + numbers->insertItem(item, idx+1); + numbers->setCurrentItem(idx+1); + numbersChanged(); + } } @@ -215,6 +241,6 @@ void DialWidget::downNumber() { -void DialWidget::pppdargsbutton() { +void DialWidget::pppdargsbutton() +{ PPPdArguments pa(_pppdata, this); - pa.showMaximized(); - pa.exec(); + QPEApplication::execDialog( &pa ); } @@ -227,3 +253,3 @@ void DialWidget::pppdargsbutton() { ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const char *name) : - QWidget(parent, name), _pppdata(pd) + QWidget(parent, name), _pppdata(pd) { @@ -231,84 +257,85 @@ ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const ch - 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) { - 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()); - } + 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) + { + 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()); + } } @@ -316,8 +343,9 @@ ExecWidget::ExecWidget(PPPData *pd, QWidget *parent, bool isnewaccount, const ch -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; +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; } @@ -332,104 +360,108 @@ bool ExecWidget::save() { IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) - : QWidget(parent, name), _pppdata(pd) + : 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(_pppdata->ipaddr() == "0.0.0.0" && - _pppdata->subnetmask() == "0.0.0.0") { - dynamicadd_rb->setChecked(true); - hitIPSelect(0); - autoname->setChecked(_pppdata->autoname()); + 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(_pppdata->ipaddr() == "0.0.0.0" && + _pppdata->subnetmask() == "0.0.0.0") + { + dynamicadd_rb->setChecked(true); + hitIPSelect(0); + autoname->setChecked(_pppdata->autoname()); + } + else + { + ipaddress_l->setText(_pppdata->ipaddr()); + subnetmask_l->setText(_pppdata->subnetmask()); + staticadd_rb->setChecked(true); + autoname->setChecked(false); + } } - else { - ipaddress_l->setText(_pppdata->ipaddr()); - subnetmask_l->setText(_pppdata->subnetmask()); - staticadd_rb->setChecked(true); - autoname->setChecked(false); + else + { + dynamicadd_rb->setChecked(true); + hitIPSelect(0); } - } - else { - dynamicadd_rb->setChecked(true); - hitIPSelect(0); - } @@ -437,18 +469,20 @@ IPWidget::IPWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char -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) { - 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::autoname_t(bool on) +{ + static bool was_warned = false; + + // big-fat warning when selecting the auto configure hostname option + 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; + } } @@ -456,11 +490,15 @@ void IPWidget::autoname_t(bool on) { -void IPWidget::save() { - if(dynamicadd_rb->isChecked()) { - _pppdata->setIpaddr("0.0.0.0"); - _pppdata->setSubnetmask("0.0.0.0"); - } else { - _pppdata->setIpaddr(ipaddress_l->text()); - _pppdata->setSubnetmask(subnetmask_l->text()); - } - _pppdata->setAutoname(autoname->isChecked()); +void IPWidget::save() +{ + if(dynamicadd_rb->isChecked()) + { + _pppdata->setIpaddr("0.0.0.0"); + _pppdata->setSubnetmask("0.0.0.0"); + } + else + { + _pppdata->setIpaddr(ipaddress_l->text()); + _pppdata->setSubnetmask(subnetmask_l->text()); + } + _pppdata->setAutoname(autoname->isChecked()); } @@ -468,15 +506,18 @@ void IPWidget::save() { -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 { - ipaddress_label->setEnabled(true); - sub_label->setEnabled(true); - ipaddress_l->setEnabled(true); - subnetmask_l->setEnabled(true); - } +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 + { + ipaddress_label->setEnabled(true); + sub_label->setEnabled(true); + ipaddress_l->setEnabled(true); + subnetmask_l->setEnabled(true); + } } @@ -486,3 +527,3 @@ void IPWidget::hitIPSelect( int i ) { DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) - : QWidget(parent, name), _pppdata(pd) + : QWidget(parent, name), _pppdata(pd) { @@ -490,160 +531,165 @@ DNSWidget::DNSWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const cha - 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) { - dnsservers->insertStringList(_pppdata->dns()); - dnsdomain->setText(_pppdata->domain()); - } - - int mode = _pppdata->autoDNS() ? 0 : 1; - bg->setButton(mode); - DNS_Mode_Selected(mode); - - tl->activate(); + 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) + { + 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) { - QRegExp r("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"); - add->setEnabled(text.find(r) != -1); +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) { - remove->setEnabled(true); +void DNSWidget::DNS_Entry_Selected(int) +{ + remove->setEnabled(true); } -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::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() { - _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::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()); } @@ -651,7 +697,9 @@ void DNSWidget::save() { -void DNSWidget::adddns() { - if(dnsservers->count() < MAX_DNS_ENTRIES) { - dnsservers->insertItem(dnsipaddr->text()); - dnsipaddr->setText(""); - } +void DNSWidget::adddns() +{ + if(dnsservers->count() < MAX_DNS_ENTRIES) + { + dnsservers->insertItem(dnsipaddr->text()); + dnsipaddr->setText(""); + } } @@ -659,8 +707,9 @@ void DNSWidget::adddns() { -void DNSWidget::removedns() { - int i; - i = dnsservers->currentItem(); - if(i != -1) - dnsservers->removeItem(i); - remove->setEnabled(dnsservers->count()>0); +void DNSWidget::removedns() +{ + int i; + i = dnsservers->currentItem(); + if(i != -1) + dnsservers->removeItem(i); + remove->setEnabled(dnsservers->count()>0); } @@ -672,74 +721,79 @@ void DNSWidget::removedns() { GatewayWidget::GatewayWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) - : QWidget(parent, name), _pppdata(pd) + : 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") { - defaultgateway->setChecked(true); - hitGatewaySelect(0); + 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") + { + defaultgateway->setChecked(true); + hitGatewaySelect(0); + } + else + { + gatewayaddr->setText(_pppdata->gateway()); + staticgateway->setChecked(true); + } + defaultroute->setChecked(_pppdata->defaultroute()); } - else { - gatewayaddr->setText(_pppdata->gateway()); - staticgateway->setChecked(true); + else + { + defaultgateway->setChecked(true); + hitGatewaySelect(0); + defaultroute->setChecked(true); } - defaultroute->setChecked(_pppdata->defaultroute()); - } - else { - defaultgateway->setChecked(true); - hitGatewaySelect(0); - defaultroute->setChecked(true); - } } -void GatewayWidget::save() { - _pppdata->setGateway(gatewayaddr->text()); - _pppdata->setDefaultroute(defaultroute->isChecked()); +void GatewayWidget::save() +{ + _pppdata->setGateway(gatewayaddr->text()); + _pppdata->setDefaultroute(defaultroute->isChecked()); } @@ -747,13 +801,16 @@ void GatewayWidget::save() { -void GatewayWidget::hitGatewaySelect( int i ) { - if(i == 0) { - gatewayaddr->setText("0.0.0.0"); - gatewayaddr->setEnabled(false); - gate_label->setEnabled(false); - } - else { - gatewayaddr->setEnabled(true); - gatewayaddr->setText(""); - gate_label->setEnabled(true); - } +void GatewayWidget::hitGatewaySelect( int i ) +{ + if(i == 0) + { + gatewayaddr->setText("0.0.0.0"); + gatewayaddr->setEnabled(false); + gate_label->setEnabled(false); + } + else + { + gatewayaddr->setEnabled(true); + gatewayaddr->setText(""); + gate_label->setEnabled(true); + } } @@ -763,83 +820,89 @@ void GatewayWidget::hitGatewaySelect( int i ) { ScriptWidget::ScriptWidget( PPPData *pd, QWidget *parent, bool isnewaccount, const char *name ) - : QWidget(parent, name),_pppdata(pd) + : 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) { - 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 ) + 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) { - stl->insertItem(*itcom); - sl->insertItem(*itarg); + 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(); + insert->setEnabled(false); + remove->setEnabled(false); + adjustScrollBar(); + tl->activate(); } -bool ScriptWidget::check() { - uint lstart = 0; - uint lend = 0; - uint errcnt = 0; +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") { - lstart++; - } - if (stl->text(i) == "LoopEnd") { - lend++; + if(sl->count() > 0) + { + for( uint i=0; i <= sl->count()-1; i++) + { + if(stl->text(i) == "LoopStart") + { + lstart++; + } + if (stl->text(i) == "LoopEnd") + { + lend++; + } + if ( lend > lstart ) errcnt++; } - if ( lend > lstart ) errcnt++; + return ( (errcnt == 0 ) && (lstart == lend) ); } - return ( (errcnt == 0 ) && (lstart == lend) ); - } - return true; + return true; } @@ -847,10 +910,12 @@ bool ScriptWidget::check() { -void ScriptWidget::save() { - QStringList typelist, arglist; - 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::save() +{ + QStringList typelist, arglist; + for(uint i=0; i < sl->count(); i++) + { + typelist.append(stl->text(i)); + arglist.append(sl->text(i)); + } + _pppdata->setScriptType(typelist); + _pppdata->setScript(arglist); } @@ -859,7 +924,8 @@ void ScriptWidget::save() { -void ScriptWidget::adjustScrollBar() { - if((int)sl->count() <= sl->numItemsVisible()) - slb->setRange(0, 0); - else - slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); +void ScriptWidget::adjustScrollBar() +{ + if((int)sl->count() <= sl->numItemsVisible()) + slb->setRange(0, 0); + else + slb->setRange(0, (sl->count() - sl->numItemsVisible())+1); } @@ -867,5 +933,6 @@ void ScriptWidget::adjustScrollBar() { -void ScriptWidget::scrolling(int i) { - sl->setTopItem(i); - stl->setTopItem(i); +void ScriptWidget::scrolling(int i) +{ + sl->setTopItem(i); + stl->setTopItem(i); } @@ -873,6 +940,7 @@ void ScriptWidget::scrolling(int i) { -void ScriptWidget::slhighlighted(int i) { - insert->setEnabled(true); - remove->setEnabled(true); - stl->setCurrentItem(i); +void ScriptWidget::slhighlighted(int i) +{ + insert->setEnabled(true); + remove->setEnabled(true); + stl->setCurrentItem(i); } @@ -880,6 +948,7 @@ void ScriptWidget::slhighlighted(int i) { -void ScriptWidget::stlhighlighted(int i) { - insert->setEnabled(true); - remove->setEnabled(true); - sl->setCurrentItem(i); +void ScriptWidget::stlhighlighted(int i) +{ + insert->setEnabled(true); + remove->setEnabled(true); + sl->setCurrentItem(i); } @@ -887,94 +956,96 @@ void ScriptWidget::stlhighlighted(int i) { -void ScriptWidget::addButton() { - //don't allow more than the maximum script entries - if(sl->count() == MAX_SCRIPT_ENTRIES-1) - return; +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; + stl->insertItem("Expect"); + sl->insertItem(se->text()); + break; case ScriptEdit::Send: - stl->insertItem("Send"); - sl->insertItem(se->text()); - break; + stl->insertItem("Send"); + sl->insertItem(se->text()); + break; case ScriptEdit::SendNoEcho: - stl->insertItem("SendNoEcho"); - sl->insertItem(se->text()); - break; + stl->insertItem("SendNoEcho"); + sl->insertItem(se->text()); + break; case ScriptEdit::Pause: - stl->insertItem("Pause"); - sl->insertItem(se->text()); - break; + stl->insertItem("Pause"); + sl->insertItem(se->text()); + break; case ScriptEdit::Hangup: - stl->insertItem("Hangup"); - sl->insertItem(""); - break; + stl->insertItem("Hangup"); + sl->insertItem(""); + break; case ScriptEdit::Answer: - stl->insertItem("Answer"); - sl->insertItem(""); - break; + stl->insertItem("Answer"); + sl->insertItem(""); + break; case ScriptEdit::Timeout: - stl->insertItem("Timeout"); - sl->insertItem(se->text()); - break; + stl->insertItem("Timeout"); + sl->insertItem(se->text()); + break; case ScriptEdit::Password: - stl->insertItem("Password"); - sl->insertItem(se->text()); - break; + stl->insertItem("Password"); + sl->insertItem(se->text()); + break; case ScriptEdit::ID: - stl->insertItem("ID"); - sl->insertItem(se->text()); - break; + stl->insertItem("ID"); + sl->insertItem(se->text()); + break; case ScriptEdit::Prompt: - stl->insertItem("Prompt"); - sl->insertItem(se->text()); - break; + stl->insertItem("Prompt"); + sl->insertItem(se->text()); + break; case ScriptEdit::PWPrompt: - stl->insertItem("PWPrompt"); - sl->insertItem(se->text()); - break; + stl->insertItem("PWPrompt"); + sl->insertItem(se->text()); + break; case ScriptEdit::LoopStart: - stl->insertItem("LoopStart"); - sl->insertItem(se->text()); - break; + stl->insertItem("LoopStart"); + sl->insertItem(se->text()); + break; case ScriptEdit::LoopEnd: - stl->insertItem("LoopEnd"); - sl->insertItem(se->text()); - break; + stl->insertItem("LoopEnd"); + sl->insertItem(se->text()); + break; case ScriptEdit::Scan: - stl->insertItem("Scan"); - sl->insertItem(se->text()); - break; + stl->insertItem("Scan"); + sl->insertItem(se->text()); + break; case ScriptEdit::Save: - stl->insertItem("Save"); - sl->insertItem(se->text()); - break; + stl->insertItem("Save"); + sl->insertItem(se->text()); + break; default: - break; - } + break; + } - //get the scrollbar adjusted, and scroll the list so we can see what - //we're adding to - adjustScrollBar(); - slb->setValue(slb->maxValue()); + //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(""); + //clear the text in the entry box + se->setText(""); } @@ -982,89 +1053,91 @@ void ScriptWidget::addButton() { -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; +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; + 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; + 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; + 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; + 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; + stl->insertItem("Hangup", stl->currentItem()); + sl->insertItem("", sl->currentItem()); + break; case ScriptEdit::Answer: - stl->insertItem("Answer", stl->currentItem()); - sl->insertItem("", sl->currentItem()); - break; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + stl->insertItem("Save", stl->currentItem()); + sl->insertItem(se->text(), sl->currentItem()); + break; default: - break; - } - adjustScrollBar(); - se->setText(""); + break; + } + adjustScrollBar(); + se->setText(""); } @@ -1072,11 +1145,13 @@ void ScriptWidget::insertButton() { -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); - } +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); + } } @@ -1091,3 +1166,3 @@ void ScriptWidget::removeButton() { PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) - : QDialog(parent,"PhoneNumberDialog",true) + : QDialog(parent,"PhoneNumberDialog",true) { @@ -1096,22 +1171,22 @@ PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) - QVBoxLayout *layout = new QVBoxLayout( this ); - layout->setSpacing( 3 ); - layout->setMargin( 3 ); + QVBoxLayout *layout = new QVBoxLayout( this ); + layout->setSpacing( 3 ); + layout->setMargin( 3 ); -// QHBox *hbox = new QHBox(this); -// setMainWidget(hbox); + // QHBox *hbox = new QHBox(this); + // setMainWidget(hbox); -// hbox->setSpacing( 2 );//KDialog::spacingHint()); + // hbox->setSpacing( 2 );//KDialog::spacingHint()); - QLabel *label = new QLabel(this, tr("Enter a phone number:")); - layout->addWidget( label ); + QLabel *label = new QLabel(this, tr("Enter a phone number:")); + layout->addWidget( label ); - le = new QLineEdit(this, "lineEdit"); - layout->addWidget( le ); + le = new QLineEdit(this, "lineEdit"); + layout->addWidget( le ); - connect(le, SIGNAL(textChanged(const QString &)), - this, SLOT(textChanged(const QString &))); + connect(le, SIGNAL(textChanged(const QString &)), + this, SLOT(textChanged(const QString &))); - le->setFocus(); - textChanged(""); + le->setFocus(); + textChanged(""); @@ -1121,6 +1196,7 @@ PhoneNumberDialog::PhoneNumberDialog(QWidget *parent) -QString PhoneNumberDialog::phoneNumber() { - QString s = le->text(); +QString PhoneNumberDialog::phoneNumber() +{ + QString s = le->text(); - return s; + return s; } @@ -1128,4 +1204,5 @@ QString PhoneNumberDialog::phoneNumber() { -void PhoneNumberDialog::textChanged(const QString &s) { -// enableButtonOK(s.length() > 0); +void PhoneNumberDialog::textChanged(const QString &s) +{ + // enableButtonOK(s.length() > 0); } 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 @@ -21,4 +21,9 @@ +#include "modulesinfo.h" +#include "detail.h" + +/* OPIE */ #include <qpe/qpeapplication.h> +/* QT */ #include <qfile.h> @@ -29,7 +34,4 @@ -#include "modulesinfo.h" -#include "detail.h" - ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) - : QWidget( parent, name, fl ) + : QWidget( parent, name, fl ) { @@ -49,10 +51,10 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) 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 * ) ) ); - } + + // 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 * ) ) ); + } @@ -76,6 +78,6 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) t->start( 5000 ); - + updateData(); - - ModulesDtl = new Detail(); + + ModulesDtl = new Detail(); QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); @@ -84,4 +86,3 @@ ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) ModulesInfo::~ModulesInfo() -{ -} +{} @@ -99,3 +100,3 @@ void ModulesInfo::updateData() } - + ModulesView->clear(); @@ -108,3 +109,4 @@ void ModulesInfo::updateData() QListViewItem *selecteditem = 0x0; - while ( true ) { + while ( true ) + { modname[0] = '\0'; @@ -135,18 +137,18 @@ 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 ( !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 ) + QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) { - QString command = "/sbin/"; - command.append( CommandCB->currentText() ); - command.append( " " ); - command.append( modname ); + QString command = "/sbin/"; + command.append( CommandCB->currentText() ); + command.append( " " ); + command.append( modname ); @@ -161,10 +163,10 @@ void ModulesInfo::viewModules( QListViewItem *modules ) { - QString modname = modules->text( 0 ); - QString capstr = "Module: "; - capstr.append( modname ); + QString modname = modules->text( 0 ); + QString capstr = "Module: "; + capstr.append( modname ); ModulesDtl->setCaption( capstr ); QString command = "/sbin/modinfo "; - command.append( modname ); + command.append( modname ); FILE* modinfo = popen( command, "r" ); - + if ( modinfo ) @@ -173,11 +175,11 @@ void ModulesInfo::viewModules( QListViewItem *modules ) ModulesDtl->detailView->setText( " Details:\n------------\n" ); - + while( true ) - { + { int success = fscanf( modinfo, "%[^\n]\n", line ); if ( success == EOF ) - break; + break; ModulesDtl->detailView->append( line ); } - + pclose( modinfo ); @@ -185,3 +187,3 @@ void ModulesInfo::viewModules( QListViewItem *modules ) - 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 @@ -19,4 +19,9 @@ +#include "processinfo.h" +#include "detail.h" + +/* OPIE */ #include <qpe/qpeapplication.h> +/* QT */ #include <qdir.h> @@ -27,2 +32,3 @@ +/* STD */ #include <sys/types.h> @@ -30,7 +36,4 @@ -#include "processinfo.h" -#include "detail.h" - ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) - : QWidget( parent, name, fl ) + : QWidget( parent, name, fl ) { @@ -51,6 +54,6 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), - this, SLOT( viewProcess( QListViewItem * ) ) ); + 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" ); @@ -88,4 +91,3 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) ProcessInfo::~ProcessInfo() -{ -} +{} @@ -94,5 +96,5 @@ void ProcessInfo::updateData() int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, - signal, blocked, sigignore, sigcatch; + signal, blocked, sigignore, sigcatch; uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, - endcode, startstack, kstkesp, kstkeip, wchan; + endcode, startstack, kstkesp, kstkeip, wchan; char state; @@ -106,3 +108,3 @@ void ProcessInfo::updateData() } - + ProcessView->clear(); @@ -128,7 +130,7 @@ void ProcessInfo::updateData() 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 ); + "%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, ' ' ); @@ -157,22 +159,22 @@ 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 ); - } + 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 ); + } } @@ -198,3 +200,3 @@ void ProcessInfo::viewProcess( QListViewItem *process ) } - 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 @@ -10,3 +10,9 @@ #include "userdialog.h" +#include "passwd.h" + +/* OPIE */ +#include <opie/odevice.h> +#include <qpe/qpeapplication.h> +/* QT */ #include <qlayout.h> @@ -16,2 +22,3 @@ +/* STD */ #include <sys/types.h> @@ -21,5 +28,3 @@ -#include "passwd.h" -#include <opie/odevice.h> using namespace Opie; @@ -31,20 +36,23 @@ using namespace Opie; */ -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) { - accounts->splitGroupEntry(*it); - if(accounts->gr_name.find(QRegExp("^#"),0)) { // Skip commented lines. - new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); - groupComboBox->insertItem(accounts->gr_name); - } - } - showMaximized(); +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) + { + accounts->splitGroupEntry(*it); + if(accounts->gr_name.find(QRegExp("^#"),0)) + { // Skip commented lines. + new QCheckListItem(groupsListView,accounts->gr_name,QCheckListItem::CheckBox); + groupComboBox->insertItem(accounts->gr_name); + } + } + QPEApplication::showDialog( this ); } @@ -55,4 +63,4 @@ UserDialog::UserDialog(int viewmode, QWidget* parent, const char* name, bool mod */ -UserDialog::~UserDialog() { -} +UserDialog::~UserDialog() +{} @@ -62,102 +70,106 @@ UserDialog::~UserDialog() { */ -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) { - // 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) { - 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) { - vlayout2->addSpacing(5); - vlayout2->addWidget(skelCheckBox); - } - hlayout->addLayout(vlayout1); - hlayout->addLayout(vlayout2); - - myTabWidget->addTab(tabpage,"User Info"); +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) + { + // 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) + { + 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) + { + vlayout2->addSpacing(5); + vlayout2->addWidget(skelCheckBox); + } + hlayout->addLayout(vlayout1); + hlayout->addLayout(vlayout2); + + myTabWidget->addTab(tabpage,"User Info"); } @@ -168,19 +180,20 @@ void UserDialog::setupTab1() { */ -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"); +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"); } @@ -197,77 +210,86 @@ void UserDialog::setupTab2() { */ -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) { - QListViewItemIterator iter( adduserDialog->groupsListView ); - 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)) { - 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()))) { - 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 ) { - 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())) { - QDir d; - 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()) { - 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; +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) + { + QListViewItemIterator iter( adduserDialog->groupsListView ); + 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)) + { + 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()))) + { + 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 ) + { + 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())) + { + QDir d; + 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()) + { + 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; } @@ -282,12 +304,17 @@ bool UserDialog::addUser(int uid, int gid) { */ -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 { - QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); - return false; - } - return true; +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 + { + QMessageBox::information(0,"Invalid Username","That username ("+QString(username)+")does not exist."); + return false; + } + return true; } @@ -303,103 +330,120 @@ bool UserDialog::delUser(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. - 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") { - 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)) { - edituserDialog->groupComboBox->setCurrentItem(i); - break; - } - } - 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. - qWarning(*it); - QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. - 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. - qWarning(*it); - QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. - 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. - 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) { - 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 ) { - 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())) { - QDir d; - 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; +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. + 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") + { + 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)) + { + edituserDialog->groupComboBox->setCurrentItem(i); + break; + } + } + 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. + qWarning(*it); + QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. + 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. + qWarning(*it); + QListViewItemIterator lvit( edituserDialog->groupsListView ); // Compare to all groups. + 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. + 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) + { + 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 ) + { + 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())) + { + QDir d; + 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; } @@ -410,9 +454,11 @@ bool UserDialog::editUser(const char *username) { */ -void UserDialog::accept() { - // Add checking... valid username? username taken? - if(loginLineEdit->text().isEmpty()) { - QMessageBox::information(0,"Empty Login","Please enter a login."); - return; - } - QDialog::accept(); +void UserDialog::accept() +{ + // Add checking... valid username? username taken? + if(loginLineEdit->text().isEmpty()) + { + QMessageBox::information(0,"Empty Login","Please enter a login."); + return; + } + QDialog::accept(); } @@ -423,16 +469,21 @@ void UserDialog::accept() { */ -void UserDialog::clickedPicture() { - QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); - if(!(filename.isEmpty())) { - userImage.reset(); - if(!(userImage.load(filename))) { - QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); - } else { -// userImage=userImage.smoothScale(48,48); - QPixmap *picture; - picture=(QPixmap *)picturePushButton->pixmap(); - picture->convertFromImage(userImage,0); - picturePushButton->update(); - } - } +void UserDialog::clickedPicture() +{ + QString filename=OFileDialog::getOpenFileName(OFileSelector::EXTENDED, QString::null); + if(!(filename.isEmpty())) + { + userImage.reset(); + if(!(userImage.load(filename))) + { + QMessageBox::information(0,"Sorry!","That icon could not be loaded.\nLoading failed on: "+filename); + } + else + { + // userImage=userImage.smoothScale(48,48); + QPixmap *picture; + picture=(QPixmap *)picturePushButton->pixmap(); + picture->convertFromImage(userImage,0); + picturePushButton->update(); + } + } } |