Jump to content

About changing theme at run-time


tappatappa
 Share

Recommended Posts

In MegaDemo

procedure TMainForm.ThemeClick(Sender: TObject);
begin
  if UniApplication<>nil then
  begin
    UniServerModule.Lock;
    try
      case TComponent(Sender).Tag of
        1 : UniServerModule.CurrentTheme:='blue';
        2 : UniServerModule.CurrentTheme:='gray';
        3 : UniServerModule.CurrentTheme:='classic';
        4 : UniServerModule.CurrentTheme:='xp';
        5 : UniServerModule.CurrentTheme:='vista';
      end;
    finally
      UniServerModule.UnLock;
    end;
    TUniGUIApplication(UniApplication).Restart;
  end;
end;

Is it possible to implement a similar feature without changing UniServerModule and restarting the Application?

Link to comment
Share on other sites

Hi,

You can use swapStyleSheet function.   Try something like this (used to work in old versions of uniGUI, not tested in newer versions) :

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/ext-4.2.1.883/resources/css/ext-all-gray.css'',''/ext-4.2.1.883/resources/css/ext-all.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/ext-4.2.1.883/resources/ext-theme-gray/ext-theme-gray-all.css'',''/ext-4.2.1.883/resources/ext-theme-classic/ext-theme-classic-all.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/uni-0.94.0.1024/css/uni-xtheme-gray.css'',''/uni-0.94.0.1024/css/uni-xtheme-blue.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/myApplication.dll/ext-4.2.1.883/resources/css/ext-all-gray.css'',''/myApplication.dll/ext-4.2.1.883/resources/css/ext-all.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/myApplication.dll/ext-4.2.1.883/resources/ext-theme-gray/ext-theme-gray-all.css'',''/myApplication.dll/ext-4.2.1.883/resources/ext-theme-classic/ext-theme-classic-all.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/myApplication.dll/ext-4.2.1.883/uni-0.94.0.1024/css/uni-xtheme-gray.css'',''/myApplication.dll/ext-4.2.1.883/uni-0.94.0.1024/css/uni-xtheme-blue.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/myApplication.dll/uni-0.94.0.1024/css/uni-xtheme-gray.css'',''/myApplication.dll/uni-0.94.0.1024/css/uni-xtheme-blue.css'');');

You'll need to adapt the code with newest ExtJS Path, uniGUI Path, dll name and the name of the theme you want to use.

Link to comment
Share on other sites

Hello ZigZig,

 

I am trying. Is not remotely as easy as I hoped :) Moreover, I guess I have to make it more flexible by retrieving the uniGUI/extjs version from ServerModule.

 

How do I have to change the path in Stand Alone Server mode (I see you refer to the dll in the paths)?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...