]> SALOME platform Git repositories - modules/shaper.git/blob - src/XGUI/XGUI_Preferences.cpp
Salome HOME
06d7fbf15637ab0252d5a5d466fe72b8cf172766
[modules/shaper.git] / src / XGUI / XGUI_Preferences.cpp
1 // File:        XGUI_Preferences.cpp
2 // Created:     07 Aug 2014
3 // Author:      Vitaly SMETANNIKOV
4
5 #include "XGUI_Preferences.h"
6 #include "XGUI_Constants.h"
7
8 #include <SUIT_ResourceMgr.h>
9 #include <SUIT_PreferenceMgr.h>
10
11 #include <QLayout>
12 #include <QApplication>
13 #include <QDialogButtonBox>
14
15 SUIT_ResourceMgr* XGUI_Preferences::myResourceMgr = 0;
16
17
18 SUIT_ResourceMgr* XGUI_Preferences::resourceMgr()
19 {
20   if (!myResourceMgr) {
21     myResourceMgr = new SUIT_ResourceMgr("NewGeom");
22     myResourceMgr->setCurrentFormat("xml");
23   }
24   return myResourceMgr;
25 }
26
27 void XGUI_Preferences::editPreferences()
28 {
29   XGUI_PreferencesDlg aDlg(resourceMgr(), QApplication::activeWindow());
30   aDlg.exec();
31 }
32
33
34
35 //**********************************************************
36 //**********************************************************
37 //**********************************************************
38 XGUI_PreferencesDlg::XGUI_PreferencesDlg(SUIT_ResourceMgr* theResurces, QWidget* theParent)
39   : QDialog(theParent)
40 {
41   setWindowTitle( tr("Edit preferences") );
42
43   QVBoxLayout* main = new QVBoxLayout(this);
44   main->setMargin( 5 );
45   main->setSpacing( 5 );
46
47   myPreferences = new SUIT_PreferenceMgr(theResurces, this);
48   main->addWidget( myPreferences );
49
50   setFocusProxy( myPreferences );
51   myPreferences->setFrameStyle( QFrame::Box | QFrame::Sunken );
52   //myPreferences->show();
53
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()));  
59
60   myPreferences->retrieve();
61   createEditors();
62 }
63
64 XGUI_PreferencesDlg::~XGUI_PreferencesDlg()
65 {
66 }
67
68 void XGUI_PreferencesDlg::createEditors()
69 {
70   int aLFpage = myPreferences->addItem("Look&Feel");
71   myPreferences->setItemIcon(aLFpage, QIcon(":pictures/view_prefs.png"));
72
73   int viewTab = myPreferences->addItem( tr("Viewer"), aLFpage );
74
75   QStringList gradList;
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");
80   
81   QList<QVariant> idList;
82   for (int i = 0; i < gradList.size(); i++)
83     idList << i;
84
85   int bgGroup = myPreferences->addItem( tr( "Background" ), viewTab );
86
87   QString aImgFiles("Image files (*.bmp *.gif *.pix *.xwd *.rgb *.rs)");
88
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 );
99
100 }
101
102
103
104
105