[uim-commit] r202 - trunk/qt/uim-kdehelper/src/pref
kzk@freedesktop.org
kzk@freedesktop.org
Sun Jan 9 16:12:18 PST 2005
Author: kzk
Date: 2005-01-09 16:12:15 -0800 (Sun, 09 Jan 2005)
New Revision: 202
Modified:
trunk/qt/uim-kdehelper/src/pref/customwidgets.h
trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp
trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.h
Log:
* uim-pref-qt is now reached the level of current gtk's.
* uim-kdehelper/src/pref/uim-pref-qt.h
- (confirmChange): new function
- (QConfirmDialog): new class
* uim-kdehelper/src/pref/uim-pref-qt.cpp
- (createGroupWidget): add group title label
- (slotSelectionChanged): confirm change
- (slotCancel): confirm change
- (confirmChange): new function
* uim-kdehelper/src/pref/customwidgets.h
- remove debug messages
Modified: trunk/qt/uim-kdehelper/src/pref/customwidgets.h
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/customwidgets.h 2005-01-09 23:35:31 UTC (rev 201)
+++ trunk/qt/uim-kdehelper/src/pref/customwidgets.h 2005-01-10 00:12:15 UTC (rev 202)
@@ -98,8 +98,6 @@
protected slots:
void slotCustomToggled( bool check )
{
- qDebug("toggled!!!!!!!");
-
Q_ASSERT( m_custom->type == UCustom_Bool );
m_custom->value->as_bool = check;
@@ -128,7 +126,6 @@
public slots:
void slotCustomValueChanged( int value )
{
- qDebug("value Changed!!!!!!!");
Q_ASSERT( m_custom->type == UCustom_Int );
m_custom->value->as_int = value;
@@ -157,7 +154,6 @@
public slots:
void slotCustomTextChanged( const QString &text )
{
- qDebug("text changed!");
Q_ASSERT( m_custom->type == UCustom_Str );
free( m_custom->value->as_str );
@@ -211,7 +207,6 @@
void slotCustomTextChanged( const QString & text )
{
- qDebug("path text changed!!!!!");
Q_ASSERT( m_custom->type == UCustom_Pathname );
free( m_custom->value->as_pathname );
@@ -246,7 +241,6 @@
public slots:
void slotHighlighted( int index )
{
- qDebug("highlighted!!!!");
Q_ASSERT( m_custom->type == UCustom_Pathname );
struct uim_custom_choice **valid_items = m_custom->range->as_choice.valid_items;
Modified: trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp 2005-01-09 23:35:31 UTC (rev 201)
+++ trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.cpp 2005-01-10 00:12:15 UTC (rev 202)
@@ -136,19 +136,24 @@
QWidget* UimPrefDialog::createGroupWidget( const char *group_name )
{
QVBox *vbox = new QVBox( m_groupWidgetStack );
- struct uim_custom_group *group;
- char **custom_syms, ** custom_sym;
- group = uim_custom_group_get( group_name );
+ struct uim_custom_group *group = uim_custom_group_get( group_name );
if( group == NULL )
return NULL;
- custom_syms = uim_custom_collect_by_group( group_name );
+ QLabel *groupLabel = new QLabel( group_name, vbox );
+ groupLabel->setAlignment( Qt::AlignHCenter );
+ QFont font;
+ font.setWeight( QFont::Bold );
+ font.setPixelSize( fontInfo().pixelSize() + 12 );
+ groupLabel->setFont( font );
+
+ /* add various widgets to the vbox */
+ char **custom_syms = uim_custom_collect_by_group( group_name );
if( custom_syms )
{
- for( custom_sym = custom_syms; *custom_sym; custom_sym++ )
+ for( char **custom_sym = custom_syms; *custom_sym; custom_sym++ )
{
- /* add various widgets to the vbox */
addCustom( vbox, *custom_sym );
}
@@ -159,6 +164,7 @@
/* buttom up all widgets */
vbox->setStretchFactor( new QWidget( vbox ), 1 );
+
return vbox;
}
@@ -285,7 +291,11 @@
void UimPrefDialog::slotSelectionChanged( QListViewItem * item )
{
- // switch group widget
+ /* confirm if save the change */
+ if( m_isValueChanged )
+ confirmChange();
+
+ /* switch group widget */
QString grpname = item->text( 0 );
m_groupWidgetStack->raiseWidget( m_groupWidgetsDict[grpname] );
}
@@ -295,6 +305,16 @@
m_isValueChanged = true;
}
+void UimPrefDialog::confirmChange()
+{
+ QConfirmDialog *cDialog = new QConfirmDialog( "The value was changed.\nSave?",
+ this );
+ if( cDialog->exec() == QDialog::Accepted )
+ {
+ slotApply();
+ }
+}
+
int main( int argc, char **argv )
{
QApplication a( argc, argv );
@@ -323,16 +343,32 @@
{
if( m_isValueChanged )
{
- // save
slotApply();
}
-
- // quit
accept();
}
void UimPrefDialog::slotCancel()
{
- // quit
+ confirmChange();
reject();
}
+
+QConfirmDialog::QConfirmDialog( const QString &msg, QWidget *parent, const char *name )
+ : QDialog( parent, name )
+{
+ QVBoxLayout *vLayout = new QVBoxLayout( this );
+ vLayout->setSpacing( 6 );
+ vLayout->setMargin( 10 );
+ QLabel *msgLabel = new QLabel( msg, this );
+ QHBox *buttonHBox = new QHBox( this );
+ QPushButton *okButton = new QPushButton( "OK", buttonHBox );
+ QPushButton *cancelButton = new QPushButton( "Cancel", buttonHBox );
+ vLayout->addWidget( msgLabel );
+ vLayout->addWidget( buttonHBox );
+
+ QObject::connect( okButton, SIGNAL(clicked()),
+ this, SLOT(accept()) );
+ QObject::connect( cancelButton, SIGNAL(clicked()),
+ this, SLOT(reject()) );
+}
Modified: trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.h
===================================================================
--- trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.h 2005-01-09 23:35:31 UTC (rev 201)
+++ trunk/qt/uim-kdehelper/src/pref/uim-pref-qt.h 2005-01-10 00:12:15 UTC (rev 202)
@@ -37,8 +37,12 @@
#include <qdict.h>
#include <qlistview.h>
#include <qwidgetstack.h>
+#include <qcheckbox.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
#include <qvbox.h>
-#include <qcheckbox.h>
+#include <qhbox.h>
#include <uim/uim.h>
#include <uim/uim-custom.h>
@@ -65,6 +69,8 @@
void addCustomTypeChoice( QVBox *vbox, struct uim_custom *custom );
void addCustomTypeKey( QVBox *vbox, struct uim_custom *custom );
+ void confirmChange();
+
protected slots:
void slotApply();
void slotOK();
@@ -83,4 +89,14 @@
QWidgetStack *m_groupWidgetStack;
};
+//---------------------------------------------------------------------------------
+class QConfirmDialog : public QDialog {
+ Q_OBJECT
+
+public:
+ QConfirmDialog( const QString &msg, QWidget *parent = 0, const char *name = 0 );
+};
+
+
+
#endif /* Not def: _UIM_PREF_QT_H_ */
More information about the Uim-commit
mailing list