summaryrefslogtreecommitdiffstats
path: root/kiconedit/properties.cpp
blob: 8d42c039818bb42b63fe74f34912760293c0588e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
    TDE Icon Editor - a small graphics drawing program for the TDE
    Copyright (C) 1998  Thomas Tanghus (tanghus@kde.org)

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    Boston, MA 02110-1301, USA.
*/

#include <tdeconfig.h>
#include <kdebug.h>
#include <kapplication.h>

#include "properties.h"

KIconEditProperties* KIconEditProperties::m_self = 0;

KIconEditProperties* KIconEditProperties::self()
{
    if (!m_self)
        m_self = new KIconEditProperties();
    return m_self;
}

KIconEditProperties::KIconEditProperties() : TQObject()
{
    TDEConfig *config = kapp->config();

    config->setGroup( "Appearance" );

    m_bgMode = (TQWidget::BackgroundMode)config->readNumEntry( "BackgroundMode", TQWidget::FixedPixmap);
    m_bgColor = config->readColorEntry( "BackgroundColor", &gray);
    m_bgPixmap = config->readPathEntry("BackgroundPixmap");

    config->setGroup( "Grid" );
    m_pasteTransparent = config->readBoolEntry( "PasteTransparent", false );
    m_showGrid = config->readBoolEntry( "ShowGrid", true );
    m_gridScale = config->readNumEntry( "GridScaling", 10 );
    m_showRulers = config->readBoolEntry( "ShowRulers", true );

    if(config->readEntry( "TransparencyDisplayType", "Checkerboard" ) == "Checkerboard")
    {
      m_transparencyDisplayType = KIconEditGrid::TRD_CHECKERBOARD;
    }
    else
    {
      m_transparencyDisplayType = KIconEditGrid::TRD_SOLIDCOLOR;
    }

    TQColor checkColor1(255, 255, 255);
    TQColor checkColor2(127, 127, 127);

    m_checkerboardColor1 = config->readColorEntry( "CheckerboardColor1", &checkColor1);
    m_checkerboardColor2 = config->readColorEntry( "CheckerboardColor2", &checkColor2);

    TQString checkerboardSize = config->readEntry( "CheckerboardSize", "Medium" );

    if(checkerboardSize == "Small")
    {
      m_checkerboardSize = KIconEditGrid::CHK_SMALL;
    }
    else
    if(checkerboardSize == "Medium")
    {
      m_checkerboardSize = KIconEditGrid::CHK_MEDIUM;
    }
    else
    {
      m_checkerboardSize = KIconEditGrid::CHK_LARGE;
    }

    TQColor solidColor(255, 255, 255);
    m_transparencySolidColor = config->readColorEntry( "TransparencySolidColor", &solidColor);
}

KIconEditProperties::~KIconEditProperties()
{
  kdDebug(4640) << "KIconEditProperties: Deleting properties" << endl;
  m_self = 0;
}

void KIconEditProperties::save()
{
    TDEConfig *config = kapp->config();

    config->setGroup( "Appearance" );

    config->writeEntry("BackgroundMode", m_bgMode );
    config->writeEntry("BackgroundColor", m_bgColor );
    config->writePathEntry("BackgroundPixmap", m_bgPixmap );

    config->setGroup( "Grid" );
    config->writeEntry("PasteTransparent", m_pasteTransparent );
    config->writeEntry("ShowGrid", m_showGrid );
    config->writeEntry("GridScaling", m_gridScale );
    config->writeEntry("ShowRulers", m_showRulers );

    TQString transparencyDisplayType;

    switch(m_transparencyDisplayType)
    {
      case KIconEditGrid::TRD_SOLIDCOLOR:
        transparencyDisplayType = "SolidColor";
        break;
      case KIconEditGrid::TRD_CHECKERBOARD:
      default:
        transparencyDisplayType = "Checkerboard";
        break;
    }

    config->writeEntry( "TransparencyDisplayType", transparencyDisplayType );
    config->writeEntry( "CheckerboardColor1", m_checkerboardColor1 );
    config->writeEntry( "CheckerboardColor2", m_checkerboardColor2 );

    TQString checkerboardSize;

    switch(m_checkerboardSize)
    {
      case KIconEditGrid::CHK_SMALL:
        checkerboardSize = "Small";
        break;
      case KIconEditGrid::CHK_MEDIUM:
        checkerboardSize = "Medium";
        break;
      case KIconEditGrid::CHK_LARGE:
      default:
        checkerboardSize = "Large";
        break;
    }

    config->writeEntry( "CheckerboardSize", checkerboardSize );
    config->writeEntry( "TransparencySolidColor", m_transparencySolidColor );

    config->sync();
}