summaryrefslogtreecommitdiffstats
path: root/src/k9titlefactor.cpp
blob: ffb4add70f02bae03db21c8152d9d3a91ea878be (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
//
// C++ Implementation:
//
// Description:
//
//
// Author: Jean-Michel PETIT <k9copy@free.fr>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//


#include "k9titlefactor.h"
#include "k9cellcopylist.h"
#include "k9dvdsize.h"
#include <tqgroupbox.h>
#include <tqslider.h>
#include <tqlabel.h>
#include <tqcheckbox.h>
#include <klocale.h>



k9TitleFactor::k9TitleFactor(TQWidget* tqparent, const char* name, WFlags fl)
        : titleFactor(tqparent,name,fl) {
    m_current=NULL;
    m_slFactorPressed=false;
    m_factor=-1;
    m_dvd=NULL;
    m_updating=false;
    SelectionChanged( NULL,m_withMenus);
    m_useDvdAuthor=false;
    slFactor->setPageStep(0);
}

k9TitleFactor::~k9TitleFactor() {}

/*$SPECIALIZATION$*/
void k9TitleFactor::setUseDvdAuthor( bool _value) {
   m_useDvdAuthor=_value;
}

float k9TitleFactor::getFactor() {
    if (m_factor==-1)
	    m_factor=m_dvd->getfactor( m_withMenus,false,m_useDvdAuthor);
    return m_factor;	
}

void k9TitleFactor::ckAutoClicked(bool checked) {
    if (m_current!=NULL && !m_updating) {
        m_current->setforceFactor(checked);
        if ( checked) {
	    m_current->setfactor( getFactor());
            slFactor->setValue(m_current->getfactor()*100.0);
            setMinFactor();
        } else {
            slFactor->setValue(getFactor()*100.0);
            slFactor->setMinValue(100);
        }

    }
}

void k9TitleFactor::slFactorReleased() {
    m_slFactorPressed=false;
}

void k9TitleFactor::slFactorPressed() {
    if (m_current !=NULL)  {
        m_current->setforceFactor(true);
        setMinFactor();
    }
    m_slFactorPressed=true;

}

void k9TitleFactor::slFactor_valueChanged( int ) {
    if (m_current !=NULL ) {
	if (m_slFactorPressed) {
		m_current->setfactor( (double)slFactor->value() /100);
		for (int i=0;i <m_current->getTitles().count();i++) {
			k9DVDTitle * title=m_current->getTitles().at(i);
			title->setfactor( (double)slFactor->value() /100);
		}
		m_factor=-1;
	}
	if (m_current->getforceFactor())	
        	tFactor->setText(TQString("%1").tqarg(m_current->getfactor(),4,'f',2));
	else
		tFactor->setText(TQString("%1").tqarg(getFactor(),4,'f',2));
    }

}

void k9TitleFactor::changedTitle(k9DVDTitle *_title) {
	if (_title ==NULL) {
		gbTitle->hide();
		lbTitle->setText(i18n("Select a Title in the treeview..."));		
		return;
	}
	
	gbTitle->show();
	m_current=_title;
	
	m_updating=true;
	gbTitle->setChecked(m_current->getforceFactor());
	m_updating=false;
	
	lbTitle->setText(TQString(i18n("Shrink Factor for %1")).tqarg(m_current->getname()));
	if (m_current->getforceFactor()) {
		slFactor->setValue(m_current->getfactor()*100.0);
		tFactor->setText(TQString("%1").tqarg(m_current->getfactor(),4,'f',2));        
		setMinFactor();
	} else {
		slFactor->setValue(getFactor()*100.0);
		tFactor->setText(TQString("%1").tqarg(getFactor(),4,'f',2));
		slFactor->setMinValue(100);
	}
		
}


void k9TitleFactor::setMinFactor() {
    k9CellCopyList *lst=new k9CellCopyList(m_dvd->getdvd(),m_dvd);
    double minFactor=lst->getMinFactor( true); //TODO : corriger pour copie sans menus
    slFactor->setMinValue(minFactor*100);

    delete lst;
}

void k9TitleFactor::SelectionChanged( k9DVD *_dvd,bool _withMenus) {
    m_dvd=_dvd;
    if (_dvd==NULL) 
	    m_current=NULL;
    m_factor=-1;
    m_withMenus=_withMenus;

    changedTitle( m_current);
    
}


#include "k9titlefactor.moc"