~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to kmidi/kmidifiledlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    KDE Icon Editor - a small graphics drawing program for the KDE
 
3
 
 
4
    Copyright (C) 1998 Thomas Tanghus (tanghus@kde.org)
 
5
 
 
6
    This program is free software; you can redistribute it and/or
 
7
    modify it under the terms of the GNU General Public
 
8
    License as published by the Free Software Foundation; either
 
9
    version 2 of the License, or (at your option) any later version.
 
10
 
 
11
    This program is distributed in the hope that it will be useful,
 
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
    General Public License for more details.
 
15
 
 
16
    You should have received a copy of the GNU Library General Public License
 
17
    along with this library; see the file COPYING.LIB.  If not, write to
 
18
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
    Boston, MA 02111-1307, USA.
 
20
*/
 
21
 
 
22
#include <qfileinfo.h>
 
23
#include <qdir.h>
 
24
#include <klocale.h>
 
25
#include <kurl.h>
 
26
#include <kurlcombobox.h>
 
27
#include <kdiroperator.h>
 
28
#include "kmidifiledlg.h"
 
29
#include "kmidi.h"
 
30
 
 
31
KMidiFileDlg::KMidiFileDlg(const QString& dirName, const QString& filter,
 
32
                                 QWidget *parent, const char *name,
 
33
                                 bool modal )
 
34
    : KFileDialog(dirName, filter, parent, name, modal)
 
35
{
 
36
/*    connect(this,SIGNAL(fileSelected(const QString&)),
 
37
            SLOT(playFile(const QString&)));
 
38
*/
 
39
    connect(this,SIGNAL(fileHighlighted(const QString&)),
 
40
            SLOT(noteFile(const QString&)));
 
41
    connect(this,SIGNAL(cancelClicked()),
 
42
            SLOT(closeFbox()));
 
43
    //setButtonOKText(i18n("Play"));
 
44
    okButton()->setText(i18n("Play"));
 
45
    //setButtonCancelText(i18n("Close"));
 
46
    cancelButton()->setText(i18n("Close"));
 
47
}
 
48
 
 
49
void KMidiFileDlg::playFile(const QString& fname)
 
50
{
 
51
/*    fprintf(stderr, "You clicked on %s\n", fname.ascii()); */
 
52
 
 
53
    KURL u( fname );
 
54
    QString thePath = u.path();
 
55
 
 
56
    if ( u.isLocalFile() ) {
 
57
      if ( QFileInfo(thePath).isDir() ) {
 
58
        setURL( QDir::cleanDirPath( thePath ) );
 
59
        return;
 
60
      }
 
61
      if (!thePath.isNull())
 
62
      {
 
63
        kmidi->restartPlayboxWith(thePath);
 
64
      }
 
65
    }
 
66
}
 
67
 
 
68
void KMidiFileDlg::noteFile(const QString& fname)
 
69
{
 
70
//    fprintf(stderr, "You selected %s\n", fname.ascii());
 
71
 
 
72
    hlfile = fname;
 
73
}
 
74
 
 
75
void KMidiFileDlg::accept()
 
76
{
 
77
    if ( locationEdit->currentText().stripWhiteSpace().isEmpty() )
 
78
        return;
 
79
 
 
80
    playFile(hlfile);
 
81
}
 
82
#define ConfigGroup QString::fromLatin1("KFileDialog Settings")
 
83
 
 
84
void KMidiFileDlg::closeFbox()
 
85
{
 
86
/* this doesn't appear to work */
 
87
    *lastDirectory = ops->url();
 
88
    KSimpleConfig *c = new KSimpleConfig(QString::fromLatin1("kdeglobals"),
 
89
                                         false);
 
90
    saveConfig( c, ConfigGroup );
 
91
    saveRecentFiles( KGlobal::config() );
 
92
    delete c;
 
93
}
 
94
 
 
95
void KMidiFileDlg::getOpenDialog(const QString& dir, const QString& filter,
 
96
                                     QWidget *parent, const char *name)
 
97
{
 
98
    static KMidiFileDlg *dlg = 0;
 
99
 
 
100
    if (!dlg) {
 
101
        dlg= new KMidiFileDlg(dir, filter, parent, name, false);
 
102
        dlg->setCaption(i18n("Open"));
 
103
    }
 
104
 
 
105
    dlg->show();
 
106
}
 
107
 
 
108
#include "kmidifiledlg.moc"