示例#1
0
文件: UiAPI.cpp 项目: A-K/naali
void UiAPI::BringWidgetToFront(QWidget *widget) const
{
    if (!widget)
    {
        LogError("BringWidgetToFront called on a null widget!");
        return;
    }

    ShowWidget(widget);
    graphicsScene->setActiveWindow(widget->graphicsProxyWidget());
    graphicsScene->setFocusItem(widget->graphicsProxyWidget(), Qt::ActiveWindowFocusReason);
}
void OToolBox :: slotToggle (int index )
{
  QAbstractButton         *b;
BEGINSEQ
  if(index<0 ||(unsigned int)index>=items.size())    ERROR
  if(!items[index] || !items[index]->WidgetQ())      ERROR
  if(!(b = GetButton(index) ) )                      ERROR
  if(items[index]->WidgetQ()->isHidden()){
    ShowWidget(index);
    b->setChecked(true);
  }else{
    HideWidget(index);
	b->setChecked(false);
  }
RECOVER

ENDSEQ

}
/***********************************************************************************
**  WebServerDialog::InitSettingsPage
************************************************************************************/
void
WebServerDialog::InitSettingsPage()
{
	OpLabel* service_icon = static_cast<OpLabel*>(GetWidgetByName("webserver_service_icon"));
	if (service_icon)
		service_icon->GetBorderSkin()->SetImage("Unite Logo");
	
	// make title bold
	OpLabel* title_label = static_cast<OpLabel*>(GetWidgetByName("webserver_title_label"));
	if (title_label)
	{
		title_label->SetSystemFontWeight(QuickOpWidgetBase::WEIGHT_BOLD);
		title_label->SetRelativeSystemFontSize(150);
	}

	if (!NeedsSetup())
	{
		BOOL enabled = m_preset_settings->IsFeatureEnabled();
		OpRadioButton* state_radio;

		if (enabled)
			state_radio = (OpRadioButton*)GetWidgetByName("webserver_enable_radio");
		else
			state_radio = (OpRadioButton*)GetWidgetByName("webserver_disable_radio");

		if (state_radio)
			state_radio->SetValue(TRUE);

		SetInputFieldsEnabled(enabled);
	}
	else
	{
		ShowWidget("webserver_enable_radio", FALSE);
		ShowWidget("webserver_disable_radio", FALSE);
	}

	// bold heading
	OpLabel* devicename_title = static_cast<OpLabel*>(GetWidgetByName("webserver_devicename_label"));
	if (devicename_title)
		devicename_title->SetSystemFontWeight(QuickOpWidgetBase::WEIGHT_BOLD);

	// wrap text
	OpLabel* text_label = static_cast<OpLabel*>(GetWidgetByName("webserver_settings_label"));
	if (text_label)
		text_label->SetWrap(TRUE);

	// set ellipsis for url
	OpLabel* url_label = static_cast<OpLabel*>(GetWidgetByName("webserver_url_label"));
	if (url_label)
		url_label->SetEllipsis(ELLIPSIS_CENTER);

	if (m_preset_settings)
	{
		OpDropDown* dropdown = static_cast<OpDropDown*>(GetWidgetByName("webserver_computername_dropdown"));
		if (dropdown)
		{
			dropdown->SetEditableText(TRUE);
			dropdown->edit->SetMaxLength(DEVICENAME_MAX_LENGTH);
			dropdown->edit->SetOnChangeOnEnter(FALSE); // make sure changes are reported back on all input

			INT32 selected_item = -1;

			const OpStringC device_name = m_preset_settings->GetDeviceName();
			const OpAutoVector<OpString>* suggestions = m_preset_settings->GetDeviceNameSuggestions();
			for (UINT idx = 0; idx < suggestions->GetCount(); idx++)
			{
				OpString* item = suggestions->Get(idx);
				dropdown->AddItem(item->CStr());
				if (selected_item == -1 && !device_name.IsEmpty() && item->Compare(device_name) == 0)
				{
					selected_item = idx;
				}
			}
			// add default item if not already in the list
			if (selected_item == -1 && !device_name.IsEmpty())
				dropdown->AddItem(device_name.CStr(), 0);

			// add one default item if there is none
			if (dropdown->CountItems() <= 0)
				dropdown->AddItem(WEBSERVER_DEFAULT_NAME);
			
			// set selected item if not already set
			if (selected_item == -1)
				selected_item = 0;

			// check if device name is part of the suggestions list
			dropdown->SetValue(selected_item);

			OpString computername;
			dropdown->GetText(computername);
			UpdateURL(computername);
		}
	}

	// init progress widgets
	OpProgressBar * progress_spinner = static_cast<OpProgressBar *>(GetWidgetByName("webserver_progress_spinner"));
	if (progress_spinner)
	{
		progress_spinner->SetType(OpProgressBar::Spinner);
		progress_spinner->SetVisibility(FALSE);
	}
	OpLabel* progress_label = static_cast<OpLabel*>(GetWidgetByName("webserver_progress_label"));
	if (progress_label)
		progress_label->SetWrap(TRUE);
	
	// make error field multi-line, make it red
	OpLabel *error_label = static_cast<OpLabel*>(GetWidgetByName("webserver_error_label"));
	if (error_label)
	{
		error_label->SetWrap(TRUE);
		error_label->SetForegroundColor(OP_RGB(255, 0, 0));
	}

	// advanced dialog settings
#ifdef PREFS_CAP_UPNP_ENABLED
	m_current_settings.SetUPnPEnabled(m_preset_settings->IsUPnPEnabled());
#endif // PREFS_CAP_UPNP_ENABLED

	m_current_settings.SetUploadSpeed(m_preset_settings->GetUploadSpeed());
	m_current_settings.SetPort(m_preset_settings->GetPort());

#ifdef PREFS_CAP_SERVICE_DISCOVERY_ENABLED
	m_current_settings.SetASDEnabled(m_preset_settings->IsASDEnabled());
#endif // PREFS_CAP_SERVICE_DISCOVERY_ENABLED

#ifdef PREFS_CAP_UPNP_DISCOVERY_ENABLED
	m_current_settings.SetUPnPServiceDiscoveryEnabled(m_preset_settings->IsUPnPServiceDiscoveryEnabled());
#endif // PREFS_CAP_UPNP_DISCOVERY_ENABLED

#ifdef WEBSERVER_CAP_SET_VISIBILITY
	m_current_settings.SetVisibleRobotsOnHome(m_preset_settings->IsVisibleRobotsOnHome());
#endif // WEBSERVER_CAP_SET_VISIBILITY
}
示例#4
0
int ExecJobMode()
{
	char *job;
	int print = 1;
	SpecialInfo* special = NULL;

	if(g_config_file_data != NULL){
		special = g_config_file_data->special_list;
	}
	job = GetCurrOpt(g_cngplp_data, ID_CNJOBEXECMODE, NULL);
	if(job != NULL){
		if(strcmp(job, "print") == 0){
			print = 1;
		}else if(strcmp(job, "store") == 0){
			print = 1;
		}else if(strcmp(job, "secured") == 0){
			if((g_cngplp_data != NULL) && (NULL == g_cngplp_data->file_name)){
				HideWidget("DocName_label");
				HideWidget("DocName_entry");
			}else{
				char *file = NULL;

				file = GetOptionList(g_cngplp_data, ID_SECURED_DOCNAME);
				ShowWidget("DocName_label");
				ShowWidget("DocName_entry");
				if(file != NULL){
					SetTextEntry("DocName_entry", file);
					free(file);
				}
			}
			ShowDialog("IdPassWdDlg", 1);
			while(special != NULL){
				if(0 == strcasecmp(special->name, "IdPassWdDlg")){
					if(!special->print){
						memFree(job);
						return 0;
					}
					break;
				}
				special = special->next;
			}
		}else if(strcmp(job, "hold") == 0){
			print = 1;
		}
		memFree(job);
	}

	const int special_func = GetCurrOptInt(ID_SPECIAL_FUNC, 0);
	if(special_func != 0){
		int job_account;
		int active_job;
		int is_color = 0;
		char *active_color;
		job_account = GetCurrOptInt(ID_JOBACCOUNT, 0);
		if(job_account != 0){
			active_job = GetCurrOptInt(ID_DISABLE_JOBACCOUNT_BW, 0);
			active_color = GetCurrOpt(g_cngplp_data, ID_CNCOLORMODE, NULL);
			if(active_color != NULL){
				if(strcmp(active_color, "mono") != 0){
					is_color = 1;
				}
				memFree(active_color);
			}
			if(!((active_job == 1) && (is_color == 0))){
				ShowWidget("JobAccountPassWD_label");
				ShowWidget("JobAccountPassWD_entry");
				ShowDialog("JobAccountDlg", 1);
				while(special != NULL){
					if(0 == strcasecmp(special->name, "JobAccountDlg")){
						if(!special->print){
							return 0;
						}else{
							return 1;
						}
					}
					special = special->next;
				}
			}
		}
	}

	return print;
}