1 // File: XGUI_Preferences.cpp
2 // Created: 07 Aug 2014
3 // Author: Vitaly SMETANNIKOV
5 #include "XGUI_Preferences.h"
6 #include "XGUI_Constants.h"
8 #include <SUIT_ResourceMgr.h>
9 #include <SUIT_PreferenceMgr.h>
12 #include <QApplication>
13 #include <QDialogButtonBox>
15 SUIT_ResourceMgr* XGUI_Preferences::myResourceMgr = 0;
18 SUIT_ResourceMgr* XGUI_Preferences::resourceMgr()
21 myResourceMgr = new SUIT_ResourceMgr("NewGeom");
22 myResourceMgr->setCurrentFormat("xml");
27 void XGUI_Preferences::editPreferences()
29 XGUI_PreferencesDlg aDlg(resourceMgr(), QApplication::activeWindow());
35 //**********************************************************
36 //**********************************************************
37 //**********************************************************
38 XGUI_PreferencesDlg::XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent)
41 setWindowTitle( tr("Edit preferences") );
43 QVBoxLayout* main = new QVBoxLayout(this);
45 main->setSpacing( 5 );
47 myPreferences = new SUIT_PreferenceMgr(theResurces, this);
48 main->addWidget( myPreferences );
50 setFocusProxy( myPreferences );
51 myPreferences->setFrameStyle( QFrame::Box | QFrame::Sunken );
52 //myPreferences->show();
54 QDialogButtonBox* aBtnBox = new QDialogButtonBox(
55 QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
56 main->addWidget(aBtnBox);
57 connect(aBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
58 connect(aBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
60 myPreferences->retrieve();
64 XGUI_PreferencesDlg::~XGUI_PreferencesDlg()
68 void XGUI_PreferencesDlg::createEditors()
70 int aLFpage = myPreferences->addItem("Look&Feel");
71 myPreferences->setItemIcon(aLFpage, QIcon(":pictures/view_prefs.png"));
73 int viewTab = myPreferences->addItem( tr("Viewer"), aLFpage );
76 gradList << tr("Horizontal gradient") << tr("Vertical gradient") <<
77 tr("First diagonal gradient") << tr("Second diagonal gradient") <<
78 tr("First corner gradient") << tr("Second corner gradient") <<
79 tr("Third corner gradient") << tr("Fourth corner gradient");
81 QList<QVariant> idList;
82 for (int i = 0; i < gradList.size(); i++)
85 int bgGroup = myPreferences->addItem( tr( "Background" ), viewTab );
87 QString aImgFiles("Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs)");
89 int bgId = myPreferences->addItem( tr("Viewer 3d" ), bgGroup,
90 SUIT_PreferenceMgr::Background, "Viewer", "background" );
91 myPreferences->setItemProperty( "gradient_names", gradList, bgId );
92 myPreferences->setItemProperty( "gradient_ids", idList, bgId );
93 myPreferences->setItemProperty( "texture_enabled", true, bgId );
94 myPreferences->setItemProperty( "texture_center_enabled", true, bgId );
95 myPreferences->setItemProperty( "texture_tile_enabled", true, bgId );
96 myPreferences->setItemProperty( "texture_stretch_enabled", true, bgId );
97 myPreferences->setItemProperty( "custom_enabled", false, bgId );
98 myPreferences->setItemProperty( "image_formats", aImgFiles, bgId );