27 #include <QApplication>
29 #include <QFileDialog>
49 if (! qtHandlesInitialized)
55 qRegisterMetaType<graphics_object> (
"graphics_object");
72 root.
set (
"defaultuicontrolbackgroundcolor",
74 root.
set (
"defaultuicontrolforegroundcolor",
76 (p.color (QPalette::WindowText))));
77 root.
set (
"defaultuipanelbackgroundcolor",
79 root.
set (
"defaultuipanelforegroundcolor",
81 (p.color (QPalette::WindowText))));
82 root.
set (
"defaultuipanelhighlightcolor",
84 root.
set (
"defaultuipanelshadowcolor",
87 qtHandlesInitialized =
true;
92 error (
"__init_qt__: QApplication object must exist.");
101 if (qtHandlesInitialized)
111 qtHandlesInitialized =
false;
139 "__init_qt__.cc",
"");
142 "__init_qt__.cc",
"");
148 makeFilterSpecs (
const Cell& filters)
152 QStringList filterSpecs;
153 QRegExp parenRe (
" ?\\(.*\\)\\s*$");
155 for (
int i = 0; i < filters.
rows (); i++)
157 QStringList extList =
159 QString desc =
fromStdString (filters(i, 1).string_value ()).trimmed ();
162 if (desc.contains (parenRe))
167 desc.remove (parenRe);
170 specItem = QString (
"%1 (%2)").arg (desc).arg (extList.join (
" "));
172 filterSpecs.append (specItem);
179 appendDirSep (
const QString&
d)
181 if (! d.endsWith (
"/") && ! d.endsWith (QDir::separator ()))
186 DEFUN (__uigetfile_qt__, args, ,
"")
201 QString defaultDirectory =
fromStdString (args(5).string_value ());
202 QString defaultFileName =
fromStdString (args(2).string_value ());
203 bool isMultiSelect = (args(4).string_value () ==
"on");
212 if (defaultFileName.isEmpty ())
213 defaultFileName = defaultDirectory;
215 defaultFileName = defaultDirectory +
"/" + defaultFileName;
217 QStringList filterSpecs = makeFilterSpecs (args(0).cell_value ());
223 QFileDialog::getOpenFileNames (0, caption, defaultFileName,
224 filterSpecs.join (
";;"), &
filter, 0);
226 if (! files.isEmpty ())
228 Cell cFiles (1, files.length ());
232 foreach (
const QString& s, files)
236 if (dirName.isEmpty ())
237 dirName = appendDirSep (
fi.canonicalPath ());
243 if (! filter.isEmpty ())
244 retval(2) =
static_cast<double> (filterSpecs.indexOf (filter) + 1);
251 QFileDialog::getOpenFileName (0, caption, defaultFileName,
252 filterSpecs.join (
";;"), &
filter, 0);
254 if (! fileName.isNull ())
256 QFileInfo
fi (fileName);
259 retval(1) =
toStdString (appendDirSep (
fi.canonicalPath ()));
260 if (! filter.isEmpty ())
261 retval(2) =
static_cast<double> (filterSpecs.indexOf (filter) + 1);
268 DEFUN (__uiputfile_qt__, args, ,
"")
283 QString defaultDirectory =
fromStdString (args(5).string_value ());
284 QString defaultFileName =
fromStdString (args(2).string_value ());
290 if (defaultFileName.isEmpty ())
291 defaultFileName = defaultDirectory;
293 defaultFileName = defaultDirectory +
"/" + defaultFileName;
295 QStringList filterSpecs = makeFilterSpecs (args(0).cell_value ());
299 QFileDialog::getSaveFileName (0, caption, defaultFileName,
300 filterSpecs.join (
";;"), &
filter, 0);
302 if (! fileName.isNull ())
304 QFileInfo
fi (fileName);
308 retval(1) =
toStdString (appendDirSep (
fi.canonicalPath ()));
311 if (! filter.isEmpty ())
312 retval(2) =
static_cast<double> (filterSpecs.indexOf (filter) + 1);
318 DEFUN (__uigetdir_qt__, args, ,
"")
329 QString defaultDirectory =
fromStdString (args(0).string_value ());
331 QString dirName = QFileDialog::getExistingDirectory (0, caption,
334 if (! dirName.isNull ())
OCTINTERP_API void install_builtin_function(octave_builtin::fcn f, const std::string &name, const std::string &file, const std::string &doc, bool can_hide_function=true)
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
QString fromStdString(const std::string &s)
static void load_toolkit(const graphics_toolkit &tk)
octave_idx_type rows(void) const
F77_RET_T const double const double double * d
void install___init_qt___functions(void)
Matrix toRgb(const QColor &c)
MArray< double > filter(MArray< double > &, MArray< double > &, MArray< double > &, int dim)
static void unload_toolkit(const std::string &name)
static bool qtHandlesInitialized
static void enable_event_processing(bool enable=true)
void set(const caseless_str &name, const octave_value &val)
OCTAVE_EXPORT octave_value_list F__shutdown_qt__(const octave_value_list &, int)
void octave_add_atexit_function(const std::string &fname)
static graphics_object get_object(double val)
OCTAVE_EXPORT octave_value_list F__init_qt__(const octave_value_list &, int)
std::string toStdString(const QString &s)
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))