1 |
dpavlin |
1 |
/* |
2 |
|
|
* PearPC |
3 |
|
|
* gui.cc |
4 |
|
|
* |
5 |
|
|
* Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License version 2 as |
9 |
|
|
* published by the Free Software Foundation. |
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 |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include <qapplication.h> |
22 |
|
|
#include <qfiledialog.h> |
23 |
|
|
#include "tools/data.h" |
24 |
|
|
#include "system/ui/gui.h" |
25 |
|
|
|
26 |
|
|
static QApplication *gApp; |
27 |
|
|
|
28 |
|
|
void sys_gui_init() |
29 |
|
|
{ |
30 |
|
|
int c=0; |
31 |
|
|
gApp = new QApplication(c, 0, TRUE); |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
bool sys_gui_open_file_dialog(String &ret, const String &title, const String &filespec, const String &filespecname, const String &home, bool existing) |
35 |
|
|
{ |
36 |
|
|
String f; |
37 |
|
|
f.assignFormat("%y (%y)", &filespecname, &filespec); |
38 |
|
|
QFileDialog* fd = new QFileDialog(home.contentChar(), f.contentChar(), NULL, title.contentChar(), FALSE); |
39 |
|
|
fd->setCaption(title.contentChar()); |
40 |
|
|
if (existing) { |
41 |
|
|
fd->setMode(QFileDialog::ExistingFile); |
42 |
|
|
} else { |
43 |
|
|
fd->setMode(QFileDialog::AnyFile); |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
QString fileName; |
47 |
|
|
if (fd->exec() == QDialog::Accepted) { |
48 |
|
|
fileName = fd->selectedFile(); |
49 |
|
|
ret = (const char *)fileName; |
50 |
|
|
delete fd; |
51 |
|
|
return true; |
52 |
|
|
} else { |
53 |
|
|
delete fd; |
54 |
|
|
return false; |
55 |
|
|
} |
56 |
|
|
} |
57 |
|
|
|
58 |
|
|
int sys_gui_messagebox(const String &title, const String &text, int buttons) |
59 |
|
|
{ |
60 |
|
|
|
61 |
|
|
} |