Changeset 161:9a24c778e43c for source


Ignore:
Timestamp:
Jan 6, 2010, 1:00:54 PM (15 years ago)
Author:
fnevgeny
Branch:
default
Phase:
public
Message:

Support for theme switching.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/class/pf/Application.js

    r160 r161  
    22532253        createPrefsDialog : function()
    22542254        {
    2255             var w;
    22562255            // "Preferences..." dialog
    2257             w = new qx.ui.window.Window("Preferences",
     2256            var w = new qx.ui.window.Window("Preferences",
    22582257                "pf/image/preferences.png");
    22592258            w.setLayout(new qx.ui.layout.VBox(10));
     
    22692268                });
    22702269           
    2271             var fr1, fr2, rc, l, e;
    2272            
    2273             fr1 = new qx.ui.groupbox.GroupBox("Default units");
    2274             fr1.setLayout(new qx.ui.layout.VBox());
    2275             w.add(fr1);
    2276            
    2277             rc = new qx.ui.container.Composite(new qx.ui.layout.HBox(10));
    2278             fr1.add(rc);
    2279 
     2270            this.doc.add(w, {left: 200, top: 100});
     2271            this.prefsWindow = w;
     2272           
     2273            var fr, l, e;
     2274           
     2275            fr = new qx.ui.groupbox.GroupBox("Default units");
     2276            fr.setLayout(new qx.ui.layout.HBox(10));
     2277            w.add(fr);
     2278           
    22802279            l = new qx.ui.basic.Label("Dimension:");
    22812280            e = new pf.ui.SelectBox;
     
    22942293                        this.prefs.units[dimension]);
    22952294                }, this);
    2296             rc.add(l);
    2297             rc.add(e);
     2295            fr.add(l);
     2296            fr.add(e);
    22982297            this.gui_prefs_dim = e;
    22992298
     
    23052304                    this.prefs.units[dimension] = units;
    23062305                }, this);
    2307             rc.add(l);
    2308             rc.add(e);
     2306            fr.add(l);
     2307            fr.add(e);
    23092308            e.update("length");
    23102309            this.gui_prefs_units = e;
    23112310
    2312             fr2 = new qx.ui.groupbox.GroupBox("Interface");
    2313             fr2.setLayout(new qx.ui.layout.VBox());
    2314             w.add(fr2);
    2315 
    2316             rc = new qx.ui.container.Composite(new qx.ui.layout.VBox(10));
    2317             fr2.add(rc);
     2311            fr = new qx.ui.groupbox.GroupBox("Interface");
     2312            fr.setLayout(new qx.ui.layout.VBox(10));
     2313            w.add(fr);
    23182314
    23192315            e = new qx.ui.form.CheckBox("Load Wikipedia articles automatically");
     
    23222318                this.prefs.autoLoadWiki = ev.getTarget().getValue();
    23232319            }, this);
    2324             rc.add(e);
     2320            fr.add(e);
    23252321
    23262322            e = new qx.ui.form.CheckBox("Remember window dimensions on exit");
     
    23292325                this.prefs.rememberWindowSize = ev.getTarget().getValue();
    23302326            }, this);
    2331             rc.add(e);
     2327            fr.add(e);
    23322328
    23332329            e = new qx.ui.form.CheckBox("Warn on exit or restart");
     
    23362332                this.prefs.warnOnExit = ev.getTarget().getValue();
    23372333            }, this);
    2338             rc.add(e);
    2339            
    2340             this.doc.add(w, {left: 200, top: 100});
    2341             this.prefsWindow = w;
     2334            fr.add(e);
     2335
     2336            fr = new qx.ui.groupbox.GroupBox("Theme");
     2337            fr.setLayout(new qx.ui.layout.VBox(10));
     2338            w.add(fr);
     2339           
     2340            var btn1 = new qx.ui.form.RadioButton("Modern");
     2341            btn1.setModel("modern");
     2342            var btn2 = new qx.ui.form.RadioButton("Classic");
     2343            btn2.setModel("classic");
     2344           
     2345            fr.add(btn1);
     2346            fr.add(btn2);
     2347           
     2348            var rm = new qx.ui.form.RadioGroup(btn1, btn2);
     2349            var sels;
     2350            if (this.prefs.themeName == "classic") {
     2351                sels = new Array(btn2);
     2352            } else {
     2353                sels = new Array(btn1);
     2354            }
     2355            rm.setSelection(sels);
     2356            rm.addListener("changeSelection", function(ev) {
     2357                    var btn = ev.getData()[0];
     2358                    this.prefs.themeName = btn.getModel();
     2359                   
     2360                    // this.applyTheme();
     2361                    alert("New theme will be applied after restart of the application");
     2362                }, this);
     2363
     2364        },
     2365
     2366        applyTheme : function()
     2367        {
     2368            var theme;
     2369            if (this.prefs.themeName == "classic") {
     2370                theme = qx.theme.Classic;
     2371            } else {
     2372                theme = pf.theme.Theme;
     2373            }
     2374            var thm = qx.theme.manager.Meta.getInstance();
     2375            thm.setTheme(theme);
    23422376        },
    23432377
     
    23682402            this.loadPreferences();
    23692403           
     2404            // Apply theme
     2405            this.applyTheme();
     2406           
    23702407            if (this.prefs.rememberWindowSize && this.prefs.dims) {
    23712408                self.resizeTo(this.prefs.dims.width, this.prefs.dims.height);
Note: See TracChangeset for help on using the changeset viewer.