~ubuntu-branches/ubuntu/saucy/acetoneiso/saucy

« back to all changes in this revision

Viewing changes to acetoneiso/sources/play.h

  • Committer: Bazaar Package Importer
  • Author(s): Nick Andrik
  • Date: 2010-01-19 20:16:15 UTC
  • Revision ID: james.westby@ubuntu.com-20100119201615-bdokwbbqhn1fo1iq
Tags: upstream-2.2.1
Import upstream version 2.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//This file is part of AcetoneISO. Copyright 2006,2007,2008,2009 Marco Di Antonio and Fabrizio Di Marco (acetoneiso@gmail.com)
 
2
//
 
3
//    AcetoneISO is free software: you can redistribute it and/or modify
 
4
//    it under the terms of the GNU General Public License as published by
 
5
//    the Free Software Foundation, either version 3 of the License, or
 
6
//    (at your option) any later version.
 
7
//
 
8
//    AcetoneISO is distributed in the hope that it will be useful,
 
9
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
//    GNU General Public License for more details.
 
12
//
 
13
//    You should have received a copy of the GNU General Public License
 
14
//    along with AcetoneISO.  If not, see <http://www.gnu.org/licenses/>.
 
15
void acetoneiso::play()
 
16
{
 
17
QFile Mtab("/etc/mtab");//dichiaro un file Mtab che sarebbe /etc/mtab
 
18
Mtab.open(QIODevice::ReadOnly);//lo apro in sola lettura
 
19
QString str1 = (Mtab.readAll());//leggo il contenuto del file mtab
 
20
 
 
21
   QDir Home = QDir::home();
 
22
   QFile file(Home.path() + "/.acetoneiso/acetoneiso.conf");
 
23
   file.open(QIODevice::ReadOnly);//lo apro in sola lettura
 
24
   QString strb = (leggiRigo( 2, &file ));
 
25
 
 
26
QDir Temp = QDir::temp();
 
27
Temp.cd("acetoneiso");
 
28
//QDir Home = QDir::home();
 
29
QDir virtual_dvd_drive( Home.path() + "/virtual-drives" + "/dvd" );
 
30
 
 
31
if(str1.contains( virtual_dvd_drive.path() ) )//Caso che il dvd è già montato.
 
32
{
 
33
 
 
34
QMessageBox::information(this, "AcetoneISO",tr("Please Unmount the movie first"));
 
35
 
 
36
}
 
37
else{   //Caso che il dvd non è montato.
 
38
QString isodamontare = QFileDialog::getOpenFileName(this,tr("Select DVD-Movie to Play"), Home.path() , tr("DVD-Movie Image (*.iso *.bin *.img *.mdf *.nrg)"));
 
39
if ( !isodamontare.isNull() )
 
40
        {
 
41
        QFileInfo fi( isodamontare );
 
42
        QString onlyfile = fi.fileName();
 
43
        onlyfile.chop(4);
 
44
        QString percorsovirtuale = virtual_dvd_drive.path();
 
45
        Monta( isodamontare, percorsovirtuale ); //function defined in a_mount.h
 
46
        
 
47
// chiamo subito lo scaricamento della copertina, speriamo bene!
 
48
//dvdGui( label_dvd2, onlyfile);
 
49
// decidi se usare metodo 1 o 2
 
50
 
 
51
QMessageBox msgBox;
 
52
msgBox.setText(tr("Choose a method to play the movie.\nMethod 1 generally works, if it doesn't try Method 2."));
 
53
QPushButton *connectButton = msgBox.addButton(tr("Method 1"), QMessageBox::ActionRole);
 
54
QPushButton *connectButton2 = msgBox.addButton(tr("Method 2"), QMessageBox::ActionRole);
 
55
msgBox.exec();
 
56
 if (msgBox.clickedButton() == connectButton) {
 
57
 
 
58
 
 
59
         if(strb.contains("kaffeine", Qt::CaseInsensitive)) {   //Se nel radio button è selezionato kaffeine.
 
60
            QString kaf_input(virtual_dvd_drive.path());
 
61
            kaf_input.prepend("dvd:/");
 
62
            KAffeine.start("kaffeine", QStringList() << kaf_input );
 
63
            }
 
64
         else{                                  
 
65
           if(strb.contains("vlc", Qt::CaseInsensitive)) { //Se nel radio button è selezionato vlc.
 
66
              VLc.start("vlc", QStringList() << virtual_dvd_drive.path() );
 
67
           }
 
68
           else {
 
69
                SMplayer.start("smplayer", QStringList() << virtual_dvd_drive.path() );
 
70
                
 
71
                }
 
72
            }
 
73
                                                }
 
74
 else if (msgBox.clickedButton() == connectButton2)
 
75
{
 
76
isodamontare.prepend("dvd:/");
 
77
 
 
78
         if(strb.contains("kaffeine", Qt::CaseInsensitive)) {   //Se nel radio button è selezionato kaffeine.
 
79
        
 
80
            KAffeine.start("kaffeine", QStringList() << isodamontare );
 
81
            }
 
82
         else{                                  
 
83
           if(strb.contains("vlc", Qt::CaseInsensitive)) { //Se nel radio button è selezionato vlc.
 
84
              VLc.start("vlc", QStringList() << isodamontare );
 
85
           }
 
86
           else {
 
87
                SMplayer.start("smplayer", QStringList() << isodamontare );
 
88
                
 
89
                }
 
90
            }
 
91
                                                }
 
92
     }
 
93
}
 
94
file.close();
 
95
Mtab.close();
 
96
}
 
97
 
 
98
/*void acetoneiso::dvdGui( QLabel *label, QString &string ) //questa funzione pulisce la label e ci riscrive il titolo del dvd.Infine richiama get_cover 
 
99
{
 
100
   QDir Temp = QDir::temp();
 
101
   Temp.cd("acetoneiso");
 
102
   label->clear();
 
103
   label->setText("DVD-Movie " + string + + " " + tr(" mounted"));
 
104
   QFile f1(Temp.path() + "/dvd");
 
105
   f1.open(QIODevice::WriteOnly | QIODevice::Text);
 
106
   QTextStream out(&f1);
 
107
   out << ( string );
 
108
   QTimer::singleShot(2000, this, SLOT(get_cover())); //QUI DEVO ASPETTARE CHE CREA IL FILE /TMP/ACETONEISO/DVD E POI FA COVER
 
109
}*/
 
110
 
 
111
void acetoneiso::unplay()
 
112
{
 
113
QDir Home = QDir::home();
 
114
QDir Temp = QDir::temp();
 
115
Temp.cd("acetoneiso");
 
116
QFile dvd_temp( Temp.path() + "/dvd" );
 
117
QFile cover( Temp.path() + "/cov.jpg" );
 
118
QDir virtual_dvd_drive( Home.path() + "/virtual-drives" + "/dvd" );
 
119
FUsermount.start("fusermount", QStringList() << "-u" << "-z" << virtual_dvd_drive.path() );
 
120
//label_dvd2->clear();
 
121
dvd_temp.remove();
 
122
cover.remove();
 
123
//label_cover->setPixmap(QPixmap(":/images/default.png"));
 
124
//button_saveCover->setVisible(false);
 
125
QFile file_xml( Temp.path() + "/xml.xml" );
 
126
file_xml.remove();
 
127
}
 
128