~ubuntu-branches/debian/sid/librecad/sid

« back to all changes in this revision

Viewing changes to librecad/src/ui/forms/qg_snapmiddleoptions.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Howard
  • Date: 2013-12-09 23:29:24 UTC
  • mfrom: (0.2.9) (11.1.7 experimental)
  • Revision ID: package-import@ubuntu.com-20131209232924-3w7aau9lo2bdv32c
Tags: 2.0.0~rc3+nolibs-1
* Merge from experimental to unstable.
* New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
Construct option widget for equidistant points on entity
 
4
 
 
5
Copyright (C) 2011 Dongxu Li (dongxuli2011@gmail.com)
 
6
Copyright (C) 2011 R. van Twisk (librecad@rvt.dds.nl)
 
7
 
 
8
This program is free software; you can redistribute it and/or
 
9
modify it under the terms of the GNU General Public License
 
10
as published by the Free Software Foundation; either version 2
 
11
of the License, or (at your option) any later version.
 
12
 
 
13
This program is distributed in the hope that it will be useful,
 
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
GNU General Public License for more details.
 
17
 
 
18
You should have received a copy of the GNU General Public License
 
19
along with this program; if not, write to the Free Software
 
20
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
21
**********************************************************************/
 
22
 
 
23
#include "qg_snapmiddleoptions.h"
 
24
 
 
25
#include <qvariant.h>
 
26
 
 
27
/*
 
28
 *  Constructs a QG_SnapMiddleOptions as a child of 'parent'
 
29
 *  and widget flags set to 'f'.
 
30
 *@i, number equidistant points, minimum 1, maximum 99
 
31
 *
 
32
 *@Author: Dongxu Li
 
33
 */
 
34
QG_SnapMiddleOptions::QG_SnapMiddleOptions(int& i, QWidget* parent, Qt::WindowFlags fl)
 
35
    : QWidget(parent, fl)
 
36
{
 
37
    setupUi(this);
 
38
    middlePoints=&i;
 
39
}
 
40
 
 
41
/*
 
42
 *  Destroys the object and frees any allocated resources
 
43
 */
 
44
QG_SnapMiddleOptions::~QG_SnapMiddleOptions()
 
45
{
 
46
    destroy();
 
47
    // no need to delete child widgets, Qt does it all for us
 
48
}
 
49
 
 
50
/*
 
51
 *  Sets the strings of the subwidgets using the current
 
52
 *  language.
 
53
 */
 
54
void QG_SnapMiddleOptions::languageChange()
 
55
{
 
56
    retranslateUi(this);
 
57
}
 
58
 
 
59
void QG_SnapMiddleOptions::destroy() {
 
60
    RS_SETTINGS->beginGroup("/Snap");
 
61
    RS_SETTINGS->writeEntry("/MiddlePoints", *middlePoints);
 
62
    RS_SETTINGS->endGroup();
 
63
}
 
64
 
 
65
void QG_SnapMiddleOptions::setMiddlePoints( int& i, bool initial) {
 
66
    middlePoints = &i;
 
67
    if(initial) {
 
68
    RS_SETTINGS->beginGroup("/Snap");
 
69
    *middlePoints=RS_SETTINGS->readNumEntry("/MiddlePoints", 1);
 
70
    if( !( *middlePoints>=1 && *middlePoints<=99)) {
 
71
        *middlePoints=1;
 
72
        RS_SETTINGS->writeEntry("/MiddlePoints", 1);
 
73
    }
 
74
    sbMiddlePoints->setValue(*middlePoints);
 
75
    RS_SETTINGS->endGroup();
 
76
    } else {
 
77
        *middlePoints=sbMiddlePoints->value();
 
78
    }
 
79
 
 
80
}
 
81
 
 
82
void QG_SnapMiddleOptions::updateMiddlePoints() {
 
83
    if (middlePoints != NULL) {
 
84
        *middlePoints = sbMiddlePoints->value();
 
85
    }
 
86
}
 
87
 
 
88
void QG_SnapMiddleOptions::on_sbMiddlePoints_valueChanged(int i)
 
89
{
 
90
    if (middlePoints != NULL) {
 
91
        *middlePoints = i;/*
 
92
    RS_SETTINGS->beginGroup("/Snap");
 
93
    RS_SETTINGS->writeEntry("/MiddlePoints", *middlePoints);
 
94
    RS_SETTINGS->endGroup();*/
 
95
    }
 
96
}
 
97
//EOF