1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: QtxPagePrefMgr.cxx
21 // Author: Sergey TELKOV
23 #include "QtxPagePrefMgr.h"
25 #include "QtxGridBox.h"
26 #include "QtxFontEdit.h"
27 #include "QtxGroupBox.h"
28 #include "QtxComboBox.h"
29 #include "QtxIntSpinBox.h"
30 #include "QtxColorButton.h"
31 #include "QtxBiColorTool.h"
32 #include "QtxDoubleSpinBox.h"
33 #include "QtxShortcutEdit.h"
34 #include "QtxBackgroundTool.h"
35 #include "QtxResourceMgr.h"
37 #include "SUIT_ShortcutMgr.h"
47 #include <QListWidget>
48 #include <QApplication>
49 #include <QDateTimeEdit>
50 #include <QStackedWidget>
52 #include <QScrollArea>
58 bool toStringList(const QVariant& value, QStringList& result)
61 if ( value.type() == QVariant::StringList )
63 result = value.toStringList();
66 else if ( value.type() == QVariant::List )
68 QList<QVariant> valueList = value.toList();
69 for ( QList<QVariant>::const_iterator it = valueList.begin(); it != valueList.end(); ++it )
71 if ( (*it).canConvert( QVariant::String ) )
72 result.append( (*it).toString() );
82 \brief GUI implementation of the QtxPreferenceMgr class: preferences manager.
87 \param resMgr resource manager
88 \param parent parent widget
90 QtxPagePrefMgr::QtxPagePrefMgr( QtxResourceMgr* resMgr, QWidget* parent )
92 QtxPreferenceMgr( resMgr ),
95 myBox = new QtxGridBox( 1, Qt::Horizontal, this, 0 );
96 QVBoxLayout* base = new QVBoxLayout( this );
98 base->setSpacing( 0 );
99 base->addWidget( myBox );
105 QtxPagePrefMgr::~QtxPagePrefMgr()
110 \brief Get recommended size for the widget.
111 \return recommended widget size
113 QSize QtxPagePrefMgr::sizeHint() const
115 return QFrame::sizeHint();
119 \brief Get recommended minimum size for the widget.
120 \return recommended minimum widget size
122 QSize QtxPagePrefMgr::minimumSizeHint() const
124 return QFrame::minimumSizeHint();
128 \brief Customize show/hide widget operation.
129 \param on if \c true the widget is being shown, otherswise
132 void QtxPagePrefMgr::setVisible( bool on )
137 QApplication::instance()->processEvents();
139 QFrame::setVisible( on );
143 \brief Update widget contents.
145 void QtxPagePrefMgr::updateContents()
147 QtxPreferenceMgr::updateContents();
149 QList<QtxPreferenceItem*> lst = childItems();
150 for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
152 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
153 if ( item && item->widget() && item->widget()->parent() != myBox )
154 item->widget()->setParent( myBox );
157 setWindowIcon( icon() );
161 \brief Callback function which is called when the child
162 preference item is added.
163 \param item child item being added
164 \sa itemRemoved(), itemChanged()
166 void QtxPagePrefMgr::itemAdded( QtxPreferenceItem* /*item*/ )
172 \brief Callback function which is called when the child
173 preference item is removed.
174 \param item child item being removed
175 \sa itemAdded(), itemChanged()
177 void QtxPagePrefMgr::itemRemoved( QtxPreferenceItem* /*item*/ )
183 \brief Callback function which is called when the child
184 preference item is modified.
185 \param item child item being modified
186 \sa itemAdded(), itemRemoved()
188 void QtxPagePrefMgr::itemChanged( QtxPreferenceItem* /*item*/ )
194 \brief Get preference item option value.
195 \param name option name
196 \return property value or null QVariant if option is not set
199 QVariant QtxPagePrefMgr::optionValue( const QString& name ) const
201 if ( name == "orientation" )
202 return myBox->orientation() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
204 return QtxPreferenceMgr::optionValue( name );
208 \brief Set preference item option value.
209 \param name option name
210 \param val new property value
213 void QtxPagePrefMgr::setOptionValue( const QString& name, const QVariant& val )
215 if ( name == "orientation" )
217 if ( val.canConvert( QVariant::Int ) )
218 myBox->setOrientation( val.toInt() == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal );
221 QtxPreferenceMgr::setOptionValue( name, val );
225 \brief Perform internal initialization.
227 void QtxPagePrefMgr::initialize() const
232 QtxPagePrefMgr* that = (QtxPagePrefMgr*)this;
233 that->initialize( that );
235 // that->myInit = true;
238 void QtxPagePrefMgr::initialize( QtxPreferenceItem* item )
243 QList<QtxPreferenceItem*> lst = item->childItems( false );
244 for ( QList<QtxPreferenceItem*>::iterator it = lst.begin(); it != lst.end(); ++it )
251 \class QtxPagePrefItem
252 \brief Base class for implementation of all the widget-based
256 class QtxPagePrefItem::Listener : public QObject
259 Listener( QtxPagePrefItem* );
262 virtual bool eventFilter( QObject*, QEvent* );
265 QtxPagePrefItem* myItem;
268 QtxPagePrefItem::Listener::Listener( QtxPagePrefItem* item )
274 QtxPagePrefItem::Listener::~Listener()
278 bool QtxPagePrefItem::Listener::eventFilter( QObject* o, QEvent* e )
280 if ( !myItem || myItem->widget() != o )
283 if ( e->type() == QEvent::Show || e->type() == QEvent::ShowToParent )
284 myItem->widgetShown();
285 if ( e->type() == QEvent::Hide || e->type() == QEvent::HideToParent )
286 myItem->widgetHided();
293 \param title preference item title
294 \param parent parent preference item
295 \param sect resource file section associated with the preference item
296 \param param resource file parameter associated with the preference item
298 QtxPagePrefItem::QtxPagePrefItem( const QString& title, QtxPreferenceItem* parent,
299 const QString& sect, const QString& param )
300 : QtxPreferenceItem( title, sect, param, parent ),
309 QtxPagePrefItem::~QtxPagePrefItem()
315 void QtxPagePrefItem::activate()
317 QtxPreferenceItem::activate();
320 widget()->setFocus();
324 \brief Get preference item editor widget.
325 \return editor widget
328 QWidget* QtxPagePrefItem::widget() const
334 \brief Set preference item editor widget.
335 \param wid editor widget
338 void QtxPagePrefItem::setWidget( QWidget* wid )
340 if ( myWidget && myListener )
341 myWidget->removeEventFilter( myListener );
348 myListener = new Listener( this );
349 myWidget->installEventFilter( myListener );
356 \brief Callback function which is called when the child
357 preference item is added.
358 \param item child item being added
359 \sa itemRemoved(), itemChanged()
361 void QtxPagePrefItem::itemAdded( QtxPreferenceItem* /*item*/ )
367 \brief Callback function which is called when the child
368 preference item is removed.
369 \param item child item being removed
370 \sa itemAdded(), itemChanged()
372 void QtxPagePrefItem::itemRemoved( QtxPreferenceItem* /*item*/ )
378 \brief Callback function which is called when the child
379 preference item is modified.
380 \param item child item being modified
381 \sa itemAdded(), itemRemoved()
383 void QtxPagePrefItem::itemChanged( QtxPreferenceItem* /*item*/ )
389 \brief Store preference item to the resource manager.
391 This method should be reimplemented in the subclasses.
392 Base implementation does nothing.
396 void QtxPagePrefItem::store()
401 \brief Retrieve preference item from the resource manager.
403 This method should be reimplemented in the subclasses.
404 Base implementation does nothing.
408 void QtxPagePrefItem::retrieve()
413 \brief Invoked when preference item widget is shown.
415 void QtxPagePrefItem::widgetShown()
420 \brief Invoked when preference item widget is hided.
422 void QtxPagePrefItem::widgetHided()
426 void QtxPagePrefItem::ensureVisible( QtxPreferenceItem* i )
428 QtxPreferenceItem::ensureVisible();
430 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
431 if ( item && item->widget() )
432 item->widget()->setVisible( true );
436 \brief Find all child items of the QtxPagePrefItem type.
437 \param list used to return list of child items
438 \param rec if \c true, perform recursive search
440 void QtxPagePrefItem::pageChildItems( QList<QtxPagePrefItem*>& list, const bool rec ) const
442 QList<QtxPreferenceItem*> lst = childItems( rec );
443 for ( QList<QtxPreferenceItem*>::const_iterator it = lst.begin(); it != lst.end(); ++it )
445 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( *it );
452 \brief Called when contents is changed (item is added, removed or modified).
454 Triggers the item update.
456 void QtxPagePrefItem::contentChanged()
462 \class QtxPageNamedPrefItem
463 \brief Base class for implementation of the named preference items
464 (items with text labels).
469 \param title preference item title
470 \param parent parent preference item
471 \param sect resource file section associated with the preference item
472 \param param resource file parameter associated with the preference item
474 QtxPageNamedPrefItem::QtxPageNamedPrefItem( const QString& title, QtxPreferenceItem* parent,
475 const QString& sect, const QString& param )
476 : QtxPagePrefItem( title, parent, sect, param ),
479 QWidget* main = new QWidget();
481 // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parent);
484 QHBoxLayout* base = new QHBoxLayout( main );
485 base->setMargin( 0 );
486 base->setSpacing( 5 );
488 myLabel = new QLabel( title, main );
489 base->addWidget( myLabel );
492 // myLabel = new QLabel( title, aGroup->gridBox() );
496 myLabel->setVisible( !title.isEmpty() );
502 QtxPageNamedPrefItem::~QtxPageNamedPrefItem()
507 \brief Set preference title.
508 \param txt new preference title.
510 void QtxPageNamedPrefItem::setTitle( const QString& txt )
512 QtxPagePrefItem::setTitle( txt );
514 label()->setText( title() );
515 if ( !title().isEmpty() )
516 label()->setVisible( true );
520 \brief Get label widget corresponding to the preference item.
523 QLabel* QtxPageNamedPrefItem::label() const
529 \brief Get control widget corresponding to the preference item.
530 \return control widget
533 QWidget* QtxPageNamedPrefItem::control() const
539 \brief Set control widget corresponding to the preference item.
540 \param wid control widget
543 void QtxPageNamedPrefItem::setControl( QWidget* wid )
545 if ( myControl == wid )
553 // QtxPagePrefGroupItem* aGroup = 0;//dynamic_cast<QtxPagePrefGroupItem*>(parentItem());
555 widget()->layout()->addWidget( myControl );
556 widget()->setFocusProxy( myControl );
557 // else myControl->setParent( aGroup->gridBox() );
561 void QtxPageNamedPrefItem::adjustLabels( QtxPagePrefItem* parent )
566 QList<QtxPreferenceItem*> childList = parent->childItems();
568 QList<QtxPageNamedPrefItem*> namedItems;
569 for ( QList<QtxPreferenceItem*>::iterator it = childList.begin(); it != childList.end(); ++it )
571 QtxPageNamedPrefItem* item = dynamic_cast<QtxPageNamedPrefItem*>( *it );
573 namedItems.append( item );
577 for ( QList<QtxPageNamedPrefItem*>::iterator it1 = namedItems.begin(); it1 != namedItems.end(); ++it1 )
579 QtxPageNamedPrefItem* item = *it1;
581 sz = qMax( sz, item->label()->sizeHint().width() );
584 for ( QList<QtxPageNamedPrefItem*>::iterator it2 = namedItems.begin(); it2 != namedItems.end(); ++it2 )
586 QtxPageNamedPrefItem* item = *it2;
588 item->label()->setMinimumWidth( sz );
593 \class QtxPagePrefListItem
594 \brief GUI implementation of the list container preference item.
599 \param title preference item title
600 \param parent parent preference item
601 \param sect resource file section associated with the preference item
602 \param param resource file parameter associated with the preference item
604 QtxPagePrefListItem::QtxPagePrefListItem( const QString& title, QtxPreferenceItem* parent,
605 const QString& sect, const QString& param )
606 : QtxPagePrefItem( title, parent, sect, param ),
609 QSplitter* main = new QSplitter( Qt::Horizontal );
610 main->setChildrenCollapsible( false );
612 main->addWidget( myList = new QListWidget( main ) );
613 main->addWidget( myStack = new QStackedWidget( main ) );
615 myList->setSelectionMode( QListWidget::SingleSelection );
617 myStack->addWidget( myInfLabel = new QLabel( myStack ) );
618 myInfLabel->setAlignment( Qt::AlignCenter );
620 connect( myList, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) );
628 QtxPagePrefListItem::~QtxPagePrefListItem()
633 \brief Get message text which is shown if the container is empty.
637 QString QtxPagePrefListItem::emptyInfo() const
643 \brief Set message text which is shown if the container is empty.
644 \param new message text
647 void QtxPagePrefListItem::setEmptyInfo( const QString& inf )
649 if ( myInfText == inf )
658 \brief Check if the preference item widget is of fixed size.
659 \return \c true if the widget has the fixed size
662 bool QtxPagePrefListItem::isFixedSize() const
668 \brief Set the preference item widget to be of fixed size.
669 \param on if \c true, the widget will have the fixed size
672 void QtxPagePrefListItem::setFixedSize( const bool on )
683 \brief Update widget contents.
685 void QtxPagePrefListItem::updateContents()
687 QtxPagePrefItem::updateContents();
692 \brief Get preference item option value.
693 \param name option name
694 \return property value or null QVariant if option is not set
697 QVariant QtxPagePrefListItem::optionValue( const QString& name ) const
699 if ( name == "fixed_size" )
700 return isFixedSize();
701 else if ( name == "empty_info" || name == "info" )
704 return QtxPagePrefItem::optionValue( name );
708 \brief Set preference item option value.
709 \param name option name
710 \param val new property value
713 void QtxPagePrefListItem::setOptionValue( const QString& name, const QVariant& val )
715 if ( name == "fixed_size" )
717 if ( val.canConvert( QVariant::Bool ) )
718 setFixedSize( val.toBool() );
720 else if ( name == "empty_info" || name == "info" )
722 if ( val.canConvert( QVariant::String ) )
723 setEmptyInfo( val.toString() );
726 QtxPagePrefItem::setOptionValue( name, val );
729 void QtxPagePrefListItem::widgetShown()
734 void QtxPagePrefListItem::ensureVisible( QtxPreferenceItem* i )
739 QtxPreferenceItem::ensureVisible( i );
741 setSelected( i->id() );
746 \brief Called when the selection in the list box is changed.
748 void QtxPagePrefListItem::onItemSelectionChanged()
754 \brief Update information label widget.
756 void QtxPagePrefListItem::updateInfo()
759 QtxPagePrefItem* item = selectedItem();
762 infoText = emptyInfo();
763 QRegExp rx( "%([%|N])" );
766 while ( ( idx = rx.indexIn( infoText ) ) != -1 )
768 if ( rx.cap() == QString( "%%" ) )
769 infoText.replace( idx, rx.matchedLength(), "%" );
770 else if ( rx.cap() == QString( "%N" ) )
771 infoText.replace( idx, rx.matchedLength(), item->title() );
774 myInfLabel->setText( infoText );
778 \brief Update widget state.
780 void QtxPagePrefListItem::updateState()
782 QtxPagePrefItem* item = selectedItem();
783 QWidget* wid = item && !item->isEmpty() ? item->widget() : myInfLabel;
785 myStack->setCurrentWidget( wid );
791 \brief Update visibile child widgets.
793 void QtxPagePrefListItem::updateVisible()
795 QList<QtxPagePrefItem*> items;
796 pageChildItems( items );
798 QMap<QWidget*, int> map;
799 for ( int i = 0; i < (int)myStack->count(); i++ )
800 map.insert( myStack->widget( i ), 0 );
802 int selId = selected();
804 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
806 if ( (*it)->isEmpty() && myInfText.isEmpty() )
809 myList->addItem( (*it)->title() );
810 myList->item( myList->count() - 1 )->setIcon( (*it)->icon() );
811 myList->item( myList->count() - 1 )->setData( Qt::UserRole, (*it)->id() );
813 QWidget* wid = (*it)->widget();
814 if ( !map.contains( wid ) )
815 myStack->addWidget( wid );
820 map.remove( myInfLabel );
822 for ( QMap<QWidget*, int>::const_iterator it = map.begin(); it != map.end(); ++it )
823 myStack->removeWidget( it.key() );
825 setSelected( selId );
826 if ( selected() == -1 && myList->count() )
827 setSelected( myList->item( 0 )->data( Qt::UserRole ).toInt() );
829 //myList->setVisible( myList->count() > 1 );
836 \brief Update widget geometry.
838 void QtxPagePrefListItem::updateGeom()
841 myList->setFixedWidth( myList->minimumSizeHint().width() + 10 );
844 myList->setMinimumWidth( 0 );
845 myList->setMaximumWidth( 16777215 );
847 QSplitter* s = ::qobject_cast<QSplitter*>( widget() );
850 int w = myList->minimumSizeHint().width() + 30;
853 szList.append( s->width() - w );
854 s->setSizes( szList );
860 \brief Get identifier of the currently selected preference item.
861 \return identifier of the currently selected item or -1 if no item is selected
864 int QtxPagePrefListItem::selected() const
866 QList<QListWidgetItem*> selList = myList->selectedItems();
867 if ( selList.isEmpty() )
870 QVariant v = selList.first()->data( Qt::UserRole );
871 return v.canConvert( QVariant::Int ) ? v.toInt() : -1;
875 \brief Get currently selected preference item.
876 \return currently selected item or 0 if no item is selected
879 QtxPagePrefItem* QtxPagePrefListItem::selectedItem() const
881 int selId = selected();
883 QList<QtxPagePrefItem*> items;
884 pageChildItems( items );
886 QtxPagePrefItem* item = 0;
887 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end() && !item; ++it )
889 if ( (*it)->id() == selId )
896 \brief Set currently selected preference item.
897 \param id identifier of the preference item to make selected
899 void QtxPagePrefListItem::setSelected( const int id )
902 for ( int i = 0; i < (int)myList->count() && idx < 0; i++ )
904 QVariant v = myList->item( i )->data( Qt::UserRole );
905 if ( v.canConvert( QVariant::Int ) && v.toInt() == id )
910 QItemSelectionModel* selModel = myList->selectionModel();
913 sel.select( myList->model()->index( idx, 0 ), myList->model()->index( idx, 0 ) );
915 selModel->select( sel, QItemSelectionModel::ClearAndSelect );
919 \class QtxPagePrefToolBoxItem
920 \brief GUI implementation of the tool box container preference item.
925 \param title preference item title
926 \param parent parent preference item
927 \param sect resource file section associated with the preference item
928 \param param resource file parameter associated with the preference item
930 QtxPagePrefToolBoxItem::QtxPagePrefToolBoxItem( const QString& title, QtxPreferenceItem* parent,
931 const QString& sect, const QString& param )
932 : QtxPagePrefItem( title, parent, sect, param )
934 setWidget( myToolBox = new QToolBox( 0 ) );
940 QtxPagePrefToolBoxItem::~QtxPagePrefToolBoxItem()
945 \brief Update widget contents.
947 void QtxPagePrefToolBoxItem::updateContents()
949 QtxPagePrefItem::updateContents();
954 \brief Update tool box widget.
956 void QtxPagePrefToolBoxItem::updateToolBox()
958 QList<QtxPagePrefItem*> items;
959 pageChildItems( items );
961 QWidget* cur = myToolBox->currentWidget();
964 QMap<QWidget*, int> map;
965 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
967 QWidget* wid = (*it)->widget();
971 if ( myToolBox->widget( i ) != wid )
973 if ( myToolBox->indexOf( wid ) != -1 )
974 myToolBox->removeItem( myToolBox->indexOf( wid ) );
976 myToolBox->insertItem( i, wid, (*it)->title() );
979 myToolBox->setItemText( i, (*it)->title() );
981 myToolBox->setItemIcon( i, (*it)->icon() );
984 map.insert( wid, 0 );
988 for ( int idx = 0; idx < (int)myToolBox->count(); idx++ )
990 QWidget* w = myToolBox->widget( idx );
991 if ( !map.contains( w ) )
995 for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
996 myToolBox->removeItem( myToolBox->indexOf( *itr ) );
999 myToolBox->setCurrentWidget( cur );
1002 void QtxPagePrefToolBoxItem::ensureVisible( QtxPreferenceItem* i )
1007 QtxPreferenceItem::ensureVisible( i );
1009 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
1010 if ( item && item->widget() )
1011 myToolBox->setCurrentWidget( item->widget() );
1015 \class QtxPagePrefTabsItem
1016 \brief GUI implementation of the tab widget container.
1021 \param title preference item title
1022 \param parent parent preference item
1023 \param sect resource file section associated with the preference item
1024 \param param resource file parameter associated with the preference item
1026 QtxPagePrefTabsItem::QtxPagePrefTabsItem( const QString& title, QtxPreferenceItem* parent,
1027 const QString& sect, const QString& param )
1028 : QtxPagePrefItem( title, parent, sect, param )
1030 setWidget( myTabs = new QTabWidget( 0 ) );
1036 QtxPagePrefTabsItem::~QtxPagePrefTabsItem()
1041 \brief Update widget contents.
1043 void QtxPagePrefTabsItem::updateContents()
1045 QtxPagePrefItem::updateContents();
1050 \brief Get tabs position.
1051 \return current tabs position (QTabWidget::TabPosition)
1052 \sa setTabPosition()
1054 int QtxPagePrefTabsItem::tabPosition() const
1056 return myTabs->tabPosition();
1060 \brief Set tabs position.
1061 \param tp new tabs position (QTabWidget::TabPosition)
1064 void QtxPagePrefTabsItem::setTabPosition( const int tp )
1066 myTabs->setTabPosition( (QTabWidget::TabPosition)tp );
1070 \brief Get tabs shape.
1071 \return current tabs shape (QTabWidget::TabShape)
1074 int QtxPagePrefTabsItem::tabShape() const
1076 return myTabs->tabShape();
1080 \brief Set tabs shape.
1081 \param ts new tabs shape (QTabWidget::TabShape)
1084 void QtxPagePrefTabsItem::setTabShape( const int ts )
1086 myTabs->setTabShape( (QTabWidget::TabShape)ts );
1090 \brief Get tabs icon size.
1091 \return current tabs icon size
1092 \sa setTabIconSize()
1094 QSize QtxPagePrefTabsItem::tabIconSize() const
1096 return myTabs->iconSize();
1100 \brief Set tabs icon size.
1101 \param sz new tabs icon size
1104 void QtxPagePrefTabsItem::setTabIconSize( const QSize& sz )
1106 myTabs->setIconSize( sz );
1110 \brief Get preference item option value.
1111 \param name option name
1112 \return property value or null QVariant if option is not set
1113 \sa setOptionValue()
1115 QVariant QtxPagePrefTabsItem::optionValue( const QString& name ) const
1117 if ( name == "position" )
1118 return tabPosition();
1119 else if ( name == "shape" )
1121 else if ( name == "icon_size" )
1122 return tabIconSize();
1124 return QtxPagePrefItem::optionValue( name );
1128 \brief Set preference item option value.
1129 \param name option name
1130 \param val new property value
1133 void QtxPagePrefTabsItem::setOptionValue( const QString& name, const QVariant& val )
1135 if ( name == "position" )
1137 if ( val.canConvert( QVariant::Int ) )
1138 setTabPosition( val.toInt() );
1140 else if ( name == "shape" )
1142 if ( val.canConvert( QVariant::Int ) )
1143 setTabShape( val.toInt() );
1145 else if ( name == "icon_size" )
1147 if ( val.canConvert( QVariant::Size ) )
1148 setTabIconSize( val.toSize() );
1151 QtxPagePrefItem::setOptionValue( name, val );
1154 void QtxPagePrefTabsItem::ensureVisible( QtxPreferenceItem* i )
1159 QtxPreferenceItem::ensureVisible( i );
1161 QtxPagePrefItem* item = dynamic_cast<QtxPagePrefItem*>( i );
1162 if ( item && item->widget() )
1163 myTabs->setCurrentWidget( item->widget() );
1169 void QtxPagePrefTabsItem::updateTabs()
1171 QList<QtxPagePrefItem*> items;
1172 pageChildItems( items );
1174 QWidget* cur = myTabs->currentWidget();
1177 QMap<QWidget*, int> map;
1178 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1180 QWidget* wid = (*it)->widget();
1184 if ( myTabs->widget( i ) != wid )
1186 if ( myTabs->indexOf( wid ) != -1 )
1187 myTabs->removeTab( myTabs->indexOf( wid ) );
1189 myTabs->insertTab( i, wid, (*it)->title() );
1192 myTabs->setTabText( i, (*it)->title() );
1194 myTabs->setTabIcon( i, (*it)->icon() );
1197 map.insert( wid, 0 );
1200 QList<QWidget*> del;
1201 for ( int idx = 0; idx < (int)myTabs->count(); idx++ )
1203 QWidget* w = myTabs->widget( idx );
1204 if ( !map.contains( w ) )
1208 for ( QList<QWidget*>::const_iterator itr = del.begin(); itr != del.end(); ++itr )
1209 myTabs->removeTab( myTabs->indexOf( *itr ) );
1212 myTabs->setCurrentWidget( cur );
1216 \class QtxPagePrefFrameItem
1217 \brief GUI implementation of the frame widget container.
1222 \param title preference item title
1223 \param parent parent preference item
1224 \param sect resource file section associated with the preference item
1225 \param param resource file parameter associated with the preference item
1227 QtxPagePrefFrameItem::QtxPagePrefFrameItem( const QString& title, QtxPreferenceItem* parent,
1228 const QString& sect, const QString& param, const bool scrollable )
1229 : QtxPagePrefItem( title, parent, sect, param )
1231 QWidget* main = new QWidget();
1232 QVBoxLayout* base = new QVBoxLayout( main );
1233 base->setMargin( 0 );
1234 base->setSpacing( 0 );
1236 base->addWidget( myBox = new QtxGridBox( 1, Qt::Horizontal, main, 5, 5 ) );
1240 QScrollArea* scroll = new QScrollArea();
1241 scroll->setWidget( main );
1242 scroll->setWidgetResizable( true );
1243 base->layout()->setSizeConstraint(QLayout::SetMinAndMaxSize);
1253 QtxPagePrefFrameItem::~QtxPagePrefFrameItem()
1258 \brief Update widget contents.
1260 void QtxPagePrefFrameItem::updateContents()
1262 QtxPagePrefItem::updateContents();
1266 QtxPageNamedPrefItem::adjustLabels( this );
1270 \brief Get frame margin.
1271 \return current frame margin
1274 int QtxPagePrefFrameItem::margin() const
1276 return myBox->insideMargin();
1280 \brief Get frame margin.
1281 \param m new frame margin
1284 void QtxPagePrefFrameItem::setMargin( const int m )
1286 myBox->setInsideMargin( m );
1290 \brief Get frame spacing.
1291 \return current frame spacing
1294 int QtxPagePrefFrameItem::spacing() const
1296 return myBox->insideSpacing();
1300 \brief Set frame spacing.
1301 \param s new frame spacing
1304 void QtxPagePrefFrameItem::setSpacing( const int s )
1306 myBox->setInsideSpacing( s );
1310 \brief Get number of frame columns.
1311 \return current columns number
1314 int QtxPagePrefFrameItem::columns() const
1316 return myBox->columns();
1320 \brief Set number of frame columns.
1321 \param c new columns number
1324 void QtxPagePrefFrameItem::setColumns( const int c )
1326 myBox->setColumns( c );
1330 \brief Get frame box orientation.
1331 \return current frame orientation
1332 \sa setOrientation()
1334 Qt::Orientation QtxPagePrefFrameItem::orientation() const
1336 return myBox->orientation();
1340 \brief Set frame box orientation.
1341 \param o new frame orientation
1344 void QtxPagePrefFrameItem::setOrientation( const Qt::Orientation o )
1346 myBox->setOrientation( o );
1350 \brief Check if the frame widget stretching is enabled.
1351 \return \c true if the widget is stretchable
1354 bool QtxPagePrefFrameItem::stretch() const
1357 QLayout* l = widget() ? widget()->layout() : 0;
1358 for ( int i = 0; l && i < l->count() && !s; i++ )
1359 s = l->itemAt( i )->spacerItem();
1361 return s ? (bool)( s->expandingDirections() & Qt::Vertical ) : false;
1365 \brief Enable/disable frame widget stretching.
1366 \param on new stretchable state
1369 void QtxPagePrefFrameItem::setStretch( const bool on )
1372 QWidget* w = widget();
1373 if ( qobject_cast<QScrollArea*>( w ) )
1374 w = qobject_cast<QScrollArea*>( w )->widget();
1375 QLayout* l = w ? w->layout() : 0;
1376 for ( int i = 0; l && i < l->count() && !s; i++ )
1377 s = l->itemAt( i )->spacerItem();
1380 s->changeSize( 0, 0, QSizePolicy::Minimum, on ? QSizePolicy::Expanding : QSizePolicy::Minimum );
1384 \brief Get preference item option value.
1385 \param name option name
1386 \return property value or null QVariant if option is not set
1387 \sa setOptionValue()
1389 QVariant QtxPagePrefFrameItem::optionValue( const QString& name ) const
1391 if ( name == "margin" )
1393 else if ( name == "spacing" )
1395 else if ( name == "columns" )
1397 else if ( name == "orientation" )
1398 return orientation();
1399 else if ( name == "stretch" )
1402 return QtxPagePrefItem::optionValue( name );
1406 \brief Set preference item option value.
1407 \param name option name
1408 \param val new property value
1411 void QtxPagePrefFrameItem::setOptionValue( const QString& name, const QVariant& val )
1413 if ( name == "margin" )
1415 if ( val.canConvert( QVariant::Int ) )
1416 setMargin( val.toInt() );
1418 else if ( name == "spacing" )
1420 if ( val.canConvert( QVariant::Int ) )
1421 setSpacing( val.toInt() );
1423 else if ( name == "columns" )
1425 if ( val.canConvert( QVariant::Int ) )
1426 setColumns( val.toInt() );
1428 else if ( name == "orientation" )
1430 if ( val.canConvert( QVariant::Int ) )
1431 setOrientation( (Qt::Orientation)val.toInt() );
1433 else if ( name == "stretch" )
1435 if ( val.canConvert( QVariant::Bool ) )
1436 setStretch( val.toBool() );
1439 QtxPagePrefItem::setOptionValue( name, val );
1442 void QtxPagePrefFrameItem::widgetShown()
1444 QtxPagePrefItem::widgetShown();
1446 QtxPageNamedPrefItem::adjustLabels( this );
1450 \brief Update frame widget.
1452 void QtxPagePrefFrameItem::updateFrame()
1454 QList<QtxPagePrefItem*> items;
1455 pageChildItems( items );
1457 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1459 QWidget* wid = (*it)->widget();
1463 if ( wid->parent() != myBox )
1464 wid->setParent( myBox );
1469 \class QtxPagePrefGroupItem
1470 \brief GUI implementation of the group widget container.
1475 \param title preference item title
1476 \param parent parent preference item
1477 \param sect resource file section associated with the preference item
1478 \param param resource file parameter associated with the preference item
1480 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const QString& title, QtxPreferenceItem* parent,
1481 const QString& sect, const QString& param )
1482 : QtxPagePrefItem( title, parent, sect, param )
1484 myGroup = new QtxGroupBox( title, 0 );
1485 myBox = new QtxGridBox( 1, Qt::Horizontal, myGroup, 5, 5 );
1486 myGroup->setWidget( myBox );
1488 setWidget( myGroup );
1495 \param cols columns number
1496 \param title preference item title
1497 \param parent parent preference item
1498 \param sect resource file section associated with the preference item
1499 \param param resource file parameter associated with the preference item
1501 QtxPagePrefGroupItem::QtxPagePrefGroupItem( const int cols, const QString& title, QtxPreferenceItem* parent,
1502 const QString& sect, const QString& param )
1503 : QtxPagePrefItem( title, parent, sect, param )
1505 myGroup = new QtxGroupBox( title, 0 );
1506 myBox = new QtxGridBox( cols, Qt::Horizontal, myGroup, 5, 5 );
1507 myGroup->setWidget( myBox );
1509 setWidget( myGroup );
1517 QtxPagePrefGroupItem::~QtxPagePrefGroupItem()
1522 \brief Assign resource file settings to the preference item.
1523 \param sect resource file section name
1524 \param param resource file parameter name
1527 void QtxPagePrefGroupItem::setResource( const QString& sect, const QString& param )
1529 QtxPagePrefItem::setResource( sect, param );
1534 \brief Update widget contents.
1536 void QtxPagePrefGroupItem::updateContents()
1538 QtxPagePrefItem::updateContents();
1540 myGroup->setTitle( title() );
1545 QtxPageNamedPrefItem::adjustLabels( this );
1549 \brief Get group box margin.
1550 \return current group box margin
1553 int QtxPagePrefGroupItem::margin() const
1555 return myBox->insideMargin();
1559 \brief Get group box margin.
1560 \param m new group box margin
1563 void QtxPagePrefGroupItem::setMargin( const int m )
1565 myBox->setInsideMargin( m );
1569 \brief Get group box spacing.
1570 \return current group box spacing
1573 int QtxPagePrefGroupItem::spacing() const
1575 return myBox->insideSpacing();
1579 \brief Set group box spacing.
1580 \param s new group box spacing
1583 void QtxPagePrefGroupItem::setSpacing( const int s )
1585 myBox->setInsideSpacing( s );
1589 \brief Get number of group box columns.
1590 \return current columns number
1593 int QtxPagePrefGroupItem::columns() const
1595 return myBox->columns();
1599 \brief Set number of group box columns.
1600 \param c new columns number
1603 void QtxPagePrefGroupItem::setColumns( const int c )
1605 myBox->setColumns( c );
1609 \brief Get group box orientation.
1610 \return current group box orientation
1611 \sa setOrientation()
1613 Qt::Orientation QtxPagePrefGroupItem::orientation() const
1615 return myBox->orientation();
1619 \brief Set group box orientation.
1620 \param o new group box orientation
1623 void QtxPagePrefGroupItem::setOrientation( const Qt::Orientation o )
1625 myBox->setOrientation( o );
1629 \brief Get 'flat' flag of the group box widget.
1630 \return \c true if the group box is flat
1632 bool QtxPagePrefGroupItem::isFlat() const
1634 return myGroup->isFlat();
1638 \brief Get 'flat' flag of the group box widget.
1639 \param on if \c true the group box will be made flat
1641 void QtxPagePrefGroupItem::setFlat( const bool on )
1643 myGroup->setFlat( on );
1647 \brief Store preference item to the resource manager.
1650 void QtxPagePrefGroupItem::store()
1652 if ( myGroup->isCheckable() )
1653 setBoolean( myGroup->isChecked() );
1657 \brief Return widget contained grid layout of this group.
1659 QtxGridBox* QtxPagePrefGroupItem::gridBox() const
1665 \brief Retrieve preference item from the resource manager.
1668 void QtxPagePrefGroupItem::retrieve()
1670 if ( myGroup->isCheckable() )
1671 myGroup->setChecked( getBoolean() );
1675 \brief Get preference item option value.
1676 \param name option name
1677 \return property value or null QVariant if option is not set
1678 \sa setOptionValue()
1680 QVariant QtxPagePrefGroupItem::optionValue( const QString& name ) const
1682 if ( name == "margin" )
1684 else if ( name == "spacing" )
1686 else if ( name == "columns" )
1688 else if ( name == "orientation" )
1689 return orientation();
1690 else if ( name == "flat" )
1693 return QtxPagePrefItem::optionValue( name );
1697 \brief Set preference item option value.
1698 \param name option name
1699 \param val new property value
1702 void QtxPagePrefGroupItem::setOptionValue( const QString& name, const QVariant& val )
1704 if ( name == "margin" )
1706 if ( val.canConvert( QVariant::Int ) )
1707 setMargin( val.toInt() );
1709 else if ( name == "spacing" )
1711 if ( val.canConvert( QVariant::Int ) )
1712 setSpacing( val.toInt() );
1714 else if ( name == "columns" )
1716 if ( val.canConvert( QVariant::Int ) )
1717 setColumns( val.toInt() );
1719 else if ( name == "orientation" )
1721 if ( val.canConvert( QVariant::Int ) )
1722 setOrientation( (Qt::Orientation)val.toInt() );
1724 else if ( name == "flat" )
1726 if ( val.canConvert( QVariant::Bool ) )
1727 setFlat( val.toBool() );
1730 QtxPagePrefItem::setOptionValue( name, val );
1733 void QtxPagePrefGroupItem::widgetShown()
1735 QtxPagePrefItem::widgetShown();
1737 QtxPageNamedPrefItem::adjustLabels( this );
1741 \brief Update widget state.
1743 void QtxPagePrefGroupItem::updateState()
1745 QString section, param;
1746 resource( section, param );
1747 myGroup->setCheckable( !title().isEmpty() && !section.isEmpty() && !param.isEmpty() );
1751 \brief Update group box widget.
1753 void QtxPagePrefGroupItem::updateGroup()
1755 QList<QtxPagePrefItem*> items;
1756 pageChildItems( items );
1758 for ( QList<QtxPagePrefItem*>::const_iterator it = items.begin(); it != items.end(); ++it )
1760 QWidget* wid = (*it)->widget();
1764 if ( wid->parent() != myBox )
1765 wid->setParent( myBox );
1770 \class QtxPagePrefLabelItem
1771 \brief Label item which can be used in the preferences editor dialog box.
1777 Creates label item with specified title.
1779 \param text label text
1780 \param parent parent preference item
1782 QtxPagePrefLabelItem::QtxPagePrefLabelItem( const QString& text, QtxPreferenceItem* parent )
1783 : QtxPagePrefItem( text, parent )
1785 setWidget( myLabel = new QLabel( text ) );
1788 QtxPagePrefLabelItem::QtxPagePrefLabelItem( Qt::Alignment align, const QString& text, QtxPreferenceItem* parent )
1789 : QtxPagePrefItem( text, parent )
1791 setWidget( myLabel = new QLabel( text ) );
1792 myLabel->setAlignment( align );
1795 QtxPagePrefLabelItem::~QtxPagePrefLabelItem()
1799 void QtxPagePrefLabelItem::setTitle( const QString& text )
1801 QtxPagePrefItem::setTitle( text );
1804 myLabel->setText( text );
1807 Qt::Alignment QtxPagePrefLabelItem::alignment() const
1809 return myLabel->alignment();
1812 void QtxPagePrefLabelItem::setAlignment( Qt::Alignment align )
1814 myLabel->setAlignment( align );
1817 QVariant QtxPagePrefLabelItem::optionValue( const QString& name ) const
1820 if ( name == "alignment" )
1821 val = (int)alignment();
1825 void QtxPagePrefLabelItem::setOptionValue( const QString& name, const QVariant& val )
1827 if ( name == "alignment" )
1829 if ( val.canConvert( QVariant::Int ) )
1830 setAlignment( (Qt::Alignment)val.toInt() );
1835 \class QtxPagePrefSpaceItem
1836 \brief Simple spacer item which can be used in the preferences
1843 Creates spacer item with zero width and height and expanding
1844 on both directions (by height and width).
1846 \param parent parent preference item
1848 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( QtxPreferenceItem* parent )
1849 : QtxPagePrefItem( QString(), parent )
1851 initialize( 0, 0, 1, 1 );
1857 Creates spacer item with zero width and height and expanding
1858 according to the specified orientation.
1860 \param o spacer orientation
1861 \param parent parent preference item
1863 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( Qt::Orientation o, QtxPreferenceItem* parent )
1864 : QtxPagePrefItem( QString(), parent )
1866 if ( o == Qt::Horizontal )
1867 initialize( 0, 0, 1, 0 );
1869 initialize( 0, 0, 0, 1 );
1875 Creates spacer item with specified width and height. The spacing
1876 item is expanding horizontally if \a w <= 0 and vertically
1879 \param w spacer width
1880 \param h spacer height
1881 \param parent parent preference item
1883 QtxPagePrefSpaceItem::QtxPagePrefSpaceItem( const int w, const int h, QtxPreferenceItem* parent )
1884 : QtxPagePrefItem( QString(), parent )
1886 initialize( w, h, w > 0 ? 0 : 1, h > 0 ? 0 : 1 );
1892 QtxPagePrefSpaceItem::~QtxPagePrefSpaceItem()
1897 \brief Get spacer item size for the specified direction.
1899 \return size for the specified direction
1902 int QtxPagePrefSpaceItem::size( Qt::Orientation o ) const
1904 return o == Qt::Horizontal ? widget()->minimumWidth() : widget()->minimumHeight();
1908 \brief Set spacer item size for the specified direction.
1910 \param sz new size for the specified direction
1913 void QtxPagePrefSpaceItem::setSize( Qt::Orientation o, const int sz )
1915 if ( o == Qt::Horizontal )
1916 widget()->setMinimumWidth( sz );
1918 widget()->setMinimumHeight( sz );
1922 \brief Get spacer item stretch factor for the specified direction.
1924 \return stretch factor for the specified direction
1927 int QtxPagePrefSpaceItem::stretch( Qt::Orientation o ) const
1929 QSizePolicy sp = widget()->sizePolicy();
1930 return o == Qt::Horizontal ? sp.horizontalStretch() : sp.verticalStretch();
1934 \brief Set spacer item stretch factor for the specified direction.
1936 \param sf new stretch factor for the specified direction
1939 void QtxPagePrefSpaceItem::setStretch( Qt::Orientation o, const int sf )
1941 QSizePolicy sp = widget()->sizePolicy();
1942 if ( o == Qt::Horizontal )
1944 sp.setHorizontalStretch( sf );
1945 sp.setHorizontalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1949 sp.setVerticalStretch( sf );
1950 sp.setVerticalPolicy( sf > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
1953 widget()->setSizePolicy( sp );
1957 \brief Get preference item option value.
1958 \param name option name
1959 \return property value or null QVariant if option is not set
1960 \sa setOptionValue()
1962 QVariant QtxPagePrefSpaceItem::optionValue( const QString& name ) const
1964 if ( name == "horizontal_size" || name == "hsize" )
1965 return size( Qt::Horizontal );
1966 else if ( name == "vertical_size" || name == "vsize" )
1967 return size( Qt::Vertical );
1968 else if ( name == "horizontal_stretch" || name == "hstretch" )
1969 return stretch( Qt::Horizontal );
1970 else if ( name == "vertical_stretch" || name == "vstretch" )
1971 return stretch( Qt::Vertical );
1973 return QtxPagePrefItem::optionValue( name );
1977 \brief Set preference item option value.
1978 \param name option name
1979 \param val new property value
1982 void QtxPagePrefSpaceItem::setOptionValue( const QString& name, const QVariant& val )
1984 if ( name == "horizontal_size" || name == "hsize" )
1986 if ( val.canConvert( QVariant::Int ) )
1987 setSize( Qt::Horizontal, val.toInt() );
1989 else if ( name == "vertical_size" || name == "vsize" )
1991 if ( val.canConvert( QVariant::Int ) )
1992 setSize( Qt::Vertical, val.toInt() );
1994 else if ( name == "horizontal_stretch" || name == "hstretch" )
1996 if ( val.canConvert( QVariant::Int ) )
1997 setStretch( Qt::Horizontal, val.toInt() );
1999 else if ( name == "vertical_stretch" || name == "vstretch" )
2001 if ( val.canConvert( QVariant::Int ) )
2002 setStretch( Qt::Vertical, val.toInt() );
2005 QtxPagePrefItem::setOptionValue( name, val );
2009 \brief Perform internal initialization.
2010 \param w spacer item width
2011 \param h spacer item height
2012 \param ws spacer item horizontal stretch factor
2013 \param hs spacer item vertical stretch factor
2015 void QtxPagePrefSpaceItem::initialize( const int w, const int h, const int hs, const int vs )
2018 sp.setHorizontalPolicy( hs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
2019 sp.setVerticalPolicy( vs > 0 ? QSizePolicy::Expanding : QSizePolicy::Fixed );
2021 sp.setHorizontalStretch( hs );
2022 sp.setVerticalStretch( vs );
2024 QWidget* wid = new QWidget();
2025 wid->setSizePolicy( sp );
2027 wid->setMinimumSize( w, h );
2033 \class QtxPagePrefCheckItem
2034 \brief GUI implementation of the resources check box item (boolean).
2039 \param title preference item title
2040 \param parent parent preference item
2041 \param sect resource file section associated with the preference item
2042 \param param resource file parameter associated with the preference item
2044 QtxPagePrefCheckItem::QtxPagePrefCheckItem( const QString& title, QtxPreferenceItem* parent,
2045 const QString& sect, const QString& param )
2047 : QtxPagePrefItem( title, parent, sect, param )
2049 myCheck = new QCheckBox( title );
2050 myCheck->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
2051 setWidget( myCheck );
2057 QtxPagePrefCheckItem::~QtxPagePrefCheckItem()
2062 \brief Set preference item title.
2063 \param txt new preference title.
2065 void QtxPagePrefCheckItem::setTitle( const QString& txt )
2067 QtxPagePrefItem::setTitle( txt );
2069 myCheck->setText( title() );
2073 \brief Store preference item to the resource manager.
2076 void QtxPagePrefCheckItem::store()
2078 setBoolean( myCheck->isChecked() );
2082 \brief Retrieve preference item from the resource manager.
2085 void QtxPagePrefCheckItem::retrieve()
2087 myCheck->setChecked( getBoolean() );
2091 \class QtxPagePrefEditItem
2092 \brief GUI implementation of the resources line edit box item
2093 for string, integer and double values.
2096 static void fixupAndSet( QLineEdit* le, const QString& txt )
2100 if ( le->validator() ) {
2101 const QDoubleValidator* de = dynamic_cast<const QDoubleValidator*>( le->validator() );
2103 int dec = de->decimals();
2104 int idx = val.lastIndexOf( QRegExp( QString("[.|%1]").arg( le->locale().decimalPoint () ) ) );
2106 QString tmp = val.mid( idx+1 );
2108 val = val.left( idx+1 );
2109 idx = tmp.indexOf( QRegExp( QString("[e|E]") ) );
2111 exp = tmp.mid( idx );
2112 tmp = tmp.left( idx );
2114 tmp.truncate( dec );
2115 val = val + tmp + exp;
2119 if ( le->validator()->validate( val, pos ) == QValidator::Invalid )
2129 Creates preference item for string value editing.
2131 \param title preference item title
2132 \param parent parent preference item
2133 \param sect resource file section associated with the preference item
2134 \param param resource file parameter associated with the preference item
2136 QtxPagePrefEditItem::QtxPagePrefEditItem( const QString& title, QtxPreferenceItem* parent,
2137 const QString& sect, const QString& param )
2138 : QtxPageNamedPrefItem( title, parent, sect, param ),
2143 setControl( myEditor = new QLineEdit() );
2150 Creates preference item for editing of the value which type
2151 is specified by parameter \a type.
2153 \param type preference item input type (QtxPagePrefEditItem::InputType)
2154 \param title preference item title
2155 \param parent parent preference item
2156 \param sect resource file section associated with the preference item
2157 \param param resource file parameter associated with the preference item
2159 QtxPagePrefEditItem::QtxPagePrefEditItem( const int type, const QString& title,
2160 QtxPreferenceItem* parent, const QString& sect,
2161 const QString& param )
2162 : QtxPageNamedPrefItem( title, parent, sect, param ),
2167 setControl( myEditor = new QLineEdit() );
2174 QtxPagePrefEditItem::~QtxPagePrefEditItem()
2179 \brief Get edit box preference item input type.
2180 \return preference item input type (QtxPagePrefEditItem::InputType)
2183 int QtxPagePrefEditItem::inputType() const
2189 \brief Set edit box preference item input type.
2190 \param type new preference item input type (QtxPagePrefEditItem::InputType)
2193 void QtxPagePrefEditItem::setInputType( const int type )
2195 if ( myType == type )
2203 \brief Get number of digits after decimal point (for Double input type)
2204 \return preference item decimals value
2207 int QtxPagePrefEditItem::decimals() const
2213 \brief Set number of digits after decimal point (for Double input type)
2214 \param dec new preference item decimals value
2217 void QtxPagePrefEditItem::setDecimals( const int dec )
2219 if ( myDecimals == dec )
2227 \brief Get the line edit's echo mode
2228 \return preference item echo mode value
2231 int QtxPagePrefEditItem::echoMode() const
2237 \brief Set the line edit's echo mode
2238 \param echo new preference item echo mode value
2241 void QtxPagePrefEditItem::setEchoMode( const int echo )
2243 if ( myEchoMode == echo )
2251 \brief Store preference item to the resource manager.
2254 void QtxPagePrefEditItem::store()
2256 setString( myEditor->text() );
2260 \brief Retrieve preference item from the resource manager.
2263 void QtxPagePrefEditItem::retrieve()
2265 QString txt = getString();
2266 fixupAndSet( myEditor, txt );
2270 \brief Get preference item option value.
2271 \param name option name
2272 \return property value or null QVariant if option is not set
2273 \sa setOptionValue()
2275 QVariant QtxPagePrefEditItem::optionValue( const QString& name ) const
2277 if ( name == "input_type" || name == "type" )
2279 else if ( name == "precision" || name == "prec" || name == "decimals" )
2281 else if ( name == "echo" || name == "echo_mode" || name == "echomode")
2284 return QtxPageNamedPrefItem::optionValue( name );
2288 \brief Set preference item option value.
2289 \param name option name
2290 \param val new property value
2293 void QtxPagePrefEditItem::setOptionValue( const QString& name, const QVariant& val )
2295 if ( name == "input_type" || name == "type" )
2297 if ( val.canConvert( QVariant::Int ) )
2298 setInputType( val.toInt() );
2300 else if ( name == "precision" || name == "prec" || name == "decimals" ) {
2301 if ( val.canConvert( QVariant::Int ) )
2302 setDecimals( val.toInt() );
2304 else if ( name == "echo" || name == "echo_mode" || name == "echomode") {
2305 if ( val.canConvert( QVariant::Int ) )
2306 setEchoMode( val.toInt() );
2309 QtxPageNamedPrefItem::setOptionValue( name, val );
2313 \brief Update edit box widget.
2315 void QtxPagePrefEditItem::updateEditor()
2320 myEditor->setEchoMode(QLineEdit::Normal);
2323 myEditor->setEchoMode(QLineEdit::NoEcho);
2326 myEditor->setEchoMode(QLineEdit::Password);
2329 myEditor->setEchoMode(QLineEdit::PasswordEchoOnEdit);
2332 myEditor->setEchoMode(QLineEdit::Normal);
2335 QValidator* val = 0;
2336 switch ( inputType() )
2339 val = new QIntValidator( myEditor );
2342 val = new QDoubleValidator( myEditor );
2343 dynamic_cast<QDoubleValidator*>( val )->setDecimals( myDecimals < 0 ? 1000 : myDecimals );
2349 QString txt = myEditor->text();
2350 delete myEditor->validator();
2351 myEditor->setValidator( val );
2352 fixupAndSet( myEditor, txt );
2356 \class QtxPagePrefSliderItem
2362 Creates preference item with slider widget
2364 \param title preference item title
2365 \param parent parent preference item
2366 \param sect resource file section associated with the preference item
2367 \param param resource file parameter associated with the preference item
2369 QtxPagePrefSliderItem::QtxPagePrefSliderItem( const QString& title, QtxPreferenceItem* parent,
2370 const QString& sect, const QString& param )
2371 : QtxPageNamedPrefItem( title, parent, sect, param )
2373 setControl( mySlider = new QSlider( Qt::Horizontal ) );
2374 widget()->layout()->addWidget( myLabel = new QLabel( ) );
2381 mySlider->setTickPosition( QSlider::TicksBothSides );
2383 connect (mySlider, SIGNAL(valueChanged(int)), this, SLOT(setIcon(int)));
2390 QtxPagePrefSliderItem::~QtxPagePrefSliderItem()
2395 \brief Get slider preference item step value.
2396 \return slider single step value
2399 int QtxPagePrefSliderItem::singleStep() const
2401 return mySlider->singleStep();
2405 \brief Get slider preference item step value.
2406 \return slider page step value
2409 int QtxPagePrefSliderItem::pageStep() const
2411 return mySlider->pageStep();
2415 \brief Get slider preference item minimum value.
2416 \return slider minimum value
2419 int QtxPagePrefSliderItem::minimum() const
2421 return mySlider->minimum();
2425 \brief Get slider preference item maximum value.
2426 \return slider maximum value
2429 int QtxPagePrefSliderItem::maximum() const
2431 return mySlider->maximum();
2435 \brief Get the list of the icons associated with the selection widget items
2436 \return list of icons
2439 QList<QIcon> QtxPagePrefSliderItem::icons() const
2445 \brief Set slider preference item step value.
2446 \param step new slider single step value
2449 void QtxPagePrefSliderItem::setSingleStep( const int& step )
2451 mySlider->setSingleStep( step );
2455 \brief Set slider preference item step value.
2456 \param step new slider single step value
2459 void QtxPagePrefSliderItem::setPageStep( const int& step )
2461 mySlider->setPageStep( step );
2465 \brief Set slider preference item minimum value.
2466 \param min new slider minimum value
2469 void QtxPagePrefSliderItem::setMinimum( const int& min )
2471 mySlider->setMinimum( min );
2472 setIcon( mySlider->value() );
2476 \brief Set slider preference item maximum value.
2477 \param max new slider maximum value
2480 void QtxPagePrefSliderItem::setMaximum( const int& max )
2482 mySlider->setMaximum( max );
2483 setIcon( mySlider->value() );
2487 \brief Set the list of the icons to the selection widget items
2488 \param icns new list of icons
2491 void QtxPagePrefSliderItem::setIcons( const QList<QIcon>& icns )
2493 if ( icns.isEmpty() )
2497 QSize maxsize(0, 0);
2498 for ( QList<QIcon>::const_iterator it = myIcons.begin(); it != myIcons.end(); ++it ) {
2499 if ( (*it).isNull() ) continue;
2500 maxsize = maxsize.expandedTo( (*it).availableSizes().first() );
2502 myLabel->setFixedSize( maxsize );
2508 \brief Store preference item to the resource manager.
2511 void QtxPagePrefSliderItem::store()
2513 setInteger( mySlider->value() );
2517 \brief Retrieve preference item from the resource manager.
2520 void QtxPagePrefSliderItem::retrieve()
2522 mySlider->setValue( getInteger( mySlider->value() ) );
2526 \brief Get preference item option value.
2527 \param name option name
2528 \return property value or null integer if option is not set
2529 \sa setOptionValue()
2531 QVariant QtxPagePrefSliderItem::optionValue( const QString& name ) const
2533 if ( name == "minimum" || name == "min" )
2535 else if ( name == "maximum" || name == "max" )
2537 else if ( name == "single_step" )
2538 return singleStep();
2539 else if ( name == "page_step" )
2541 else if ( name == "icons" || name == "pixmaps" )
2543 QList<QVariant> lst;
2544 QList<QIcon> ics = icons();
2545 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2550 return QtxPageNamedPrefItem::optionValue( name );
2554 \brief Set preference item option value.
2555 \param name option name
2556 \param val new property value
2559 void QtxPagePrefSliderItem::setOptionValue( const QString& name, const QVariant& val )
2561 if ( val.canConvert( QVariant::Int ) )
2563 if ( name == "minimum" || name == "min" )
2564 setMinimum( val.toInt() );
2565 else if ( name == "maximum" || name == "max" )
2566 setMaximum( val.toInt() );
2567 else if ( name == "single_step" )
2568 setSingleStep( val.toInt() );
2569 else if ( name == "page_step" )
2570 setPageStep( val.toInt() );
2572 QtxPageNamedPrefItem::setOptionValue( name, val );
2574 else if ( name == "icons" || name == "pixmaps" )
2577 QtxPageNamedPrefItem::setOptionValue( name, val );
2580 void QtxPagePrefSliderItem::setIcon( int pos )
2582 int index = pos - mySlider->minimum();
2583 if ( !myIcons.isEmpty() && index >= 0 && index < myIcons.size() && !myIcons[index].isNull() )
2584 myLabel->setPixmap( myIcons[index].pixmap( myIcons[index].availableSizes().first() ) );
2590 \brief Update slider widget.
2592 void QtxPagePrefSliderItem::updateSlider()
2594 int val = mySlider->value();
2595 int stp = singleStep();
2596 int ptp = pageStep();
2597 int min = minimum();
2598 int max = maximum();
2600 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2601 mySlider->setFocusPolicy(Qt::StrongFocus);
2603 mySlider->setValue( val );
2604 setSingleStep( stp );
2609 myLabel->setVisible( !myIcons.empty() );
2610 widget()->layout()->setSpacing( !myIcons.empty() ? 6 : 0 );
2614 \brief Set the list of the icons from the resource manager.
2615 \param var new icons list
2618 void QtxPagePrefSliderItem::setIcons( const QVariant& var )
2620 if ( var.type() != QVariant::List )
2624 QList<QVariant> varList = var.toList();
2625 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2627 if ( (*it).canConvert<QIcon>() )
2628 lst.append( (*it).value<QIcon>() );
2629 else if ( (*it).canConvert<QPixmap>() )
2630 lst.append( (*it).value<QPixmap>() );
2632 lst.append( QIcon() );
2638 \class QtxPagePrefSelectItem
2639 \brief GUI implementation of the resources selector item
2640 (string, integer or double values list).
2642 All items in the list (represented as combo box) should be specified
2643 by the unique identifier which is stored to the resource file instead
2644 of the value itself.
2650 Creates preference item with combo box widget which is not editable
2651 (direct value entering is disabled).
2653 \param title preference item title
2654 \param parent parent preference item
2655 \param sect resource file section associated with the preference item
2656 \param param resource file parameter associated with the preference item
2658 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const QString& title, QtxPreferenceItem* parent,
2659 const QString& sect, const QString& param )
2660 : QtxPageNamedPrefItem( title, parent, sect, param ),
2663 setControl( mySelector = new QtxComboBox() );
2664 mySelector->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
2665 mySelector->setDuplicatesEnabled( false );
2672 Creates preference item with combo box widget which is editable
2673 according to the specified input type (integer, double or string values).
2675 \param type input type (QtxPagePrefSelectItem::InputType)
2676 \param title preference item title
2677 \param parent parent preference item
2678 \param sect resource file section associated with the preference item
2679 \param param resource file parameter associated with the preference item
2681 QtxPagePrefSelectItem::QtxPagePrefSelectItem( const int type, const QString& title, QtxPreferenceItem* parent,
2682 const QString& sect, const QString& param )
2683 : QtxPageNamedPrefItem( title, parent, sect, param ),
2686 setControl( mySelector = new QtxComboBox() );
2687 mySelector->setDuplicatesEnabled( false );
2694 QtxPagePrefSelectItem::~QtxPagePrefSelectItem()
2699 \brief Get edit box preference item input type.
2700 \return preference item input type (QtxPagePrefSelectItem::InputType)
2703 int QtxPagePrefSelectItem::inputType() const
2709 \brief Set edit box preference item input type.
2710 \param type new preference item input type (QtxPagePrefSelectItem::InputType)
2713 void QtxPagePrefSelectItem::setInputType( const int type )
2715 if ( myType == type )
2723 \brief Get the list of the values from the selection widget.
2724 \return list of values
2725 \sa numbers(), icons(), setStrings()
2727 QStringList QtxPagePrefSelectItem::strings() const
2730 for ( int i = 0; i < mySelector->count(); i++ )
2731 res.append( mySelector->itemText( i ) );
2736 \brief Get the list of the values identifiers from the selection widget.
2737 \return list of values IDs
2738 \sa strings(), icons(), setNumbers()
2740 QList<QVariant> QtxPagePrefSelectItem::numbers() const
2742 QList<QVariant> res;
2743 for ( int i = 0; i < mySelector->count(); i++ )
2745 if ( mySelector->hasId( i ) )
2746 res.append( mySelector->id( i ) );
2752 \brief Get the list of the icons associated with the selection widget.items
2753 \return list of icons
2754 \sa strings(), numbers(), setIcons()
2756 QList<QIcon> QtxPagePrefSelectItem::icons() const
2759 for ( int i = 0; i < mySelector->count(); i++ )
2760 res.append( mySelector->itemIcon( i ) );
2765 \brief Set the list of the values to the selection widget.
2766 \param lst new list of values
2767 \sa strings(), setNumbers(), setIcons()
2769 void QtxPagePrefSelectItem::setStrings( const QStringList& lst )
2771 mySelector->clear();
2772 mySelector->addItems( lst );
2776 \brief Set the list of the values identifiers to the selection widget
2777 \param ids new list of values IDs
2778 \sa numbers(), setStrings(), setIcons()
2780 void QtxPagePrefSelectItem::setNumbers( const QList<QVariant>& ids )
2783 for ( QList<QVariant>::const_iterator it = ids.begin(); it != ids.end(); ++it, i++ ) {
2784 if ( i >= mySelector->count() )
2785 mySelector->addItem(QString("") );
2787 mySelector->setId( i, *it );
2792 \brief Set the list of the icons to the selection widget items
2794 Important: call this method after setStrings() or setNumbers()
2796 \param icns new list of icons
2797 \sa icons(), setStrings(), setNumbers()
2799 void QtxPagePrefSelectItem::setIcons( const QList<QIcon>& icns )
2802 for ( QList<QIcon>::const_iterator it = icns.begin(); it != icns.end() && i < mySelector->count(); ++it, i++ )
2803 mySelector->setItemIcon( i, *it );
2807 \brief Store preference item to the resource manager.
2810 void QtxPagePrefSelectItem::store()
2812 if ( mySelector->isCleared() )
2815 int idx = mySelector->currentIndex();
2817 if ( mySelector->hasId( idx ) ) {
2818 QVariant id = mySelector->id( idx );
2819 if ( id.type() == QVariant::Int )
2820 setInteger( id.toInt() );
2821 else if ( id.type() == QVariant::String )
2822 setString( id.toString() );
2824 else if ( idx >= 0 ) {
2825 setString( mySelector->itemText( idx ) );
2830 \brief Retrieve preference item from the resource manager.
2833 void QtxPagePrefSelectItem::retrieve()
2835 QString txt = getString();
2837 // try to find via the id
2838 int idx = mySelector->index( txt );
2841 for ( int i = 0; i < mySelector->count() && idx == -1; i++ )
2843 if ( mySelector->itemText( i ) == txt )
2849 mySelector->setCurrentIndex( idx );
2850 else if ( mySelector->isEditable() )
2853 if ( mySelector->validator() &&
2854 mySelector->validator()->validate( txt, pos ) == QValidator::Invalid )
2855 mySelector->setCleared( true );
2858 mySelector->setCleared( false );
2859 mySelector->addItem( txt );
2860 mySelector->setCurrentIndex( mySelector->count() - 1 );
2866 \brief Get preference item option value.
2867 \param name option name
2868 \return property value or null QVariant if option is not set
2869 \sa setOptionValue()
2871 QVariant QtxPagePrefSelectItem::optionValue( const QString& name ) const
2873 if ( name == "input_type" || name == "type" )
2875 else if ( name == "strings" || name == "labels" )
2877 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2881 else if ( name == "icons" || name == "pixmaps" )
2883 QList<QVariant> lst;
2884 QList<QIcon> ics = icons();
2885 for ( QList<QIcon>::const_iterator it = ics.begin(); it != ics.end(); ++it )
2890 return QtxPageNamedPrefItem::optionValue( name );
2894 \brief Set preference item option value.
2895 \param name option name
2896 \param val new property value
2899 void QtxPagePrefSelectItem::setOptionValue( const QString& name, const QVariant& val )
2901 if ( name == "input_type" || name == "type" )
2903 if ( val.canConvert( QVariant::Int ) )
2904 setInputType( val.toInt() );
2906 else if ( name == "strings" || name == "labels" )
2908 else if ( name == "numbers" || name == "ids" || name == "indexes" )
2910 else if ( name == "icons" || name == "pixmaps" )
2913 QtxPageNamedPrefItem::setOptionValue( name, val );
2917 \brief Set the list of the values from the resource manager.
2918 \param var new values list
2921 void QtxPagePrefSelectItem::setStrings( const QVariant& var )
2924 if ( toStringList( var, values ) )
2925 setStrings( values );
2929 \brief Set the list of the values identifiers from the resource manager.
2930 \param var new values IDs list
2933 void QtxPagePrefSelectItem::setNumbers( const QVariant& var )
2935 if ( var.type() != QVariant::List )
2938 setNumbers( var.toList() );
2942 \brief Set the list of the icons from the resource manager.
2943 \param var new icons list
2946 void QtxPagePrefSelectItem::setIcons( const QVariant& var )
2948 if ( var.type() != QVariant::List )
2952 QList<QVariant> varList = var.toList();
2953 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
2955 if ( (*it).canConvert<QIcon>() )
2956 lst.append( (*it).value<QIcon>() );
2957 else if ( (*it).canConvert<QPixmap>() )
2958 lst.append( (*it).value<QPixmap>() );
2960 lst.append( QIcon() );
2966 \brief Update selector widget.
2968 void QtxPagePrefSelectItem::updateSelector()
2970 QValidator* val = 0;
2971 switch ( inputType() )
2974 val = new QIntValidator( mySelector );
2977 val = new QDoubleValidator( mySelector );
2983 mySelector->setEditable( inputType() != NoInput );
2985 if ( mySelector->isEditable() && !mySelector->currentText().isEmpty() && val )
2988 QString str = mySelector->currentText();
2989 if ( val->validate( str, pos ) == QValidator::Invalid )
2990 mySelector->clearEditText();
2993 delete mySelector->validator();
2994 mySelector->setValidator( val );
2998 \class QtxPagePrefSpinItem
2999 \brief GUI implementation of the resources spin box item
3000 (for integer or double value).
3006 Creates spin box preference item for the entering integer values.
3008 \param title preference item title
3009 \param parent parent preference item
3010 \param sect resource file section associated with the preference item
3011 \param param resource file parameter associated with the preference item
3013 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const QString& title, QtxPreferenceItem* parent,
3014 const QString& sect, const QString& param )
3015 : QtxPageNamedPrefItem( title, parent, sect, param ),
3024 Creates spin box preference item for the entering values which type
3025 is specified by the parameter \a type.
3027 \param type input type (QtxPagePrefSpinItem::InputType).
3028 \param title preference item title
3029 \param parent parent preference item
3030 \param sect resource file section associated with the preference item
3031 \param param resource file parameter associated with the preference item
3033 QtxPagePrefSpinItem::QtxPagePrefSpinItem( const int type, const QString& title,
3034 QtxPreferenceItem* parent, const QString& sect,
3035 const QString& param )
3036 : QtxPageNamedPrefItem( title, parent, sect, param ),
3045 QtxPagePrefSpinItem::~QtxPagePrefSpinItem()
3050 \brief Get spin box preference item input type.
3051 \return preference item input type (QtxPagePrefSpinItem::InputType)
3054 int QtxPagePrefSpinItem::inputType() const
3060 \brief Set spin box preference item input type.
3061 \param type new preference item input type (QtxPagePrefSpinItem::InputType)
3064 void QtxPagePrefSpinItem::setInputType( const int type )
3066 if ( myType == type )
3074 \brief Get spin box preference item step value.
3075 \return spin box single step value
3078 QVariant QtxPagePrefSpinItem::step() const
3080 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3081 return isb->singleStep();
3082 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3083 return dsb->singleStep();
3089 \brief Get double spin box preference item precision value.
3090 \return double spin box precision
3093 QVariant QtxPagePrefSpinItem::precision() const
3095 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3096 return dsb->decimals();
3102 \brief Get spin box preference item minimum value.
3103 \return spin box minimum value
3106 QVariant QtxPagePrefSpinItem::minimum() const
3108 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3109 return isb->minimum();
3110 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3111 return dsb->minimum();
3117 \brief Get spin box preference item maximum value.
3118 \return spin box maximum value
3121 QVariant QtxPagePrefSpinItem::maximum() const
3123 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3124 return isb->maximum();
3125 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3126 return dsb->maximum();
3132 \brief Get spin box preference item prefix string.
3133 \return spin box prefix string
3136 QString QtxPagePrefSpinItem::prefix() const
3138 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3139 return isb->prefix();
3140 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3141 return dsb->prefix();
3147 \brief Get spin box preference item suffix string.
3148 \return spin box suffix string
3151 QString QtxPagePrefSpinItem::suffix() const
3153 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3154 return isb->suffix();
3155 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3156 return dsb->suffix();
3162 \brief Get spin box preference item special value text (which is shown
3163 when the spin box reaches minimum value).
3164 \return spin box special value text
3165 \sa setSpecialValueText()
3167 QString QtxPagePrefSpinItem::specialValueText() const
3169 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3171 return sb->specialValueText();
3177 \brief Set spin box preference item step value.
3178 \param step new spin box single step value
3181 void QtxPagePrefSpinItem::setStep( const QVariant& step )
3183 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3185 if ( step.canConvert( QVariant::Int ) )
3186 isb->setSingleStep( step.toInt() );
3188 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3190 if ( step.canConvert( QVariant::Double ) )
3191 dsb->setSingleStep( step.toDouble() );
3196 \brief Set double spin box preference item precision value.
3197 \param step new double spin box precision value
3200 void QtxPagePrefSpinItem::setPrecision( const QVariant& prec )
3202 if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3204 if ( prec.canConvert( QVariant::Int ) ) {
3205 dsb->setDecimals( qAbs( prec.toInt() ) );
3206 dsb->setPrecision( prec.toInt() );
3212 \brief Set spin box preference item minimum value.
3213 \param min new spin box minimum value
3216 void QtxPagePrefSpinItem::setMinimum( const QVariant& min )
3218 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3220 if ( min.canConvert( QVariant::Int ) )
3221 isb->setMinimum( min.toInt() );
3223 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3225 if ( min.canConvert( QVariant::Double ) )
3226 dsb->setMinimum( min.toDouble() );
3231 \brief Set spin box preference item maximum value.
3232 \param min new spin box maximum value
3235 void QtxPagePrefSpinItem::setMaximum( const QVariant& max )
3237 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3239 if ( max.canConvert( QVariant::Int ) )
3240 isb->setMaximum( max.toInt() );
3242 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3244 if ( max.canConvert( QVariant::Double ) )
3245 dsb->setMaximum( max.toDouble() );
3250 \brief Set spin box preference item prefix string.
3251 \param txt new spin box prefix string
3254 void QtxPagePrefSpinItem::setPrefix( const QString& txt )
3256 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3257 isb->setPrefix( txt );
3258 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3259 dsb->setPrefix( txt );
3263 \brief Set spin box preference item suffix string.
3264 \param txt new spin box suffix string
3267 void QtxPagePrefSpinItem::setSuffix( const QString& txt )
3269 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3270 isb->setSuffix( txt );
3271 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3272 dsb->setSuffix( txt );
3276 \brief Set spin box preference item special value text (which is shown
3277 when the spin box reaches minimum value).
3278 \param txt new spin box special value text
3279 \sa specialValueText()
3281 void QtxPagePrefSpinItem::setSpecialValueText( const QString& txt )
3283 QAbstractSpinBox* sb = ::qobject_cast<QAbstractSpinBox*>( control() );
3285 sb->setSpecialValueText( txt );
3289 \brief Store preference item to the resource manager.
3292 void QtxPagePrefSpinItem::store()
3294 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3295 setInteger( isb->value() );
3296 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3297 setDouble( dsb->value() );
3301 \brief Retrieve preference item from the resource manager.
3304 void QtxPagePrefSpinItem::retrieve()
3306 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3307 isb->setValue( getInteger( isb->value() ) );
3308 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3309 dsb->setValue( getDouble( dsb->value() ) );
3313 \brief Get preference item option value.
3314 \param name option name
3315 \return property value or null QVariant if option is not set
3316 \sa setOptionValue()
3318 QVariant QtxPagePrefSpinItem::optionValue( const QString& name ) const
3320 if ( name == "input_type" || name == "type" )
3322 else if ( name == "minimum" || name == "min" )
3324 else if ( name == "maximum" || name == "max" )
3326 else if ( name == "step" )
3328 else if ( name == "precision" )
3330 else if ( name == "prefix" )
3332 else if ( name == "suffix" )
3334 else if ( name == "special" )
3335 return specialValueText();
3337 return QtxPageNamedPrefItem::optionValue( name );
3341 \brief Set preference item option value.
3342 \param name option name
3343 \param val new property value
3346 void QtxPagePrefSpinItem::setOptionValue( const QString& name, const QVariant& val )
3348 if ( name == "input_type" || name == "type" )
3350 if ( val.canConvert( QVariant::Int ) )
3351 setInputType( val.toInt() );
3353 else if ( name == "minimum" || name == "min" )
3355 else if ( name == "maximum" || name == "max" )
3357 else if ( name == "step" )
3359 else if ( name == "precision" )
3360 setPrecision( val );
3361 else if ( name == "prefix" )
3363 if ( val.canConvert( QVariant::String ) )
3364 setPrefix( val.toString() );
3366 else if ( name == "suffix" )
3368 if ( val.canConvert( QVariant::String ) )
3369 setSuffix( val.toString() );
3371 else if ( name == "special" )
3373 if ( val.canConvert( QVariant::String ) )
3374 setSpecialValueText( val.toString() );
3377 QtxPageNamedPrefItem::setOptionValue( name, val );
3381 \brief Update spin box widget.
3383 void QtxPagePrefSpinItem::updateSpinBox()
3386 QVariant stp = step();
3387 QVariant prec = precision();
3388 QVariant min = minimum();
3389 QVariant max = maximum();
3391 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3393 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3396 switch ( inputType() )
3399 setControl( new QtxIntSpinBox() );
3402 setControl( new QtxDoubleSpinBox() );
3408 control()->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3411 setPrecision( prec );
3415 if ( QtxIntSpinBox* isb = ::qobject_cast<QtxIntSpinBox*>( control() ) )
3417 if ( val.canConvert( QVariant::Int ) )
3418 isb->setValue( val.toInt() );
3420 else if ( QtxDoubleSpinBox* dsb = ::qobject_cast<QtxDoubleSpinBox*>( control() ) )
3422 if ( val.canConvert( QVariant::Double ) )
3423 dsb->setValue( val.toDouble() );
3428 \class QtxPagePrefTextItem
3429 \brief GUI implementation of the resources text box edit item
3430 (for large text data).
3435 \param parent parent preference item
3436 \param sect resource file section associated with the preference item
3437 \param param resource file parameter associated with the preference item
3439 QtxPagePrefTextItem::QtxPagePrefTextItem( QtxPreferenceItem* parent, const QString& sect,
3440 const QString& param )
3441 : QtxPageNamedPrefItem( QString(), parent, sect, param )
3443 myEditor = new QTextEdit();
3444 myEditor->setAcceptRichText( false );
3446 setControl( myEditor );
3451 \param title preference item title
3452 \param parent parent preference item
3453 \param sect resource file section associated with the preference item
3454 \param param resource file parameter associated with the preference item
3456 QtxPagePrefTextItem::QtxPagePrefTextItem( const QString& title, QtxPreferenceItem* parent,
3457 const QString& sect, const QString& param )
3458 : QtxPageNamedPrefItem( title, parent, sect, param )
3460 myEditor = new QTextEdit();
3461 myEditor->setAcceptRichText( false );
3463 setControl( myEditor );
3469 QtxPagePrefTextItem::~QtxPagePrefTextItem()
3474 \brief Store preference item to the resource manager.
3477 void QtxPagePrefTextItem::store()
3479 setString( myEditor->toPlainText() );
3483 \brief Retrieve preference item from the resource manager.
3486 void QtxPagePrefTextItem::retrieve()
3488 myEditor->setPlainText( getString() );
3492 \class QtxPagePrefColorItem
3493 \brief GUI implementation of the resources color item.
3498 \param title preference item title
3499 \param parent parent preference item
3500 \param sect resource file section associated with the preference item
3501 \param param resource file parameter associated with the preference item
3503 QtxPagePrefColorItem::QtxPagePrefColorItem( const QString& title, QtxPreferenceItem* parent,
3504 const QString& sect, const QString& param )
3505 : QtxPageNamedPrefItem( title, parent, sect, param )
3507 // QtxPagePrefGroupItem* aGroup 0; //= dynamic_cast<QtxPagePrefGroupItem*>( parent );
3509 // setControl( myColor = new QtxColorButton( aGroup ? aGroup->gridBox() : 0 ) );
3510 setControl( myColor = new QtxColorButton( 0 ) );
3511 myColor->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
3517 QtxPagePrefColorItem::~QtxPagePrefColorItem()
3522 \brief Store preference item to the resource manager.
3525 void QtxPagePrefColorItem::store()
3527 setColor( myColor->color() );
3531 \brief Retrieve preference item from the resource manager.
3534 void QtxPagePrefColorItem::retrieve()
3536 myColor->setColor( getColor() );
3540 \class QtxPagePrefBiColorItem
3541 \brief GUI implementation of the resources item to store a bi-color value.
3543 The main color is specified explicitly. The secondary color is calculated
3544 by changing "value" and "saturation" parameters of the main color in the
3545 HSV notation using specified delta.
3550 \param title preference item title
3551 \param parent parent preference item
3552 \param sect resource file section associated with the preference item
3553 \param param resource file parameter associated with the preference item
3555 QtxPagePrefBiColorItem::QtxPagePrefBiColorItem( const QString& title, QtxPreferenceItem* parent,
3556 const QString& sect, const QString& param )
3557 : QtxPageNamedPrefItem( title, parent, sect, param )
3559 setControl( myColors = new QtxBiColorTool( 0 ) );
3565 QtxPagePrefBiColorItem::~QtxPagePrefBiColorItem()
3570 \bried Get auxiliary text
3571 \return text assigned to the item
3574 QString QtxPagePrefBiColorItem::text() const
3576 return myColors->text();
3580 \bried Set auxiliary text
3581 \param t text being assigned to the item
3584 void QtxPagePrefBiColorItem::setText( const QString& t )
3586 myColors->setText( t );
3590 \brief Store preference item to the resource manager.
3593 void QtxPagePrefBiColorItem::store()
3595 setString( Qtx::biColorToString( myColors->mainColor(), myColors->delta() ) );
3599 \brief Retrieve preference item from the resource manager.
3602 void QtxPagePrefBiColorItem::retrieve()
3606 Qtx::stringToBiColor( getString(), c, d );
3607 myColors->setMainColor( c );
3608 myColors->setDelta( d );
3612 \brief Get preference item option value.
3613 \param name option name
3614 \return property value or null QVariant if option is not set
3615 \sa setOptionValue()
3617 QVariant QtxPagePrefBiColorItem::optionValue( const QString& name ) const
3619 if ( name == "text" )
3622 return QtxPageNamedPrefItem::optionValue( name );
3626 \brief Set preference item option value.
3627 \param name option name
3628 \param val new property value
3631 void QtxPagePrefBiColorItem::setOptionValue( const QString& name, const QVariant& val )
3633 if ( name == "text" )
3635 if ( val.canConvert( QVariant::String ) )
3636 setText( val.toString() );
3639 QtxPageNamedPrefItem::setOptionValue( name, val );
3643 \class QtxPagePrefFontItem
3644 \brief GUI implementation of the resources font item.
3649 \param feat font editor widget features (QtxFontEdit::Features)
3650 \param title preference item title
3651 \param parent parent preference item
3652 \param sect resource file section associated with the preference item
3653 \param param resource file parameter associated with the preference item
3655 QtxPagePrefFontItem::QtxPagePrefFontItem( const int feat, const QString& title,
3656 QtxPreferenceItem* parent, const QString& sect,
3657 const QString& param )
3658 : QtxPageNamedPrefItem( title, parent, sect, param )
3660 setControl( myFont = new QtxFontEdit( feat ) );
3665 \param title preference item title
3666 \param parent parent preference item
3667 \param sect resource file section associated with the preference item
3668 \param param resource file parameter associated with the preference item
3670 QtxPagePrefFontItem::QtxPagePrefFontItem( const QString& title, QtxPreferenceItem* parent,
3671 const QString& sect, const QString& param )
3672 : QtxPageNamedPrefItem( title, parent, sect, param )
3674 setControl( myFont = new QtxFontEdit() );
3680 QtxPagePrefFontItem::~QtxPagePrefFontItem()
3685 \brief Get font widget features.
3686 \return font widget features (ORed QtxFontEdit::Features flags)
3689 int QtxPagePrefFontItem::features() const
3691 return myFont->features();
3695 \brief Set font widget features.
3696 \param f new font widget features (ORed QtxFontEdit::Features flags)
3699 void QtxPagePrefFontItem::setFeatures( const int f )
3701 myFont->setFeatures( f );
3705 \brief Specifies whether widget works in Native or Custom mode. Native mode
3706 is intended for working with system fonts. Custom mode is intended for
3707 working with manually defined set of fonts. Set of custom fonts can be
3708 specified with setFonts() method
3709 \param mode mode from QtxFontEdit::Mode enumeration
3712 void QtxPagePrefFontItem::setMode( const int mode )
3714 myFont->setMode( mode );
3718 \brief Verifies whether widget works in Native or Custom mode
3719 \return Native or Custom mode
3722 int QtxPagePrefFontItem::mode() const
3724 return myFont->mode();
3728 \brief Sets list of custom fonts.
3729 <b>This method is intended for working in Custom mode only.</b>
3730 \param fams list of families
3731 \sa fonts(), setMode()
3733 void QtxPagePrefFontItem::setFonts( const QStringList& fams )
3735 myFont->setFonts( fams );
3739 \brief Gets list of custom fonts
3740 \return list of families
3741 \sa setFonts(), setMode()
3743 QStringList QtxPagePrefFontItem::fonts() const
3745 return myFont->fonts();
3749 \brief Sets list of available font sizes.
3750 <b>This method is intended for working in Custom mode only.</b> The list of sizes can
3751 be empty. In this case system generate listof size automatically from 8 till 72.
3752 \param sizes list of sizes
3753 \sa sizes(), setMode()
3755 void QtxPagePrefFontItem::setSizes( const QList<int>& sizes )
3757 myFont->setSizes( sizes );
3761 \brief Gets list of custom fonts
3762 \return list of families
3763 \sa setFonts(), setMode()
3765 QList<int> QtxPagePrefFontItem::sizes() const
3767 return myFont->sizes();
3771 \brief Store preference item to the resource manager.
3774 void QtxPagePrefFontItem::store()
3776 setFont( myFont->currentFont() );
3780 \brief Retrieve preference item from the resource manager.
3783 void QtxPagePrefFontItem::retrieve()
3785 myFont->setCurrentFont( getFont() );
3789 \brief Get preference item option value.
3790 \param name option name
3791 \return property value or null QVariant if option is not set
3792 \sa setOptionValue()
3794 QVariant QtxPagePrefFontItem::optionValue( const QString& name ) const
3796 if ( name == "features" )
3798 else if ( name == "mode" )
3800 else if ( name == "fonts" || name == "families" )
3802 else if ( name == "sizes" )
3804 QList<QVariant> lst;
3805 QList<int> nums = sizes();
3806 for ( QList<int>::const_iterator it = nums.begin(); it != nums.end(); ++it )
3811 return QtxPageNamedPrefItem::optionValue( name );
3815 \brief Set preference item option value.
3816 \param name option name
3817 \param val new property value
3820 void QtxPagePrefFontItem::setOptionValue( const QString& name, const QVariant& val )
3822 if ( name == "features" )
3824 if ( val.canConvert( QVariant::Int ) )
3825 setFeatures( val.toInt() );
3827 else if ( name == "mode" )
3829 if ( val.canConvert( QVariant::Int ) )
3830 setMode( val.toInt() );
3832 else if ( name == "fonts" || name == "families" )
3835 if ( toStringList( val, values ) )
3838 else if ( name == "sizes" )
3840 if ( val.type() == QVariant::List )
3843 QList<QVariant> varList = val.toList();
3844 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it )
3846 if ( (*it).canConvert( QVariant::Int ) )
3847 lst.append( (*it).toInt() );
3853 QtxPageNamedPrefItem::setOptionValue( name, val );
3857 \class QtxPagePrefPathItem
3858 \brief GUI implementation of the resources file/directory path item.
3863 \param type path widget mode (Qtx::PathType )
3864 \param title preference item title
3865 \param parent parent preference item
3866 \param sect resource file section associated with the preference item
3867 \param param resource file parameter associated with the preference item
3869 QtxPagePrefPathItem::QtxPagePrefPathItem( const Qtx::PathType type, const QString& title,
3870 QtxPreferenceItem* parent, const QString& sect, const QString& param )
3871 : QtxPageNamedPrefItem( title, parent, sect, param )
3873 setControl( myPath = new QtxPathEdit( type ) );
3878 \param title preference item title
3879 \param parent parent preference item
3880 \param sect resource file section associated with the preference item
3881 \param param resource file parameter associated with the preference item
3883 QtxPagePrefPathItem::QtxPagePrefPathItem( const QString& title, QtxPreferenceItem* parent,
3884 const QString& sect, const QString& param )
3885 : QtxPageNamedPrefItem( title, parent, sect, param )
3887 setControl( myPath = new QtxPathEdit() );
3893 QtxPagePrefPathItem::~QtxPagePrefPathItem()
3898 \brief Get path widget mode.
3899 \return current path widget mode (Qtx::PathType)
3902 Qtx::PathType QtxPagePrefPathItem::pathType() const
3904 return myPath->pathType();
3908 \brief Set path widget mode.
3909 \param type new path widget mode (Qtx::PathType)
3912 void QtxPagePrefPathItem::setPathType( const Qtx::PathType type )
3914 myPath->setPathType( type );
3918 \brief Get currently used path widget filters.
3919 \return file or directory path filters
3922 QString QtxPagePrefPathItem::pathFilter() const
3924 return myPath->pathFilter();
3928 \brief Set path widget filters.
3929 \param f new file or directory path filters
3932 void QtxPagePrefPathItem::setPathFilter( const QString& f )
3934 myPath->setPathFilter( f );
3938 \brief Get currently used path widget options.
3939 \return file or directory path options
3940 \sa setPathOptions()
3942 QFileDialog::Options QtxPagePrefPathItem::pathOptions() const
3944 return myPath->pathOptions();
3948 \brief Set path widget options.
3949 \param f new file or directory path options
3952 void QtxPagePrefPathItem::setPathOptions( const QFileDialog::Options options )
3954 myPath->setPathOptions( options );
3959 \brief Store preference item to the resource manager.
3962 void QtxPagePrefPathItem::store()
3964 setString( myPath->path() );
3968 \brief Retrieve preference item from the resource manager.
3971 void QtxPagePrefPathItem::retrieve()
3973 myPath->setPath( getString() );
3977 \brief Get preference item option value.
3978 \param name option name
3979 \return property value or null QVariant if option is not set
3980 \sa setOptionValue()
3982 QVariant QtxPagePrefPathItem::optionValue( const QString& name ) const
3984 if ( name == "path_type" )
3986 else if ( name == "path_filter" )
3987 return pathFilter();
3988 else if ( name == "path_options" )
3989 return QVariant::fromValue(pathOptions());
3991 return QtxPageNamedPrefItem::optionValue( name );
3995 \brief Set preference item option value.
3996 \param name option name
3997 \param val new property value
4000 void QtxPagePrefPathItem::setOptionValue( const QString& name, const QVariant& val )
4002 if ( name == "path_type" )
4004 if ( val.canConvert( QVariant::Int ) )
4005 setPathType( (Qtx::PathType)val.toInt() );
4007 else if ( name == "path_filter" )
4009 if ( val.canConvert( QVariant::String ) )
4010 setPathFilter( val.toString() );
4012 else if ( name == "path_options" )
4014 if ( val.canConvert( QVariant::Int ) )
4015 setPathOptions( (QFileDialog::Options)val.toInt() );
4018 QtxPageNamedPrefItem::setOptionValue( name, val );
4022 \class QtxPagePrefPathListItem
4023 \brief GUI implementation of the resources files/directories list item.
4028 \param parent parent preference item
4029 \param sect resource file section associated with the preference item
4030 \param param resource file parameter associated with the preference item
4032 QtxPagePrefPathListItem::QtxPagePrefPathListItem( QtxPreferenceItem* parent,
4033 const QString& sect, const QString& param )
4034 : QtxPageNamedPrefItem( QString(), parent, sect, param )
4036 setControl( myPaths = new QtxPathListEdit() );
4041 \param type path list widget mode (Qtx::PathType)
4042 \param title preference item title
4043 \param parent parent preference item
4044 \param sect resource file section associated with the preference item
4045 \param param resource file parameter associated with the preference item
4047 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const Qtx::PathType type, const QString& title,
4048 QtxPreferenceItem* parent, const QString& sect, const QString& param )
4049 : QtxPageNamedPrefItem( title, parent, sect, param )
4051 setControl( myPaths = new QtxPathListEdit( type ) );
4056 \param title preference item title
4057 \param parent parent preference item
4058 \param sect resource file section associated with the preference item
4059 \param param resource file parameter associated with the preference item
4061 QtxPagePrefPathListItem::QtxPagePrefPathListItem( const QString& title, QtxPreferenceItem* parent,
4062 const QString& sect, const QString& param )
4063 : QtxPageNamedPrefItem( title, parent, sect, param )
4065 setControl( myPaths = new QtxPathListEdit() );
4071 QtxPagePrefPathListItem::~QtxPagePrefPathListItem()
4076 \brief Get path list widget mode.
4077 \return currently used path list widget mode (Qtx::PathType)
4080 Qtx::PathType QtxPagePrefPathListItem::pathType() const
4082 return myPaths->pathType();
4086 \brief Set path list widget mode.
4087 \param type new path list widget mode (Qtx::PathType)
4090 void QtxPagePrefPathListItem::setPathType( const Qtx::PathType type )
4092 myPaths->setPathType( type );
4096 \brief Store preference item to the resource manager.
4099 void QtxPagePrefPathListItem::store()
4101 setString( myPaths->pathList().join( ";" ) );
4105 \brief Retrieve preference item from the resource manager.
4108 void QtxPagePrefPathListItem::retrieve()
4110 myPaths->setPathList( getString().split( ";" ) );
4114 \brief Get preference item option value.
4115 \param name option name
4116 \return property value or null QVariant if option is not set
4117 \sa setOptionValue()
4119 QVariant QtxPagePrefPathListItem::optionValue( const QString& name ) const
4121 if ( name == "path_type" )
4124 return QtxPageNamedPrefItem::optionValue( name );
4128 \brief Set preference item option value.
4129 \param name option name
4130 \param val new property value
4133 void QtxPagePrefPathListItem::setOptionValue( const QString& name, const QVariant& val )
4135 if ( name == "path_type" )
4137 if ( val.canConvert( QVariant::Int ) )
4138 setPathType( (Qtx::PathType)val.toInt() );
4141 QtxPageNamedPrefItem::setOptionValue( name, val );
4145 \class QtxPagePrefDateTimeItem
4146 \brief GUI implementation of resources date/time item.
4152 Creates an item to enter date and time.
4154 \param title preference item title
4155 \param parent parent preference item
4156 \param sect resource file section associated with the preference item
4157 \param param resource file parameter associated with the preference item
4159 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const QString& title, QtxPreferenceItem* parent,
4160 const QString& sect, const QString& param )
4161 : QtxPageNamedPrefItem( title, parent, sect, param ),
4164 setControl( myDateTime = new QDateTimeEdit() );
4165 myDateTime->setCalendarPopup( true );
4166 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4173 Creates preference item for editing of the date and/or time value:
4174 the type is specified by parameter \a type.
4176 \param type preference item input type (QtxPagePrefDateTimeItem::InputType)
4177 \param title preference item title
4178 \param parent parent preference item
4179 \param sect resource file section associated with the preference item
4180 \param param resource file parameter associated with the preference item
4182 QtxPagePrefDateTimeItem::QtxPagePrefDateTimeItem( const int type, const QString& title, QtxPreferenceItem* parent,
4183 const QString& sect, const QString& param )
4184 : QtxPageNamedPrefItem( title, parent, sect, param ),
4187 setControl( myDateTime = new QDateTimeEdit() );
4188 myDateTime->setCalendarPopup( true );
4189 myDateTime->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
4196 QtxPagePrefDateTimeItem::~QtxPagePrefDateTimeItem()
4201 \brief Get date/time box preference item input type.
4202 \return preference item input type (QtxPagePrefDateTimeItem::InputType)
4205 int QtxPagePrefDateTimeItem::inputType() const
4211 \brief Set date/time box preference item input type.
4212 \param type new preference item input type (QtxPagePrefDateTimeItem::InputType)
4215 void QtxPagePrefDateTimeItem::setInputType( const int type )
4217 if ( myType == type )
4225 \brief Check if the popup calendar menu is enabled.
4226 \return \c true if calendar popup menu is enabled
4228 bool QtxPagePrefDateTimeItem::calendar() const
4230 return myDateTime->calendarPopup();
4234 \brief Enable/disable popup calendar menu.
4235 \param on new flag state
4237 void QtxPagePrefDateTimeItem::setCalendar( const bool on )
4239 myDateTime->setCalendarPopup( on );
4243 \brief Get maximum date value.
4244 \return maximum date value
4245 \sa setMaximumDate(), minimumDate(), maximumTime(), minimumTime()
4247 QDate QtxPagePrefDateTimeItem::maximumDate() const
4249 return myDateTime->maximumDate();
4253 \brief Get maximum time value.
4254 \return maximum time value
4255 \sa setMaximumTime(), minimumTime(), maximumDate(), minimumDate()
4257 QTime QtxPagePrefDateTimeItem::maximumTime() const
4259 return myDateTime->maximumTime();
4263 \brief Get minimum date value.
4264 \return minimum date value
4265 \sa setMinimumDate(), maximumDate(), maximumTime(), minimumTime()
4267 QDate QtxPagePrefDateTimeItem::minimumDate() const
4269 return myDateTime->minimumDate();
4273 \brief Get minimum time value.
4274 \return maximum time value
4275 \sa setMinimumTime(), maximumTime(), maximumDate(), minimumDate()
4277 QTime QtxPagePrefDateTimeItem::minimumTime() const
4279 return myDateTime->minimumTime();
4283 \brief Set maximum date value.
4284 \param d new maximum date value
4285 \sa maximumDate(), minimumDate(), maximumTime(), minimumTime()
4287 void QtxPagePrefDateTimeItem::setMaximumDate( const QDate& d )
4290 myDateTime->setMaximumDate( d );
4292 myDateTime->clearMaximumDate();
4296 \brief Set maximum time value.
4297 \param t new maximum time value
4298 \sa maximumTime(), minimumTime(), maximumDate(), minimumDate()
4300 void QtxPagePrefDateTimeItem::setMaximumTime( const QTime& t )
4303 myDateTime->setMaximumTime( t );
4305 myDateTime->clearMaximumTime();
4309 \brief Set minimum date value.
4310 \param d new minimum date value
4311 \sa minimumDate(), maximumDate(), maximumTime(), minimumTime()
4313 void QtxPagePrefDateTimeItem::setMinimumDate( const QDate& d )
4316 myDateTime->setMinimumDate( d );
4318 myDateTime->clearMinimumDate();
4322 \brief Set minimum time value.
4323 \param t new minimum time value
4324 \sa minimumTime(), maximumTime(), maximumDate(), minimumDate()
4326 void QtxPagePrefDateTimeItem::setMinimumTime( const QTime& t )
4329 myDateTime->setMinimumTime( t );
4331 myDateTime->clearMinimumTime();
4335 \brief Store preference item to the resource manager.
4338 void QtxPagePrefDateTimeItem::store()
4341 switch ( inputType() )
4344 str = myDateTime->date().toString( Qt::ISODate );
4347 str = myDateTime->time().toString( Qt::ISODate );
4350 str = myDateTime->dateTime().toString( Qt::ISODate );
4358 \brief Retrieve preference item from the resource manager.
4361 void QtxPagePrefDateTimeItem::retrieve()
4363 QString str = getString();
4364 switch ( inputType() )
4367 myDateTime->setDate( QDate::fromString( str, Qt::ISODate ) );
4370 myDateTime->setTime( QTime::fromString( str, Qt::ISODate ) );
4373 myDateTime->setDateTime( QDateTime::fromString( str, Qt::ISODate ) );
4379 \brief Get preference item option value.
4380 \param name option name
4381 \return property value or null QVariant if option is not set
4382 \sa setOptionValue()
4384 QVariant QtxPagePrefDateTimeItem::optionValue( const QString& name ) const
4386 if ( name == "input_type" || name == "type" )
4388 else if ( name == "minimum_date" || name == "min_date" )
4389 return minimumDate();
4390 else if ( name == "maximum_date" || name == "max_date" )
4391 return maximumDate();
4392 else if ( name == "minimum_time" || name == "min_time" )
4393 return minimumTime();
4394 else if ( name == "maximum_time" || name == "max_time" )
4395 return maximumTime();
4397 return QtxPageNamedPrefItem::optionValue( name );
4401 \brief Set preference item option value.
4402 \param name option name
4403 \param val new property value
4406 void QtxPagePrefDateTimeItem::setOptionValue( const QString& name, const QVariant& val )
4408 if ( name == "input_type" || name == "type" )
4410 if ( val.canConvert( QVariant::Int ) )
4411 setInputType( val.toInt() );
4413 else if ( name == "minimum_date" || name == "min_date" )
4415 if ( val.canConvert( QVariant::Date ) )
4416 setMinimumDate( val.toDate() );
4418 else if ( name == "maximum_date" || name == "max_date" )
4420 if ( val.canConvert( QVariant::Date ) )
4421 setMaximumDate( val.toDate() );
4423 else if ( name == "minimum_time" || name == "min_time" )
4425 if ( val.canConvert( QVariant::Time ) )
4426 setMinimumTime( val.toTime() );
4428 else if ( name == "maximum_time" || name == "max_time" )
4430 if ( val.canConvert( QVariant::Time ) )
4431 setMaximumTime( val.toTime() );
4434 QtxPageNamedPrefItem::setOptionValue( name, val );
4438 \brief Update date/time widget.
4440 void QtxPagePrefDateTimeItem::updateDateTime()
4443 switch ( inputType() )
4446 dispFmt = QDateEdit().displayFormat();
4449 dispFmt = QTimeEdit().displayFormat();
4452 dispFmt = QDateTimeEdit().displayFormat();
4456 myDateTime->setDisplayFormat( dispFmt );
4461 \brief Creates preference item for editing of key bindings
4462 \param theParent parent preference item. Must not be nullptr.
4464 QtxPagePrefShortcutTreeItem::QtxPagePrefShortcutTreeItem(QtxPreferenceItem* theParent)
4465 : QtxPagePrefItem(QString(), theParent)
4467 auto container = std::shared_ptr<SUIT_ShortcutContainer>();
4468 const auto itContainers = QtxPagePrefShortcutTreeItem::shortcutContainers.find(rootItem());
4469 if (itContainers == QtxPagePrefShortcutTreeItem::shortcutContainers.end()) {
4470 container.reset(new SUIT_ShortcutContainer());
4471 QtxPagePrefShortcutTreeItem::shortcutContainers.emplace(rootItem(), container);
4474 container = itContainers->second.lock();
4476 container.reset(new SUIT_ShortcutContainer());
4477 itContainers->second = container;
4481 QtxShortcutTree* tree = new QtxShortcutTree(container);
4482 tree->myModuleIDs = SUIT_ShortcutMgr::get()->getShortcutModuleIDs();
4487 \brief Retrieves shortcut preferences from ShortcutMgr.
4488 Updates UI of controlling widget.
4491 void QtxPagePrefShortcutTreeItem::retrieve()
4493 static_cast<QtxShortcutTree*>(widget())->setShortcutsFromManager();
4497 \brief Retrieves shortcut preferences from resource files, ignoring user preferences.
4498 Updates UI of controlling widget.
4501 void QtxPagePrefShortcutTreeItem::retrieveDefault()
4503 static_cast<QtxShortcutTree*>(widget())->setDefaultShortcuts();
4507 \brief Applies modified shortcut preferences to ShortcutMgr.
4508 Updates UI of controlling widget.
4509 And ShortcutMgr, in turn, serilizes shortcut preferences using the resource manager.
4512 void QtxPagePrefShortcutTreeItem::store()
4514 static_cast<QtxShortcutTree*>(widget())->applyChangesToShortcutMgr();
4517 /*static*/ std::map<QtxPreferenceItem*, std::weak_ptr<SUIT_ShortcutContainer>> QtxPagePrefShortcutTreeItem::shortcutContainers =
4518 std::map<QtxPreferenceItem*, std::weak_ptr<SUIT_ShortcutContainer>>();
4522 \class QtxPagePrefBackgroundItem
4523 \brief GUI implementation of the resources item to store background data.
4525 Preference item allows specifying background data in different ways:
4527 - texture image file
4528 - simple two-color gradient
4529 - complex custom gradient (NOT IMPLEMENTED YET)
4531 Allowed background modes can be specified using setModeAllowed() method.
4532 Texture modes can be enabled/disabled using setTextureModeAllowed() method.
4533 Also, showing texture controls can be enabled/disabled by means of
4534 setTextureAllowed() method.
4535 Verical or horizontal orientation of the widget can be chosen via setOrientation()
4536 method (default orientation is horizontal).
4538 Simple gradient types can be specified using setGradients() method.
4540 \sa Qtx::BackgroundData, QtxBackgroundTool
4545 \param title preference item title
4546 \param parent parent preference item
4547 \param sect resource file section associated with the preference item
4548 \param param resource file parameter associated with the preference item
4550 QtxPagePrefBackgroundItem::QtxPagePrefBackgroundItem( const QString& title, QtxPreferenceItem* parent,
4551 const QString& sect, const QString& param )
4552 : QtxPageNamedPrefItem( title, parent, sect, param )
4554 setControl( myBgTool = new QtxBackgroundTool( 0 ) );
4560 QtxPagePrefBackgroundItem::~QtxPagePrefBackgroundItem()
4565 \brief Get allowed two-color gradients to the widget
4566 \param gradients gradients names are returned via this parameter
4567 \param ids gradients identifiers are returned via this parameter (empty list can be returned)
4569 void QtxPagePrefBackgroundItem::gradients( QStringList& gradList, QIntList& idList ) const
4571 myBgTool->gradients( gradList, idList );
4575 \brief Set allowed two-color gradients to the widget
4576 \param gradients gradients names
4577 \param ids optional gradients identifiers; if not specified, gradients are automatically numbered starting from 0
4579 void QtxPagePrefBackgroundItem::setGradients( const QStringList& gradients, const QIntList& ids )
4581 myBgTool->setGradients( gradients, ids );
4585 \brief Check if specific background mode is allowed
4586 \param mode background mode
4587 \return \c true if specified background mode is enabled or \c false otherwise
4588 \sa setModeAllowed()
4590 bool QtxPagePrefBackgroundItem::isModeAllowed( Qtx::BackgroundMode mode ) const
4592 return myBgTool->isModeAllowed( mode );
4596 \brief Enable / disable specific background mode
4597 \param mode background mode
4598 \param on enable / disable flag
4601 void QtxPagePrefBackgroundItem::setModeAllowed( Qtx::BackgroundMode mode, bool on )
4603 myBgTool->setModeAllowed( mode, on );
4607 \brief Check if specific texture mode is allowed
4608 \param mode texture mode
4609 \return \c true if specified texture mode is enabled or \c false otherwise
4610 \sa setTextureModeAllowed(), setTextureAllowed()
4612 bool QtxPagePrefBackgroundItem::isTextureModeAllowed( Qtx::TextureMode mode ) const
4614 return myBgTool->isTextureModeAllowed( mode );
4618 \brief Enable / disable specific texture mode
4619 \param mode texture mode
4620 \param on enable / disable flag (\c true by default)
4621 \sa isTextureModeAllowed(), setTextureAllowed()
4623 void QtxPagePrefBackgroundItem::setTextureModeAllowed( Qtx::TextureMode mode, bool on )
4625 myBgTool->setTextureModeAllowed( mode, on );
4629 \brief Check if texture controls are allowed (shown)
4630 \return \c true if texture controls are enabled or \c false otherwise
4631 \sa setTextureAllowed(), setTextureModeAllowed()
4633 bool QtxPagePrefBackgroundItem::isTextureAllowed() const
4635 return myBgTool->isTextureAllowed();
4639 \brief Enable / disable texture controls
4640 \param on enable / disable flag (\c true by default)
4641 \sa isTextureAllowed(), setTextureModeAllowed()
4643 void QtxPagePrefBackgroundItem::setTextureAllowed( bool on )
4645 myBgTool->setTextureAllowed( on );
4649 \brief Get allowed image formats
4650 \return image formats
4652 QString QtxPagePrefBackgroundItem::imageFormats() const
4654 return myBgTool->imageFormats();
4658 \brief Set allowed image formats
4659 \param formats image formats
4661 void QtxPagePrefBackgroundItem::setImageFormats( const QString& formats )
4663 myBgTool->setImageFormats( formats );
4667 \brief Get widget editor orientation
4670 Qt::Orientation QtxPagePrefBackgroundItem::orientation() const
4672 return myBgTool->orientation();
4676 \brief Set widget editor orientation
4677 \param o orientation
4679 void QtxPagePrefBackgroundItem::setOrientation( Qt::Orientation o )
4681 myBgTool->setOrientation( o );
4685 \brief Store preference item to the resource manager.
4688 void QtxPagePrefBackgroundItem::store()
4690 setString( Qtx::backgroundToString( myBgTool->data() ) );
4694 \brief Retrieve preference item from the resource manager.
4697 void QtxPagePrefBackgroundItem::retrieve()
4699 myBgTool->setData( Qtx::stringToBackground( getString() ) );
4703 \brief Get preference item option value.
4704 \param name option name
4705 \return property value or null QVariant if option is not set
4706 \sa setOptionValue()
4708 QVariant QtxPagePrefBackgroundItem::optionValue( const QString& name ) const
4710 if ( name == "texture_enabled" )
4711 return isTextureAllowed();
4712 else if ( name == "color_enabled" )
4713 return isModeAllowed( Qtx::ColorBackground );
4714 else if ( name == "gradient_enabled" )
4715 return isModeAllowed( Qtx::SimpleGradientBackground );
4716 else if ( name == "custom_enabled" )
4717 return isModeAllowed( Qtx::CustomGradientBackground );
4718 else if ( name == "texture_center_enabled" )
4719 return isTextureModeAllowed( Qtx::CenterTexture );
4720 else if ( name == "texture_tile_enabled" )
4721 return isTextureModeAllowed( Qtx::TileTexture );
4722 else if ( name == "texture_stretch_enabled" )
4723 return isTextureModeAllowed( Qtx::StretchTexture );
4724 else if ( name == "orientation" )
4725 return orientation();
4726 else if ( name == "image_formats" )
4727 return imageFormats();
4728 else if ( name == "gradient_names" ) {
4731 gradients( grList, idList );
4734 else if ( name == "gradient_ids" ) {
4737 gradients( grList, idList );
4738 QList<QVariant> lst;
4739 for ( QIntList::const_iterator it = idList.begin(); it != idList.end(); ++it )
4744 return QtxPageNamedPrefItem::optionValue( name );
4748 \brief Set preference item option value.
4749 \param name option name
4750 \param val new property value
4753 void QtxPagePrefBackgroundItem::setOptionValue( const QString& name, const QVariant& val )
4755 if ( name == "texture_enabled" ) {
4756 if ( val.canConvert( QVariant::Bool ) )
4757 setTextureAllowed( val.toBool() );
4759 else if ( name == "color_enabled" ) {
4760 if ( val.canConvert( QVariant::Bool ) )
4761 setModeAllowed( Qtx::ColorBackground, val.toBool() );
4763 else if ( name == "gradient_enabled" ) {
4764 if ( val.canConvert( QVariant::Bool ) )
4765 setModeAllowed( Qtx::SimpleGradientBackground, val.toBool() );
4767 else if ( name == "custom_enabled" ) {
4768 if ( val.canConvert( QVariant::Bool ) )
4769 setModeAllowed( Qtx::CustomGradientBackground, val.toBool() );
4771 else if ( name == "texture_center_enabled" ) {
4772 if ( val.canConvert( QVariant::Bool ) )
4773 setTextureModeAllowed( Qtx::CenterTexture, val.toBool() );
4775 else if ( name == "texture_tile_enabled" ) {
4776 if ( val.canConvert( QVariant::Bool ) )
4777 setTextureModeAllowed( Qtx::TileTexture, val.toBool() );
4779 else if ( name == "texture_stretch_enabled" ) {
4780 if ( val.canConvert( QVariant::Bool ) )
4781 setTextureModeAllowed( Qtx::StretchTexture, val.toBool() );
4783 else if ( name == "orientation" ) {
4784 if ( val.canConvert( QVariant::Int ) )
4785 setOrientation( (Qt::Orientation)val.toInt() );
4787 else if ( name == "image_formats" ) {
4788 if ( val.canConvert( QVariant::String ) )
4789 setImageFormats( val.toString() );
4791 else if ( name == "gradient_names" ) {
4793 if ( toStringList( val, values ) )
4794 setGradients( values );
4796 else if ( name == "gradient_ids" ) {
4797 if ( val.canConvert( QVariant::List ) ) {
4800 gradients( grList, idList );
4802 QList<QVariant> varList = val.toList();
4803 for ( QList<QVariant>::const_iterator it = varList.begin(); it != varList.end(); ++it ) {
4804 if ( (*it).canConvert( QVariant::Int ) )
4805 idList.append( (*it).toInt() );
4807 setGradients( grList, idList );
4811 QtxPageNamedPrefItem::setOptionValue( name, val );
4817 Creates preference item of user defined widget. The item widget has to be inherited from
4818 QtxUserDefinedContent class. An instance of this class has to be installed into the item
4819 with help of setContent method. Methods optionValue and setOptionValue use pointer on the
4820 content widget an qint64 value.
4822 \param parent parent preference item
4824 QtxUserDefinedItem::QtxUserDefinedItem( QtxPreferenceItem* parent )
4825 : QtxPageNamedPrefItem(QString(), parent), myContent(0)
4830 \brief Lets to Store preferences for content instance
4833 void QtxUserDefinedItem::store()
4836 myContent->store( resourceMgr(), preferenceMgr());
4841 \brief Lets to Retrieve preferences for content instance
4844 void QtxUserDefinedItem::retrieve()
4847 myContent->retrieve( resourceMgr(), preferenceMgr());
4852 * \brief Returns option value
4853 * \param theName is a string "content"
4854 * \return pointer on QtxUserDefinedContent class instance as a qint64 value
4856 QVariant QtxUserDefinedItem::optionValue( const QString& theName ) const
4858 if ( theName == "content" )
4859 return (qint64) myContent;
4861 return QtxPreferenceItem::optionValue( theName );
4865 * \brief Sets option value
4866 * \param theName is a string "content"
4867 * \param theVal is a pointer on QtxUserDefinedContent class instance represented as qint64 value
4869 void QtxUserDefinedItem::setOptionValue( const QString& theName, const QVariant& theVal)
4871 if ( theName == "content" ) {
4872 if ( theVal.canConvert( QVariant::ULongLong ) ) {
4873 setContent( (QtxUserDefinedContent*)theVal.toULongLong() );
4876 QtxPreferenceItem::setOptionValue( theName, theVal );
4880 * \brief Defines content of the property item as a Widget which has to be inherited from
4881 * QtxUserDefinedContent class.
4882 * \param theContent is an QtxUserDefinedContent class instance.
4884 void QtxUserDefinedItem::setContent( QtxUserDefinedContent* theContent )
4886 myContent = theContent;
4887 setControl(myContent);