summaryrefslogtreecommitdiffstats
path: root/configdialog/kbfxconfigdlgbutton.ui.h
blob: 0901dd28782a1f0d13bfd73084f4c1810f58d871 (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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** TQt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/

void KbfxConfigDlgButton::init()
{
	connect ( this, TQT_SIGNAL ( KbfxConfigDlgButtonChanged ( const char *, const TQString & ) ),
	          this, TQT_SLOT ( ChangeForm ( const char *, const TQString & ) ) );
}

/* actions performed when url is selected */
void KbfxConfigDlgButton::KbfxURLRequesterNormalUrlSelected ( const TQString &selected_img_path )
{
	emit KbfxConfigDlgButtonChanged ( "normal", selected_img_path );
}

void KbfxConfigDlgButton::KbfxURLRequesterPressedUrlSelected ( const TQString &selected_img_path )
{
	emit KbfxConfigDlgButtonChanged ( "pressed", selected_img_path );
}

void KbfxConfigDlgButton::KbfxURLRequesterHoverUrlSelected ( const TQString &selected_img_path )
{
	emit KbfxConfigDlgButtonChanged ( "hover", selected_img_path );
}

void KbfxConfigDlgButton::KbfxButtonToggled ( bool )
{
	if ( KbfxButton->state() == 2 )
		KbfxButton->setPixmap ( ConfigInit().m_KbfxPressedButtonPath );

	if ( KbfxButton->state() == 0 )
		KbfxButton->setPixmap ( ConfigInit().m_KbfxNormalButtonPath );
}

/* url processing */
void KbfxConfigDlgButton::ChangeForm ( const char *name, const TQString &path )
{
	kdDebug() << "Received: "  << name << " + " << path << endl;

	TQString tmppath = path;
	if ( tmppath.startsWith ( "file://" ) ) tmppath.remove ( "file://" );

	TQImage tmp ( tmppath );

	TQString tmpname = name;
	if ( tmpname == "pressed" )
	{
		if ( tmp.isNull() )
		{
			KMessageBox::error ( 0,
			                     tr2i18n ( "<p align='center'>Image cannot be used as a pressed button skin!</p>"
			                               "<p align='center'>Will use default pressed button skin.</p>" ),
			                     tr2i18n ( "Error loading image" ) );
			tmppath = ConfigInit().m_KbfxPressedButtonPathDefault;
		}

		kdDebug() << tmpname << " :: " << tmppath << endl;

		KbfxURLRequesterPressed->setURL ( tmppath );
		KbfxPixmapLabelPressed->setPixmap ( tmppath );
		ConfigInit().m_KbfxPressedButtonPath = tmppath;

		if ( KbfxButton->state() == 2 )
			KbfxButton->setPixmap ( ConfigInit().m_KbfxPressedButtonPath );
	}

	if ( tmpname == "normal" )
	{
		if ( tmp.isNull() )
		{
			KMessageBox::error ( 0,
			                     tr2i18n ( "<p align='center'>Image cannot be used as a normal button skin!</p>"
			                               "<p align='center'>Will use default normal button skin.</p>" ),
			                     tr2i18n ( "Error loading image" ) );
			tmppath = ConfigInit().m_KbfxNormalButtonPathDefault;
		}

		kdDebug() << tmpname << " :: "  << tmppath << endl;

		KbfxURLRequesterNormal->setURL ( tmppath );
		KbfxPixmapLabelNormal->setPixmap ( tmppath );
		ConfigInit().m_KbfxNormalButtonPath = tmppath;

		if ( KbfxButton->state() == 0 )
			KbfxButton->setPixmap ( ConfigInit().m_KbfxNormalButtonPath );
	}

	if ( tmpname == "hover" )
	{
		if ( tmp.isNull() )
		{
			KMessageBox::error ( 0,
			                     tr2i18n ( "<p align='center'>Image cannot be used as a hover button skin!</p>"
			                               "<p align='center'>Will use default hover button skin.</p>" ),
			                     tr2i18n ( "Error loading image" ) );
			tmppath = ConfigInit().m_KbfxHoverButtonPathDefault;
		}

		kdDebug() << tmpname << " :: " << tmppath << endl;

		KbfxURLRequesterHover->setURL ( tmppath );
		KbfxPixmapLabelHover->setPixmap ( tmppath );
		ConfigInit().m_KbfxHoverButtonPath = tmppath;
	}
}

/* initialize Button page at the beginning or after "Default" pressed */
void KbfxConfigDlgButton::ChangeForm()
{
	KbfxURLRequesterNormal->setURL ( ConfigInit().m_KbfxNormalButtonPath );
	KbfxURLRequesterPressed->setURL ( ConfigInit().m_KbfxPressedButtonPath );
	KbfxURLRequesterHover->setURL ( ConfigInit().m_KbfxHoverButtonPath );
	KbfxPixmapLabelNormal->setPixmap ( ConfigInit().m_KbfxNormalButtonPath );
	KbfxPixmapLabelPressed->setPixmap ( ConfigInit().m_KbfxPressedButtonPath );
	KbfxPixmapLabelHover->setPixmap ( ConfigInit().m_KbfxHoverButtonPath );
	KbfxButtonToggled ( 1 );

	if ( ConfigInit().m_fadeTime == 0 )
		KbfxFadeButton->setChecked ( FALSE );
	else
		KbfxFadeButton->setChecked ( TRUE );
	if ( ConfigInit().m_ToolBarResize == TRUE && KbfxResizeKicker->state() == 0 )
		KbfxResizeKicker->toggle();
	if ( ConfigInit().m_ToolBarResize == FALSE && KbfxResizeKicker->state() == 2 )
		KbfxResizeKicker->toggle();

	KbfxFadeTime->setText ( TQString::number ( ConfigInit().m_fadeTime ) );
}


void KbfxConfigDlgButton::KbfxResizeKickerToggled ( bool )
{
	if ( KbfxResizeKicker->state() == 2 )
	{
		KbfxResizeKicker->setText ( tr2i18n ( "Panel Resize is 'ON'" ) );
		ConfigInit().m_ToolBarResize = TRUE;
	}

	if ( KbfxResizeKicker->state() == 0 )
	{
		KbfxResizeKicker->setText ( tr2i18n ( "Panel Resize is 'OFF'" ) );
		ConfigInit().m_ToolBarResize = FALSE;
	}

	kdDebug() << "Panel Resize is: "
	<< ConfigInit().m_ToolBarResize
	<< endl;

}



void KbfxConfigDlgButton::KbfxFadeButton_toggled( bool _state )
{
	if ( _state )
	{
		KbfxFadeTime->setText ( TQString::number ( ConfigInit().m_fadeTimeDefault ) );
		ConfigInit().m_fadeTime = ConfigInit().m_fadeTimeDefault;
	}
	else
	{
		ConfigInit().m_fadeTime = 0;
	}
}


void KbfxConfigDlgButton::KbfxFadeTime_lostFocus()
{
	int _value = ( KbfxFadeTime->text () ).toInt();
	ConfigInit().m_fadeTime = _value;
	ConfigInit().checkValues();

	KbfxFadeTime->setText ( TQString::number ( ConfigInit().m_fadeTime ) );
}