comparison libgui/graphics/__init_qt__.cc @ 19655:af0399a5aae0 gui-release

untabify QtHandles source files
author John W. Eaton <jwe@octave.org>
date Fri, 23 Jan 2015 16:24:46 -0500
parents be7ac98fab43
children 2f4406e9dad6
comparison
equal deleted inserted replaced
19654:a1d172bfcb2f 19655:af0399a5aae0
46 bool __init__ (void) 46 bool __init__ (void)
47 { 47 {
48 if (! qtHandlesInitialized) 48 if (! qtHandlesInitialized)
49 { 49 {
50 if (qApp) 50 if (qApp)
51 { 51 {
52 qRegisterMetaType<graphics_object> ("graphics_object"); 52 qRegisterMetaType<graphics_object> ("graphics_object");
53 53
54 gh_manager::enable_event_processing (true); 54 gh_manager::enable_event_processing (true);
55 55
56 graphics_toolkit tk (new Backend ()); 56 graphics_toolkit tk (new Backend ());
57 gtk_manager::load_toolkit (tk); 57 gtk_manager::load_toolkit (tk);
58 58
59 octave_add_atexit_function ("__shutdown_qt__"); 59 octave_add_atexit_function ("__shutdown_qt__");
60 60
61 // Change some default settings to use Qt default colors 61 // Change some default settings to use Qt default colors
62 QPalette p; 62 QPalette p;
63 graphics_object root = gh_manager::get_object (0); 63 graphics_object root = gh_manager::get_object (0);
64 64
65 /* 65 /*
66 root.set ("defaultfigurecolor", 66 root.set ("defaultfigurecolor",
67 octave_value (Utils::toRgb (p.color (QPalette::Window)))); 67 octave_value (Utils::toRgb (p.color (QPalette::Window))));
68 */ 68 */
69 root.set ("defaultuicontrolbackgroundcolor", 69 root.set ("defaultuicontrolbackgroundcolor",
70 octave_value (Utils::toRgb (p.color (QPalette::Window)))); 70 octave_value (Utils::toRgb (p.color (QPalette::Window))));
71 root.set ("defaultuicontrolforegroundcolor", 71 root.set ("defaultuicontrolforegroundcolor",
72 octave_value (Utils::toRgb 72 octave_value (Utils::toRgb
73 (p.color (QPalette::WindowText)))); 73 (p.color (QPalette::WindowText))));
74 root.set ("defaultuipanelbackgroundcolor", 74 root.set ("defaultuipanelbackgroundcolor",
75 octave_value (Utils::toRgb (p.color (QPalette::Window)))); 75 octave_value (Utils::toRgb (p.color (QPalette::Window))));
76 root.set ("defaultuipanelforegroundcolor", 76 root.set ("defaultuipanelforegroundcolor",
77 octave_value (Utils::toRgb 77 octave_value (Utils::toRgb
78 (p.color (QPalette::WindowText)))); 78 (p.color (QPalette::WindowText))));
79 root.set ("defaultuipanelhighlightcolor", 79 root.set ("defaultuipanelhighlightcolor",
80 octave_value (Utils::toRgb (p.color (QPalette::Light)))); 80 octave_value (Utils::toRgb (p.color (QPalette::Light))));
81 root.set ("defaultuipanelshadowcolor", 81 root.set ("defaultuipanelshadowcolor",
82 octave_value (Utils::toRgb (p.color (QPalette::Dark)))); 82 octave_value (Utils::toRgb (p.color (QPalette::Dark))));
83 83
84 qtHandlesInitialized = true; 84 qtHandlesInitialized = true;
85 85
86 return true; 86 return true;
87 } 87 }
88 else 88 else
89 error ("__init_qt__: QApplication object must exist."); 89 error ("__init_qt__: QApplication object must exist.");
90 } 90 }
91 91
92 return false; 92 return false;
93 } 93 }
94 94
211 if (isMultiSelect) 211 if (isMultiSelect)
212 { 212 {
213 QString filter; 213 QString filter;
214 QStringList files = 214 QStringList files =
215 QFileDialog::getOpenFileNames (0, caption, defaultFileName, 215 QFileDialog::getOpenFileNames (0, caption, defaultFileName,
216 filterSpecs.join (";;"), &filter, 0); 216 filterSpecs.join (";;"), &filter, 0);
217 217
218 if (! files.isEmpty ()) 218 if (! files.isEmpty ())
219 { 219 {
220 Cell cFiles (1, files.length ()); 220 Cell cFiles (1, files.length ());
221 QString dirName; 221 QString dirName;
222 int i = 0; 222 int i = 0;
223 223
224 foreach (const QString& s, files) 224 foreach (const QString& s, files)
225 { 225 {
226 QFileInfo fi (s); 226 QFileInfo fi (s);
227 227
228 if (dirName.isEmpty ()) 228 if (dirName.isEmpty ())
229 dirName = appendDirSep (fi.canonicalPath ()); 229 dirName = appendDirSep (fi.canonicalPath ());
230 cFiles(i++) = toStdString (fi.fileName ()); 230 cFiles(i++) = toStdString (fi.fileName ());
231 } 231 }
232 232
233 retval(0) = cFiles; 233 retval(0) = cFiles;
234 retval(1) = toStdString (dirName); 234 retval(1) = toStdString (dirName);
235 if (! filter.isEmpty ()) 235 if (! filter.isEmpty ())
236 retval(2) = static_cast<double> (filterSpecs.indexOf (filter) + 1); 236 retval(2) = static_cast<double> (filterSpecs.indexOf (filter) + 1);
237 } 237 }
238 } 238 }
239 else 239 else
240 { 240 {
241 QString filter; 241 QString filter;
242 QString fileName = 242 QString fileName =
243 QFileDialog::getOpenFileName (0, caption, defaultFileName, 243 QFileDialog::getOpenFileName (0, caption, defaultFileName,
244 filterSpecs.join (";;"), &filter, 0); 244 filterSpecs.join (";;"), &filter, 0);
245 245
246 if (! fileName.isNull ()) 246 if (! fileName.isNull ())
247 { 247 {
248 QFileInfo fi (fileName); 248 QFileInfo fi (fileName);
249 249
250 retval(0) = toStdString (fi.fileName ()); 250 retval(0) = toStdString (fi.fileName ());
251 retval(1) = toStdString (appendDirSep (fi.canonicalPath ())); 251 retval(1) = toStdString (appendDirSep (fi.canonicalPath ()));
252 if (! filter.isEmpty ()) 252 if (! filter.isEmpty ())
253 retval(2) = static_cast<double> (filterSpecs.indexOf (filter) + 1); 253 retval(2) = static_cast<double> (filterSpecs.indexOf (filter) + 1);
254 } 254 }
255 } 255 }
256 256
257 return retval; 257 return retval;
258 } 258 }
259 259
287 QStringList filterSpecs = makeFilterSpecs (args(0).cell_value ()); 287 QStringList filterSpecs = makeFilterSpecs (args(0).cell_value ());
288 288
289 QString filter; 289 QString filter;
290 QString fileName = 290 QString fileName =
291 QFileDialog::getSaveFileName (0, caption, defaultFileName, 291 QFileDialog::getSaveFileName (0, caption, defaultFileName,
292 filterSpecs.join (";;"), &filter, 0); 292 filterSpecs.join (";;"), &filter, 0);
293 293
294 if (! fileName.isNull ()) 294 if (! fileName.isNull ())
295 { 295 {
296 QFileInfo fi (fileName); 296 QFileInfo fi (fileName);
297 297
298 retval(0) = toStdString (fi.fileName ()); 298 retval(0) = toStdString (fi.fileName ());
299 if (fi.exists ()) 299 if (fi.exists ())
300 retval(1) = toStdString (appendDirSep (fi.canonicalPath ())); 300 retval(1) = toStdString (appendDirSep (fi.canonicalPath ()));
301 else 301 else
302 retval(1) = toStdString (appendDirSep (fi.absolutePath ())); 302 retval(1) = toStdString (appendDirSep (fi.absolutePath ()));
303 if (! filter.isEmpty ()) 303 if (! filter.isEmpty ())
304 retval(2) = static_cast<double> (filterSpecs.indexOf (filter) + 1); 304 retval(2) = static_cast<double> (filterSpecs.indexOf (filter) + 1);
305 } 305 }
306 306
307 return retval; 307 return retval;
308 } 308 }
309 309
319 319
320 QString caption = fromStdString (args(1).string_value ()); 320 QString caption = fromStdString (args(1).string_value ());
321 QString defaultDirectory = fromStdString (args(0).string_value ()); 321 QString defaultDirectory = fromStdString (args(0).string_value ());
322 322
323 QString dirName = QFileDialog::getExistingDirectory (0, caption, 323 QString dirName = QFileDialog::getExistingDirectory (0, caption,
324 defaultDirectory); 324 defaultDirectory);
325 325
326 if (! dirName.isNull ()) 326 if (! dirName.isNull ())
327 retval = toStdString (dirName); 327 retval = toStdString (dirName);
328 328
329 return retval; 329 return retval;