Patch level : 10.0 202
Files correlati : ba0.exe Ricompilazione Demo : [ ] Commento : Corretta gestione abilitazione voci di menu dopo un cambio utente git-svn-id: svn://10.65.10.50/trunk@18024 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
6e3ca6b9f5
commit
57247704fa
@ -225,19 +225,6 @@ bool TPicture_mask::on_key(KEY k)
|
||||
case K_F8:
|
||||
set(DLG_USER, app().main_menu().last_search_string(), true);
|
||||
return true;
|
||||
/* Obsoleto coi nuovi alberi
|
||||
case K_ENTER:
|
||||
case K_UP:
|
||||
case K_DOWN:
|
||||
case K_LEFT:
|
||||
case K_RIGHT:
|
||||
if (focus_field().is_kind_of(CLASS_TREE_FIELD))
|
||||
{
|
||||
TTree_field& tf = (TTree_field&)focus_field();
|
||||
return tf.win().on_key(k);
|
||||
}
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1184,10 +1171,12 @@ bool TMenu_application::check_user()
|
||||
|
||||
if (ok)
|
||||
{
|
||||
set_perms(); // Aggiorna permessi utente
|
||||
customize_colors(); // Aggiorna set di colori
|
||||
reload_images(); // Ritrasparentizza immagini
|
||||
reload_images(); // Ritrasparentizza immagini e abilitazioni alberi
|
||||
xvt_dwin_invalidate_rect(TASK_WIN, NULL); // Ridisegna sfondo
|
||||
load_preferences();
|
||||
load_preferences(); // Aggiorna menu preferiti
|
||||
test_temp(); // Cancella file temporanei
|
||||
}
|
||||
|
||||
return ok;
|
||||
@ -1398,9 +1387,6 @@ bool TMenu_application::user_create()
|
||||
app.run();
|
||||
}
|
||||
|
||||
set_perms();
|
||||
test_temp();
|
||||
|
||||
if (!test_programs())
|
||||
return false;
|
||||
|
||||
|
178
ba/ba0101.cpp
178
ba/ba0101.cpp
@ -200,62 +200,83 @@ bool TMenuitem::create(const char* t)
|
||||
int TMenuitem::icon() const
|
||||
{ return _icon; }
|
||||
|
||||
TSubmenu* TMenuitem::child_submenu() const
|
||||
{
|
||||
TSubmenu* sm = NULL;
|
||||
if (is_submenu())
|
||||
{
|
||||
sm = menu().find(_action);
|
||||
if (sm->items() == 0)
|
||||
sm = NULL;
|
||||
}
|
||||
return sm;
|
||||
}
|
||||
|
||||
bool TMenuitem::enabled() const
|
||||
{
|
||||
bool yes = false;
|
||||
if (_exist)
|
||||
if (_exist < 0)
|
||||
{
|
||||
bool yes = false;
|
||||
if (is_submenu())
|
||||
{
|
||||
yes = child_submenu() != NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
yes = !menu().is_dangerous(_action);
|
||||
if (yes)
|
||||
{
|
||||
const int endname = _action.find(' ');
|
||||
const TFilename name(endname > 0 ? _action.left(endname) : _action);
|
||||
TFilename n = name;
|
||||
if (!n.custom_path())
|
||||
{
|
||||
const char* ext[] = { "exe", "pif", "com", "bat", NULL };
|
||||
int e;
|
||||
|
||||
for (e = 0; ext[e]; e++)
|
||||
{
|
||||
n = name; n.ext(ext[e]);
|
||||
if (n.custom_path())
|
||||
break;
|
||||
}
|
||||
yes = ext[e] != NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
((TMenuitem*)this)->_exist = yes;
|
||||
}
|
||||
|
||||
bool yes = _exist != 0;
|
||||
if (yes)
|
||||
{
|
||||
if (is_submenu())
|
||||
{
|
||||
TSubmenu* mnu = menu().find(_action);
|
||||
yes = mnu && mnu->enabled() && mnu->items() > 0;
|
||||
}
|
||||
const TSubmenu* mnu = child_submenu();
|
||||
yes = mnu != NULL && mnu->enabled();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_exist < 0)
|
||||
{
|
||||
if (_enabled < 0)
|
||||
{
|
||||
if (menu().is_dangerous(_action))
|
||||
{
|
||||
yes = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int endname = _action.find(' ');
|
||||
const TFilename name(endname > 0 ? _action.left(endname) : _action);
|
||||
TFilename n = name;
|
||||
if (n.custom_path())
|
||||
yes = true;
|
||||
else
|
||||
{
|
||||
const char* ext[] = { "exe", "pif", "com", "bat", NULL };
|
||||
int e;
|
||||
|
||||
for (e = 0; ext[e]; e++)
|
||||
{
|
||||
n = name; n.ext(ext[e]);
|
||||
if (n.custom_path())
|
||||
break;
|
||||
}
|
||||
yes = ext[e] != NULL;
|
||||
}
|
||||
}
|
||||
((TMenuitem*)this)->_exist = yes;
|
||||
}
|
||||
if (_exist)
|
||||
{
|
||||
TExternal_app app(_action);
|
||||
const TExternal_app app(_action);
|
||||
yes = app.can_run();
|
||||
((TMenuitem*)this)->_enabled = yes;
|
||||
}
|
||||
if (!yes)
|
||||
((TMenuitem*)this)->_enabled = false;
|
||||
yes = _enabled != 0;
|
||||
}
|
||||
}
|
||||
return yes;
|
||||
}
|
||||
|
||||
void TMenuitem::reset_permissions()
|
||||
{
|
||||
_enabled = -1;
|
||||
}
|
||||
|
||||
bool TMenuitem::perform_submenu() const
|
||||
{
|
||||
TSubmenu* mnu = menu().find(_action);
|
||||
TSubmenu* mnu = child_submenu();
|
||||
bool ok = mnu != NULL && mnu->enabled();
|
||||
if (ok)
|
||||
ok = menu().jumpto(mnu);
|
||||
@ -359,9 +380,8 @@ bool TMenuitem::perform() const
|
||||
|
||||
TSubmenu::TSubmenu(TMenu* menu, const char* name)
|
||||
: _menu(menu), _name(name), _items(12),
|
||||
_enabled(true), _firm(false)
|
||||
{
|
||||
}
|
||||
_exist(true), _firm(false), _enabled(-1)
|
||||
{ }
|
||||
|
||||
void TSubmenu::read(TScanner& scanner)
|
||||
{
|
||||
@ -387,21 +407,9 @@ void TSubmenu::read(TScanner& scanner)
|
||||
const int equal = line.find('=');
|
||||
if (equal > 0)
|
||||
{
|
||||
bool disable = true;
|
||||
TToken_string mod(line.after('='), ',');
|
||||
mod.strip_spaces();
|
||||
FOR_EACH_TOKEN(mod, cod)
|
||||
{
|
||||
//const word code = dongle().module_name2code(cod);
|
||||
//if (main_app().has_module(code))
|
||||
if (_menu->has_module(cod))
|
||||
{
|
||||
disable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (disable)
|
||||
_enabled = false;
|
||||
_modules = mod;
|
||||
}
|
||||
} else
|
||||
if (line.starts_with("Picture", true))
|
||||
@ -416,7 +424,7 @@ void TSubmenu::read(TScanner& scanner)
|
||||
TString16 flags;
|
||||
get_next_string(line, 6, flags, brace);
|
||||
if (flags.find('D') >= 0)
|
||||
_enabled = false;
|
||||
_exist = false;
|
||||
if (flags.find('F') >= 0)
|
||||
_firm = true;
|
||||
} else
|
||||
@ -471,6 +479,55 @@ TImage& TSubmenu::image() const
|
||||
return menu().image(picture());
|
||||
}
|
||||
|
||||
bool TSubmenu::enabled() const
|
||||
{
|
||||
if (_enabled < 0)
|
||||
{
|
||||
bool yes = _exist != 0;
|
||||
if (yes)
|
||||
{
|
||||
if (_modules.full() && _modules != "0" && _modules != "ba")
|
||||
{
|
||||
yes = false;
|
||||
TToken_string& mod = (TToken_string&)_modules;
|
||||
FOR_EACH_TOKEN(mod, cod)
|
||||
{
|
||||
if (_menu->has_module(cod))
|
||||
{
|
||||
yes = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (yes)
|
||||
{
|
||||
yes = false;
|
||||
for (int i = items()-1; i >= 0 && !yes; i--)
|
||||
{
|
||||
const TMenuitem& mi = item(i);
|
||||
yes = mi.enabled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
((TSubmenu*)this)->_enabled = yes;
|
||||
}
|
||||
return _enabled != 0;
|
||||
}
|
||||
|
||||
void TSubmenu::reset_permissions()
|
||||
{
|
||||
if (_enabled >= 0)
|
||||
{
|
||||
_enabled = -1;
|
||||
for (int i = items()-1; i >= 0; i--)
|
||||
{
|
||||
TMenuitem& mi = item(i);
|
||||
mi.reset_permissions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TSubmenu::perform(int i)
|
||||
{
|
||||
bool ok = i >= 0 && i < items();
|
||||
@ -519,7 +576,6 @@ bool TMenu::read(const char* name, TString& root)
|
||||
// Menu
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
bool TMenu::read(const char* name)
|
||||
{
|
||||
TString root;
|
||||
@ -616,7 +672,6 @@ TSubmenu* TMenu::find_string(const TString& str)
|
||||
restart();
|
||||
|
||||
TSubmenu * sm;
|
||||
|
||||
for (sm = (TSubmenu*)get(); sm; sm = (TSubmenu*)get())
|
||||
{
|
||||
if (sm->enabled() && !_ignore_list.is_key(sm->name()))
|
||||
@ -721,6 +776,11 @@ TImage& TMenu::image(const char* name)
|
||||
void TMenu::reload_images()
|
||||
{
|
||||
_images.destroy();
|
||||
|
||||
// Reset permissions
|
||||
restart();
|
||||
for (TSubmenu* sm = (TSubmenu*)get(); sm; sm = (TSubmenu*)get())
|
||||
sm->reset_permissions();
|
||||
}
|
||||
|
||||
bool TMenu::has_module(const char* mod)
|
||||
|
15
ba/ba0101.h
15
ba/ba0101.h
@ -51,6 +51,7 @@ public:
|
||||
const TString& action() const { return _action; }
|
||||
bool enabled() const;
|
||||
bool disabled() const { return !enabled(); }
|
||||
void reset_permissions();
|
||||
|
||||
bool is_submenu() const { return _type == '[' && _action.full(); }
|
||||
bool is_program() const { return _type != '[' && _action.full(); }
|
||||
@ -59,6 +60,7 @@ public:
|
||||
bool run_fullscreen() const;
|
||||
|
||||
TSubmenu& submenu() const { return *_submenu; }
|
||||
TSubmenu* child_submenu() const;
|
||||
TMenu& menu() const;
|
||||
|
||||
bool create(const char* t);
|
||||
@ -75,8 +77,10 @@ class TSubmenu : public TObject
|
||||
TString _caption;
|
||||
TFilename _picture;
|
||||
TArray _items;
|
||||
bool _enabled : 2;
|
||||
bool _firm : 2;
|
||||
TToken_string _modules;
|
||||
char _enabled : 2;
|
||||
char _firm : 2;
|
||||
char _exist : 2;
|
||||
|
||||
public:
|
||||
void read(TScanner& scanner);
|
||||
@ -99,10 +103,11 @@ public:
|
||||
|
||||
TImage& image() const;
|
||||
|
||||
bool query_firm() const { return _firm; }
|
||||
bool enabled() const { return _enabled; }
|
||||
bool query_firm() const { return _firm != 0; }
|
||||
bool enabled() const;
|
||||
bool disabled() const { return !enabled(); }
|
||||
|
||||
void reset_permissions();
|
||||
|
||||
bool perform(int i);
|
||||
|
||||
TSubmenu(TMenu* menu, const char* name);
|
||||
|
@ -148,16 +148,13 @@ bool TMenu_tree::goto_root()
|
||||
bool TMenu_tree::goto_firstson()
|
||||
{
|
||||
const TMenuitem& mi = curr_item();
|
||||
if (mi.is_submenu())
|
||||
const TSubmenu* sm = mi.child_submenu();
|
||||
if (sm != NULL)
|
||||
{
|
||||
const TSubmenu* sm = _menu->find(mi.action());
|
||||
if (sm && sm->items() > 0)
|
||||
{
|
||||
_curr_id << '/' << mi.action() << ".0";
|
||||
_submenu = sm;
|
||||
_menuitem = 0;
|
||||
return true;
|
||||
}
|
||||
_curr_id << '/' << mi.action() << ".0";
|
||||
_submenu = sm;
|
||||
_menuitem = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -407,15 +407,14 @@ void TOutlook_mask::load_perspective(int per)
|
||||
|
||||
bool TOutlook_mask::can_be_closed() const
|
||||
{
|
||||
bool yes = true;
|
||||
if (is_running())
|
||||
const bool yes = !is_running();
|
||||
if (!yes)
|
||||
{
|
||||
TBook_field& bf = (TBook_field&)field(DLG_MAIN);
|
||||
if (bf.pages() == 0)
|
||||
((TOutlook_mask*)this)->send_key(K_FORCE_CLOSE, 0);
|
||||
else
|
||||
warning_box(TR("E' necessario chiudere tutte le applicazioni attive"));
|
||||
yes = false;
|
||||
}
|
||||
return yes;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user